akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n, m, Q;
    cin >> n >> m >> Q;
    int l, r;
    int a[n][n];
    rep(i, n)rep(j, n) a[i][j] = 0;
    rep(i, m){
        cin >> l >> r;
        l--; r--;
        a[l][r]++;
    }
    int p[Q], q[Q];
    rep(i, Q){
        cin >> p[i] >> q[i];
        p[i]--; q[i]--;
    }

    int s[n][n];
    s[0][0] = a[0][0];
    rep(i, n - 1) {
        s[i+1][0] = s[i][0] + a[i+1][0];
        s[0][i+1] = s[0][i] + a[0][i+1];
    }
    rep(i, n - 1)rep(j, n - 1){
        s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + a[i+1][j+1];
    }

    rep(i, Q){
        if (p[i] > 0){
            cout << s[q[i]][q[i]] + s[p[i]-1][p[i]-1] - s[p[i]-1][q[i]] - s[q[i]][p[i]-1] << endl;
        }else{
            cout << s[q[i]][q[i]] << endl;
        }
        
        
    }
    
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL long long
const int MAXN = 1e5 ;
using namespace std ;

inline LL read ( ) {
	int x = 0 , w = 1 ; char c = '-' ;
	
	while ( c < '0' || c > '9' ) { c = getchar ( ) ; if ( c == '-' ) w = -1 ; }
	while ( c >= '0' && c <= '9' ) { x = ( x << 1 ) + ( x << 3 ) + ( c ^ '0' ) , c = getchar ( ) ; }
	
	return x * w ;
}

LL f[MAXN + 5] , a[MAXN + 5] , b[MAXN + 5] , c[MAXN + 5] ;

int main ( ) {
	int n = read () ;
		
	for ( int i = 1 ; i <= n ; ++i ) 
		a[i] = read ( ) ;
	
	for ( int i = 1 ; i <= n ; ++i ) 
		b[i] = read ( ) ;
	
	for ( int i = 1 ; i <= n ; ++i ) 
		c[i] = read ( ) ;
	
	sort ( a + 1 , a + 1 + n ) ;
	sort ( b + 1 , b + 1 + n ) ;
	sort ( c + 1 , c + 1 + n ) ;
	
	int p = 0 ;
	
	for ( int i = 1 ; i <= n ; ++i ) {
		while ( p < n && a[p + 1] < b[i] ) ++p ;
		f[i] = p ;
	}
	
	p = 0 ;

	LL Ans = 0 , tmp = 0 ;
	
	for ( int i = 1 ; i <= n ; ++i ) {
		while ( p < n && b[p + 1] < c[i] ) ++p , tmp += f[p] ;
		Ans += tmp ; 
	}

	
	printf ( "%lld\n" , Ans ) ;
	
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int inf = 1000003;
const int N = 1005;
int d[N][N] , vis[N][N];
char a[N][N];
int r , c;
priority_queue< pair<int, pair<int, int> >, vector< pair<int, pair<int, int> > >, greater< pair<int, pair<int, int> > > > pq;
bool isValid(int nx , int ny){
    if(nx < 0 || nx >= r || ny < 0 || ny >= c){
        return false;
    }
    if(a[nx][ny] == '#'){
        return false;
    }
    return true;
}
void relax(int sx, int sy , int tx, int ty , int w){
    if(d[tx][ty] > d[sx][sy] + w){
        d[tx][ty] = d[sx][sy] + w;
        pq.push({d[tx][ty] , {tx,ty}});
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>r>>c;
    int sx , sy;
    cin>>sx>>sy;
    sx--; sy--;
    int tx, ty;
    cin>>tx>>ty;
    tx--; ty--;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin>>a[i][j];
        }
    }
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            d[i][j] = inf;
        }
    }
    d[sx][sy] = 0;
    pq.push({0 , {sx , sy}});
    while(!pq.empty()){
        auto f = pq.top();
        pq.pop();
        int x = f.second.first;
        int y = f.second.second;
        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                if(i == 0 && j == 0){
                    continue;
                }
                int ax = i + x;
                int bx = j + y;
                if(!isValid(ax , bx)){
                    continue;
                }
                if(abs(i) + abs(j) == 1){
                    relax(x , y, ax , bx , 0);
                }else{
                    relax(x , y , ax , bx , 1);
                }
            }
        }
    }
    if(d[tx][ty] == inf){
        cout<<"-1";
    }else{
        cout<<d[tx][ty];
    }
    
}

Measured memory_bytes: 8628
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
#include <time.h>
#include <bitset>
#include <stack>

using namespace std;

vector <int> a = {11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381};

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    for (int i = 0; i < n; ++i) cout << a[i] << ' ';
    cout << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <unordered_map>

