akhauriyash/Code-Regression huggingface dataset:
from collections import deque

n = int(input())
t = [list() for _ in range(n)]
color = [0] * (n-1)

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    t[a].append((b, i))

q = deque([(0, 0)])
while q:
    v, pc = q.popleft()
    nc = 0
    for nv, edge in t[v]:
        nc += 1
        if nc == pc: nc += 1
        color[edge] = nc
        q.append((nv, nc))

print(max(color))
print(*color, sep="\n")

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define tc ll t;cin >> t;while(t--)

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	n %= 10;
	if(n == 3){
		cout << "bon "<<endl;
	}
	else if(n == 0 || n == 1 || n == 6 || n == 8){
		cout << "pon"<<endl;
	}
	else{
		cout << "hon" << endl;
	}
	return 0;
}


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

#define mod 1000000007
#define modd 998244353
#define PI 3.1415926
#define ll long long
#define ld long double
#define pb push_back
#define popb pop_back
#define beg begin()
#define en end()
#define sz(v) (int)((v).size())
#define all(v) (v).begin(),(v).end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define endl "\n"
#define forn(i,a,n) for(int i=a;i<int(n);++i)
#define forb(i,a,n) for(int i=int(n)-1;i>=a;--i)
#define cout(ans) cout<< ans << "\n"
#define couts(ans) cout<< ans <<" "
#define maxx *max_element
#define minn *min_element


void speed()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}


ll c[400005];
ll neg[400005];
void solve()
{
    int n,k;cin>>n>>k;
    int a[n];
    forn(i,0,n)
    {
        cin>>a[i];
    }
    ll sum=0;
    sort(a,a+n);
    forn(i,0,k)

    {
        sum+=a[i];
    }
    cout(sum);
}


int main()
{   
    speed();
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        solve();
    }
}

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

int n;
double memo[321][321][321];

double dp(int i, int j, int k){
	
	if(i + j + k == 0) return 0.0;
	if(memo[i][j][k] != -1.0) return memo[i][j][k];
	
	double den = 1.0 - (double)(n - i - j - k)/(double)n;
	
	double ret = 1.0/(double)den;
	
	if(i) ret += (dp(i-1,j,k)*((double)i/n))/den;
	if(j) ret += (dp(i+1,j-1,k)*((double)j/n))/den;
	if(k) ret += (dp(i,j+1,k-1)*((double)k/n))/den;
	
	return memo[i][j][k] = ret;
}

int main(){
	
	for(int i = 0 ; i < 321 ; i ++)
		for(int j = 0 ; j < 312 ; j ++)
			for(int k = 0 ; k < 312 ; k ++)
				memo[i][j][k] = -1.0;
	
	scanf("%d",&n);
	
	int n1 = 0, n2 = 0, n3 = 0;
	for(int a, i = 0 ; i < n ; i ++){
		scanf("%d",&a);
		(a == 1) ? n1 ++ : (a == 2) ? n2 ++ : n3++;
	}
	
	printf("%.15lf\n",dp(n1,n2,n3));
	
	return 0;
}

Measured memory_bytes: 258688
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int f[200005];
int Find(int x){
    if(f[x]==x)return x;
    return f[x]=Find(f[x]);
}
map<int,int> m;
LL fra[200005];
LL inv[200005];
int mod=1e9+7;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
map<int,int> cnt[200005];
int main(){ 
    fra[0]=1;
    for(int i = 1;i<200005;i++)
        fra[i]=fra[i-1]*i%mod;
    inv[200000]=f_pow(fra[200000],mod-2);
    for(int i = 199999;i>=0;i--)
        inv[i]=inv[i+1]*(i+1)%mod;
    int n,x,y;
    scanf("%d %d %d",&n,&x,&y);
    pii p[200005];
    for(int i = 0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        p[i]=mp(y,x);
    }
    sort(p,p+n);
    for(int i = 0;i<n;i++)
        f[i]=i;
    vector<int> v;
    for(int t=0;t<2;t++)
    for(int i = 0;i<n;i++){
        if(m.find(p[i].y)==m.end()){
            m[p[i].y]=i;
            v.pb(i);
        }
        if(p[m[p[i].y]].x+p[i].x<=x){
            int a=Find(m[p[i].y]);
            int b=Find(i);
            f[a]=b;
        }
        if(p[i].y==p[v[0]].y){
            if(v.size()!=1&&p[i].x+p[v[1]].x<=y){
                int a=Find(v[1]);
                int b=Find(i);
                f[a]=b;
            }
        }
        else{
            if(p[i].x+p[v[0]].x<=y){
                int a=Find(v[0]);
                int b=Find(i);
                f[a]=b;
            }
        }
    }
    for(int i = 0;i<n;i++){
        cnt[Find(i)][p[i].y]++;
    }
    LL ans=1;
    for(int i = 0;i<n;i++){
        int tot=0;
        for(auto it:cnt[i]){
            tot+=it.y;
            ans=ans*inv[it.y]%mod;
         //   if(cnt[i].size()>=2||it.y>=2)
        //    printf("%d ",it.y);
        }
        //if(tot>=2)printf("\n");
        ans=ans*fra[tot]%mod;
    }
    assert(ans>0);
    printf("%lld\n",ans);
}
/*
2 2 1
3 2 3
4 2 4 4 7

*/

