akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;

int D;
int C[26];
int A[365][26];
int con[365];
set<int>st[26];
int score(){
	vector<int>last(26,-1);
	int res=0;
	rep(i,D){
		last[con[i]]=i;
		res+=A[i][con[i]];
		rep(j,26){
			res-=C[j]*(i-last[j]);
		}
	}
	return res;
}
int change(int x,int y){
	int res=A[x][y]-A[x][con[x]];
	auto pre_old=--st[con[x]].lower_bound(x);
	auto next_old=st[con[x]].upper_bound(x);
	res+=(*next_old-x-1)*(*next_old-x)/2*C[con[x]];
	res-=(x-*pre_old+*next_old-*pre_old-1)*(*next_old-x)/2*C[con[x]];
	auto pre_new=--st[y].lower_bound(x);
	auto next_new=st[y].lower_bound(x);
	res+=(x-*pre_new+*next_new-*pre_new-1)*(*next_new-x)/2*C[y];
	res-=(*next_new-x-1)*(*next_new-x)/2*C[y];
	return res;
}
unsigned long xor128() {
  static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
  unsigned long t=(x^(x<<11));
  x=y; y=z; z=w;
  return ( w=(w^(w>>19))^(t^(t>>8)) );
}
double rand_double(){
	return (long double)xor128()/ULONG_MAX;
}
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>D;
	rep(i,26){
		cin>>C[i];
		st[i].insert(-1);st[i].insert(D);
	}
	vector<int>last(26,-1);
	rep(i,D){
		int mx=-mod,idx;
		rep(j,26){
			cin>>A[i][j];
			if(chmax(mx,A[i][j]+C[j]*(i-last[j])*4))idx=j;
		}
		con[i]=idx;st[idx].insert(i);
       last[idx]=i;
	}
	int score_=score();
	cerr<<score_<<endl;
	double C=1980*100;
	int cnt=0;
	while(1000.*clock()/CLOCKS_PER_SEC<=1980){
		int x=xor128()%D,y;
		do{
			y=xor128()%26;
		}while(con[x]==y);
		int diff=change(x,y);
		double ti=1980-1000.*clock()/CLOCKS_PER_SEC;
		double rem=ti/1980.;
		if(diff>=0||(ti/C>rand_double()&&diff>=-5000-5000.*rem)){
			score_+=diff;
			st[con[x]].erase(x);
			con[x]=y;
			st[y].insert(x);
		}
		cnt++;
		if(cnt%100000==0)cerr<<score_<<"\n";
	}
	rep(i,D)cout<<con[i]+1<<"\n";
	cerr<<score_<<" "<<cnt<<endl;
}


Measured memory_bytes: 3748
#include <stdio.h>
#include <math.h>

int sq(int n){
    int a;
    a = (int)sqrt((double)n);
    if(a*a == n){
        return n;
    }else{
        sq(n-1);
    }
}

int main(void){
    int n;
    int ans;
    
    scanf("%d", &n);
    ans = sq(n);
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}


