akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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 MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n;
  cin >> n;
  priority_queue<P>q;
  vector<ll>ans(n+1,0);
  rep(i,n){
    ll a;
    cin >> a;
    q.push(P(a,i+1));
  }
  ll idx=n;
  
  while(!q.empty()){
    ll cnt=0;
    auto p=q.top();
    P mp;
    while(!q.empty() && q.top().first==p.first){
      cnt++;
      mp=q.top();
      q.pop();
    }
    idx=min(idx,mp.second);
    
    ll diff;
    if(!q.empty())diff=mp.first-q.top().first;
    else diff=mp.first;
    ans[idx]+=diff*(n-q.size());
  }
  rep(i,n) cout << ans[i+1] << endl;
      
      
      
  
}


Measured memory_bytes: 15600
N, M = map(int, input().split())
S = []
for i in range(M):
    k = list(map(int, input().split()))
    s = k[1:]
    S.append(s)
p = list(map(int, input().split()))

ans = 0
for bit in range(1 << N):
    #矛盾チェック
    flag = True
    for i in range(M):
        sum = 0
        for j in S[i]:
            if bit & (1 << (j-1)):
                sum += 1
        if sum%2 != p[i]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)          

Measured memory_bytes: 39920
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int r; readV(r);
  if (r < 1200)
    writeln("ABC");
  else if (r < 2800)
    writeln("ARC");
  else
    writeln("AGC");
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = input()
    if N[-1] in ('2', '4', '5', '7', '9'):
        print('hon')
    elif N[-1] in ('0', '1', '6', '8'):
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
 
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
 
int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
 
    ll i,j,h;
    ll Q,M,K,P,A,B,C,N,X;
 
    long double x;
 
    string S;
 
    ll ans=0;
    ll count=0;
    ll flag=0;
    ll temp=0;
    vector<char> kotae;
    vector<string> ss;
    ll a,b;
    cin >>N>>A>>B>>C;

rep(i,N){
  cin>>S;
  ss.push_back(S);
}
//cout<<"aa"<<endl;
map <char,ll> mm;
mm['B']=B;
mm['A']=A;
mm['C']=C;
//cout<<0;
if(A+B+C==0){
  cout<<"No"<<endl;
  return 0;
}else if(A+B+C==1){
  rep(i,N){
  	if(mm[ss[i][0]]==0 && mm[ss[i][1]]==0){
      cout << "No"<<endl;
      return 0;
    }else if (mm[ss[i][0]]==0){
      mm[ss[i][0]]++;
      mm[ss[i][1]]--;
      kotae.push_back(ss[i][0]);
    }else{
      mm[ss[i][0]]--;
      mm[ss[i][1]]++;
      kotae.push_back(ss[i][1]);
    }
  }
}else{
    //cout<<"ee"<<endl;
    //cout<<ss[i][0<<ss[i][1]<<endl;
    
	if(mm[ss[0][0]]==0 && mm[ss[0][1]]==0){
        cout<<"No"<<endl;
        return 0;
    }else{
        
        rep(i,N){
            
            if(mm[ss[i][0]]==0){
                mm[ss[i][0]]++;
                mm[ss[i][1]]--;
                kotae.push_back(ss[i][0]);
            }else if(mm[ss[i][1]]==0){
                mm[ss[i][1]]++;
                mm[ss[i][0]]--;
                kotae.push_back(ss[i][1]);
            }else if(i!=N-1 && (mm[ss[i][0]]==1 || mm[ss[i][1]]==1)){
                if(ss[i+1][0]==ss[i][0] || ss[i+1][1]==ss[i][0] ){
                    mm[ss[i][1]]--;
                    mm[ss[i][0]]++;
                    kotae.push_back(ss[i][0]);
                    

                }else{
                    mm[ss[i][1]]++;
                    mm[ss[i][0]]--;
                    kotae.push_back(ss[i][1]);
                }
            
            }else{
                mm[ss[i][0]]--;
                mm[ss[i][1]]++;
                kotae.push_back(ss[i][1]);
            }
        }


    }
}
 