Measured memory_bytes: 32244
/* package whatever; // don't place package name! */
     
    import java.util.*;
    import java.lang.*;
    import java.io.*;
     
    /* Name of the class has to be "Main" only if the class is public. */
    class Main
    {
    	public static void main (String[] args)
    	{
    		Scanner sc = new Scanner(System.in);
    		while(sc.hasNext()) {
    			int n = sc.nextInt();
	    		long k = sc.nextLong();
	    		
	    		ArrayList<Long> keys = new ArrayList<Long>();
	    		HashMap<Long, Long> map = new HashMap<Long, Long>();
	    		
	    		for(int i = 0; i < n; i++) {
	    			long a = sc.nextLong();
	    			long b = sc.nextLong();
	    			if(map.containsKey(a)) {
	    				map.put(a, map.get(a) + b);
	    			} else {
	    				map.put(a, b);
	    				keys.add(a);
	    			}
	    		}
	    		Collections.sort(keys);
	  
	    		long sum = 0;
	    		for(long key : keys) {
	    		    sum += map.get(key);
	    			if(sum >= k) {
	    				System.out.println(key);
	    				break;
	    			}
	    		}	
	    		
    		}

    	}
    	
    	public static void debug(ArrayList<Long> o) {
    	    System.out.println(Arrays.toString(o.toArray()));
    	}
    }


Measured memory_bytes: 98664
#include<cstdio>//AT2665
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

int n,a,b,c,d,delta,whole;

double nxt,half=0.5,maxhalf,lft;