int main(){
	vl a(6);
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
	vl k(4);
	REP(i, 4){
		k[i] = 0;
	}
	REP(i, 6){
		if(a[i] == 1){
			k[0]++;
		} else if(a[i] == 2){
			k[1]++;
		} else if(a[i] == 3){
			k[2]++;
		} else {
			k[3]++;
		}
	}
	if(k[0] == 1 && k[1] == 2 && k[2] == 2 && k[3] == 1){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

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

int main(){
	string s;
	bool flag = false;
	cin >> s;
	
	int cindex;
	if(s[0] == 'A'){
		int ccnt = 0;
		for(int i=2;i < s.size()-1;i++){
			if(s[i] == 'C') ccnt++;
			cindex = i;
		}
		if(ccnt == 1){
			int cnt = 0;
			for(int i=0;i<s.size();i++){
				for(char ch = 'A';ch <= 'Z';ch++){
					if(s[i] == ch) cnt++;
				}
			}
			if(cnt == 2) flag = true;
		}
	}
	if(flag) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

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

int main(){ 
  ll n, a, b;
  cin >> n >> a >> b;

  ll cnt = n / (a + b);

  ll res = cnt * a;
  ll d = max(0LL, n - cnt * (a + b));
  if (a <= d) res += a;
  else res += d;
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------// 
void solve(){   
    ll n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, k - n);

}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("../input", "r", stdin);
                                                            // freopen("../output", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif


    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int mmul(int p,int q,int m){
    ll lp=p,lq=q; return (int)(((lp%m)*(lq%m))%m);
}

int mpow(int x,int n,int m){
    ll res=x,ans=1;
    while(n!=0){
        if(n%2==0){ res = mmul(res,res,m);n>>=1;
        }else{      ans = mmul(ans,res,m);--n;}
    }
    return (int)ans;
}

int mdiv(int p,int q,int m){
    return mmul(p,mpow(q,m-2,m),m);
}

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll n,k;
    cin >>n>>k;
    ll in=0,tr=0;
    vector<int> a(n);

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

    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            if(a[j] < a[i])in++;
        }
    }

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

            if(a[j] < a[i])tr++;
        }
    }

    //cout <<endl<< in << " " << tr<<endl;

    ans += mmul(in,k,MOD);
    //cout << in << " x " << k<<endl;
    ans %= MOD;

    ll mul = k*(k-1)/2;
    mul %= MOD;

    ans += mmul(tr,mul,MOD);
    ans %= MOD;
    
    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}





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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 109, M = 2e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int n, m, x;    cin >> n >> m >> x;

    int cost[n], c[n][m];
    for(int i = 0;i < n;i++){
        cin >> cost[i];
        for(int j = 0;j < m;j++)
            cin >> c[i][j];
    }


    int ans = OO;
    for(int i = 0;i < (1 << n);i++){
        int totalCost = 0, skills[m] = {0};
        for(int j = 0;j < n;j++){
            if(((i >> j) & 1) == 0)   continue;
            for(int k = 0;k < m;k++)    skills[k] += c[j][k];
            totalCost += cost[j];
        }

        int ok = 1;
        for(int k = 0;k < m;k++)    if(skills[k] < x)   ok = 0;

        if(ok)  ans = min(ans, totalCost);
    }

    cout << (ans == OO ? -1 : ans);

}

Measured memory_bytes: 3616
def resistors_in_parallel(N: int, A: list)->float:
    return 1.0 / sum(1.0/a for a in A)


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    ans = resistors_in_parallel(N, A)
    print(ans)


Measured memory_bytes: 2940
main :: IO ()
main = do
  [a, b, c] <- map read . words <$> getLine
  putStrLn $ fromBool $ solve a b c

fromBool :: Bool -> String
fromBool False = "No"
fromBool True  = "Yes"

solve :: Int -> Int -> Int -> Bool
solve a b c = a == b && b == c


Measured memory_bytes: 508
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
/*
bool eqq(char a[11],char b[11])
{
	REP(i,11)
	{
		if(a[i]!=b[i])return 0;
	}
	return 1;
}

int main()
{
	char s[101][11];
	char t[101][11];
	int n,m;
	cin>>n;
	REP(i,n)cin>>s[i];
	cin>>m;
	REP(j,m)cin>>t[j];
	int maxcnt=0;
	for(int i=0;i<n;i++)
	{
		cout<<i<<endl;//
		cout<<s[i]<<endl;//
		int cnt=0;
		for(int k=0;k<n;k++)
		{
			if(eqq(s[i],s[k]))
			{
				cout<<s[k]<<endl;//
				cnt++;
			}
		}
		cout<<cnt<<endl;//
		for(int j=0;j<m;j++)
		{
			if(eqq(s[i],t[j]))
			{
				cout<<t[j]<<endl;//
				cnt--;
			}
		}
		cout<<cnt<<endl;//
		maxcnt=max(cnt,maxcnt);
	}
	cout<<maxcnt<<endl;
	return 0;
}
*/