cout<<"Yes"<<endl;
rep(i,N){
    cout<<kotae[i]<<endl;
}
 
    return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a,b;
	cin >> a >>b;
	if(a == 1)
		a += 13;
	if(b == 1)
		b += 13;

	if(a < b)
		cout << "Bob" << endl;
	else if(a > b)
		cout << "Alice" << endl;
	else
		cout << "Draw" << endl;

	return 0;
}

Measured memory_bytes: 256
# 入力：たこ焼きの総数、たこ焼きのキャパシティ、1回焼く時間
num, unit, min = gets.chomp.split.map(&:to_i)
# キャパシティいっぱいで焼く回数
times = (num / unit)
# たこ焼きを焼く半端な数があまっていれば
if (num % unit > 0)
  # 回数を1増やす
  times += 1
end
# 出力：全て焼くための時間
puts  times * min

Measured memory_bytes: 14340
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  when (n /= 0) $ do
    xs <- rgetl n $ split toInt
    mapM_ (putStrLn . concat . map format) $ solve xs
    main
    
solve :: [[Int]] -> [[Int]]
solve = map (\ss -> ss ++ [sum ss]) . transpose . map (\ss -> ss ++ [sum ss]) . transpose
    
format :: Int -> String
format x
  | x < 10 = "    " ++ show x
  | x < 100 = "   " ++ show x
  | x < 1000 = "  " ++ show x
  | x < 10000 = " " ++ show x
  | otherwise = show x

toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

Measured memory_bytes: 4144
import java.io.*;
import java.util.*;

class Main{
	public void run(){
        String s = next();
		String ans = (s.length() >= 4 && s.substring(0, 4).equals("YAKI")) ? "Yes" : "No";
        out.printf("%s\n", ans);
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi pair     <int,int>
#define vss vector  <string>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define PI  3.141592654
#define OO (ll)1e18
#define mod(x,m) (x%m + m )%m
using namespace std;
void ONLINE__JUDGE();

pii swapii( pii pr ){ return { pr.S , pr.F }; }
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 2e7 + 9;

ll n , d;
vector < vii > vec;

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> n >> d;
    for ( int i = 0 , j; i < n; ++i )
    {
        vii v;
        for ( int j = 0,k; j < d; ++j )
            cin >> k , v.pb(k);
        vec.pb(v);
    }

    ll cnt = 0;
    for ( int i = 0; i < n; ++i )
        for ( int j = i+1; j < n; ++j )
        {
            ll dist = 0;
            for ( int k = 0; k < d; ++k )
                dist += (vec[i][k]-vec[j][k])*(vec[i][k]-vec[j][k]);

            ll sqr = sqrt( dist );
            if ( sqr*sqr == dist ) cnt++;
        }
    cout << cnt;
    return 0;
}


void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}



Measured memory_bytes: 256
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define N 400005


void Weapons19(){
    int w,s;cin>>w>>s;
    if(w<=s)cout<<"unsafe";
    else cout<<"safe";



















}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

 
    Weapons19();
    
}