using namespace std;

#define N 33

int cnt[N];

int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        int flag = 1;
        char c;
        unordered_map<string, int> ma;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            if (ma[s]) flag = 0;
            else ma[s] = 1;
            if (i != 0) if (s[0] != c) flag = 0;
            c = s[s.size() - 1];
        }
        if (flag) puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int n,m;
ll ans = 0LL;
ll G[100][100];

void dfs(int i, int cnt, int max_cnt, vector<bool> v){
    if(cnt == max_cnt){
        ll tmp_ans = 0LL;
        repp(x, n){
            if(!v[x]) continue;
            ll tmp = LLONG_MAX;
            repp(y, n){
                if(!v[y] || x == y) continue;
                tmp = min(tmp, G[x][y]);
            }
            tmp_ans += tmp;
        }
        ans = max(ans, tmp_ans);
        return;
    }
    if(i == n) return;

    for(int j=i;j<n;j++){
        bool flag = true;
        repp(x, n){
            if(v[x] && G[j][x] == 0LL){
                flag = false;
                break;
            }
        }
        if(flag){
            v[j] = true;
            dfs(j+1, cnt+1, max_cnt, v);
            v[j] = false;
        }
    }
    return;
}

int main(){
    int u,v;
    ll f;
    cin >> n >> m;
    rep(m){
        cin >> u >> v >> f;
        u--; v--;
        G[u][v] = G[v][u] = f;
    }
    
    reppp(i, 2, 15){
        if(2*m/(i-1) < i) break;
        dfs(0, 0, i, vector<bool>(n, false));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3240
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == 'U' || s[i] == 'D') continue;
		if( !(i&1) && s[i] != 'R') {
			cout << "No";
			exit(0);
		}

		if( (i&1) && s[i] != 'L') {
			cout << "No";
			exit(0);
		}
	}
	
	cout << "Yes";


	return 0;
}


Measured memory_bytes: 256
private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDouble() = readLn().toDouble()
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main(args: Array<String>) {
    val n=readInt()
    var ac=0
    var wa=0
    var tle=0
    var re=0
    repeat(n){
        when(readLine()){
            "AC"->ac++
            "WA"->wa++
            "TLE"->tle++
            "RE"->re++
        }
    }
    println("AC x $ac")
    println("WA x $wa")
    println("TLE x $tle")
    println("RE x $re")
}