int main()
{
	string s[101],t[101];
	int n,m;
	cin>>n;
	REP(i,n)
	{
		cin>>s[i];
	}
	cin>>m;
	REP(j,m)
	{
		cin>>t[j];
	}
	
	int maxcnt=0;
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		for(int k=0;k<n;k++)
		{
			if(s[i]==s[k])
			{
				cnt++;
			}
		}
		for(int j=0;j<m;j++)
		{
			if(s[i]==t[j])
			{
				cnt--;
			}
		}
		maxcnt=max(cnt,maxcnt);
	}
	cout<<maxcnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import fractions

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

sx, sy, tx, ty = lr()

ans = ""
ans += "R" * (tx - sx)
ans += "U" * (ty - sy)
ans += "L" * (tx - sx)
ans += "D" * (ty - sy)
ans += "D"
ans += "R" * (tx - sx + 1)
ans += "U" * (ty - sy + 1)
ans += "L"
ans += "U"
ans += "L" * (tx - sx + 1)
ans += "D" * (ty - sy + 1)
ans += "R"

print(ans)


Measured memory_bytes: 5332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long n;
    cin >> n;
    vector<long long> ini(5,0);
    long long ans=0;
    for(int i=0;i<n;i++){
        string x;
        cin >> x;
        string str = x.substr(0,1);
        if(str=="M"){
            ini[0]++;
        }
        if(str=="A"){
            ini[1]++;
        }
        if(str=="R"){
            ini[2]++;
        }
        if(str=="C"){
            ini[3]++;
        }
        if(str=="H"){
            ini[4]++;
        }
    }
    for(int i =0;i<5;i++){
        for(int j=0;j<5 && j!=i;j++){
                for(int k=0;k<5 && k!=j && k!=i ;k++){
                        ans +=ini[i]*ini[j]*ini[k];
                    }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Jul 25 22:14:29 JST 2020
 **/

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

constexpr int N = 15;
int x[N], y[N];
int x_ord[N], y_ord[N];
Int p[N];
int min_dist[N], orig_dist[N];
signed main() {
    int n;
    std::cin >> n;
    REP(i, n) std::cin >> x[i] >> y[i] >> p[i];
    REP(i, n) x_ord[i] = i, y_ord[i] = i;
    std::sort(x_ord, x_ord + n, [&](int i, int j) { return x[i] < x[j]; });
    std::sort(y_ord, y_ord + n, [&](int i, int j) { return y[i] < y[j]; });
    REP(i, n) orig_dist[i] = std::min(std::abs(x[i]), std::abs(y[i]));
    std::vector<Int> ans(n + 1, 1e18);
    REP(S, 1 << n) {
        Int cnt = __builtin_popcount(S);
        // Sの部分集合の列挙
        for (int T = S;; T = (T - 1) & S) {
            // 操作
            REP(i, n) min_dist[i] = orig_dist[i];
            REP(_, 2) {
                int l = 1e9;
                for (int i : x_ord) {
                    if (T >> i & 1) l = x[i];
                    chmin(min_dist[i], std::abs(x[i] - l));
                }
                std::reverse(ALL(x_ord));
            }
            REP(_, 2) {
                int l = 1e9;
                for (int i : y_ord) {
                    if ((S ^ T) >> i & 1) l = y[i];
                    chmin(min_dist[i], std::abs(y[i] - l));
                }
                std::reverse(ALL(y_ord));
            }
            Int acc = 0;
            REP(i, n) acc += p[i] * min_dist[i];
            chmin(ans[cnt], acc);
            if (T == 0) break;
        }
    }
    for (Int z : ans) std::cout << z << "\n";
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  int n,k; cin>>n>>k;
  if(n%k==0)
  cout<<0<<endl;
  else
  cout<<1<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    cin >> A >> B;
    if (A + B >= 10) cout << "error" << endl;
    else cout << A + B << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
ans = n * (n + 1) - 1  # 1とk 自信

i = 2
while i * i <= n:
    num = n // i
    min_i = i * i
    max_i = i * num
    ans += (num - i + 1) * (min_i + max_i)  # 自分自身
    ans -= min_i
    i += 1
print(ans)


Measured memory_bytes: 9172
a,b= map(int,input().split())
line=''.join(['.#']*50)
dot=['.','#']
cl=[''.join(['.']*100),''.join(['#']*100)]
ba=[b-1,a-1]
ans=[]
y=ans.append
for c in [0,1]:
    y(cl[c])
    for i in range(ba[c]//50):
        y(line)
        y(cl[c])
    y(''.join(['.#']*(ba[c]%50))+cl[c][(ba[c]%50)*2:])
    y(cl[c])
print(len(ans),100)
for l in ans:print(''.join(l))

Measured memory_bytes: 9228
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    int card[100];
    for(int i = 0; i < N; i++ )
    {
        cin >> card[i];
    }
    sort(card, card + N,greater<int>());
    int alice=0;
    int bob = 0;

    for (int i = 0; i < N; i++)
    {
        if(i%2==0){
            alice += card[i];
        }else{
            bob += card[i];
        }
    }
    res = alice - bob;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times {|i|yield(i)}                    end
def repl(st,en,n=1);        st.step(en,n){|i|yield(i)} end

num = gc
data = []
data << num[0]
repl 1, num.size-1 do |i|
	cu = []
	data.each do |d|
		cu << d + '+'+ num[i]
		cu << d + num[i]
	end
	data = cu.dup
end

ans = 0
data.each do |d|
	eval "ans+=#{d}"
end

puts ans


Measured memory_bytes: 2940
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main( void ) {

    int a, b;
    double x;
    cin >> a >> b;
    
    x = (double)(a + b) / 2;
    a = (a + b) / 2;

    if ( x > (double)a ) {
        cout << a + 1 << endl;
    } else {
        cout << a << endl;
    }

    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int n, m;
vpi hen;

bool hantei(vi &v)
{
    int cp = 1;
    for(auto np : v)
    {
        bool b = false;
        for(auto &p : hen)
        {
            if((cp == p.first && np == p.second) || (cp == p.second && np == p.first)) b = true;
        }
        if(!b) return false;
        cp = np;
    }
    return true;
}

int main()
{
    cin >> n >> m;
    hen.resize(m);
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >> b;
        hen.at(i) = make_pair(a, b);
    }
    vi ten;
    for(int i=2; i<=n; i++)
    {
        ten.push_back(i);
    }
    int cnt = 0;
    do
    {
        if(hantei(ten)) cnt++;
    } while (next_permutation(ten.begin(), ten.end()));
    cout << cnt << endl;

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;++i){
    cin>>p[i];
  }
  int64_t cnt=0;
  int i=0;
  while(i<N-1){
    if(p[i]==i+1){
      swap(p[i],p[i+1]);
      ++cnt;
    }
    ++i;
  }
  if(p[N-1]==N) ++cnt;

  cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <iostream>
    using namespace std;
    int getsoma(int numero){
        int nax = numero;
        int somatotal = 0;
        while(numero > 0){
            nax = numero;
            nax = nax % 10;
            somatotal += nax;

            numero /= 10;
        }
        return somatotal;
    }

    int main() {
        long long int a;
        cin >> a;
        if(a == 100000 || a == 10000 || a == 1000|| a == 100 || a == 10){
            cout << 10 << endl;
            return 0;
        }
        cout << getsoma(a) <<endl;
        return 0;
    }

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

S = [0] * (N + 1)
S[0] = 0
for i in range(N):
    S[i+1] = S[i] + W[i]

Min = [0] * N
for i in range(N):
    Min[i] = abs(S[i+1] - (S[-1] - S[i+1]))

print(min(Min))

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i=0;i<N;i++) {
        cin >> A[i];
        A[i]--;
    }
    vector<ll> loop(N+1);
    loop[0] = 0;
    for (int i=0;i<N;i++){
        loop[i+1] = A[loop[i]];
    }
    if (N>=K) {
        cout << loop[K] + 1 << "\n";
        return 0;
    }
    vector<ll> stop(N,-1);
    stop[0] = 0;
    ll start,end;
    for (int i=0;i<=N;i++){
        if (stop[loop[i]] == -1) {
            stop[loop[i]] = i+1;
        } else {
            start = stop[loop[i]];
            end = i+1;
        }
    }
    K -= start;
    ll res = K % (end - start);
    ll ans = loop[start+res]+1;
    cout << ans << "\n";
}

Measured memory_bytes: 7952
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

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...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	while (N != 0) {
		vi D(100);
		REP(i, N) {
			int M;
			cin >> M;
			REP(j, M) {
				int d;
				cin >> d;
				D[d]++;
			}
		}
		int ans = 0;
		int cnt = 0;
		REP(i, 100) {
			if (D[i] < Q) continue;
			if (cnt < D[i]) {
				ans = i;
				cnt = D[i];
			}
		}
		cout << ans << endl;
		cin >> N >> Q;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct node {
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
};
 
struct node *tree = NULL;
 
void insert(struct node **root, struct node *node)
{
  struct node *parent = NULL;
  struct node *current = *root;
 
  while (current != NULL) {
    parent = current;
    if (node->key < current->key) {
      current = current->left;
    } else {
      current = current->right;
    }
  }
 
  node->parent = parent;
 
  if (parent == NULL) {
    *root = node;
  } else if (node->key < parent->key) {
    parent->left = node;
  } else {
    parent->right = node;
  }
}
void preorder_traverse(struct node* node)
{
  if (node != NULL) {
    printf(" %d", node->key);
    preorder_traverse(node->left);
    preorder_traverse(node->right);
  }
}
 
void inorder_traverse(struct node *node)
{
  if (node != NULL) {
    inorder_traverse(node->left);
    printf(" %d", node->key);
    inorder_traverse(node->right);
  }
}
 
int main (int argc, char** argv)
{
  int i, num;
  char str[32] = {0};
  fgets(str, 32, stdin);
  num = atoi(str);
  for (i = 0; i < num; i++) {
    fgets(str, 32, stdin);
    strtok(str, "\r\n");
    if (strstr(str, "insert")) {
      struct node *node = (struct node *)malloc(sizeof(struct node));
      node->key = atoi(&str[7]);
      node->left = NULL;
      node->right = NULL;
      insert(&tree, node);
    } else if (strstr(str, "print")) {
      inorder_traverse(tree);
      printf("\n");
      preorder_traverse(tree);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}



int main()
{
  string str;
  cin>>str;
  for(int i=0;i<str.size();i++)
  {
      cout<<'x';
  }
  cout<<endl;
}

















Measured memory_bytes: 256
from collections import Counter
from itertools import combinations


n = int(input())
l = list(map(int, input().split()))

ans = 0
c = Counter(l)

for pat in combinations(c.keys(), 3):
    x, y, z = sorted(pat)
    if x + y > z:
        ans += c[x] * c[y] * c[z]

print(ans)


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

int main(){
  long long int N,M,K;
  long long int A[200000],B[200000];
  int ct = 0,memo=0;
  cin >> N >> M >> K;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    if(i > 0){A[i] += A[i-1];}
  }
  for(int i = 0;i < M;i++){
    cin >> B[i];
    if(i > 0){B[i] += B[i-1];}
    if(B[i] <= K){memo++;}
  }
  ct = memo;
  if(memo == M){memo--;}
  for(int i = 0;i < N;i++){
    while(1){
      if(memo < 0){
        if(A[i] <= K&&i >= ct){ct = i+1;}
        break;
      }
      if(A[i] + B[memo] > K){
        memo--;
      }
      else{
        if(i + memo+2 > ct){ct = memo+i+2;}
        break;
      }
    }
  }
  cout << ct << endl;
  return 0;
}

Measured memory_bytes: 6744
#include <stdio.h>

int main() {
  int a, b;
  char c;
  scanf("%d %c %d", &a, &c, &b);
  while(c != '?') {
    if(c == '+') {
      printf("%d\n", a + b);
    } else if(c == '-') {
      printf("%d\n", a - b);
    } else if(c == '*') {
      printf("%d\n", a * b);
    } else if(c == '/') {
      printf("%d\n", a / b);
    }
    scanf("%d %c %d", &a, &c, &b);
  }
  return 0;
}

Measured memory_bytes: 2648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;

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

    int n,k;
    cin >> n >> k;
    int ans = 0;
    for(int i=k;i<=n+1;i++){
        int minu = i*(i-1)/2;
        //int minu = 0; for(int j=0;j<i;j++) minu += j;
        int mxnu = i*(2*n-i+1)/2;
        //int mxnu = 0; for(int j=0;j<i;j++) mxnu += (n-j);
        ans += (mxnu - minu +1)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3688
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if(a.equals("A")){
      System.out.println("T");
    }else if(a.equals("G")){
      System.out.println("C");
    }else if(a.equals("C")){
      System.out.println("G");
    }else if(a.equals("T")){
      System.out.println("A");
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;
    P c, d;
    cin >> c.first >> c.second >> d.first >> d.second;
    c.first--; c.second--;
    d.first--; d.second--;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> dist(h, vector<int>(w, INF));
    auto comp = [](pair<P, int> a, pair<P, int> b) {
        return a.second>b.second;
    };
    priority_queue<pair<P, int>, vector<pair<P, int>>, decltype(comp)> q{comp};
    q.emplace(c, 0);
    dist[c.first][c.second] = 0;
    while (!q.empty()) {
        auto now = q.top();
        int x = now.first.first;
        int y = now.first.second;
        int di = now.second;
        q.pop();
        if (di>dist[x][y]) continue;
        rep(i, 4) {
            int ix = x + dx[i];
            int iy = y + dy[i];
            if (ix<0 || ix>=h || iy<0 || iy>=w) continue;
            if (s[ix][iy]=='#') continue;
            if (di<dist[ix][iy]) {
                dist[ix][iy] = di;
                q.emplace(P(ix, iy), di);
            }
        }
        for (int i=-2; i<=2; i++) {
            for (int j=-2; j<=2; j++) {
                if (i==0 && j==0) continue;
                int ix = x + i;
                int iy = y + j;
                if (ix<0 || ix>=h || iy<0 || iy>=w) continue;
                if (s[ix][iy]=='#') continue;
                if (di+1<dist[ix][iy]) {
                    dist[ix][iy] = di+1;
                    q.emplace(P(ix, iy), di+1);
                }
            }
        }
    }
    int ans = dist[d.first][d.second];
    if (ans==INF) ans = -1;
    
    pr(ans);
    return 0;
}


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

int n;
int ball[10];
int r, l;
int now;

bool dfs(int r, int l, int now);

int main(){

	cin >> n;

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

		for(int j=0; j<10; j++){
			cin >> ball[j];
		}

		if(dfs(0, 0, 0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

bool dfs(int right, int left, int now){
	if(now == 10) return true;
	if(right < ball[now]) return dfs(ball[now], left, now+1);
	if(left < ball[now]) return dfs(right, ball[now], now+1);
	return false;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(string, s);
	print((s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
vector <int>g[16][2];
int n;
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin>>x;
        for(int j=0; j<x; j++)
        {
            int a,b;
            cin>>a>>b;
            g[i][b].push_back(a);
        }
    }
    int ans=0;
    for(int i=0; i<(1<<n); i++)
    {
        bool flag=true;
        for(int y=1; y<=n; y++)
        {
            bool f=true;
            for(int k=0; k<g[y][0].size(); k++)
                if(1<<(g[y][0][k]-1)&i)
                    f=false;
            for(int k=0; k<g[y][1].size(); k++)
                if(!((1<<g[y][1][k]-1)&i))
                    f=false;
            if(f&&(!(1<<(y-1)&i)))
                flag=false;
            if(!f&&(1<<(y-1)&i))
                flag=false;
        }
        if(flag)
            ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)
	a = append(a, 0)

	sum := 0
	pre := 0
	for i := 0; i < n+1; i++ {
		sum += abs(a[i] - pre)
		pre = a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(wr, sum-abs(pre-a[i])-abs(a[i]-a[i+1])+abs(pre-a[i+1]))
		pre = a[i]
	}

}


Measured memory_bytes: 4736
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
if a + b + c + d == 7:
    print(s[0] + '+' + s[1] + '+' + s[2] + '+' + s[3] + '=7')
elif a + b + c - d == 7:
    print(s[0] + '+' + s[1] + '+' + s[2] + '-' + s[3] + '=7')
elif a + b - c + d == 7:
    print(s[0] + '+' + s[1] + '-' + s[2] + '+' + s[3] + '=7')
elif a - b + c + d == 7:
    print(s[0] + '-' + s[1] + '+' + s[2] + '+' + s[3] + '=7')
elif a + b - c - d == 7:
    print(s[0] + '+' + s[1] + '-' + s[2] + '-' + s[3] + '=7')
elif a - b - c + d == 7:
    print(s[0] + '-' + s[1] + '-' + s[2] + '+' + s[3] + '=7')
elif a - b + c - d == 7:
    print(s[0] + '-' + s[1] + '+' + s[2] + '-' + s[3] + '=7')
elif a - b - c - d == 7:
    print(s[0] + '-' + s[1] + '-' + s[2] + '-' + s[3] + '=7')


Measured memory_bytes: 9120
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
s = list(map(str, input().split()))
# print(s)
# print(set(s))
if len(set(s)) == 3:
    print("Three")
if len(set(s)) == 4:
    print("Four")


Measured memory_bytes: 3832
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353; //1000000007;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int N;
	get(N);

	std::vector<int> ai(N);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
	}

	int surp = 0;
	LLONG ans = 0;
	for (int i = 0; i < N; i++) {
		ans += ai[i] / 2;
		if (ai[i] % 2 && surp) {
			ans++;
			surp = 0;
		}
		else if (ai[i] && surp && ai[i] % 2 == 0) {
			surp = 1;
		}
		else {
			surp = ai[i] % 2;
		}
	}

	printf("%lld\n", ans);
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

struct edge{
  ll to,a;
};

int main(){
  
  int n,m,s,t;
  scanf("%d %d %d %d",&n,&m,&s,&t);
  s--,t--;
  vector<vector<edge>> v(n),w(n);
  rep(i,m){
    ll u,u_,a,b;scanf("%lld %lld %lld %lld",&u,&u_,&a,&b);
    u--,u_--;
    v[u].push_back({u_,a});
    v[u_].push_back({u,a});
    w[u].push_back({u_,b});
    w[u_].push_back({u,b});
  }
  vector<ll> yen(n,1e18);
  vector<ll> snuuk(n,1e18);
  auto dijkstra = [](vector<vector<edge>> &v,vector<ll> &d,int s){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> que;
    que.push(make_pair(0,s));
    d[s] = 0;
    while(!que.empty()){
      pair<ll,ll> ov = que.top();que.pop();
      if(ov.first > d[ov.second])continue;
      for(auto nv : v[ov.second]){
        if(d[nv.to] <= d[ov.second]+nv.a)continue;
        d[nv.to] = d[ov.second]+nv.a;
        que.push(make_pair(d[nv.to],nv.to));
      }
    }
  };
  dijkstra(v,yen,s);
  dijkstra(w,snuuk,t);
  multiset<ll> st;
  rep(i,n)st.insert(yen[i]+snuuk[i]);
  rep(i,n){
    cout << (ll)1e15-(*st.begin()) << endl;
    st.erase(st.find(yen[i]+snuuk[i]));
  }


  return 0;
}

Measured memory_bytes: 24276
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
int main(){
    long long n,k;
    cin >> n >> k;
    long long total=0;
    long long ans=0;
    pair<int,int> ab[n];
    long long a,b;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        ab[i]=make_pair(a,b);
    }
    sort(ab,ab+n);
    for(int i=0;i<n;i++){
        a = ab[i].first;
        b = ab[i].second;
        total += b;
        if(total>=k){
            ans = a;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, M;
const int Nmax = 1e5;
vector<pair<int, int>> BA;

int main(){
	cin >> N >> M;
	for(int i=0; i<N; i++){
		int a, b;
		cin >> a >> b;
		BA.push_back({b, a});
	}
	sort(BA.begin(), BA.end());
	reverse(BA.begin(), BA.end());

	vector<int> nextl;
	for(int i=0; i<M; i++) nextl.push_back(i);
	ll ans = 0;
	for(int i=0; i<N; i++){
		int b = BA[i].first;
		int a = BA[i].second;
		vector<int> step;
		int k=M-a;
		while(k>=0&&nextl[k]!=k){
			step.push_back(k);
			k=nextl[k];
		}
		for(auto j: step){
			nextl[j] = k;
		}
		if(k<0) continue;

		ans += b;
		//cout << a << " " << b << " " <<nextl[k] << endl;
		nextl[k] = k-1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1908
import itertools
N=int(input())
Ev=[[] for i in range(N)]
for i in range(N):
    A=int(input())
    for j in range(A):
        x, y = map(int, input().split())
        Ev[i].append([x-1, y] )
ans=0
for i in range(2**N):
    flag=True
    for j in range(N):
        if (i>>j)&1==0:
            continue
        for x,y in Ev[j]:
            if (i>>x)&1!=y:
                flag=False
                break
    if flag:
        ans = max(ans, bin(i)[2:].count('1'))

print(ans)










Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long X = sc.nextLong();
        long money=100;
      	int s=0;
        
        
        while(money<X){
        	money+=money/100;
        	s++;
        }
		System.out.println(s);
		
	}
}

Measured memory_bytes: 27064
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Vikash Kumar @ Codechef/codeforces 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define ll                    long long int
#define ll_MAX                LLONG_MAX
#define ll_MIN                LLONG_MIN
#define pi                    3.14159265358979323846
#define count_1(n)            __builtin_popcountll(n)
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define mid(s,e)              (s+(e-s)/2)
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

inline void solve(){
    /*_Start_*/
    int x,y;cin>>x>>y;
    string ans="No";
    for(int i=0;i<=x;i++){
      if(( (i*2)+((x-i)*4) )==y)
        ans="Yes";
    }
    cout<<ans<<endl;
    /*_End_*/
   
}

int main()
{
	cout<<fixed<<setprecision(12);
	//freopen("input.txt", "r", stdin);
	fastio;ll  t=1,tc=1;
	//cin>>t;
	while(t--){solve();}return 0;
}

Measured memory_bytes: 3636
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
cur = [1] * (N+1)  # 1-indexed
PY = [lr() + [i] for i in range(M)]
PY.sort(key=lambda x: x[1])
answer = [None] * M  # 0-indexed
for p, y, i in PY:
    x = str(p).zfill(6) + str(cur[p]).zfill(6)
    answer[i] = x
    cur[p] += 1

for a in answer:
    print(a)


Measured memory_bytes: 32540