akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
using namespace std;
const int maxn = 1 << 20;
int n, dat[2 * maxn - 1], dat2[2 * maxn - 1], n2;
void init(int n_) {
	n = 1;
	while (n < n_)n *= 2;
	for (int i = 0; i < 2 * n - 1; i++) {
		dat[i] = INT_MAX;
	}
}
void init2(int n_) {
	n2 = 1;
	while (n2 < n_)n2 *= 2;
	for (int i = 0; i < 2 * n2 - 1; i++) {
		dat2[i] = INT_MAX;
	}
}
void update(int k, int a) {
	k += n - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}
void update2(int k, int a) {
	k += n2 - 1;
	dat2[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat2[k] = min(dat2[k * 2 + 1], dat2[k * 2 + 2]);
	}
}
int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l&&r <= b)return dat[k];
	else {
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}
int query2(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l&&r <= b)return dat2[k];
	else {
		int vl = query2(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query2(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}
typedef pair<int, int> P;
P b[200005];
int nn;
int binary(int k) {
	int lb = -1, ub = nn;
	while (ub - lb > 1) {
		int mid = (ub + lb) / 2;
		if (b[mid].first >= k)ub = mid;
		else lb = mid;
	}
	return b[ub].second;
}
signed main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[200005];
	cin >> nn;
	for (int i = 0; i < nn; i++) {
		cin >> a[i];
	}
	init(nn);
	init2(nn);
	for (int i = 0; i < nn; i++) {
		b[i] = P(a[i], i);
	}
	sort(b, b + nn);
	for (int i = 0; i < nn; i += 2) {
		update(i, a[i]);
	}
	for (int i = 1; i < nn; i += 2) {
		update2(i, a[i]);
	}
	vector<int> ans;
	priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> que;
	que.push(make_tuple(query(0, nn, 0, 0, n), 0, nn));
	int cnt = 0;
	while (!que.empty()) {
		cnt += 1;
		tuple<int, int, int> now;
		now = que.top();
		que.pop();
		int mi, a, b;
		mi = get<0>(now);
		a = get<1>(now);
		b = get<2>(now);
		int pomi;
		pomi = binary(mi);
		int ma;
		if (pomi % 2 == 0)
			ma = query2(pomi, b, 0, 0, n);
		else ma = query(pomi, b, 0, 0, n);
		ans.push_back(mi);
		ans.push_back(ma);
		int poma;
		poma = binary(ma);
		if (pomi > a) {
			if (a % 2 == 0)
				que.push(make_tuple(query(a, pomi, 0, 0, n), a, pomi));
			else
				que.push(make_tuple(query2(a, pomi, 0, 0, n), a, pomi));
		}
		if (poma - 1 > pomi + 1) {
			if ((pomi + 1) % 2 == 0)
				que.push(make_tuple(query(pomi + 1, poma, 0, 0, n), pomi + 1, poma));
			else
				que.push(make_tuple(query2(pomi + 1, poma, 0, 0, n), pomi + 1, poma));
		}
		if (b - 1 > poma) {
			if ((poma + 1) % 2 == 0)
				que.push(make_tuple(query(poma + 1, b, 0, 0, n), poma + 1, b));
			else
				que.push(make_tuple(query2(poma + 1, b, 0, 0, n), poma + 1, b));
		}
	}
	for (int i = 0; i < nn; i++) {
		cout << ans[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 11916
import java.util.*;

public class Main {    
    
   public static void main(String[] args){
       
       Scanner sc = new Scanner(System.in);
    
       String A = sc.next();
       String B = sc.next();
       String C = sc.next();
       
       System.out.println("A" + B.substring(0,1) + "C");
       
   }
}

Measured memory_bytes: 21844
/*

宣告——
汝身在我之下，托付吾之命运于汝之剑，
遵从圣杯之名，若汝遵从此意志此理，回应吧。
在此起誓，吾是成就世间一切行善之人，吾是肃清世间一切罪恶之人，
被狂乱之槛所囚的囚徒。吾是此锁链的操纵者，
汝为身缠三大言灵之七天，从抑止之轮显现吧，天秤之守护者！

*/
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;
vector<int>s[100010];
int main(){
	n=read();int tmp=n,i,j,cur=0;
	tmp*=2;tmp=(int)sqrt(tmp);
	if(tmp*(tmp+1)!=n*2){puts("No");return 0;}
	puts("Yes");
	for(i=1;i<=tmp;i++){
		for(j=1;j<=i;j++){
			s[i+1].push_back(cur+j);
			s[j].push_back(cur+j);
		}
		cur+=i;
	}
	printf("%d\n",tmp+1);
	for(i=1;i<=tmp+1;i++){
		printf("%d",s[i].size());
		for(auto j:s[i]) printf(" %d",j);
		printf("\n");
	}
}


Measured memory_bytes: 4608
#include<stdio.h>

int main() {
	int a[3];

	scanf("%d %d %d", &a[0],&a[1],&a[2]);
	
	int i,j;

	for (i = 0; i < 3; i++) {
		for (j = i; j < 3; j++) {
			if (a[i] > a[j]) {
				int temp;
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
	
	for (i = 0; i < 3; i++) {
		printf("%d", a[i]);
		if (i == 2)break;
		printf(" ");
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 2712
/*
AizuOnline A0038
Poker Hand

*/
#include <stdio.h>
#include <stdlib.h>

extern int compare_int(const void* , const void* );

main()
{ int i,j,cnt;
  int a[5];

  while(5 == scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4]))
  {      qsort(a,5,sizeof(int),compare_int ); 

         cnt = 0;
         for(i=0;i<4;i++)
           for(j=i+1;j<5;j++)
             cnt += (a[i]==a[j])?1:0;
/*   printf("cnt=%d\n",cnt); */
        if(cnt==1)
          printf("one pair\n");
        else if(cnt==2)
          printf("two pair\n");
        else if(cnt==3)
          printf("three card\n");
        else if(cnt==4)
          printf("full house\n");
        else if(cnt==6)
          printf("four card\n");
        else if((a[0]+1 == a[1] &&
           a[0]+2 == a[2] &&
           a[0]+3 == a[3] &&
           a[0]+4 == a[4])||
           (a[0] == 1 &&
            a[1] == 10 &&
            a[2] == 11 &&
            a[3] == 12 &&
            a[4] == 13 ))
          printf("straight\n");
        else
          printf("null\n");
  }

return(0);
}

int compare_int(const void* a, const void* b)
{
	return ( *(int*)a - *(int*)b );
}

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

using P=pair<int,int>;
using S=pair<P,P>;

using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;

int main(){
    int w,h;
    while(cin>>w>>h,h){
        vector<string> l(h+2,""),r(h+2,"");
        for(int i=0;i<w+2;i++){
            l[0]+="#";
            l[h+1]+="#";
            r[0]+="#";
            r[h+1]+="#";
        }
        for(int i=0;i<h;i++){
            cin>>l[i+1]>>r[i+1];
            l[i+1]="#"+l[i+1]+"#";
            r[i+1]="#"+r[i+1]+"#";
        }
        h+=2;
        w+=2;

        int lh,lw;
        int rh,rw;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(l[i][j]=='L'){
                    lh=i,lw=j;
                }
                if(r[i][j]=='R'){
                    rh=i,rw=j;
                }
            }
        }

        P iniL={lh,lw},iniR={rh,rw};
        S ini={iniL,iniR};

        vvvvi dp(h,vvvi(w,vvi(h,vi(w,false))));
        queue<S> que;

        que.push(ini);
        bool isok=false;

        int dh[]={0,1,0,-1};
        int dw[]={1,0,-1,0};
        while(!que.empty()){
            auto state=que.front();
            que.pop();
            P lp=state.first,rp=state.second;
            if(dp[lp.first][lp.second][rp.first][rp.second]) continue;
            dp[lp.first][lp.second][rp.first][rp.second]=true;
            int isL=(l[lp.first][lp.second]=='%');
            int isR=(r[rp.first][rp.second]=='%');
            if(isL+isR==2){
                isok=true;
                break;
            }
            if(isL+isR==1) continue;
            
            for(int i=0;i<4;i++){
                P toL={lp.first+dh[i],lp.second+dw[i]};
                if(l[toL.first][toL.second]=='#') toL=lp;
                P toR={rp.first+dh[i],rp.second-dw[i]};
                if(r[toR.first][toR.second]=='#') toR=rp;
                que.push({toL,toR});
            }
        }
        
        cout<<(isok ? "Yes" : "No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 38496
N,K = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7

# dp[i][j]:i番の子まででj個の飴を分け合う方法の数。
# iの場合、i-1番目の子までj-k個の飴を分け合い、残りのk個をi+1番目の子に与えると考えると
# dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + dp[i-1][j-2] + ... + dp[i-1][j-ai]
# となる。この式のjをj-1とすると
# dp[i][j-1] = dp[i-1][j-1] + dp[i-1][j-2] + dp[i-1][j-3] + ... + dp[i-1][j-1-ai]
# となり、2つの式を引き算すると
# dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1-ai]
# となる。
# j-1-ai < 0 の場合は
# dp[i][j]   = dp[i-1][j] + dp[i-1][j-1] + dp[i-1][j-2] + ... + dp[i-1][0]
# dp[i][j-1] =              dp[i-1][j-1] + dp[i-1][j-2] + ... + dp[i-1][0]
# となるから
# dp[i][j]   = dp[i][j-1] + dp[i-1][j]

dp = [[0 for _ in range(K+1)] for _ in range(N)]

for i in range(K+1):
  if A[0] >= i:
    dp[0][i] = 1
#print(dp)
for i in range(1,N):
  for j in range(K+1):
    if j == 0:
      dp[i][j] = dp[i-1][j]
    elif j-1-A[i] >= 0:
      dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1-A[i]]
    else:
      dp[i][j] = dp[i][j-1] + dp[i-1][j]
    dp[i][j] %= MOD
  #print(dp)

print(dp[N-1][K])


Measured memory_bytes: 171372
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
bool content(int mask,int pos){
	return ((mask & (1<<pos)) != 0);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int N;
	while(cin>>N,N){
		vector<vector<int> > time(N,vector<int>(N+1));
		REP(i,N){
			REP(j,N+1){
				cin >> time[i][j];
			}
		}
		vector<int> dp((1<<N),1e9);
		dp[0] = 0;
		REP(i,N){
			dp[(1<<i)] = time[i][0];
		}
		REP(mask,(1<<N)){
			REP(i,N){//iwokuriasuru
				if(content(mask,i)){
					int minroot = time[i][0];
					REP(j,N) if(content(mask^(1<<i),j)) minroot = min(minroot,time[i][j+1]);
					dp[mask] = min(dp[mask],dp[mask^(1<<i)] + minroot);
				}
			}
			//			cout << mask << " " << dp[mask] << endl;
		}
		cout << dp[(1<<N)-1] << endl;
	}
  return 0;
}

Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl

void solve(){
	int x,n; cin>>x>>n;
	if(n == 0){cout<<x;return;}
	vi v(n);
	rep(i,0,n-1) cin>>v[i];
	sort(all(v));
	if(!binary_search(all(v),x)){cout<<x;return;}
	rep(dif,1,101){
		int key = x-dif;
		if(!binary_search(all(v),key)){cout<<key;return;}
		key=x+dif;
		if(!binary_search(all(v),key)){cout<<key;return;}
	}
}

int main(){
	fastio()
	
	int T = 1; //cin>>T;
	while(T--)solve();

	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {
  int n; cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  string t;
  cin >> t;

  int r = 0;
  int l = 0;
  for(int i=0; i<n; i++){
    string a = s[i];
    string b = s[i];
    for(int j=0; j<a.size(); j++){
      if( a[j] == '?' ) a[j] = 'a';
      if( b[j] == '?' ) b[j] = 'z';
    }
    if( a <= t ) r++;
    if( b >= t ) l++;
  }

  for(int i=n-l; i<=r; i++){
    if( i == r ) cout << i+1 << endl;
    else cout << i+1 << " ";
  }

  return 0;
}

//


Measured memory_bytes: 896
#include <cstdio>

using namespace std;

int n;

char s[100010];

char p[100010];

char getNext(char result, char a1, char a2) {
    if (result == 'o') {
        if (a1 == 'W' && a2 == 'S') {
            return 'W';
        } else if (a1 == 'W' && a2 == 'W') {
            return 'S';
        } else if (a1 == 'S' && a2 == 'S') {
            return 'S';
        } else {
            return 'W';
        }
    } else {
        if (a1 == 'W' && a2 == 'S') {
            return 'S';
        } else if (a1 == 'W' && a2 == 'W') {
            return 'W';
        } else if (a1 == 'S' && a2 == 'S') {
            return 'W';
        } else {
            return 'S';
        }
    }
}

bool check() {
    p[n] = '\0';
    for (int i = 0; i < n - 3; i++) {
        p[i + 3] = getNext(s[i + 2], p[i + 1], p[i + 2]);
    }
    bool test1, test2;
    if (s[0] == 'o') {
        if (p[0] == 'S') {
            test1 = p[1] == p[n - 1];
        } else {
            test1 = p[1] != p[n - 1];
        }
    } else {
        if (p[0] == 'S') {
            test1 = p[1] != p[n - 1];
        } else {
            test1 = p[1] == p[n - 1];
        }
    }
    if (s[n - 1] == 'o') {
        if (p[n - 1] == 'S') {
            test2 = p[0] == p[n - 2];
        } else {
            test2 = p[0] != p[n - 2];
        }
    } else {
        if (p[n - 1] == 'S') {
            test2 = p[0] != p[n - 2];
        } else {
            test2 = p[0] == p[n - 2];
        }
    }
    return test1 && test2;
}

int main() {
    scanf("%d", &n);
    scanf("%s", s);

    if (s[1] == 'o') {
        p[0] = 'W';
        p[1] = 'S';
        p[2] = 'W';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        p[0] = 'S';
        p[1] = 'S';
        p[2] = 'S';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        p[0] = 'S';
        p[1] = 'W';
        p[2] = 'W';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        p[0] = 'W';
        p[1] = 'W';
        p[2] = 'S';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        printf("%d", -1);
    } else {
        p[0] = 'W';
        p[1] = 'S';
        p[2] = 'S';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        p[0] = 'S';
        p[1] = 'W';
        p[2] = 'S';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        p[0] = 'S';
        p[1] = 'S';
        p[2] = 'W';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        p[0] = 'W';
        p[1] = 'W';
        p[2] = 'W';
        if (check()) {
            printf("%s", p);
            return 0;
        }
        printf("%d", -1);
    }
}


Measured memory_bytes: 384
n = int(input())
ps = [3, 5, 7, 11, 13]

ans = 0
for i in range(1, n + 1, 2):
    t = 1
    x = i
    for p in ps:
        cnt = 0
        while x % p == 0:
            x //= p
            cnt += 1
        t *= cnt + 1
    if t == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    
    int group[]={0,0,2,0,1,0,1,0,0,1,0,1,0};
    int a,b;
    cin>>a>>b;
    
    if(group[a]==group[b]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,m,i,j;
    cin>>n>>m;
    ll u,v;
    vector<ll> e[n];
    for(i=0;i<m;i++)
    {
        cin>>u>>v;
        u--;
        v--;
        e[u].pb(v);
        e[v].pb(u);
    }
    vector<bool> vis(n,false);
    queue<ll> q;
    vector<ll> p(n,-1);
    q.push(0);
    vis[0] = true;
    while(!q.empty())
    {
        u = q.front();
        q.pop();
        for(auto v : e[u])
        {
            if(!vis[v]) {vis[v]=true;q.push(v);p[v]=u;}
        }
    }
    ll c = 0;
    for(i=1;i<n;i++) 
    {
        if(p[i]==-1) c++;
    }
    if(c) cout<<"No\n";
    else 
    {
        cout<<"Yes\n";
        for(i=1;i<n;i++)
        {
           cout<<p[i]+1<<"\n";
        }
    }
}


Measured memory_bytes: 12892
#include<bits/stdc++.h>
using namespace std;
string s;
int l,flag;
int main(){
	getline(cin,s);
	l=s.size();
	for(int i=0;i<l;i++)
		if(s[i]=='F'&&flag){
			puts("Yes");
			return 0;
		}
		else if(s[i]=='C')flag++;
	puts("No");
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N= int(input())
s_list = []
p_list = []
for _ in range(N):
    s, p = input().split()
    s_list.append(s)
    p_list.append(int(p))

s_unique = list(set(s_list))
s_unique.sort()
for s in s_unique:
    ps = []
    indexs = [i for i,x in enumerate(s_list) if x==s]
    for index in indexs:
        ps.append(p_list[index])
    ps_sorted_index = np.argsort(ps)[::-1]
    for i in ps_sorted_index:
        print(indexs[i]+1)



Measured memory_bytes: 21280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

inline int gcd(int a, int b) { return (a%b == 0) ? b : gcd(b, a%b); }
inline int fac(int n) { return (n==0) ? 1 : n * fac(n - 1); }

int main() {
    ll p[4];
    double p_unit[4];
    double lit[4] = {0.25, 0.5, 1.0, 2.0};
    for (int i = 0; i < 4; i++)
    {
        cin >> p[i];
        p_unit[i] = p[i] / lit[i];
    }
    ll n;
    cin >> n;

    ll total = 0;
    while (n > 0)
    {
        int max_lit_index = 0;
        for (int i = 0; i < 4; i++) {
            if (n >= lit[i])
                max_lit_index = i;
        }

        double min_lit_unit = 1000000000;
        int min_lit_index = 0;
        for (int i = 0; i < max_lit_index + 1; i++)
        {
            if (min_lit_unit > p_unit[i]) {
                min_lit_unit = p_unit[i];
                min_lit_index = i;
            }
        }

        ll cnt = n / lit[min_lit_index];
        total += cnt * p[min_lit_index];
        n -= cnt * lit[min_lit_index];
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3604
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll A, B, C;
    cin >> A >> B >> C;
    set<ll> abc({A,B,C});
    yes(abc.size() == 2);
    //
    return 0;
}

Measured memory_bytes: 3032
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static long Gcd(long a, long b)
    {
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

    public static void Main()
    {
        //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        //Console.SetOut(sw);
        var N = Read();
        var s = Reads();
        var a = new long[N];
        for (long i = 0; i < N; i++)
            a[i]=s[i];
        var x = new long[N+1];
        var y = new long[N+1];
        x[0] = 0;
        x[N] = 0;
        var m = new long[N];
        for (var i = 0; i <N; i++)
        {
            x[i + 1] = Gcd(x[i], a[i]); // x[i]はa[0] a[1] .....a[i-1] のGCD
        }

        for (var i = N - 1; i >=0; i--)
        {
            y[i] = Gcd(y[i + 1], a[(int)i]);// y[i]はa[i]a[i+1]......a[N-1]のGCD
        }
        for(var i = 0; i < N; i++)
        {
            m[i] = Gcd(x[i], y[i + 1]);
        }

        Console.WriteLine(m.Max());


        //Console.Out.Flush();
    }
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	int n, l, i, j, k;
	
	cin >> n >> l;

	j = 0;
	k = l + 1;
	rep(i, n) {
		j += l + i;
		if (abs(k) > abs(l + i))k = l + i;
	}
	cout << j - k << endl;

	return 0;
}


Measured memory_bytes: 256
A = list(map(int, input().split()))
A.sort()

if A[1] == 1:
    print(1000000)
else:
    ans = 0
    for a in A:
        if a == 1:
            ans += 300000
        elif a == 2:
            ans += 200000
        elif a == 3:
            ans += 100000
    print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
	int n;
	cin>>n;
	string str;
	cin>>str;
	int low=0, high=n-1, cnt=0;
	while(low<high){
		if(str[low]=='W'&&str[high]=='R'){
			str[low]='R';
			str[high]='W';
			cnt++;
		}
		else if(str[low]=='W'){
			high--;
		}
		else{
			low++;
		}
	}
	cout<<cnt;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int k=0;
  for(int i=1;i<N;i++){
    if(s[i]=='E')
      k++;
  }
  int Min=k;
  //cout << Min << endl;
  for(int i=1;i<N;i++){
    if(s[i-1]=='E'&&s[i]=='E'){
      k--;
    }
    if(s[i-1]=='W'&&s[i]=='W'){
      k++;
    }
    Min=min(Min,k);
    //cout << k << endl;
  }
  cout << Min << endl;
}

Measured memory_bytes: 900
# ABC 077
import bisect

N = int(input())
A = sorted([int(j) for j in input().split()])
B = sorted([int(j) for j in input().split()])
C = sorted([int(j) for j in input().split()])
ans = 0
for b in B:
    a_cnt = bisect.bisect_left(A,b)
    c_cnt = N - bisect.bisect_right(C,b)
    ans += a_cnt * c_cnt
print(ans)        

Measured memory_bytes: 23244
#include <stdio.h>
 
int main(){
int i;
int A[3];
for(i = 0; i<3 ;i++){
scanf("%d",&A[i]);
}
int max=A[0];
int min=A[0];
int  mid=A[0];
for(i = 0; i<3 ;i++){
  
if(A[i]>max){
  max=A[i];
}

if(A[i]<min){
  min=A[i];
}
}

for(i = 0; i<3 ;i++){
if(A[i]!=max&&A[i]!=min){
   mid=A[i];
}
}

int x;
x=(mid-min)+(max-mid);

printf("%d\n",x);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3588
A,B,H,M = map(int,input().split())

import math

x=abs(H/12+1/12*M/60-M/60)
x=min(x,1-x)
theta=2*math.pi*x
c=A**2+B**2-2*A*B*math.cos(theta)
print(math.sqrt(c))

Measured memory_bytes: 62344
import numpy as np
from itertools import chain, combinations, product

H, W, K = [int(x) for x in input().split()]
rows = [input() for _ in range(H)]

def create_grid(rows, value_map, dtype=None):
    return np.array([[value_map[c] for c in row] for row in rows], dtype=dtype)
grid = create_grid(rows, {'.': 0, '#': 1})

count = 0
row_combinations = list(chain(*[combinations(range(H), i) for i in range(H)]))
column_combinations = list(chain(*[combinations(range(W), i) for i in range(W)]))
for rows, columns in product(row_combinations, column_combinations):
    copy = grid.copy()
    for i in rows:
        copy[i] = 0
    for j in columns:
        copy[:, j] = 0
    if copy.sum() == K:
        count += 1

print(count)


Measured memory_bytes: 27260
N = list(map(int, input()))
ans = 'N'
if N[0] == N[1] and N[0] == N[2]:
    ans = 'Y'
elif N[1] == N[2] and N[1] == N[3]:
    ans = 'Y'

if ans == 'Y':
    print('Yes')
else:
    print('No')

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


int main() {
	string s;
	cin >> s;
	long ans = 0;
	for (int i = 0; i < (1 << (s.size() - 1)); i++) {
		string t;
		t += s[0];
		for (int j = 0; j < s.size() - 1; j++) {
          
			if (i & (1 << j)) {
				ans += stol(t);
				t = s[j + 1];
			}
          
			else {
				t += s[j + 1];
			}
		}
		ans += stol(t);
	}
	cout << ans << endl;			
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
typedef struct Node {int p,l,r;}Node;

Node T[MAX];
int n,D[MAX];

void print(int u)
{
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)
    printf("root, ");
  else if(T[u].l==NIL)
      printf("leaf, ");
  else   printf("internal node, ");

  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  
  if(T[u].l!=NIL)rec(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL)r=i;
  }
  rec(r,0);

  for(i=0;i<n;i++)
    print(i);

  return 0;
}



Measured memory_bytes: 6456
#include<stdio.h>
int main()
{
	int N, i, a[100], min, max;
	min = 0; max = 0;
	scanf("%d",&N);
	scanf("%d",&a[1]);
	min = a[1]; max = a[1];
	for (i=2; i <= N;i++){ scanf("%d",&a[i]);
		if (a[i] < min) min = a[i];
		else{ if (a[i] > max) max = a[i]; else ;}
	}
	printf("%d",max - min);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    long long ans = 0;
    REP(i, 1000){
        stringstream ss;
        ss << setw(3) << setfill('0') << i;
        auto tmp = ss.str();
        bool is_zero = false, is_one = false, is_two = false;
        REP(j, N){
            if(S[j] == tmp[2] and is_zero and is_one) is_two = true;
            if(S[j] == tmp[1] and is_zero) is_one = true;
            if(S[j] == tmp[0]) is_zero = true;
        }
        if(is_two) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

typedef pair<int, int> P;
typedef tuple<int, int, int> triple;
typedef long long ll;

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1) {
      r *= x;
      r %= MOD;
    }
    x *= x;
    x %= MOD;
    y >>= 1;
  }
  return r;
}

ll fac[200010], facinv[200010];  // 200010 is Larger than 1e5 + 1e5.
void cominit() {
  fac[0] = facinv[0] = 1;
  ll c = 1;
  for (int i = 1; i < 200010; ++i) {
    c *= i;
    c %= MOD;
    fac[i] = c;
    facinv[i] = powmod(c, MOD-2);
  }
}

ll combination(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll permutation(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  map<int, int> factors;
  for (int i = 2; i * i <= M; ++i) {
    while (M % i == 0) {
      ++factors[i];
      M /= i;
    }
  }
  if (M > 1) {
    ++factors[M];
  }

  cominit();
  ll r = 1;
  for (auto x : factors) {
    r *= combination(x.second + N - 1, N - 1);
    r %= MOD;
  }

  cout << r << endl;
}


Measured memory_bytes: 3328
#include<stdio.h>
#define size 1000000
int a[size],c[size];
void seive()   {    int i,j;
    //for(i=0;i<size;i++)    a[i]=1;    a[0]=a[1]=0;
    for(i=4;i<size;i+=2)     a[i]=1;
    for(i=3;i*i<size;i+=2)   {
        if(!a[i])   {
            for(j=i*i;j<size;j+=2*i)
                a[j]=1;  }   }    }

int main()
{
    seive();
    int i,n=0,x;
    for(i=2;i<size;i++)
    {
        if(!a[i])
        {
            n++;
        }
        c[i]=n;
    }
    while(scanf("%d",&x)==1)
    {
        printf("%d\n",c[x]);
    }
    return 0;
}

Measured memory_bytes: 8836
N = int(input())
c = [[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
    top = int(str(i)[0])
    bot = int(str(i)[-1])
    c[top][bot]+=1

ans=0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int> a(5);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	int k; cin >> k;
	int key = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = i; j < 5; j++) {
			int dis = abs(a[i] - a[j]);
			if (dis > k) {
				key++;
			}
		}
	}
	if (key == 0) { cout << "Yay!" << endl; }
	else { cout << ":(" << endl; }
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Queue<String> p = new LinkedList<>();
		Queue<Integer> values = new LinkedList<>();
	
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int q = in.nextInt();		
		
		int time = 0;
		
		in.nextLine();
		while(n > 0) {
			p.add(in.next());
			values.add(in.nextInt());
			n--;
			
			
		}
		
		while (!p.isEmpty()) {
			String pr = p.poll();
			Integer ti = values.poll();
			
			if (ti <= q)
			{
				time += ti;
				System.out.println(pr + " " + time);
			}
			else
			{
				ti = ti - q;
				p.add(pr);
				values.add(ti);
				time += q;
			}
		}
	
		
		
	
	
	}
	

}


Measured memory_bytes: 77784
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    vector<long> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];

    vector<long> ps(n + 1);
    for (int i = 0; i < n; i++) {
        ps[i + 1] = ps[i] + x[i];
    }
    long res = LONG_MAX;
    for (int k = 1; k <= n; k++) {
        int i = n;
        long s = 0;
        int c = 0;
        while (i > 0) {
            int j = max(i - k, 0);
            long y = (3 + c * 2);
            if (c == 0) y += 2;
            s += (ps[i] - ps[j]) * y;
            if (s > 1e17) s = 1e17;
            c++;
            i = j;
        }
        s += 1ll * (k + n) * q;
        res = min(res, s);
    }
    cout << res << "\n";

    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> count(N, 0);
  for(int i = 0; i < 2 * M; i++){
    int a;
    cin >> a;
    count.at(a - 1) ++;
  }
  for(int i = 0; i < N; i++){
    cout << count.at(i) <<endl;
  }
}

Measured memory_bytes: 256
str1 = input()
str2 = input()

n = len(str1)
d1 = dict()
d2 = dict()
for i in range(26):
    d1[chr(97+i)] = ''
    d2[chr(97+i)] = ''
res = "Yes"
for i in range(n):
    if d1[str1[i]] != '' and d1[str1[i]]!=str2[i]:
        res = "No"
        break
    if d2[str2[i]] != '' and d2[str2[i]]!=str1[i]:
        res = "No"
        break
    if d1[str1[i]] == '':
        d1[str1[i]] = str2[i]
    if d2[str2[i]] == '':
        d2[str2[i]] = str1[i]
print(res)


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int n, k, x, y;

int main() {
  cin >> n >> k >> x >> y;
  if (n > k) {
    cout << x * k + y * (n - k);
  } else {
    cout << x * n;
  }
}


Measured memory_bytes: 3616
import java.util.Scanner;

/**
 *
 * @author kids
 */
public class Main {
    
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        int vert=scanner.nextInt();
        int horiz=scanner.nextInt();
        
        int table[][]=new int[101][101];
        
        for(int i=0;i<vert;i++){
            for(int j=0;j<horiz;j++){
                table[i][j]=scanner.nextInt();
            }
        }
        
        for(int i=0;i<vert;i++){
            table[i][horiz]=0;
            for(int j=0;j<horiz;j++){
                table[i][horiz]+=table[i][j];
            }
        }
        
        for(int i=0;i<horiz;i++){
            table[vert][i]=0;
            for(int j=0;j<vert;j++){
                table[vert][i]+=table[j][i];
            }
        }
        
        table[vert][horiz]=0;
        for(int i=0;i<horiz;i++){
            table[vert][horiz]+=table[vert][i];
        }
        
        for(int i=0;i<vert+1;i++){
            for(int j=0;j<horiz;j++){
                System.out.print(table[i][j]+" ");
            }
            System.out.print(table[i][horiz]+"\n");
        }
        
    }   
     
}

Measured memory_bytes: 41436
from sys import stdin

S = stdin.read().lower()

alphabet = 'abcdefghijklmnopqrstuvwxyz'
count = [0] * len(alphabet)

for c in S:
    if c in alphabet:
        i = alphabet.index(c)
        count[i] += 1

for i in range(len(alphabet)):
    print(alphabet[i], ':', count[i])



Measured memory_bytes: 5576
from fractions import gcd


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


A, B, K = map(int, input().split())
a = gcd(A, B)
Ans = make_divisors(a)

print(Ans[K-1])

Measured memory_bytes: 63980
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <sstream>

using namespace std;

int N, K;

int main(){
    
    cin >> N >> K;
    
    int a = 1, b = 1, ans = 0;
    
    for(int i = 1; i < N+1; i++){
        
        a *= 2;
        b += K;
        ans = min(a ,b);
        a = ans;
        b = ans;
    }
    

    cout << ans << endl ;
    
    return 0;
}


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

int abs(int a){
    return (a>0?a:-a);
}
int main(){
    int N;
    cin >> N;
    vector<int> t(N),x(N),y(N);
    for(int i=0;i<N;i++){
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }
    if(N!=1){
        for(int i=0;i<N-1;i++){
            if(abs(t.at(i+1)-t.at(i))%2 == (abs(x.at(i+1)-x.at(i))+abs(y.at(i+1)-y.at(i)))%2 && abs(t.at(i+1)-  t.at(i)) >= abs(x.at(i+1)-x.at(i))+abs(y.at(i+1)-y.at(i)) ){
                continue;
            }else{
                cout << "No" << endl;
                goto Exit;
            }
        }
    }else if(N==1){
        if(t.at(0)%2 == (abs(x.at(0))+abs(y.at(0)))%2 && abs(t.at(0)) >= abs(x.at(0))+abs(y.at(0))) ;
        else{
            cout << "No" << endl;
            goto Exit;
        }
    }
    cout << "Yes" << endl;
Exit:
    ;
}


Measured memory_bytes: 1408
n,k = map(int,input().split())
li = list(map(int,input().split()))
rc = [list(map(int,input().split())) for i in range(k)]

rc.sort(key=lambda x:x[1], reverse=True)

tmp = 0

for i in rc:
    li += [i[1]]*i[0]
    tmp += i[0]
    if tmp>n:
        break 

print(sum(sorted(li, reverse=True)[0:n]))

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

using namespace std;
int main(int argc, const char * argv[]) {
    int data[5], div[5];
    int i, min, pos, sum;
    min = 10;
    pos = -1;
    sum = 0;
    for(i = 0;i < 5;i++){
        cin >> data[i];
        div[i] = data[i] % 10;
        if(min > div[i] && div[i] != 0){
            min = div[i];
            pos = i;
        }
    }
    // printf("%d\n", pos);
    if(pos == -1){
        printf("%d\n", data[0]+data[1]+data[2]+data[3]+data[4]);
    }else{
        for(i = 0;i<5;i++){
            if(i != pos){
                if(data[i] % 10 != 0){
                    sum += data[i]+(10 - data[i] % 10);
                }else{
                    sum += data[i];
                }
            }else{
                sum += data[pos];
            }
        }
        printf("%d\n", sum);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;++i)
#define dec(i,j,k) for(re int i=j;i>=k;--i)
#define ll long long
using namespace std;
const int ii=500000004;
const int mod=1e9+7;
const int maxn=2010;
const int maxm=10010;
inline int read()
{
	re int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+(ch^48); ch=getchar();}
	return x*f;
}
inline ll re_ad()
{
	re ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+(ch^48); ch=getchar();}
	return x*f;
}
ll fac[maxm],facinv[maxm],inv[maxm];
ll dp[5010][5010];
int n,a[1000005],b[1000005];
ll qmul(ll a,ll b)
{
	ll base=0;
	while(b)
	{
		if(b&1) base=(base+a)%mod;
		b>>=1;
		a=(a+a)%mod;
	}
	return base;
}
ll qpow(ll a,ll b)
{
	ll base=1;
	while(b)
	{
		if(b&1) base=qmul(base,a);
		b>>=1;
		a=qmul(a,a);
	}
	return base;
}
void init()
{
	fac[0]=1; inv[0]=0; inv[1]=1; fac[1]=1;
	inc(i,2,maxm-10) fac[i]=fac[i-1]*i%mod,inv[i]=(mod-(mod/i)*inv[mod%i])%mod;
	facinv[maxm-10]=qpow(fac[maxm-10],mod-2);
	dec(i,maxm-11,0) facinv[i]=facinv[i+1]*(i+1)%mod;
}
ll C(int n,int m)
{
	return fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
int main()
{
	init();
	n=read();
	inc(i,1,n)
	{
		a[i]=read(); b[i]=read();
		dp[maxn-a[i]][maxn-b[i]]++;
	}
	inc(i,-maxn+1,maxn)
	    inc(j,-maxn+1,maxn)
		{
			dp[maxn+i][maxn+j]+=dp[maxn+i-1][maxn+j]+dp[maxn+i][maxn+j-1];//从左边来的方案+从下面来的方案 
			dp[maxn+i][maxn+j]%=mod;
		}
	ll ans=0;
	inc(i,1,n)
	{
		ans+=dp[a[i]+maxn][b[i]+maxn];
		ans%=mod;
		ans-=C((a[i]+b[i])<<1,min(a[i],b[i])<<1);
		ans=(ans+mod)%mod;
	}
	ans=qmul(ans,ii);
	cout<<ans<<endl;
} 

Measured memory_bytes: 165120
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, i;
    scan(N, i);
    auto ans = N + 1 - i;
    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

#define ALL(x) begin(x), end(x)

int main() {
  string S;
  cin >> S;
  bool pred =
      S[0] == 'A' && count(S.begin() + 2, S.end() - 1, 'C') == 1 &&
      all_of(S.begin()+1,S.end(), [](char c) { return (c >= 'a' && c <= 'z') || c == 'C'; });

  cout << (pred ? "AC" : "WA") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) rep(i, 0, n)
using namespace std;

set<int> memo[20][20];

set<int> rec(int l, int r, vector<set<int>>& vals, vector<char>& ops) {
    if (!memo[l][r].empty()) return memo[l][r];
    if (l + 1 == r) return memo[l][r] = vals[l];
    vector<set<int>> L, R;
    L.emplace_back(vals[l]);
    for (int i = r - 1; i > l; --i) R.emplace_back(vals[i]);
    set<int> res;
    for (int i = l; i < r - 1; ++i) {
        set<int> tmp1 = rec(l, i + 1, vals, ops);
        set<int> tmp2 = rec(i + 1, r, vals, ops);
        for (int v1 : tmp1) for (int v2 : tmp2) {
            if (ops[i] == '+') res.emplace(v1 + v2);
            else if (ops[i] == '-') res.emplace(v1 - v2);
            else if (ops[i] == '*') res.emplace(v1 * v2);
            else if (v2 != 0) res.emplace(v1 / v2);
        }
        L.emplace_back(vals[i + 1]);
        R.pop_back();
    }
    return memo[l][r] = res;
}

set<int> num(const string& s, int& i) {
    int tmp = (s[i++] - '0');
    while (isdigit(s[i])) tmp = tmp * 10 + (s[i++] - '0');
    set<int> res;
    res.emplace(tmp);
    return res;
}

set<int> expr(const string& s, int& i) {
    int l = i;
    vector<set<int>> vals;
    vector<char> ops;
    if (s[i] == '(') {
        ++i;    // skip '('
        vals.emplace_back(expr(s, i));
        ++i;    // skip ')'
    } else {
        vals.emplace_back(num(s, i));
    }
    while (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/') {
        ops.emplace_back(s[i]);
        ++i;    // skip op
        if (s[i] == '(') {
            ++i;    // skip '('
            vals.emplace_back(expr(s, i));
            ++i;    // skip ')'
        } else {
            vals.emplace_back(num(s, i));
        }
    }
    REP(i, 20) REP(j, 20) memo[i][j].clear();
    return rec(0, vals.size(), vals, ops);
}

signed main() {
    string s;
    while (cin >> s, s != "#") {
        int i = 0;
        cout << expr(s, i).size() << endl;
    }
}


Measured memory_bytes: 3340
#include<stdio.h>

int main(void){
    long r=0,D=0,x=0;
    scanf("%ld %ld %ld",&r,&D,&x);
    for(int i=1;i<=10;i++){
        x=r*x-D;
        printf("%ld\n",x);
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.*;

class Main {
    BufferedReader bf;
    PrintWriter writer;
    StringBuilder sb;
    static boolean local_system = false;

    void run() throws IOException {
        int[] c = ni();
        int d = c[0] % c[1] == 0 ? c[0] / c[1] : c[0] / c[1] + 1;
        writer.println(d*c[2]);
    }

    public static void main(String[] args) throws IOException {
        long start_time = System.currentTimeMillis();
        Main obj = new Main();
        obj.run();
        long end_time = System.currentTimeMillis();
        if (local_system) obj.writer.println("Time : " + (end_time - start_time));
        obj.close();
    }

    public Main(){
        writer = new PrintWriter(System.out);
        bf = new BufferedReader(new InputStreamReader(System.in));
        sb = new StringBuilder();
    }

    public int i() throws IOException {
        return Integer.parseInt(bf.readLine());
    }

    public long l() throws IOException {
        return Long.parseLong(bf.readLine());
    }

    public int[] ni() throws IOException {
        String[] data = bf.readLine().split(" ");
        int[] send = new int[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Integer.parseInt(data[i]);
        return send;
    }

    public long[] nl() throws IOException {
        String[] data = bf.readLine().split(" ");
        long[] send = new long[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Long.parseLong(data[i]);
        return send;
    }

    public void close() throws IOException{
        writer.flush();
        writer.close();
        bf.close();
    }
}




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

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

    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1'){
            s[i] = '9';
        }else if(s[i] == '9'){
            s[i] = '1';
        }
    }

    cout << s << endl;
    
    return 0;

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		for(int i = 0 ; i < n ; i++) b[i] = sc.nextInt();
		for(int i = 0 ; i < n ; i++) c[i] = sc.nextInt();
		long ans = 0;
		Arrays.sort(a);
		Arrays.sort(c);
		// 中段で全探索
		for(int i = 0 ; i < n ; i++) {
			ans += binarySearch(a, b[i]) * (n - binarySearch(c, b[i] + 1));
		}
		System.out.println(ans);
	}

	// array[i] < targetを満たす最大のiを求める
	public static long binarySearch(int[] array, int target) {
		int l = -1;
		int r = array.length;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			if(array[mid] < target) l = mid;
			else r = mid;
		}
		return r;
	}

}


Measured memory_bytes: 95932
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if (Math.abs(a - b) <= d && Math.abs(b - c) <= d || Math.abs(c - a) <= d) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


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

int main(){
    int N;cin>>N;
    int max = 0;
    int ans = 0;
    for(int i = 0; i < N ; i++){
        int h;cin >> h;
        if(max <= h){
            max = h;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

#define REP(i,a,b) for(int i=a; i<=b; i++)
#define arrL(i,a,b) for(int i=a; i<b; i++)

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    ROUT;
}

void solve()
{
    int n, l;

    string s, ans;

    vector<string>v;

    cin>>n>>l;

    while(n--){
        cin>>s;

        v.pb(s);
    }

    sort(begin(v), end(v));

    ans=v[0];

    if(v.size()>1){
        arrL(i, 1, v.size()){
            ans+=v[i];
        }
    }

    cout<<ans<<endl;
}

int main()

{
    ///fileIO();
    fasterIO();

    solve();

    return 0;
}


Measured memory_bytes: 256