int main(){
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    nxt+=c+d;
    nxt/=2;
    half=nxt-c;
    maxhalf=half*(n-1);
    delta=abs(a-b);
    if(delta>(n-1)*nxt+maxhalf){//超过最远距离
        printf("NO\n");
        return 0;
    }
    whole=(int)(delta/nxt);
    lft=delta-nxt*whole;
    if(n&1){//n%2==1
        if(whole&1){
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    else{//n%2==0
        if(whole&1){
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
X,Y=map(int,input().split())
if 2*Y<X or 2*X<Y or not((2*Y-X)%3==0) or not((2*X-Y)%3==0):
  print(0)
else:
  A=(2*Y-X)//3
  B=(2*X-Y)//3
  k=1
  for i in range(A+1,A+B+1):
    k=(k*i)%1000000007
  j=1
  for i in range(1,B+1):
    j=(j*i)%1000000007
  l=(pow(j,1000000005,1000000007)*k)%1000000007
  print(l)
  

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int x,n,i1,i2,i3,ans= 0;
	
	while(1){
		
	
		scanf("%d",&n);
		scanf("%d",&x);
		if(n == 0 && x == 0){
			break;
		}
	
		for(i1= 1;i1 <= n; i1++){
			for(i2 = 1;i2 <= n;i2++){
				for(i3 = 1;i3 <= n;i3++){
					
					if( i1 != i2 && i1 != i3 && i2 != i3 && i1 + i2 + i3 == x){

						ans += 1;
					}			
				}
			}
		}
		printf("%d\n",ans / 6);
		ans =0;
	}
	return 0;
}

Measured memory_bytes: 600
def knapsack(n, w, info):
    # dp[i][j] := i番目までの品物の中から重さの総和がjを超えないように選んだときの、
    #             価値の総和の最大値
    dp = [[0]*(w + 1) for i in range(n + 1)]
 
    for i in range(n):
        for j in range(w + 1):
            weight, value = info[i]
            if j < weight:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value)
    return dp
  
n, t = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

dp = knapsack(n, t, info)
dq = knapsack(n, t, info[::-1])
ans = 0
for i in range(n):
    for j in range(t):
        ans = max(dp[i][j] + dq[n-(i+1)][t-(j+1)] + info[i][1], ans)
print(ans)

Measured memory_bytes: 186968
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> A(n);
    for(int i=0;i<n;i++)cin>>A[i];
    int res = x+n;
    for(int i=0;i<n;i++){
        int day = 1;
        while(true){
            day += A[i];
            if(day<=d)res++;
            if(day>=d)break;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int count =0;
    for (int i =0; i<S.length()-1; i++) {
      if (S.charAt(i) != S.charAt(i+1)) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 25484
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100005
using namespace std;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n, m, x[N], y[N];
bool fuck[405], S[405][405];

bool check(int x, int y){
	for(int k = 1; k <= n; k++)
		if(S[x][k] & S[y][k])
			return false;
	return true;
}

int main(){
	n = read(); m = read();
	for(int i = 1; i <= m; i++) x[i] = read(), y[i] = read();
	for(int i = 1; i <= n; i++){
		fuck[i] = true;
		S[i][i] = true;
		for(int j = m; j && fuck[i] ; j--){
			if(S[i][x[j]] && S[i][y[j]]) fuck[i] = false;
			else if(S[i][x[j]] && !S[i][y[j]])
				S[i][y[j]] = true;
			else if(!S[i][x[j]] && S[i][y[j]])
				S[i][x[j]] = true;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) if(fuck[i])
		for(int j = i + 1; j <= n; j++)
			if(fuck[j] && check(i, j))
				ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  set<ll> se;
  rep(i,0,n){
    ll a;
    cin>>a;
    se.insert(a);
  }
  if(se.sz==n){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<string,int>Psi;

int main(){
  int n;
  cin>>n;
  int tmp=n/1000;
  int s[4];
  s[0]=tmp;
  n=n-tmp*1000;
  tmp=n/100;
  s[1]=tmp;
  n=n-tmp*100;
  tmp=n/10;
  s[2]=tmp;
  s[3]=n%10;
  //cout<<s[0]<<s[1]<<s[2]<<s[3]<<endl;
  int pre=s[0]*10+s[1];
  int fpre=0;
  int fpost=0;
  int post=s[2]*10+s[3];
  if(pre<=12&&1<=pre){
    fpre=1;
  }
  if(post<=12&&1<=post){
    fpost=1;
  }
  if(fpre==1&&fpost==1){
    cout<<"AMBIGUOUS"<<endl;
  }else if(fpre==0&&fpost==0){
    cout<<"NA"<<endl;
  }else if(fpre==0&&fpost==1){
    cout<<"YYMM"<<endl;
  }else{
    cout<<"MMYY"<<endl;
  }
}

Measured memory_bytes: 256
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 1e5 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll n, k, mn = INF, x[N];

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n >> k;

  for(int i = 1; i <= n; i++){
    cin >> x[i];
  }

  for(int i = 1; i <= n - k + 1; i++){
    ll j = i + k - 1;
    ll d = abs(x[j] - x[i]) + min(abs(x[i]), abs(x[j]));
    mn = min(mn, d);
  }

  cout << mn;
}


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

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

    int h[N],m[N];
    for (int i =0; i<N ;i++) {
        cin >> h[i];
        cin >> m[i];
    }

    int M;
    cin >> M;

    int k[M],g[M];
    for (int i =0; i<M ;i++) {
        cin >> k[i];
        cin >> g[i];
    }

    int cntN=0,cntM=0;

    while (true) {
        if (h[cntN] == k[cntM] && m[cntN] == g[cntM]) {
            if (m[cntN] < 10) {
                cout << to_string(h[cntN]) + ":" + "0" + to_string(m[cntN]);
            } else {
                cout << to_string(h[cntN]) + ":" + to_string(m[cntN]);
            }
            if (cntN < N) cntN++;
            if (cntM < M) cntM++;
        } else if (
            h[cntN] < k[cntM] || 
            (h[cntN] == k[cntM] &&
            m[cntN] < g[cntM])
        ) {
            if (m[cntN] < 10) {
                cout << to_string(h[cntN]) + ":" + "0" + to_string(m[cntN]);
            } else {
                cout << to_string(h[cntN]) + ":" + to_string(m[cntN]);
            }
            if (cntN < N) cntN++;
            else cntM++;
        } else {
            if (g[cntM] < 10) {
                cout << to_string(k[cntM]) + ":" + "0" + to_string(g[cntM]);
            } else {
                cout << to_string(k[cntM]) + ":" + to_string(g[cntM]);
            }
            if (cntM < M) cntM++;
            else cntN++;
        }

        if (cntM > M-1 && cntN > N-1) {
            cout << endl;
            break;
        } else if (cntN > N-1) {
            cout << " ";
            for ( ; cntM < M ; cntM++) {
                if (g[cntM] < 10) {
                    cout << to_string(k[cntM]) + ":" + "0" + to_string(g[cntM]);
                } else {
                    cout << to_string(k[cntM]) + ":" + to_string(g[cntM]);
                }

                if (cntM != M-1) {
                    cout << " ";
                }
            }
            cout << endl;
            break;
        } else if (cntM > M-1) {
            cout << " ";
            for ( ; cntN < N ; cntN++) {
                if (m[cntN] < 10) {
                    cout << to_string(h[cntN]) + ":" + "0" + to_string(m[cntN]);
                } else {
                    cout << to_string(h[cntN]) + ":" + to_string(m[cntN]);
                }

                if (cntN != N-1) {
                    cout << " ";
                }
            }
            cout << endl;
            break;
        } else {
            cout << " ";
        }
    }

    return 0;
}



Measured memory_bytes: 3276
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 50 + 5;


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

Measured memory_bytes: 256
from itertools import permutations
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
connected = [[False] * (N+1) for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    connected[a][b] = connected[b][a] = True
ans = 0
for perm in permutations(list(range(2, N+1))):
    perm = (1,) + perm
    for i in range(N-1):
        u, v = perm[i], perm[i+1]
        if not connected[u][v]:
            break
    else:
        ans += 1
print(ans)

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

using namespace std;

const long long INF = 1e18L + 5;
long long int* A;

long long int sum(int i, int j){
    long long int tot = 0;
    for(int k = i; k <= j; k++){
        tot += A[k];
    }
    return tot;
}

int main(){
    int N;
    cin>>N;
    long long int dp[N+1][N+1];
    A = new long long int[N+1];

    for(int i=1; i<= N; i++){
        cin>>A[i];
        dp[i][i] = 0;
    }

    for(int l=2; l<= N; l++){
        for(int i=1; i<= N - l + 1; i++){
            int j = i + l -1;

            long long int temp = sum(i, j);
            dp[i][j] = INF;

            for(int k = i; k < j; k++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + temp);
            }
        }
    }

    cout<<dp[1][N];

    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int n,m;
cin >> n >> m;
vector<vector<int>> a(m,vector<int>(2));
rep(i,m)rep(j,2) cin >> a.at(i).at(j);
int lft = -1,rgt = 1000000;
rep(i,m)rep(j,2){
  lft = max(lft,a.at(i).at(0)) ;
  rgt = min(rgt,a.at(i).at(1)) ;
}
int ans = rgt - lft +1;
cout << (ans>=0?ans:0)<< endl;
}


Measured memory_bytes: 8688
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int D;
long long G;
vector<int> ps, cs;

int main(){
  cin >> D >> G;
  ps.resize(D); cs.resize(D);
  for (int i = 0; i < D; i++) cin >> ps[i] >> cs[i];
  
  int answer = 1000;
  
  for (int mask = 0; mask < (1<<D); mask++) {
    long long total = 0;
    int num = 0;
    
    for (int i = 0; i < D; i++) {
      if (mask & (1<<i)) {
        total += 100 * (i + 1) * ps[i] + cs[i];
        num += ps[i];
      }
    }
    
    if (total >= G) {
      answer = min(answer, num);
    } else {
      for (int i = D - 1; i >= 0; i--) {
        if (!(mask & (1<<i))) {
          for (int j = 0; j < ps[i]; j++) {
            if (total < G) {
              total += 100 * (i + 1);
              num++;
            }
          }
        }
      }
      answer = min(answer, num);
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
N = int(input())

for i in range(1, 10):
    for j in range(1, 10):
        if i * j == N:
            print("Yes")
            break   # 一致すれば jのループを抜けて
    else:
        continue
    break   # i ループを抜ける
else:   # i ループで break しなければ
    print("No")


Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int sum=a+b+c;
  if(sum>=22){
    cout<<"bust"<<endl;
  }
  else{
    cout<<"win"<<endl;
  }
  return(0);
}


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

using namespace std;


#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),v).end()

#define PB(a) push_back(a)
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true){
  int n;cin>>n;
  if(n==0) break;
  int t[n+2][n+2];
  for(int i=1;i<=n;i++)for(int j=0;j<=n;j++) cin>>t[i][j];
  std::vector<int> dp((1<<n),INF);
  dp[0]=0;
  for(int i=0;i<(1<<n);i++){
      for(int j=0;j<n;j++){
          int tmp = i & ~(1<<j);//j?????????????????????
          if(i & (1<<j)){
              for(int k=0;k<n;k++){
                  dp[i]=min(dp[i],dp[tmp]+t[j+1][0]);
                  if(tmp & (1<<k))dp[i]=min(dp[i],dp[tmp]+t[j+1][k+1]);
              }
          }
      }
  }
  cout<<dp[(1<<n)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3332
# coding: utf-8
# Your code here!
import heapq
 
L,R=map(int,input().split())
 
ans=2018*2017
if (R-L)>=2018:
    print("0")
else:
    l=list(range(L,R+1))
    for i in range(len(l)):
        for j in range(i+1,len(l)):
            #print(l[i],l[j],(l[i]*l[j])%2019)
            ans=min(ans,(l[i]*l[j])%2019)
            

    print(ans)
    

Measured memory_bytes: 3060
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v% MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<mod>;

map< ll, int > prime_factor(ll n) {
    map< ll, int > ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

mint comb(ll k, ll n) {
    mint ans = 1;
    if (k - n < n)return comb(k, k - n);
    mint ansMul = 1, ansDiv = 1;
    rep(i, n) {
        ansMul *= (k - i);
        ansDiv *= (i + 1);
    }
    ans = ansMul / ansDiv;
    //ans = ansMul / ansDiv;
    return ans;
}

int main() {
	ll n, m;
    mint ans = 1;
	cin >> n >> m;
    map<ll, int>mp = prime_factor(m);
    for (auto p : mp) {
        ans *= comb(n + p.second - 1, n-1);
    }
    cout << ans<< endl;
	return 0;
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin>>s;
  bool c=false;
  bool cf=false;
  for(int i=0;i<s.size();i++){
    if(s[i]=='C')c=true;
    if(c&&s[i]=='F')cf=true;
  }
  if(cf)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main() {
    int n,l;
    cin >> n >> l;
    vector<int> v(n);
    for(int i=1;i< n+1 ;++i){
        v[i-1] = l+i-1;
    }
    sort(v.begin(),v.end(), [](int a, int b){return abs(a) < abs(b);});
    cout << accumulate(v.begin(),v.end(), 0) - v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

const int N = 1e6 + 4;
const int mod = 1e9 + 7;
int prime[N];
vector<pair<int,int>> tmp[10002];
void sieve(){

	for(int i = 2 ;i  < N ;  ++i){

		if(prime[i])
			continue;

		for(int j = i ; j < N ; j+=i){

			if(!prime[j])
				prime[j] = i;
		}
	}
}

int power(int a , int n){

	int res = 1;
	while(n){

		if(n&1)
			res*=a , res%=mod;
		a = a*a;
		a%=mod;
		n/=2;
	}

	return res;
}

void solve(){

	int n;
	cin>>n;
	vector<int> a(n);

	for(int i = 0 ; i < n ; ++i)
		cin>>a[i];

	sieve();

	map<int,int> mp;

	for(int i = 0 ; i < n ; ++i){

		if(a[i]==1)
			continue;
		int val = a[i];
		while(val > 1){

			int c = val;
			int cnt = 0;
			while(c%prime[val]==0){

				c/=prime[val];
				cnt++;
			}
			tmp[i].pb({prime[val] , cnt});
			val = c;
		}
		//debug(tmp);
		for(auto it : tmp[i]){

			mp[it.ff] = max(it.ss , mp[it.ff]);
		}
	}

	int res = 1;

	for(auto it : mp){

		res*=power(it.ff , it.ss);
		res%=mod;
	}
	int ans = 0;
	for(int i = 0 ; i < n ; ++i){

		int val = 1;

		for(auto it : tmp[i]){

			val *= power(it.ff , it.ss);
			val%=mod;
		}

		int x = res*power(val , mod-2);
		x%=mod;
		ans+=x;
		ans%=mod;
	}

	cout<<ans<<endl;
}


signed main(){
    
    int t;
    t = 1;
    //cin>>t;
    while(t--)
        solve();
}



Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RNG(i, from, to) for (int i = (from); i < (int)(to); i++)
#define gcd(i, j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template <typename S, typename T>
string to_string(pair<S, T> p) { return "(" + to_string(p.first) + "," + to_string(p.second) + ")"; }
template <typename T>
string to_string(T p[2]) { return "[" + to_string(p[0]) + "," + to_string(p[1]) + "]"; }
template <typename T>
void println(T e) { cout << to_string(e) << endl; }
template <typename T>
void println(const vector<T> &v)
{
    cout << "[";
    for (const auto &e : v)
    {
        cout << to_string(e) << ",";
    }
    cout << "]";
    cout << endl;
}
template <typename T>
void println(const vector<vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        println(v);
    }
}
template <typename Iter>
void println(Iter first, Iter last)
{
    for (auto it = first; it != last; it++)
    {
        cout << *it << " ";
    };
    cout << endl;
}
const ll DVSR = 1e9 + 7;

int main(int argc, char const *argv[])
{
    ll N, R;
    cin >> N >> R;
    if (N >= 10)
    {
        cout << R << endl;
    }
    else
    {
        cout << R + (100 * (10 - N)) << endl;
    }
    return 0;
}


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


int main(){
	char out[300],in[300];
	int i,j,a,b;
	
	while(~scanf(" %s ",in)){
		i=0;
		j=0;
		for(i=0;;i++){
			if(in[i]=='\0')break;
			if(i%2==1 && in[i]>'5')j=1;
			if(in[i]<='0' || in[i]>'6')j=1;
		}
		
		if(i%2==1 || j==1){
			printf("NA\n");
			continue;
		}
		
		for(i=0;;i+=2){
			if(in[i]=='\0')break;
			if(in[i]=='6'){
				switch(in[i+1]){
				case '1':
					out[j]='z';
					break;
				case '2':
					out[j]='.';
					break;
				case '3':
					out[j]='?';
					break;
				case '4':
					out[j]='!';
					break;
				case '5':
					out[j]=' ';
					break;
				}
			}else{
				out[j]=(in[i]-'1')*5+in[i+1]-'1'+'a';
			}
			++j;
			out[j]='\0';
		}
		printf("%s\n",out);
	}
	return 0;
}

Measured memory_bytes: 0
require "pp"

n = gets.to_i
half_n = n / 2

res = 0
(1..half_n).each do |x|
    sum_max = (n / x).to_i
    res += x * sum_max * (sum_max + 1) / 2
end

res += n * (n + 1) / 2 - half_n * (half_n + 1) / 2

puts res


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

#define N 1005

using namespace std;

long long A,B,C,AA,BB,CC,k;

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(A);read(B);read(C);read(k);
}
 
int main(){
	init();
	if(abs(A-B)<=1000000000000000000){
		if(k%2==0)
		cout<<A-B<<endl;
		else cout<<B-A<<endl;
	}
	else puts("Unfair");
	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    string s, t;cin >> s >> t;
    rep(i, s.size()) {
        cout << s[i];
        if (i < t.size()) cout << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,a[100],result=0,i,j;

  cin>>n;
  for(i=0;i<n;i++) cin>>a[i];

  for(i=0;i<n-1;i++){
    int now,minnum=101;
    for(j=i;j<n;j++) if(minnum>a[j]){
        now=j;
        minnum=a[j];
      }
    if(i!=now){
      swap(a[i],a[now]);
      result++;
    }
  }
  for(i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl;

  cout<<result<<endl;
  return 0;
}



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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
//cout<<"Yes"<<endl;
//cout<<"No"<<endl;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

vector<ll> Eratosthenes(ll N)
{
    vector<bool> is_prime( N + 1 );
    for( ll i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    vector<ll> P;
    for( ll i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( ll j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.push_back( i );
        }
    }
    return P;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    Pll enjoy;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        enjoy.first=a;
        enjoy.second=ex;
        res.push_back(enjoy);
    }

    // 最後に残った数について
    if (N != 1){
      enjoy.first=N;enjoy.second=1;
       res.push_back(enjoy);
    }
    return res;
}
int main(){
  ll n;
  cin>>n;
  vector <ll>v1;
  vector <ll>v2;
  vector<pair<long long, long long> > res;
  //v1=Eratosthenes(n);
  //v2=enum_divisors(n);
  res=prime_factorize(n);
  ll sum=0;
  REP(i,res.size()){
    ll tmp=res[i].second;
    ll n=1;
    while(1){
      ll k=n+1;
      if(tmp*2<k*(k+1)){
        break;
      }
      n++;
    }
    sum+=n;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3524
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 50; 
using namespace std;

int n, num[N], x[N][N], y[N][N], cnt, vis[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

bool check()
{
	for(int i = 1; i <= n; i++)
		if(vis[i])
			for(int j = 1; j <= num[i]; j++)
				if((y[i][j] && !vis[x[i][j]]) || (!y[i][j] && vis[x[i][j]]))
					return 0; 
	return 1; 
}

void dfs(int step, int res)
{
	if(step == n + 1)
	{
		if(check())
			cnt = max(cnt, res); 
		return; 
	}
	dfs(step + 1, res);
	vis[step] = 1;
	dfs(step + 1, res + 1);
	vis[step] = 0; 
}

int main()
{
	n = read <int> ();
	for(int i = 1; i <= n; i++)
	{
		num[i] = read <int> ();
		for(int j = 1; j <= num[i]; j++)
			x[i][j] = read <int> (), y[i][j] = read <int> (); 
	}
	dfs(1, 0);
	printf("%d\n", cnt); 
	return 0; 
}


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

int main(){
  int A;
  int B;
  int C;
  int D;
  int L;
  int R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if(L > R){
    cout << "Left" <<endl;
  }
  
  else if(L == R){
    cout << "Balanced" << endl;
  }
  
  else{
    cout << "Right" << endl;
  }

}

Measured memory_bytes: 256
import os

n,m = (int(x) for x in input().split())

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for i in range(m):
    a,b = (int(x)-1 for x in input().split())
    unite(a,b)

ans = 0
for i in range(0,n):
    ans = max([ans,size(i)])

print(ans)


Measured memory_bytes: 14756
H, W, M = map(int, input().split())
row=[0]*H #x座標を入れるっちゅうかカウント
col=[0]*W #y座標を入れる
 
mat=[] #座標を入れる
 
for i in range(M):
    h, w = map(int, input().split())
    row[h-1]+=1
    col[w-1]+=1
    mat.append((h-1,w-1))
r=max(row)
c=max(col)
 
rr=[1 if row[i]==r else 0 for i in range(H)] #maxな列のインデックス
cc=[1 if col[i]==c else 0 for i in range(W)] #maxな行のインデックス
 
x=0 #maxな列と行の交差点にある爆弾の個数をカウント
for k in mat:
    if rr[k[0]]==1 and cc[k[1]]==1:
        x+=1
        
if sum(rr)*sum(cc)==x: #行と列の全ての交差点に爆弾があれば-1する
    print(r+c-1)
else:
    print(r+c)

Measured memory_bytes: 153568
#include <iostream>
#include <math.h>
using namespace std;
int insertionSort(int, int, int);
void shellSort(int* , int);
int cnt = 0;
int main(void)
{
	int A[1000000], N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	shellSort(A, N);
}
int insertionSort(int A[], int n, int g)
{
	int v, j, cnt = 0;
	for (int i = g; i < n; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
	return (cnt);
}
void shellSort(int A[], int n)
{
	int cnt = 0;
	int m = 0;
	int G[13] = {  };
	do {
		if (m == 0) { G[0] = n - 1; }
		else { G[m] = G[m - 1] / 2; }
		m++;
	} while (G[m - 1] > 1);
	cout << m << endl;
	for (int i = 0; i < m; i++) {
		cnt += insertionSort(A, n, G[i]);
		cout << G[i] << " ";
	}
	cout << endl << cnt << endl;
	for (int i = 0; i < n; i++) {
		cout << A[i] << endl;
	}
}

Measured memory_bytes: 5064
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll diffx = x2 - x1;
    ll diffy = y2 - y1;
    print(x2 - diffy << " " << y2 + diffx << " " << x1 - diffy << " " << y1 + diffx);
    return 0;
}


Measured memory_bytes: 256
/*
 * src.cpp
 *
 *  Created on: 2016/09/11
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

struct Point{
	int x,y;
	Point(int x=0,int y=0):x(x),y(y){}
	bool operator < (const Point &p)const{
		if (x!=p.x){
			return x<p.x;
		}
		return y<p.y;
	}
};

int H,W,N;

ll cnt[10];
set<Point> st;

int main(){
	scanf("%d %d %d",&H,&W,&N);
	cnt[0]=(ll)(W-2)*(H-2);
	REP(i,N){
		Point p;
		scanf("%d %d",&p.y,&p.x);
		FOR(w,-2,1){
			FOR(h,-2,1){
				int c=0;	//塗られているマスの数
				bool flg=false;	//はみ出しているかのチェック
				REP(dx,3){
					REP(dy,3){
						int x=p.x+w+dx;
						int y=p.y+h+dy;
						if (x<1 || y<1 || x>W || y>H){
							flg=true;	//はみ出した
						}
						if (st.find(Point(x,y))!=st.end()){
							//塗られているマス
							c++;
						}
					}
				}
				if (!flg){
					cnt[c]--;
					cnt[c+1]++;
				}
			}
		}
		st.insert(p);
	}
	REP(i,10){
		printf("%lld\n",cnt[i]);
	}
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string B;
  cin >> B;
  if(B == "A"){
    cout << "T" << endl;
  }
  if(B == "T"){
    cout << "A" << endl;
  }
  if(B == "G"){
    cout << "C" << endl;
  }
  if(B == "C"){
    cout << "G" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i <= (int)(n); i++)

int main()
{
  int n;
  cin >> n;
  
  ll a[n];
  rep(i,n) cin >> a[i];
  
  ll ans = 0;
  rep(i,n)
  {
    ans += a[i]-1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   int x;
   cin >> x;
   cout << 48-x << endl;
}


Measured memory_bytes: 760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            String[] s = new String[N];

            int count = 0;
            int countA = 0;
            int countB = 0;
            int countBoth = 0;

            for (int i = 0; i < N; i++) {
                s[i] = in.next();
                if (s[i].startsWith("B") && s[i].endsWith("A")) {
                    countBoth++;
                } else if (s[i].startsWith("B")) {
                    countB++;
                } else if (s[i].endsWith("A")) {
                    countA++;
                }
                int len = s[i].length();
                for (int j = 0; j < len - 1; j++) {
                    if (s[i].charAt(j) == 'A' && s[i].charAt(j + 1) == 'B') {
                        count++;
                    }
                }
            }

            int minAB = Math.min(countA, countB);
            countA -= minAB;
            countB -= minAB;
            count += minAB;

            if (countBoth > 0) {
                if (minAB > 0 || countA > 0 || countB > 0) {
                    count += countBoth;
                } else {
                    count += countBoth - 1;
                }
            }
            out.println(count);
        }

    }
}



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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    string str; cin >> str;
    cout << str.substr(0, 5) << ' ' << str.substr(6, 7) << ' ' << str.substr(14) << endl;

}


Measured memory_bytes: 384
N = int(input())

# 完全グラフは惜しい
# 各頂点から自身を除く頂点すべてに辺を貼る
# 誤差をなくすために辺を削る
# 元々十分に辺が張られているので、連結は保たれるだろう

# 補グラフ

# 要素数の偶奇で異なる
# 奇数: [1-6, 2-5, 3-4, 7]
# 偶数: [1-8, 2-7, 3-6, 4-5]

e = [[False for _ in range(N + 1)] for _ in range(N + 1)]
# 1-indexed
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i == j: continue
        e[i][j] = True
        e[j][i] = True
# 完全グラフを作る

total = -1
if N % 2 == 0:
    total = N + 1
else:
    total = N
# 補グラフのcounterpartを探すのに使用
# total - 自身 = 相方

for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i == j: continue
        cp_i = total - i
        e[i][cp_i] = False
        # 辺を削る

print(sum(e[i].count(True) for i in range(1, N + 1)) // 2)
# 辺をa->b, b->aで二重計上しているので、半分にする

for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if e[i][j]:
            print(i, j)


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

using namespace std;

int main(){
	long long int n;
	cin>>n;
	long long int count=0;
	if(n==1){
		count++;
		cout<<count;
		return 0;
	}
	count=1;
	long long int sum=1;
	while(n!=1){
		n/=2;
		sum+=count*2;
		count*=2;
	}

	cout<<sum;
}

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

using namespace std;

typedef long long ll;

int main() {
	int N, M;
	while (cin >> N >> M, N || M) {
		vector<int> x(N+1, 0), y(M+1, 0);
		for (int i = 0; i < N; ++i) {
			cin >> x[i+1];
			x[i+1] += x[i];
		}
		for (int i = 0; i < M; ++i) {
			cin >> y[i+1];
			y[i+1] += y[i];
		}
		ll ans = 0;
		map<int, int> mx;
		for (int i = 0; i < x.size(); ++i) {
			for (int j = i+1; j < x.size(); ++j) {
				mx[x[j]-x[i]]++;
			}
		}
		for (int i = 0; i < y.size(); ++i) {
			for (int j = i+1; j < y.size(); ++j) {
				ans += mx[y[j]-y[i]];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 19040