Measured memory_bytes: 3648
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	string w;
	cin >> w;
	vector<int> cnt(26, 0);
	FOR(i, 0, w.size()) {
		cnt[w[i] - 'a']++;
	}

	bool ret = true;
	FOR(i, 0, 26) {
		if (cnt[i] % 2)
			ret = false;
	}
	cout << (ret ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef struct {
	string p;
	long k;
}stu;
int main()
{
	int n, p;
	cin >> n >> p;
	queue<stu>a;
	while (n--)
	{
		stu ko;
		cin >> ko.p >> ko.k;
		a.push(ko);
	}
	long sum = 0;
	while (!a.empty())
	{
		if (a.front().k > p) {
			a.front().k -= p;
			sum += p;
			a.push(a.front());
			a.pop();
		}
		else {
			sum += a.front().k;
			cout << a.front().p << " " << sum << endl;
			a.pop();
		}
	}
	return 0;
}




Measured memory_bytes: 6296
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>

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

using namespace std;
using ll = long long int;

int main(void) {
    int n; cin >> n;
    bool t = false;
    REP(i, 9) {
        REP(j, 9) {
            if ((i + 1) * (j + 1) == n) t = true;
        }
    }
    t ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int P=1e9+7,M=1e5+5;
int n,d,A[M];
int cf[M],_cf[M];
int fast(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=1ll*res*a%P;
		a=1ll*a*a%P;
		b>>=1;
	}
	return res;
}
void add(int &a,int b){
	a+=b;
	if(a<0)a+=P;
	if(a>=P)a-=P;
}
int C(int n,int m){
	if(m>n||m<0)return 0;
	return 1ll*cf[n]*_cf[m]%P*_cf[n-m]%P;
}
int main(){
	cf[0]=_cf[0]=1;
	for(int i=1;i<M;i++)cf[i]=1ll*cf[i-1]*i%P;
	for(int i=1;i<M;i++)_cf[i]=fast(cf[i],P-2);
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++){
		int x;
		scanf("%d",&x);
		if(A[x])d=i-A[x];
		A[x]=i;
	}
	for(int i=1;i<=n+1;i++){
		int a=C(n+1,i);
		add(a,-C(n-d,i-1));
		cout<<a<<'\n';
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
#define endl '\n'
#define DB(x) cout<<#x<<" : "<<x<<'\n'
const ll INF = 1e18L + 5;
int main(){
    // FASTIO;
    string s,t; cin>>s>>t;
    vector<vector<int>> dp(s.size()  + 1 , vector<int>(t.size() + 1, 0));

    for(int i = 1; i< 1 + (int)s.size(); ++i){
        for(int j = 1; j< 1 + (int)t.size(); ++j){
            if(s[i-1] == t[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
 
    int i = (int)s.size(), j = (int)t.size();
    string lcs = "";
    while(i != 0 && j != 0){
        if(dp[i][j] == dp[i-1][j]){
                --i;
        }
        else if(dp[i][j] == dp[i][j-1]){
                --j;
        }
        else{
            lcs += s[i-1];
            --i; --j;
        }
        
    }
    reverse(lcs.begin(), lcs.end());
    cout<<lcs;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0; i<s.length(); i++)
	{
		if(s[i]=='7')
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 200005;
int n, k, a[N];
int suf[N];
unordered_map<int, int> f;
int ans;

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    for(int i = n-1; i >= 0; --i) {
        suf[i] = suf[i+1] + a[i] - 1;
        suf[i] %= k;
    }

    for(int j = 0; j <= n; ++j) {
        if(j - k >= 0) {
            f[suf[j-k]]--;
        }
        ans += f[suf[j]];
        f[suf[j]]++;
    }

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


Measured memory_bytes: 11592
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n=int(input())
l=make_divisors(n)
s=(len(l)+1)//2
a=len(str(l[:s][-1]))
b=len(str(l[::-1][:s][-1]))
print(max(a,b))


Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  long long n;
  int m;
  cin >>n>>m;
  vector<int>a(m);
  long long days =0;
  for (int i=0;i<m;i++){
    cin >>a[i];
    days +=a[i];
  }

  if (days >n){
    cout<<-1<<endl;
  }else {
    cout<<n - days <<endl;
  }
return 0;
}


Measured memory_bytes: 3644
N = int(input())
Nmax1 = [0, 0]
Nmax2 = [0, 0]
A = []
for i in range(N):
    x = int(input())
    if Nmax1[0] <= x:
        Nmax2[0] = Nmax1[0]
        Nmax2[1] = Nmax1[1]
        Nmax1[0] = x
        Nmax1[1] = i
    elif Nmax2[0] < x:
        Nmax2[0] = x
        Nmax2[1] = i

ans = [Nmax1[0]]*N
ans[Nmax1[1]] = Nmax2[0]

for i in ans:
    print(i)


Measured memory_bytes: 10852
#include<iostream>

using namespace std;

int A, B, card[10000][2];

int main(){

	while(1){

		int n, i;

		cin >> n;
		if(n==0){break;}

		A = 0;
		B = 0;

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

		for(i=0; i<n; i++){
			if(card[i][0]==card[i][1]){
				A += card[i][0];
				B += card[i][0];
			}
			else if(card[i][0] > card[i][1]){
				A += card[i][0] + card[i][1];
			}
			else{
				B += card[i][0] + card[i][1];
			}
		}

		cout << A << ' '<< B << endl;

	}

	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
#define MAX 44

int main(){

  int f[MAX],n,i;

  f[0]=1;
  f[1]=1;


  scanf("%d",&n);

  for(i=2 ; i<=n ; i++){
    f[i] = f[i-2] + f[i-1];
  }

  printf("%d\n",f[n]);

  return 0;
}

Measured memory_bytes: 596
MAX = 2*10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

N, M, K = map(int, input().split())
ans = 0

for d in range(1, N):
    ans += d*(N-d)*M**2
    ans %= MOD
    
for d in range(1, M):
    ans += d*(M-d)*N**2
    ans %= MOD

ans *= C(N*M-2, K-2)
ans %= MOD

print(ans)

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

typedef long long int ll;
int col[111],row[111];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("o.txt","w",stdout);
    int h,w;
    cin>>h>>w;
    char a[h][w];

    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
  for(int i=0;i<h;i++)
    {
        int cn=0;
        for(int j=0;j<w;j++)
        {
           if(a[i][j]=='.') cn++;
        }
        if(cn==w) row[i]=1;
    }
    for(int i=0;i<w;i++)
    {
        int cn=0;
        for(int j=0;j<h;j++)
        {
           if(a[j][i]=='.') cn++;
        }
        if(cn==h) col[i]=1;
    }

for(int i=0;i<h;i++)
    {
        if(row[i]!=1){
        for(int j=0;j<w;j++)
        {
         if(col[j]!=1)  cout<<a[i][j];
        }
        cout<<endl;
        }
    }
    return 0;
}



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

typedef long long ll;
int x[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    int k;cin>>k;
    cout<<x[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
pos = []
for i in range(N):
    pos.append(tuple(map(int, input().split())))
total = 0
for i in range(N):
    for j in range(i+1, N):
        x1, y1 = pos[i]
        x2, y2 = pos[j]
        total += ((x2-x1)**2 + (y2-y1)**2)**.5
print(total*2/N)


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

using namespace std;


int main()
{
	int n; cin >> n;
	int arr[n];
	for(auto &i : arr) cin >> i;
	int dp[n];
	for(int i = 0; i < n; i++) dp[i] = 0;
	for(int i = 1; i < n; i++){
		int x = INT_MAX, y = INT_MAX;
		if(i >= 1) x = dp[i-1]+abs(arr[i]-arr[i-1]);
		if(i >= 2) y = dp[i-2]+abs(arr[i]-arr[i-2]);
		dp[i] = min(x,y);
	}
	cout << dp[n-1];
}


Measured memory_bytes: 4408
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int h[100010];
int main()
{
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> h[i];
  }
  h[0]=max(0,h[0]-1);
  bool f = true;
  for(int i=1;i<n;++i){
    if(h[i-1]>h[i]){
      f = false;
      break;
    }
    else if(h[i-1]==h[i]){
      continue;
    }
    else{
      h[i]--;
    }
  }
  if(f){
    cout << "Yes" << "\n";
  }
  else{
    cout << "No" << "\n";
  }
  return 0;
}


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

int main() {
    int A, B, C, K; cin >> A >> B >> C >> K;
    if (A >= K) {
        cout << K << endl;
    } else if (A + B >= K) {
        cout << A << endl;
    } else {
        cout << A - (K - A - B) << endl;
    }
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

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

  vector <ll> AB(N);
  ll ans = 0;
  for (int i = 0; i < N; i++){
    ll A, B; cin >> A >> B;
    AB[i] = A + B;
    ans -= B;
  }
  sort(AB.begin(), AB.end(), greater<ll>());

  for (int i = 0; i < N; i+=2){
    ans += AB[i];
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(){
  int m,f,r;

  while(1){
    cin >> m >> f >> r;
    int sum = m + f;

    if( (m == -1)&&(f==-1)&&(r==-1)) break;
    if( (m == -1)||(f==-1)) {
      cout << "F" << endl;
      continue;
    }

    if(sum >= 80) cout << "A" << endl;
    else if((sum >= 65)&&(sum < 80) ) cout << "B" << endl;
    else if((sum >= 50)&&(sum < 65) ) cout << "C" << endl;
    else if((sum >= 30)&&(sum < 50) ) {
      if(r >= 50) cout << "C" << endl;
      else cout << "D" << endl;
    }
    else if(sum < 30 ) cout << "F" << endl;
  }




}


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

int main(){
	string s;
	cin >> s;
	string ans="No";
	int count = 0;
	for(int i = 1; i < s.length(); i++){
		if(s[i]=='i' & s[i-1]=='h' ){
			count++;
		}
	}
	if(count == s.length()/2 & s.length()%2 ==0){
		ans = "Yes";
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100001];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	sort(a, a + n);
	a[n] = -1;
	
	int ans = 0, p = -1, c = 0;
	inc(i, n + 1) {
		if(a[i] == p) { c++; } else { ans += (c % 2); p = a[i]; c = 1; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll n,ans=0;
void dfs(ll x,ll a,ll b,ll c){
  if(x>n) return;
  if(a&&b&&c) ans++;
  dfs(x*10+3,1,b,c);
  dfs(x*10+5,a,1,c);
  dfs(x*10+7,a,b,1);
}

int main(){
  cin>>n;
  dfs(0,0,0,0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N,W=map(int,input().split())

L=[]
for i in range(N):
    v,w=map(int,input().split())
    L.append([v,w])
    
DP=[0 for i in range(W+1)]

for i in range(N):
    for j in range(W+1):
        if W-j+L[i][1]<=W:
            DP[W-j+L[i][1]]=max(DP[W-j+L[i][1]],DP[W-j]+L[i][0])
print(DP[-1])


Measured memory_bytes: 5928
from collections import deque
queue=deque()
n=int(input())
for _ in range(n):
  command=input().split()
  if command[0]=="insert":
    queue.appendleft(command[1])
  if command[0]=="delete":
    try:
      queue.remove(command[1])
    except:
      pass
  if command[0]=="deleteFirst":
    queue.popleft()
  if command[0]=="deleteLast":
    queue.pop()
print(*queue)


Measured memory_bytes: 69732
import sys
from itertools import permutations as permi
input = sys.stdin.readline
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
t = []
a = 0
b = 0
for pm in permi([x for x in range(1, N + 1)], N): t.append(pm)
for i in range(len(t)):
  if p == t[i]: a = i
  if q == t[i]: b = i 
print(abs(a - b))

Measured memory_bytes: 45680
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
  int n;
  cin>>n;
  int ans=0;
  vector<int> v(n),c(n);
  rep(i,0,n) {
    cin>>v[i];
  }
  rep(i,0,n){
    cin>>c[i];
  	if(v[i]>c[i]) ans+=v[i]-c[i];
  }
  cout<<ans;
}


Measured memory_bytes: 256
import java.io.IOException;

public class Main{
    public static void main(String[] a) throws IOException {

		java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
		int change;
		int[] Hill = new int[]{0,0,0,0};

		for(int i = 0;i < 10;i++){
			Hill[3] = Integer.parseInt(in.readLine());

			for(int j=2;j >= 0;j--){
				if(Hill[j+1] > Hill[j]){
					change = Hill[j+1];
					Hill[j+1] = Hill[j];
					Hill[j] = change;
				}else{
					break;
				}
			}
		}
		for(int i=0;i < 3;i++){
			System.out.println(Hill[i]);
		}
    }
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	char str[26];
	scanf("%s",str);
	str[3] = '\0';
	puts(str);
	return 0;
}

Measured memory_bytes: 3716
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

fn main() {
   input! {
      n: usize,
      m: usize,
      abc: [(Usize1, Usize1, i64); m]
   }
   let mut to = vec![vec![]; n];
   for (a, b, c) in abc {
      to[a].push((b, c));
   }
   let inf: i64 = 1001001001001001001;
   let mut score = vec![-inf; n];
   score[0] = 0;
   for _ in 0..n {
      let mut s = score.clone();
      for v in 0..n {
         if score[v] == -inf {
            continue;
         }
         for &(u, c) in to[v].iter() {
            s[u] = std::cmp::max(s[u], score[v] + c);
         }
      }
      score = s;
   }

   let ans = score[n - 1];

   for _ in 0..n {
      let mut s = score.clone();
      for v in 0..n {
         if score[v] == -inf {
            continue;
         }
         for &(u, c) in to[v].iter() {
            s[u] = std::cmp::max(s[u], score[v] + c);
         }
      }
      score = s;
   }

   if ans < score[n - 1] {
      println!("inf");
   } else {
      println!("{}", ans);
   }
}


Measured memory_bytes: 2236
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
ll dp[110000][3];
ll happy[110000][3];
int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           rep(i,1,n+1){
             rep(j,0,3){
            cin>>happy[i][j]; 
             }
           }
           rep(i,1,n+1){
             rep(place,0,3){
              rep(j,0,3){
                if(j==place)continue;
                chmax(dp[i][place],dp[i-1][j]+happy[i][place]);
              }
             }
           }
           ll ans=0;
           rep(i,0,3){
            chmax(ans,dp[n][i]); 
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 8268
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
int n,d[105];
main(){
	while(~getI(n)){
		F(i,0,n){
			VgetII(a,b);
			d[i]=(a==b);
		}
		bool yes=0;
		F(i,0,n-2)
			if(d[i]&&d[i+1]&&d[i+2]) yes=1;
		puts(yes==1?"Yes":"No");
	}
}


Measured memory_bytes: 3752
/*input

*/
/**
 * Vacation
 * @author: Raj
 */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#define endl '\n'
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define MOD 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb(n) emplace_back(n)
#define pb(n) push_back(n)
#define F first
#define S second
#define int long long int
#define double long double
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
void note_to_myself(){
	//new_data_set s;
	//logn operations
	//cout << *(s.find_by_order(day)) << " ";
	//cout << "The index of number 6::" << p.order_of_key(6) << endl; 
}
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mul(int x, int y) {
	return ((long long)x * y) % MOD;
}
inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
	a %= MOD;
	if (a < 0) a += MOD;
	int b = MOD, u = 0, v = 1;
	while (a) {
		int t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	assert(b == 1);
	if (u < 0) u += MOD;
	return u;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> dp(3);
	for (int day = 0; day < n; ++day){
		vector<int> newdp(3,0);
		vector<int> c(3);
		for (int i = 0; i < 3; ++i){
			cin >> c[i];
		}
		for (int i = 0; i < 3; ++i){
			for (int j = 0; j < 3; ++j){
				if(i!=j)	newdp[j] = max(newdp[j],dp[i]+c[j]);
			}
		}
		dp = newdp;
	}
	cout << max({dp[0],dp[1],dp[2]}); 
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define precise cout<<fixed<<setprecision(0); 
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define YES cout<<"Yes\n"
#define NO cout<<"No\n"
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  string s;
  cin>>s;
  if(s[0]=='S'&&s[1]=='S'&&s[2]=='S')
  {
    cout<<"0";nl;
  }
  else if (s[0]=='R'&&s[1]=='R'&&s[2]=='R')
  {
    cout<<3;nl;
  }
  else if ((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
  {
    cout<<2;nl;
  }
  else
  {
    cout<<1;nl;
  }
  
  return;
}
int main()
{
    IOS;
    int T=1;
   // cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3756
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;

typedef struct{
  int to;
  int cost;
}edge;
typedef pair<int,int> P;

const int MAX = 101;
const int INF = (1<<25);
vector<edge> V[MAX];
int d[MAX];
int n,k;

void solve(int from){
  fill(d,d+MAX,INF);
  priority_queue<P, vector<P> ,greater<P> > Q;
  d[from] = 0;
  Q.push(P(0,from));
  while(!Q.empty()){
    P p = Q.top();
    Q.pop();
    int now = p.second;
    if(d[now] < p.first) continue;
    for(int i = 0; i < V[now].size(); i++){
      edge e = V[now][i];
      if(d[e.to] > d[now] + e.cost){
	d[e.to] = d[now]+e.cost;
	Q.push(P(d[e.to],e.to));
      }
    }
  }
}

void init(){
  //fill(d,d+MAX,INF);
  for(int i = 0; i <= n; i++) V[i].clear();
}
int main(){

  while(cin >> n >> k &&n+k){
    init();
    for(int i = 0; i < k; i++){
      int in;
      cin >> in;
      if(in){
	int from,to,cost;
	edge info;
	cin >> from >> to >> cost;
	info.cost = cost;
	info.to = to;
	V[from].push_back(info);
	info.to = from;
	V[to].push_back(info);
      }else{
	int from,to;
	cin >> from >> to;
	solve(from);
	if(d[to] == INF) cout << "-1" << endl;
	else cout << d[to] << endl;
      }
    }
  }
  return 0;
}

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

using namespace std;

int main (void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    if ( K < A )
        cout << K << endl;
    else if ( K < A + B )
        cout << A << endl;
    else
        cout << A - min(C, K-A-B) << endl;

    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n;
      cin >> n;
      vector<int> a(n);
      
      for(int i=0; i<n; i++) cin >> a.at(i);
      
      int count=0;
      while(1){
        bool check=false;
        for(int i=0; i<n; i++){
          if(a.at(i)%2==1) check=true;
        }
        if(check) break;
        for(int i=0; i<n; i++) a.at(i)/=2;
        count++;
      }
      
      cout << count << endl;
    }

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N = int(input())
    a = np.array([[0 if c == "." else 1 for c in list(input().strip())] for i in range(N)])

    c = 0
    ok = [False] * N
    all_white = True
    for i in range(N):
        tmp = np.count_nonzero(a[:,i] == 0)
        if tmp > 0:
            c += 1
        if tmp != N:
            all_white = False
            ok[i] = True
    
    if all_white:
        print(-1)
        return
    
    ans = int(1e9)
    for i in range(N):
        if ok[i]:
            tmp = np.count_nonzero(a[i] == 0)
        else:
            tmp = np.count_nonzero(a[i] == 0) + 1
        ans = min(ans, tmp + c)
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16480
#include <cstdio>

using namespace std;

int main() {
    int x, y;
    scanf("%d %d", &x, &y);

    while(x != 0 || y != 0) {
        if (x < y) {
            printf("%d %d\n", x, y);
        } else {
            printf("%d %d\n", y, x);
        }
        scanf("%d %d", &x, &y);
    }
    return 0;
}



Measured memory_bytes: 2704
#include<iostream>
using namespace std;
int main()
{
	int m,n,r=0;
	cin>>n;
	while(n>0)
	{
		m=n%10;
		if(m==7)
		{
			r=1;
			break;
		}
		n-=m;
		n/=10;
	}
	if(r==1)
	cout<<"Yes"<<endl;
	if(r==0)
	cout<<"No"<<endl;
}

Measured memory_bytes: 3136
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const int mod = 1000000007;

struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint RepeatSquaring(mint N, ll P) {
  if (P == 0) return 1;
  if (P % 2 == 0) {
    mint t = RepeatSquaring(N, P / 2);
    return t * t;
  }
  return RepeatSquaring(N, P - 1) * N;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  int N, K;
  cin >> N >> K;
  combination c(N);

  ll ans = 0;
  for (int i = 1; i <= K; i += 1) {
    // まずは赤を並べ、そこに青を入れるi個の場所を考える
    // 赤がN-K個なので隙間は端を含めてN-K+1個

    // 次に、i個の場所に対する青の入れ方を考える
    // これはK個の青の隙間（K-1）個に
    // i-1個のしきりを入れるのと同様なので

    cout << c(N - K + 1, i) * c(K - 1, i - 1) << endl;
  }
  return 0;
}

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

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

int main(){
    int N;
    cin >> N;
    map<int, int> mp;
    for(int i=1; i<=N; i++){
        map<int, int> m = prime_factor(i);
        for(auto x : m)
            mp[x.first] += x.second;
    }

    int ans = 0;
    vector<int> divs;
    for(auto x : mp)
        divs.push_back(x.first);

    int sz = divs.size();
    for(int i=0; i<sz; i++){
        for(int j=i+1; j<sz; j++){
            for(int k=j+1; k<sz; k++){
                int x = divs[i];
                int y = divs[j];
                int z = divs[k];
                if(mp[x] >= 4 && mp[y] >= 4 && mp[z] >= 2) ans++;
                if(mp[x] >= 4 && mp[y] >= 2 && mp[z] >= 4) ans++;
                if(mp[x] >= 2 && mp[y] >= 4 && mp[z] >= 4) ans++;
            }
        }
    }
    for(int i=0; i<sz; i++){
        for(int j=i+1; j<sz; j++){
            int x = divs[i];
            int y = divs[j];
            if(mp[x] >= 24 && mp[y] >= 2) ans++;
            if(mp[x] >= 2 && mp[y] >= 24) ans++;
            if(mp[x] >= 14 && mp[y] >= 4) ans++;
            if(mp[x] >= 4 && mp[y] >= 14) ans++;
        }
    }
    for(int i=0; i<sz; i++){
        int x = divs[i];
        if(mp[x] >= 74) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=1e6+3;
const int M=998244353;



void solve(){
	int k;
	sfi(k)

	string s;
	cin>>s;

	if(s.length()<=k){
		cout<<s;
		return;
	}

	for(int i=0;i<k;i++){
		cout<<s[i];
	}

	cout<<"...";
}	

int main(){	

			solve();

	return 0;	
}

Measured memory_bytes: 3688
#include<cstdio>
#define LL long long
#define maxn 100005
int n,m,id[maxn],st[maxn],tp;
LL k,x[maxn],ans[maxn];
bool vis[maxn];
void swap(int &a,int &b) { int t=a; a=b; b=t; }
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&x[i]);
	for(int i=n;i;i--) x[i]-=x[i-1],id[i]=i;
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=m;i++)
	{
		int a;
		scanf("%d",&a);
		swap(id[a],id[a+1]);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			tp=0;
			for(int j=i;!vis[j];j=id[j]) st[++tp]=j,vis[j]=true;
			for(int j=1;j<=tp;j++) ans[st[j]]=x[st[(k+j-1)%tp+1]];
		}
	for(int i=1;i<=n;i++) ans[i]+=ans[i-1];
	for(int i=1;i<=n;i++) printf("%lld.0\n",ans[i]);
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

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

	int64 k, q;
	cin >> k >> q;
	vector<int64> d(k);
	REP(i, k) cin >> d[i];
	REP(i, q) {
    int64 n, x, m;
    cin >> n >> x >> m;
    vector<int64> v(k);
    int64 sum = x%m;
    int64 zero = 0;
    REP(j, k) {
      v[j] = d[j] % m;
      sum += ((n-1)/k + ((n-1)%k > j)) * v[j];
      if (v[j] == 0) {
        zero += (n-1)/k;
        zero += (n-1)%k > j;
      }
    }
//    cout << sum << endl;
    cout << n-1 - zero - sum/m << endl;
  }
}


Measured memory_bytes: 384