Measured memory_bytes: 58144
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define pi 3.14159265358979323846
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	ll a,b,x;
	cin>>a>>b>>x;
	double ans = (2*x<=a*a*b)?(atan(a*b*b/(2.0*x))):(atan((2.0*b/a)-(2.0*x/(a*a*a))));
	ans *= 180/pi;
	cout<<setprecision(12)<<ans;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class UnionFindTree
{
private:
    int n;
    int groupNum;       // グループの数
    vector<int> parent; // 親ノード
    vector<int> rank;   // 木の高さの上限
    vector<int> num;    // グループの要素数
    int find(int i){
        if(parent[i] == i)
            return i;
        else
            return parent[i] = find(parent[i]);
    }
public:
    UnionFindTree(int n){ // コンストラクタ
        this->n = n;
        groupNum = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // aとbのグループを併合
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                num[b] += num[a];
            }
            else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                num[a] += num[b];
            }
            -- groupNum;
        }
    }
    bool same(int a, int b){ // aとbのグループが同じかを調べる
        return find(a) == find(b);
    }
    int getNum(){ // グループの数を返す
        return groupNum;
    }
    int getNum(int a){ // aのグループの要素数を返す
        return num[find(a)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i=0; i<m; ++i){
        cin >> a[i] >> b[i];
        -- a[i];
        -- b[i];
    }

    UnionFindTree uft(n);
    vector<long long> ans(m);
    ans[m-1] = n * (n - 1LL) / 2;
    for(int i=m-1; i>0; --i){
        ans[i-1] = ans[i];
        if(!uft.same(a[i], b[i])){
            long long tmp = uft.getNum(a[i]) * (long long)uft.getNum(b[i]);
            ans[i-1] -= tmp;
            uft.unite(a[i], b[i]);
        }
    }

    for(int i=0; i<m; ++i)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;

int main(){

    long long N, M;
    cin >> N >> M;

    if(N > M) swap(N, M);

    if(N == 1 && M == 1) cout << 1 << endl;
    else if(N == 1 && M != 1) cout << M - 2 << endl;
    else if(N >= 2 && M >= 2) cout << (N - 2) * (M - 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	double n,d;
	cin>>n>>d;
	int count=0;
	while(n--)
	 {  double x,y;
	 	cin>>x>>y;
	 	double s=sqrt((x*x)+(y*y));
	 	if(s<=d)
	 	  count++;
	 	
	 }
	 cout<<count<<endl;
	 return 0;
}

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

vector<int> a;
map<int,int> ma;

int dp[5100][5100] = {0};
int rec(int i, int j) {
    if (dp[i][j] != 0) return dp[i][j];
    int val = a[i] * 2 - a[j];
    if (!ma.count(val)) return 2;
    int k = ma[val];
    int res = rec(k, i) + 1;
    
    //cout << i << ", " << j << ": " << res << endl;
    
    return dp[i][j] = res;
}

int main() {
    int N; cin >> N;
    a.resize(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    
    for (int i = 0; i < N; ++i) ma[a[i]] = i;
    int res = 2;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            res = max(res, rec(i, j));
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 47764
#include <iostream>
using namespace std;

int main(){
	string yoho;
	string jikkyo;

	cin >> yoho;
	cin >> jikkyo;

	int count = 0;
	for(int i=0; i<3; i++){
		if(yoho[i] == jikkyo[i]){
			count++;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main() {
    int n;
    cin >> n;
    
    vector<ll> l(100);
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
}

Measured memory_bytes: 3592
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))


c = [[0 for _ in range(w)] for _ in range(h)]

z = 0
for i in range(len(a)):
    for j in range(a[i]):
        p = z + j
        y = p // w
        x = p % w
        if(y%2 == 1):x = w - x - 1
        c[y][x] = i+1
    z += a[i]
for b in c:
    s = map(str,b)
    print(' '.join(s))


Measured memory_bytes: 3572
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 2e9
#define infll 1e18
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define PI acos(-1)
#define sz(a) (int) (a).size()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;
typedef long double ld;


const int N = 52;

int n,m,id[] = {1,0,-1,0}, jd[] = {0,1,0,-1};
char grid[N][N];

int main() {
    scanf("%d%d",&n,&m);
    
    lp(i, 1, n) scanf("%s",grid[i]+1);
    
    lp(i, 1, n) lp(j, 1, m) if(grid[i][j] == '#'){
        if(i > 1 && grid[i-1][j] == '#')
            continue;
        if(i < n && grid[i+1][j] == '#')
            continue;
        if(j > 1 && grid[i][j-1] == '#')
            continue;
        if(j < m && grid[i][j+1] == '#')
            continue;
        
        return printf("No\n"), 0;
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
import bisect
x = int(input())
ex = [1]

for b in range(2, 32):
  for p in range(2, 10):
    if b**p <= 1000:
      ex.append(b**p)
    else:
      break
      
ex.sort()
r = bisect.bisect_right(ex, x)
    
print(ex[r-1])



Measured memory_bytes: 3060
#include <iostream>
using namespace std;

int main(int argc, char** argv){
  int n,m,x,y,ans;
  bool possible[100000];
  int count[100000];
  cin >> n >> m;
  for(int i = 0;i < n; i++){
    possible[i] = false;
    count[i] = 1;
  }
  possible[0] = true;
  for(int i = 0; i < m; i++){
    cin >> x >> y;
    count[--x]--;
    count[--y]++;
    if(possible[x]) possible[y] = true;
    if(count[x]==0) possible[x] = false;
  }
  ans = 0;
  for(int i = 0; i < n; i++){
    if(possible[i]) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 768
program main
integer::n,i,k=0
integer, allocatable::a(:),b(:),c(:)
read*,n
allocate(a(n),b(n),c(n-1))
read*,a,b,c
do i=1,n
k=k+b(a(i))
if(a(i)==a(i-1)+1)then
k=k+c(a(i-1))
end if
end do
print*,k
end program main

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#include<algorithm>
#include<vector>
struct bimatch{
	int n;
	vector<vector<int> >G;
	vector<int>match;
	vector<bool>used;
	bimatch(int _n=0):n(_n),G(n),match(n),used(n){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool dfs(int v)
	{
		used[v]=true;
		for(int u:G[v])

		{
			int w=match[u];
			if(w<0||!used[w]&&dfs(w))
			{
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}
	int count()
	{
		int ans=0;
		bool flag=true;
		fill(match.begin(),match.end(),-1);
		while(flag)
		{
			flag=false;
			fill(used.begin(),used.end(),false);
			for(int v=0;v<n;v++)if(match[v]<0&&dfs(v))ans++,flag=true;
		}
		return ans;
	}
};
vector<int>G[2000];
int N,M;
bool used[2000];
void dfs(int u)
{
	used[u]=true;
	for(int v:G[u])
	{
		if(!used[v])dfs(v);
	}
}
main()
{
	cin>>N>>M;
	bimatch P(2*N);
	for(int i=0;i<M;i++)
	{
		int x,y;cin>>x>>y;
		x--,y--;
		P.add_edge(x,N+y);
		G[x].push_back(N+y);
		G[N+y].push_back(x);
	}
	int a=P.count();
	int b=0;
	for(int i=0;i<2*N;i++)
	{
		if(!used[i]&&!G[i].empty())
		{
			dfs(i);
			b++;
		}
	}
	cout<<M-a<<" "<<M-b<<endl;
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>

using namespace std;

using ull = unsigned long long;

using ll = long long;

int main (void){
  ll n, m;
  cin >> n >> m;
  cin.ignore();

  //if(m > 5) m = 5;

  ll x; // 1回あたりの実行時間
  x = 1900 * m + 100 * (n - m);

  // 式
  // 成功確率 1/2^M

  // ans = x + (1-p) * ans
  // ans = x / p

  ll ans;
  ans = x * pow(2, m);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define #Asukaminato ha kawaii
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.
 
 
int main(){
 int n,m;
 int A[100][100],B[100];
 int ans[100];
 cin>>n>>m;
 for (int i = 0; i < n; i++)
 {
   for (int j = 0; j < m; j++)
   {
     cin>>A[i][j];
   }
   
 }
 
 for (int i = 0; i < m; i++)
 {
   cin>>B[i];
 }
  
 
 for (int i = 0; i < n; i++)
 {
  ans[i] = 0; for (int j = 0; j < m; j++)
  {
   ans[i]+=A[i][j]*B[j]; 
  }
  }
  
  for (int i = 0; i < n; i++)
  {
    cout<<ans[i]<<endl;
    
  }
  return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a;string b;
  cin>>a>>b;
  ll c=100*(b[0]-'0')+10*(b[2]-'0')+b[3]-'0';
  print(a*c/100);
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
int gcd(int x,int y)
{
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
int main()
{
	int n;
	cin>>n;
	int x=gcd(n,360);
	cout<<360/x<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
  char cmd[2]; // command
  int digit; // digit to insert
  priority_queue<int> Q;
  while (true) {
    scanf(" %s", cmd);
    if (cmd[0] == 'i') {
      scanf(" %d", &digit);
      Q.push(digit);
    } else {
      if (cmd[1] == 'n') break;
      cout << Q.top() << endl;
      Q.pop();
    }
  }
}

Measured memory_bytes: 5932
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
using namespace std;


unordered_map<ll,ll> m,m2;
unordered_map<ll,vector<ll>> m3;
vector<ll> v,v1;
ll flag; 

ll dfs(ll a)
{
         ll i,j,sum;
         j=0;
         sum=0;
         for(i=0;i<m3[a].size();i++)
          {
              j=m3[a][i];
              if(m.find(j)==m.end())
              {
                  if(m[a]==1)
                  {
                       m[j]=-1;
                       v.push_back(j);
                       dfs(j);
                  }
                  else
                  {
                      m[j]=1;
                      v1.push_back(j);
                      dfs(j);
                  }
              }
              if(m[a]==m[j])
              {
                  cout<<-1;
                  exit(0);
              }
          }
          return i;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    long long int i,j,a,b,n,x,y,z,t,k,sum,sum1;
  //  vector<long long int> v,v1;
    string s,s1;
   // unordered_map<long long int,long long int> m,m1;
  //  unordered_map<long long int,vector<long long int>> m3;
    t=1;
   // cin>>t;
    while(t--)
    {
       cin>>s;
       if(s=="ABC")
       {
           cout<<"ARC";
       }
       else
       {
           cout<<"ABC";
       }
       
    }
}





Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define pii     pair<ll,ll>
#define vi      vector<ll>
#define mp      make_pair
#define pb      push_back
#define F       first
#define S       second
#define pf(n)   printf("%lld\n",n)
#define sf(n)   scanf("%lld",&n)
#define fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)  x.begin(),x.end()
#define ms(n,i) memset(n,i,sizeof n)
#define sz(x)   (ll)x.size()
#define pi      3.141592653589793238
#define hell    1000000007
#define hell2   1000000009
#define endl    '\n'
#define inf     1e18
#define N       100005

int main()
{
    ll n;
    cin>>n;
    ll i,j,k;
    cin>>k;
    vi a(n),dp(n);
    for(i=0;i<n;i++)
        cin>>a[i],dp[i]=inf;
    dp[0]=0;
    for(i=1;i<n;i++){
        for(j=i-1;j>=max(0LL,i-k);j--)
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        //cout<<dp[i]<<" ";
    }
    //cout<<endl;
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
        long long int N,M;
        scanf("%lld %lld", &N,&M);
        if (2*N>=M) {
                printf("%lld\n",M/2);
        }else{
                printf("%lld\n",(2*N+M)/4);
        }
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;

int ans[200005];
set<pair<ll,int> > S;
int main(){
    int n,q; cin >> n >> q;
    vector<pair<ll,pair<ll,ll> > > v;
    for(int i=0;i<n;i++){
        ll s,t,x; cin >> s >> t >> x;
        v.push_back(make_pair(x,make_pair(s-x,t-x-1)));
    }
    for(int i=0;i<q;i++){
        ll d; cin >> d;
        S.insert(make_pair(d,i));
        ans[i]=-1;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        if(S.empty())continue;
        ll l=v[i].second.first;
        ll r=v[i].second.second;
        auto iter=S.lower_bound(make_pair(l,-1));
        while(S.size()&&iter!=S.end()&&(*iter).first<=r){
            ans[(*iter).second]=v[i].first;
            S.erase(iter++);
        }
    }
    for(int i=0;i<q;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 21100
class Graph
  attr_reader :nodes
  
  def initialize(n)
    @n = n
    @nodes = Array.new(@n) { [] }
  end
  
  def add(from, to, cost, time)
    @nodes[from] << [from, to, cost, time]
    @nodes[to] << [to, from, cost, time]
  end
  
  def size
    @n
  end
end

def dijekstra(start, graph, value_as_dist)
  n = graph.size
  dist = Array.new(n) { Float::INFINITY }
  is_fixed = Array.new(n) { false }
  queue = [*0...n]
  
  dist[start] = 0
  is_fixed[start] = true
  
  until queue.empty?
    queue.sort_by! { |i| dist[i] }
    
    tmp = queue.shift
    is_fixed[tmp] = true
    
    graph.nodes[tmp].each do |from, to, cost, time|
      next if is_fixed[to]
      new_len = dist[from] + (value_as_dist == 0 ? cost : time)
      
      if new_len < dist[to]
        dist[to] = new_len
      end
    end
  end
  
  dist
end

while true
  n, m = gets.split.map(&:to_i)

  break if n + m == 0

  graph = Graph.new(m)
  memo = Array.new(m) { Array.new(2) }

  n.times do
    a, b, cost, time = gets.split.map(&:to_i)
    
    graph.add(a - 1, b - 1, cost, time)
  end
  
  gets.to_i.times do
    p_k, q_k, r_k = gets.split.map(&:to_i)

    memo[p_k - 1][r_k + 1] = dijekstra(p_k - 1, graph, r_k) if memo[p_k - 1][r_k + 1].nil?
    
    puts memo[p_k - 1][r_k + 1][q_k - 1]
  end
end

Measured memory_bytes: 11344
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    string S;
    cin >> S;
    ll N = S.size();
    ll ans1 = 0;
    ll ans2 = 0;
    FOR(i,0,N)ans1 += S[i] == (i%2 ? '0' : '1');
    FOR(i,0,N)ans2 += S[i] == (i%2 ? '1' : '0');
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

bool isprime(int x) {
  if (x <= 1) {
    return false;
  } else {
    for (int i=2; i*i<=x; i++) {
      if (x % i == 0) return false;
    }
    return true;
  }
}

int main() {
  int q, ans=0; cin >> q;
  vector<vector<int>> lr(q, vector<int>(2));
  for (int i=0; i<q; i++) cin >> lr[i][0] >> lr[i][1];
  
  vector<int> likes(100001, 0);
  for (int i=3; i<=100001; i++) {
    if (isprime(i) && isprime((i+1)/2)) likes[i] = 1;
  }
  
  vector<int> sl(100002, 0);
  for (int i=0; i<100001; i++) sl[i+1] = sl[i] + likes[i];
  
  for (int i=0; i<q; i++) {
   cout << sl[lr[i][1]+1] - sl[lr[i][0]] << endl;
  }
  return 0;
}


Measured memory_bytes: 6912
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

int main() {

    int N;
    string S;
    cin >> N >> S;

    int pos = 0;
    while (pos != S.size()) {
        if (S[pos] == S[pos + 1]) {
            S.erase(pos, 1);
            continue;
        }
        pos++;
    }

    cout << S.size();
}

Measured memory_bytes: 512
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

h,w = [int(i) for i in input().split()]
b = [input() for i in range(h)]

ans = [[0]*w for i in range(h)]

for i in range(h):
    res = 0
    for j in range(w):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

for i in range(h):
    res = 0
    for j in range(w-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

for j in range(w):
    res = 0
    for i in range(h):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

for j in range(w):
    res = 0
    for i in range(h-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

print(max(max(row) for row in ans) + 1)

Measured memory_bytes: 92380
from scipy.sparse.csgraph import *;from scipy.sparse import *;H,W,*S=open(0).read().split();H,W=int(H),int(W);m=H*W;A=[]
for i in range(m):
 h,w=divmod(i,W)
 if S[h][w]=='S':A=[m*2,h,m*2,w+m]+A
 elif S[h][w]=='T':A=[h,m*3,w+m,m*3]+A
 elif S[h][w]=='o':A+=[h,w+m,w+m,h]
f=maximum_flow(csr_matrix(([999]*4+[1]*(len(A)//2-4),(A[::2], A[1::2])),(m*4,m*4)),m*2,m*3).flow_value;print(f if f<999 else -1)

Measured memory_bytes: 40772
def partition(A,p,r):
    x=int(A[r][1])
    i=p
    for j in range(p,r):
        if int(A[j][1])<=x:
            A[i],A[j]=A[j],A[i]
            i+=1
    A[i],A[r]=A[r],A[i]
    return i

def quickSort(A,p,r):
    if p<r:
        q=partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)
n=int(input())
a=[input().split() for i in range(n)]
a_before=a[:]
quickSort(a,0,n-1)
isStable=True
for i in range(1,n):
    if a[i][1]==a[i-1][1] and a_before.index(a[i])<a_before.index(a[i-1]):
        isStable=False
        break
if isStable:
    print("Stable")
else:
    print("Not stable")
for i in a:
    print(" ".join(i))


Measured memory_bytes: 28900
-- ABC124 C problem
import Control.Monad

{-
-- conversion from String to Int
toInt :: String -> Int
toInt x = read x :: Int

-- obtain [Int] from I/O
getInts :: IO [Int]
getInts = do
  x <- getLine
  let y = (map $ toInt) $ words x
  return y
-}

abc124c :: String -> Int -> Int
abc124c [] n = 0
abc124c ('0':str) n =
  case (mod n 2) of
    0 -> (abc124c str (n+1))
    1 -> 1 + (abc124c str (n+1))
abc124c ('1':str) n =
  case (mod n 2) of
    0 -> 1 + (abc124c str (n+1))
    1 -> (abc124c str (n+1))

-- main function
main :: IO ()
main = do
  s <- getLine
  let l = length s
  let p = abc124c s 0
  print (min (l-p) p)

Measured memory_bytes: 7548
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int num[3][3];
int main(){
  ll n,m;bool ok=true;
  cin>>n>>m;
  vll x(m),d(m-1);
  if(m<=n){cout<<0<<endl;}
  else{
    REP(i,m){
      cin>>x[i];
    }
    sort(x.begin(),x.end());
    REP(i,m-1){
      d[i]=x[i+1]-x[i];
    }
    sort(d.begin(),d.end());reverse(d.begin(),d.end());
    ll r=x[m-1]-x[0];
    REP(i,n-1){
      r-=d[i];
    }
    cout<<r<<endl;
  }
  
}

Measured memory_bytes: 1792
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
lr = [tuple(map(int, input().split())) for _ in range(k)]
lr.sort()
dp = [0]*(n)
cum = [0]*(n)
dp[0] = 1
cum[0] = 1
vals = [0] * k
M = 998244353
for i in range(1,n):
    for j,(l,r) in enumerate(lr):
#         vals[j] = cum[r] - cum[l-1]
        if i-l>=0:
            tmp = cum[max(i-l,0)]
            if i-r-1>=0:
                tmp -= cum[max(0, i-r-1)]
            vals[j] = tmp
            vals[j] %= M
    dp[i] = sum(vals)
    dp[i] %= M    
    cum[i] = cum[i-1] + dp[i]
    cum[i] %= M
ans = dp[n-1]%M
print(ans%M)

Measured memory_bytes: 71980
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    int nowX = 0;
    int nowY = 0;
    int bt = 0;
    rep(i,N){
        int t,x,y;
        cin >> t >> x >> y;
        int mntime = abs(x-nowX) + abs(y-nowY);
        if(mntime==0||(t-bt)<mntime||abs(t-bt-mntime)%2==1){
            cout << "No" << endl;
            return 0;
        }
        nowX=x,nowY=y,bt = t;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    int n;
    cin >> n;

    cout << (n + 1) / 2;

}








Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n, m;

    cin >> n >> m;

    vector <pii> v(n);

    for(int i = 0; i < n; i++)
    {
        cin >> v[i].fi >> v[i].se;
    }

    sort(all(v));

    ll novac = 0;

    for(int i = 0; i < n; i++)
    {
        novac += (ll)min(m, v[i].se) * (ll)v[i].fi;
        m -= min(m, v[i].se);

        if(m <= 0)
        {
            break;
        }
    }

    cout << novac << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;

int main() {
  int64_t A, B, X;
  cin >> A >> B >> X;
  if (X == 1) {
    cout << B - A + 1 << "\n";
  } else {
    if (A == 0) {
      cout << B / X + 1 << "\n";
    } else {
      cout << B / X - (A - 1) / X << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

IS = lambda: int(input())

N = IS()
A = [IS() for _ in range(5)]

mn = min(A)
mi = A.index(mn)
d,m = divmod(N, mn)
print(4 + d + (m != 0))

Measured memory_bytes: 3572
#include <algorithm>
#include <cstdio>
#define MOD 998244353
typedef long long ll;
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
const int mx = 1e6;
ll fact[1000005], inv[1000005], sig[1000005], val1[1000005], val2[1000005];
inline ll C(int n, int m)
{
	if (m < 0 || n < m)
		return 0;
	return fact[n] * inv[m] % MOD * inv[n - m] % MOD;
}
int main()
{
	// freopen("AGC019-F.in", "r", stdin);
	fact[0] = inv[0] = sig[0] = 1;
	for (int i = 1; i <= mx; i++)
		fact[i] = fact[i - 1] * i % MOD;
	inv[mx] = quick_pow(fact[mx], MOD - 2);
	for (int i = mx; i; i--)
	{
		inv[i - 1] = inv[i] * i % MOD;
		sig[i] = fact[i - 1] * inv[i] % MOD;
	}
	int n, m;
	scanf("%d%d", &n, &m);
	if (n > m)
		std::swap(n, m);
	int rem = m;
	for (int i = n + m - 1; i && rem; i--)
	{
		if (rem > i - rem + 1)
		{
			rem--;
			if (rem != m - 1)
				val1[i] = (val1[i + 1] + C(n + m - i - 2, m - (rem + 1)) * C(i, rem)) % MOD;
			else
				val1[i] = C(i, rem);
		}
		else if (rem != m)
			val1[i] = (val1[i + 1] - C(n + m - i - 2, m - (rem + 1)) * C(i, rem - 1)) % MOD;
	}
	rem = n;
	for (int i = n + m - 1; i && rem; i--)
	{
		if (rem > i - rem + 1)
		{
			rem--;
			if (rem != n - 1)
				val2[i] = (val2[i + 1] + C(n + m - i - 2, n - (rem + 1)) * C(i, rem)) % MOD;
			else
				val2[i] = C(i, rem);
		}
		else if (rem != n)
			val2[i] = (val2[i + 1] - C(n + m - i - 2, n - (rem + 1)) * C(i, rem - 1)) % MOD;
	}
	ll cur = C(n + m, m) * m % MOD, ans = cur * sig[n + m] % MOD;
	for (int i = n + m - 1; i; i--)
	{
		(cur -= val1[i] + val2[i]) %= MOD;
		(ans += cur * sig[i]) %= MOD;
	}
	printf("%lld\n", (ans + MOD) * quick_pow(C(n + m, m), MOD - 2) % MOD);
	return 0;
}


Measured memory_bytes: 39168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a(5);
	rep(i,3){
		int x,y;cin >> x >> y;
		a.at(x)++;
		a.at(y)++;
	}
	for(int i=1;i<=4;i++){
		if(a.at(i)>2){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from itertools import accumulate

N,M = map(int,input().split())
info = [list(map(int,input().split())) for _ in range(M)]

cnt = [0]*(N+1)

for L, R in info:
    L -= 1; R -= 1
    cnt[L] += 1
    cnt[R+1] -= 1

cnt = list(accumulate(cnt))

ans = 0
for c in cnt:
    if c >= M:
        ans += 1
print(ans)

Measured memory_bytes: 32464
#include<bits/stdc++.h>
using namespace std;

int main()
{
	char temp;
	int r,c;
	cin>>r>>c;
	long long int grid[r][c]={},dp[r][c]={};
	dp[0][0]=1;
	
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			cin>>temp;
			grid[i][j]=((temp=='.')?1:0);
			if(!i&&j)dp[0][j]=grid[0][j]&dp[0][j-1];
			else if(i&&!j)dp[i][0]=grid[i][0]&dp[i-1][0];	
		}
	}
	
	for(int i=1;i<r;i++)
		for(int j=1;j<c;j++)
			dp[i][j]=((grid[i][j])?dp[i-1][j]+dp[i][j-1]:0)%1000000007;	

	cout<<dp[r-1][c-1]<<"\n";
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
using namespace std;
char arr [51];
int n,f;
int main() {
    cin>>n;
    for (int i =0; i<n; i++){
        cin>>arr[i];
    }
    for (int i =0; i<n; i++){
        if (arr[i] == 'A' && arr[i+1] == 'B' && arr[i+2]=='C'){
            f++;
        }
    }
    cout<<f<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
int n,k,a;
inline int min(int x,int y){return x<y?x:y;}
int main()
{
	scanf("%d%d",&n,&k);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		ans+=min(a,k-a);
	}
	printf("%d\n",ans<<1);
}


Measured memory_bytes: 128
"use strict";
function main(input) {
    let N = parseInt(input.replace("\n", "")) % 10;
    if ([2, 4, 5, 7, 9].indexOf(N) !== -1) {
        console.log("hon");
    } else if ([0, 1, 6, 8].indexOf(N) !== -1) {
        console.log("pon");
    } else {
        console.log("bon");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29600
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll mo=1e9+7;
ll sum=1;

void mod(ll x){
    sum=sum*x;
    sum=sum%mo;
}

int main(){
    int n; cin >> n;
    ll a[n],b[n];
    ll am=0,bm=0,ap,bp;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]>am){am=a[i];ap=i;}
    }
    for(int i=0;i<n;i++){cin >> b[i];if(b[i]>bm)bm=b[i];}
    for(int i=n-1;i>=0;i--){if (b[i]==bm){bp=i;break;}}

    if (am!=bm){sum=0;}
    else if(ap>bp){sum=0;}
    else{
        for(int i=ap+1;i<bp;i++){mod(am);}
        for(int i=ap;i>0;i--){
            if(a[i]==a[i-1]){mod(a[i]);}
        }
        for(int i=bp+1;i<n-1;i++){
            if(b[i]==b[i+1]){mod(b[i]);}
        }
    }
    cout <<sum <<endl;
return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (ll i = 0LL; i < n; i++)
#define repext(i, a, b) for (ll i = a; i < b; i++)
#define reprev(i, n) for (ll i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (ll i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

template <typename T>
vector<T> accum_sum(vector<T> a)
{
    T l = a.size();
    vector<T> ret(l);

    ret[0] = a[0];

    repext(i, 1, l)
    {
        ret[i] = a[i] + ret[i - 1];
    }

    return ret;
}
// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    srt(a);

    vector<ll> a_sum = accum_sum(a);
    int cnt = 1;

    repext(i, 1, n) {
        if (a[i] > a_sum[i - 1] * 2) {
            cnt = 1;
        } else {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N, A, B;
	cin >> N >> A >> B;
	long long ans = 0;
	long long AB = A + B;
	ans += (N / AB) * A;
	N %= AB;
	if(N < A)ans += N;
	else ans += A;
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define MID ((l+r)>>1)
#define lc (rt<<1)
#define rc (rt<<1|1)
#define ls lc,l,MID
#define rs rc,MID+1,r
#define st 1,1,n
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
const int N=1e5+1;
const int M=1e9+7;
int n,m;
int p;
int main(){Accel
	cin>>n;
	int mx=0,k=1,x;
	FOR(i,1,n){cin>>p;
		if(abs(p)>mx)mx=abs(p),k=i,x=p<0?1:0;
	}
	cout<<2*n-2<<endl;
	FOR(i,1,n){
		if(k!=i)
		cout<<k<<" "<<i<<endl;
	}
	if(x){
		for(int i=n-1;i;i--)
			cout<<i+1<<" "<<i<<endl;
	}
	else{
		FOR(i,2,n)
			cout<<i-1<<" "<<i<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, sum=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x>=(K-x))
      sum+=2*(K-x);
    else
      sum+=2*x;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  map<string,bool> m;
  cin >> n;
  char a = '!';
  for(int i=0;i<n;i++){
    string st;
    cin >> st;
    if(a=='!') a=st[0];
    if(m[st] || a!=st[0]){
      cout << "No" << endl;
      return 0;
    }
    a=st[st.size()-1];
    m[st]=true;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
define('MAX', pow(10, 9));
$x = 0;
$a[0] = 0;
for ($i = 1; $i < PHP_INT_MAX; $i++) {
    $tmp = pow($i, 5);
    if ($tmp - $a[$i - 1] > MAX) {
        break;
    }
    $a[$i] = $tmp;
    $a[-$i] = -$tmp;
}

fscanf(STDIN, "%d", $N);
 
$cnt = count($a);
foreach ($a as $k1 => $v1) {
    foreach ($a as $k2 => $v2) {
        if ($v1 - $v2 === $N) {
            printf("%d %d", $k1, $k2);
            break 2;
        }
    }
}


Measured memory_bytes: 16180
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S;
	cin >> S;

	sort(S.begin(), S.end());

	if (S == "abc") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 3564