akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <cstdlib>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    string s;
    cin>>s;
    string s1="", s2="";
    s1 += s[0];
    s1 += s[1];
    s2 += s[2];
    s2 += s[3];
    int x = stoi(s1);
    int y = stoi(s2);
    bool flag1 = (x>=1 && x<=12)? true:false;
    bool flag2 = (y>=1 && y<=12)? true:false;
    if(flag1 && flag2) OUT("AMBIGUOUS");
    else if(flag1) OUT("MMYY");
    else if(flag2) OUT("YYMM");
    else OUT("NA");
}



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

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

	int64_t N, K;
	cin >> N >> K;

	map<int64_t, int64_t> mp;
	for( int i = 0; i < N; ++i ) {
		int a, b;
		cin >> a >> b;
		mp[a] += b;
	}

	int64_t cnt = 0;
	auto p = mp.begin();

	for( ; p != mp.end(); ++p ) {
		cnt += p->second;

		if( cnt >= K ) {
			break;
		}
	}

	cout << p->first << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;

    std::vector<int> a(3 * n);
    for (int i = 0; i < 3 * n; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end(), std::greater<int>());

    long long ans = 0;

    for (int i = 0; i < n; i++) {
        ans += a[2 * i + 1];
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
map<int,bool> mp;
map<int,bool> mp2;
map<int,bool> mp3;
int main(){
	int n;
	string s;
	cin>>n>>s;
	vector<int> v;
	vector<int> v2;
	vector<int> v3;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R')v.push_back(i),mp[i]=1;
		else if(s[i]=='G')v2.push_back(i),mp2[i]=1;
		else v3.push_back(i),mp3[i]=1;
	}
	long long cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			for(int j=0;j<v2.size();j++){
				int k=lower_bound(v3.begin(),v3.end(),v2[j])-v3.begin();
				if(mp3[v2[j]+v2[j]-i])cnt+=v3.size()-k-1;
				else cnt+=v3.size()-k;
			}
			for(int j=0;j<v3.size();j++){
				int k=lower_bound(v2.begin(),v2.end(),v3[j])-v2.begin();
				if(mp2[v3[j]+v3[j]-i])cnt+=v2.size()-k-1;
				else cnt+=v2.size()-k;
			}
			v.erase(v.begin());
		}
		else if(s[i]=='G'){
			for(int j=0;j<v.size();j++){
				int k=lower_bound(v3.begin(),v3.end(),v[j])-v3.begin();
				if(mp3[v[j]+v[j]-i])cnt+=v3.size()-k-1;
				else cnt+=v3.size()-k;
			}
			for(int j=0;j<v3.size();j++){
				int k=lower_bound(v.begin(),v.end(),v3[j])-v.begin();
				if(mp[v3[j]+v3[j]-i])cnt+=v.size()-k-1;
				else cnt+=v.size()-k;
			}
			v2.erase(v2.begin());
		}
		else{
			for(int j=0;j<v.size();j++){
				int k=lower_bound(v2.begin(),v2.end(),v[j])-v2.begin();
				if(mp2[v[j]+v[j]-i])cnt+=v2.size()-k-1;
				else cnt+=v2.size()-k;
			}
			for(int j=0;j<v2.size();j++){
				int k=lower_bound(v.begin(),v.end(),v2[j])-v.begin();
				if(mp[v2[j]+v2[j]-i])cnt+=v.size()-k-1;
				else cnt+=v.size()-k;
			}
			v3.erase(v3.begin());
		}
	}
	cout<<cnt<<endl; 
	return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	vector<bitset<64> > masks(n, bitset<64>(0));
	for(int i = 0; i < n; i++) {
		int a, b;
		scanf("%d", &a);
		for(int j = 0; j < a; j++) {
			scanf("%d", &b);
			masks[i].set(b);
		}
	}
	int q;
	scanf("%d", &q);
	bitset<64> bit(0);
	for(int i = 0; i < q; i++) {
		int id, x;
		scanf("%d%d", &id, &x);
		if(id == 0) {
			printf("%d\n", bit.test(x));
		}else if(id == 1) {
			bit |= masks[x];
		}else if(id == 2) {
			bit &= ~masks[x];
		}else if(id == 3) {
			bit ^= masks[x];
		}else if(id == 4) {
			printf("%d\n", (bit & masks[x]) == masks[x]);
		}else if(id == 5) {
			printf("%d\n", (bit & masks[x]).any());
		}else if(id == 6) {
			printf("%d\n", (bit & masks[x]).none());
		}else if(id == 7) {
			printf("%lu\n", (bit & masks[x]).count());
		}else if(id == 8) {
			printf("%lu\n", (bit & masks[x]).to_ulong());
		}
	}
}



Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
 
#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))
 
#define pb push_back
#define mp make_pair
 
#define ALL(a) (a).begin(), (a).end()
 
#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
 
#define INF 1001001001
#define LLINF 1001001001001001001LL
 
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
 
#define PQ priority_queue
 
#define FST first
#define SEC second
#define int long long
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
//------------------HEAD---------------------
struct edge{
    int u, v, cost;
    bool operator < (const edge& e){
        return cost > e.cost; // 逆順ソート
    }
};

// 更地から構築していく。コスト高い辺から置いていく。
// 最終的に基地がk+1箇所に分断されていればok

int par[11234];
int rank_[11234];
int n,t,k;
void init(){
    rep(i,n){
        par[i]=i;
        rank_[i]=0;
    }
}

int find(int x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rank_[x]<rank_[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rank_[x]==rank_[y])++rank_[x];
    }
}

bool same(int x,int y){
    return find(x)==find(y);
}


edge E[11234];
bool isbase[11234];

signed main(void){
    int i=0;
    while(1){
        i+=1;
    cin>>n>>t>>k;init();
    //cerr<<n<<t<<k<<endl;
    if(!(n||t||k))break;
    rep(i,n-1){
        cin>>E[i].u>>E[i].v>>E[i].cost;
        --E[i].u;--E[i].v;
    }
    sort(E,E+n-1);
    rep(i,n)isbase[i]=false;
    rep(i,t){
        int tmp;cin>>tmp;
        isbase[tmp-1]=true;
    }
    int ans=0;
    rep(i, n-1){
        edge e=E[i];
        int u,v;
        u=find(e.u);
        v=find(e.v);
        //cerr<<u<<isbase[u]<<v<<isbase[v]<<endl;
        if(isbase[u]&&isbase[v]){
            if(t>k+1){
                unite(u,v);
                --t;//cerr<<t<<endl;
            }else{
                ans+=e.cost;
            }
        }else{
            unite(u,v);
            isbase[u]=isbase[v]=isbase[u]||isbase[v];
        }
        
    }
    
    printf("Case %lld: %lld\n", i, ans);
    }
    return 0;
}


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

int main(int argc, const char * argv[]) {
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if (n <= k){
        cout << n * x;
    } else {
        cout << k * x + (n - k) * y;
    }
    return 0;
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc124_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = new string[5];
            int[] num = new int[5];
            for (int i = 0; i<num.Length; ++i)
            {
                input[i] = Console.ReadLine();
                num[i] = int.Parse(input[i]);
            }
            int difference = int.Parse(Console.ReadLine());

            int result = 0;
            int ng = 0;
            for(int i=0; i<num.Length; ++i)
            {
                for (int j = (i+1); j < num.Length; j++)
                {
                    if (Math.Abs(result = num[i] - num[j]) > difference) ++ng;
                }
            }

            if (ng == 0) Console.WriteLine("Yay!");
            else Console.WriteLine(":(");

        }
    }
}


Measured memory_bytes: 13140
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll N; cin>>N;
    ll a=0,b=0;
    ll minimum = 0;
    for (ll i = 1; i*i <= N; ++i) {
        if(N%i==0) {
            a = i;
            b = N / a;
            minimum = min(a+b,minimum);
        }
    }
    cout<<(a-1)+(b-1)<<endl;

    return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define mp make_pair
#define ALL(x)	x.begin(),x.end() 

typedef long long ll;
//const double PI = 4*atan(1.);
//const int INF = 0x3f3f3f3f;
const int maxn = 2e5+10;
const int mod = 1e9 + 7;

int num[70];
ll dp[70][70][2][2][2];
int sum[70];

ll dfs(int pos, bool lim, bool vBig, bool adj, int pre1) { // u <= v
    if (pos == -1)  return pre1 && !adj;
    if (~dp[pos][pre1][lim][vBig][adj])   return dp[pos][pre1][lim][vBig][adj];
    int up = lim ? num[pos] : 1;
    ll ans = 0;
    for (int i = 0; i <= up; ++i) { // a + b = v
        int upp = vBig ? 1 : i;
        for (int j = 0; j <= upp; ++j) { // a xor b = u
            if (i < j) { // 0 1   
                if (pre1 - 1 >= pos + 1) continue ;
                (ans += dfs(pos - 1, lim && i == up, vBig, adj, pos)) %= mod;
            } else if (j == 1) { // 1 1
                (ans += dfs(pos - 1, lim && i == up, vBig, adj || (pre1 != 66 && pre1 == pos + 1), pre1)) %= mod;
            } else { // 0 0, 1 0
                (ans += dfs(pos - 1, lim && i == up, vBig || i > j, adj, i == 1 ? pos : pre1)) %= mod;
            }
        }
    }
    return dp[pos][pre1][lim][vBig][adj] = ans;
}

ll solve(ll x) {
    int pos = 0;
    while (x) {
        num[pos++] = x & 1;
        x >>= 1;
    }
    return dfs(pos - 1, 1, 0, 0, 66);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << solve(n) << '\n';
    return 0;
}


Measured memory_bytes: 3900
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 22 10:08:31 2018

@author: Yuya
"""

N=int(input())

a = list(map(int, input().split()))



#count_sum=0
#count = 1
#
#for i in range(N-1):
#    flag=-1
#    if a[i+1]!=a[i]:
#        if count>a[i]:
#            count_sum += count-a[i]
#        elif count<a[i]:
#            count_sum += count
#        count=1
#        flag=1
#    else:
#        count+=1
#
#if flag==-1:
#    if count>a[N-1]:
#        count_sum += count-a[N-1]
#    elif count<a[N-1]:
#        count_sum += count
#
#print(count_sum)

count_a = [0]*100000
ans = 0

for i in range(N):
    if a[i]<100001:
        count_a[a[i]-1] += 1
    else:
        ans += 1


for i in range(100000):
    if i+1<count_a[i]:
        ans+=count_a[i]-i-1
    elif i+1>count_a[i]:
        ans+=count_a[i]

print(ans)

Measured memory_bytes: 14212
import copy

N = int(input())
X = list(map(int, input().split()))
X_copy = copy.copy(X)
X_copy.sort()

left = X_copy[len(X)//2-1]
right = X_copy[len(X)//2]

# print(X_copy, left, right)

for x in X:
    if x <= left:
        print(right)
    else:
        print(left)

Measured memory_bytes: 93128
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 100010;

int pos[N], dir[N], x[N], ans[N];
int n, m, T;

int main(){
	scanf("%d%d%d", &n, &m, &T);
	For(i, 1, n){
		scanf("%d%d", &x[i], &dir[i]);
		pos[i] = dir[i] == 1 ? (x[i] + T) % m : ((x[i] - T) % m + m) % m;
	}
	long long ret = 0;
	For(i, 2, n) if(dir[i] ^ dir[1]){
		int delt = 0;
		if(dir[1] == 1) delt = x[i] - x[1];
		else delt = (x[1] + m - x[i]) % m;
		ret += (2ll * T + m - delt) / m;
	}
	ret %= n;
	if(dir[1] == 2) ret = (n - ret) % n;

	int p = pos[1];
	
	sort(pos + 1, pos + n + 1);
	if(dir[1] == 2) p = int(lower_bound(pos + 1, pos + n + 1, p) - pos);
	else p = int(upper_bound(pos + 1, pos + n + 1, p) - pos) - 1;

	--p;
	For(i, 0, n - 1) ans[(ret + i) % n] = pos[(p + i) % n + 1];
	For(i, 0, n - 1) printf("%d\n", ans[i]);
	return 0;
}

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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

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

	ll K;
	cin >> K;
	ll n=50;
	ll div=(K+n-1)/n,rem=n*div-K;
	cout << n << endl;
	for (int i=0;i<n;i++) {
		ll cur=n-1+div;
		if (i<rem) cur+=rem-1-n;
		else cur+=rem;
		cout << cur << ' ';
	}
	cout << endl;
		
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, ii> iii;
typedef vector<pair<pair<int,int>,int>> viii;
typedef vector<pair<pair<ll,ll>,ll>> viiil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000
#define MOD 1000000007;

void solve() {
    int n, k;
    cin >> n >> k;
    
    vi a(n);
    rep(i, n) cin >> a[i];
    
    int dp[n];
    rep(i, n) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1 ; i < n ; i++) {
        for (int j = i - 1 ; j >= max(0, i - k) ; j--) {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
        
    }
    cout << dp[n - 1] << endl;
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        //solve();
    }
}

int main() {
    //querySolve();
    solve();

}


Measured memory_bytes: 4040
import sys
from math import ceil

n, *cap = map(int, sys.stdin.read().split())

def main():
    min_cap = min(cap)
    i = cap.index(min_cap) + 1
    
    res = (i - 1) + ceil(n / min_cap) + (5 - i)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    int tmpnum, maxdiff, minnum;
    for(int i=0;i<n;++i)
    {
        cin >> tmpnum;
        if(i==0)
            minnum = tmpnum;
        else if(i==1)
            maxdiff = tmpnum - minnum;

        if(tmpnum < minnum)
        {
            minnum = tmpnum;
        }
        else if(tmpnum - minnum > maxdiff)
        {
            maxdiff = tmpnum - minnum;
        }
    }
    cout << maxdiff << endl;
}
    


Measured memory_bytes: 3096
n = int(input())
A = list(map(int, input().split()))
A=sorted(A)
up=max(A)
table=[0]*(up+1)
for i in range(n):
    table[A[i]]+=1
aset=set(A)

for i in range(len(aset)):
    if table[A[i]]>0:
        j=2
        while A[i]*j<up+1:
            if table[A[i]*j]>0:
                table[A[i]*j]=-1
            j+=1

cnt=0
for x in table:
    if x==1:
        cnt+=1
print(cnt)

Measured memory_bytes: 122848
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def syakutori(array):
    n = len(array)
    r = 1
    res = 0
    now = array[0]
    for l in range(n):
        while 0 < r < n and now^array[r] == now+array[r]:
            now = now ^ array[r]
            r += 1
        res += r-l
        now = now ^ array[l]

        if l == r:
            r += 1

    return res


def main():
    N = NI()
    A = NLI()
    print(syakutori(A))


if __name__ == "__main__":
    main()

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

/////////////////////////////////////////////////////////////
class ModuloOperator {
 public:
  ll modulo;

  ModuloOperator(ll modulo) { this->modulo = modulo; }

  ll add(ll a, ll b) {
    ll ret = a + b;
    ret %= modulo;
    return ret;
  }

  ll sub(ll a, ll b) {
    ll ret = a - b;
    if (ret < 0)
      ret += modulo;
    else
      ret %= modulo;
    return ret;
  }

  ll mul(ll a, ll b) {
    ll ret = a * b;
    ret %= modulo;
    return ret;
  }

  ll div(ll a, ll b) { return mul(a, pow(b, modulo - 2)); }

  ll pow(ll x, ll y) {
    ll res = 1LL;

    x %= modulo;

    while (y > 0) {
      if (y & 1) {
        res = mul(res, x);
      }

      y = y >> 1;
      x = mul(x, x);
    }

    return res;
  }
};
/////////////////////////////////////////////////////////////

const int MAX_N = (int)(3e5 + 5);
const int MAX_LOG = (int)(6e1 + 1);
const ll MOD = (ll)(1e9 + 7);

int n;
ll a[MAX_N];

int cnt[MAX_N];

ModuloOperator mo(MOD);

void add_to_cnt(ll t) {
  for (int i = 0; i < MAX_LOG; ++i) {
    if (t >> i & 1LL) cnt[i] += 1;
  }
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  ll ans = 0LL;

  add_to_cnt(a[0]);

  for (int i = 1; i < n; ++i) {
    ll tmp = a[i];

    // printf("~~~~~~~ai: %lld\n", tmp);

    ll base = 1LL;

    for (int j = 0; j < MAX_LOG; ++j) {
      int oz = (tmp >> j & 1LL) ? 1 : 0;
      ll times = oz == 1 ? i - cnt[j] : cnt[j];
      ll commit = mo.mul(base, times);

      // printf("%d: %lld\n", j, commit);

      ans = mo.add(ans, commit);
      base = mo.mul(base, 2LL);
    }

    add_to_cnt(a[i]);
  }

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

  return 0;
}


Measured memory_bytes: 2560
//
//  main.cpp
//  acm
//
//  Created by 谢峰 on 17/3/12.
//  Copyright © 2017年 谢峰. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cfloat>
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, pause
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, pause
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, pause
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, pause

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

const int N = 100005;

int n;
int a[N];

int main() {
    int ans, id;
    LL sum;
    while (~in(n)) {
        rep (i, n) in(a[i]);
        sort(a, a + n);
//        rep (i, n) cout << a[i] << ' ';
        ans = 0, sum = 0;
        rep (i, n) {
            id = i, sum += a[i];
            while (i + 1 < n && a[i + 1] <= 2 * sum) {
                sum += a[i + 1];
                i++;
//                sc2(i, sum);
            }
            if (i == n - 1) ans += i - id + 1;
//            sc(i);
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 640
N,M,K = map(int,input().split())
ans = 'No'
flag = False
for x in range(M+1):
    if flag:
        break
    for y in range(N+1):
        if (N-y)*x+(M-x)*y == K:
            ans = 'Yes'
            flag = True
            break
print(ans)

Measured memory_bytes: 3060
class OfficialHouse:
    def __init__(self):
        self.bill = [[[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]]]


    def input_bfrv(self, b, f, r, v):
        self.bill[b-1][f-1][r-1] += v

    def result(self):
        for i in range(4):
            for j in range(3):
                print("", ' '.join(map(str, self.bill[i][j])))
            if i != 3:
                print("####################")

oh = OfficialHouse()

n = int(input())

for i in range(n):
   bfrv = input().split()
   b = int(bfrv[0])
   f = int(bfrv[1])
   r = int(bfrv[2])
   v = int(bfrv[3])

   oh.input_bfrv(b, f, r, v)

oh.result()

Measured memory_bytes: 7784
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, D;
map<int, set<pii>> y2x, x2y;
map<int, vi> Y2X, X2Y;
vi X, Y;
ll ans = 0;

ll f(map<int, vi> &S, int z, int lb, int ub) {
    return distance(lower_bound(all(S[z]), lb), lower_bound(all(S[z]), ub));
}

void dfs(int v) {
    y2x[Y[v]].erase(mp(X[v],v));
    x2y[X[v]].erase(mp(Y[v], v));

    ans += f(X2Y, X[v] + D, Y[v] - D, Y[v] + D + 1);
    ans += f(X2Y, X[v] - D, Y[v] - D, Y[v] + D + 1);
    ans += f(Y2X, Y[v] + D, X[v] - D + 1, X[v] + D);
    ans += f(Y2X, Y[v] - D, X[v] - D + 1, X[v] + D);

    for(int x : {X[v] + D, X[v] - D}) {
        while(1) {
            auto it = x2y[x].lower_bound(mp(Y[v] - D, 0));
            if(it != x2y[x].end() && it->first <= Y[v] + D)dfs(it->second);
            else break;
        }
    }

    for(int y : {Y[v] + D, Y[v] - D}) {
        while(1) {
            auto it = y2x[y].lower_bound(mp(X[v] - D, 0));
            if(it != y2x[y].end() && it->first <= X[v] + D)dfs(it->second);
            else break;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> N >> a >> b;
    --a; --b;
    X = Y = vi(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        X[i] = x - y;
        Y[i] = x + y;
    }

    D = max(abs(X[a] - X[b]), abs(Y[a]-Y[b]));

    rep(i, N) {
        y2x[Y[i]].insert(mp(X[i],i));
        x2y[X[i]].insert(mp(Y[i], i));
        Y2X[Y[i]].push_back(X[i]);
        X2Y[X[i]].push_back(Y[i]);
    }
    each(z, Y2X)sort(all(z.second));
    each(z, X2Y)sort(all(z.second));

    dfs(a);
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 85504
#include<stdio.h>
#include<stdlib.h>

#define POS(i,j) ((i)*(m+1)+(j))

void run(void){
  const int m=1000;
  int *dp=(int *)calloc((m+1)*(m+1),sizeof(int));
  int n;
  scanf("%d",&n);
  while(n--){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    dp[POS(a,b)]++;
    dp[POS(a,d)]--;
    dp[POS(c,b)]--;
    dp[POS(c,d)]++;
  }
  int i,j;
  for(i=0;i<=m;i++) for(j=1;j<=m;j++) dp[POS(i,j)]+=dp[POS(i,j-1)];
  for(j=0;j<=m;j++) for(i=1;i<=m;i++) dp[POS(i,j)]+=dp[POS(i-1,j)];
  int max=0;
  for(i=0;i<=m;i++) for(j=0;j<=m;j++) if(dp[POS(i,j)]>max) max=dp[POS(i,j)];
  printf("%d\n",max);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 5764
import sys


def naive_dijkstra(links, n, l):
    F30 = (1 << 30) - 1
    INF = 10 ** 18

    refuels = [[-1] * n for _ in range(n)]

    for s in range(n):
        rs = refuels[s]

        dists = [INF] * n
        dists[s] = 0
        remain_nodes = set(range(n))

        for _ in range(n):
            v = -1
            w = INF
            for u in remain_nodes:
                if dists[u] < w:
                    v = u
                    w = dists[u]
            if v == -1:
                break
            remain_nodes.remove(v)

            count = w >> 30
            used = w & F30
            rs[v] = count

            for u, c in links[v]:
                if l - used < c:
                    nw = ((count + 1) << 30) | c
                else:
                    nw = w + c
                if nw < dists[u]:
                    dists[u] = nw

    return refuels


n, m, l = list(map(int, input().split()))
lines = sys.stdin.readlines()

links = [set() for _ in range(n)]

for line in lines[:m]:
    a, b, c = map(int, line.split())
    a -= 1
    b -= 1
    if l < c:
        continue
    links[a].add((b, c))
    links[b].add((a, c))

dists = naive_dijkstra(links, n, l)
buf = []

for line in lines[m + 1:]:
    s, t = map(int, line.split())
    buf.append(dists[s - 1][t - 1])

print('\n'.join(map(str, buf)))


Measured memory_bytes: 79580
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int n,a,t1,t2;
	long long dp[101][21]={0};
	cin>>n>>a;
	dp[0][a]=1;
	for(int i=1;i<n-1;i++){
		cin>>a;
		for(int j=0;j<=20;j++){
			if(dp[i-1][j]!=0){
				t1=a+j;
				t2=j-a;
				if(t1>=0&&t1<=20){
					dp[i][t1]+=dp[i-1][j];
				}
				if(t2>=0&&t2<=20){
					dp[i][t2]+=dp[i-1][j];
				}
			}
		}
	}
	cin>>a;
	printf("%lld\n",dp[n-2][a]);
}

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

int doubleup(int num,int goal);

int main()
{
	int n,a,b,c,d,flag=1;
	char road[200010];
	char *p,*q;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	scanf("%s",road);
	
	p=strstr(road+a,"##");
	if((p)&&(p-road)<d)flag=0;
	else
	{
		if(c>d)
		{
			q=strstr(road+b-2,"...");
			//printf("%d %d\n",q-road+1,d);
			if((q)&&(q-road+1)<d)flag=1;
			else flag=0;
		}
	}
	if(flag)printf("Yes");
	else printf("No");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long Sum1[5005],Sum2[5005],dp[5005][5005];
int N,a[5005][5005];
int main(){
	scanf("%d",&N);
	for (int i=1;i<=N;i++)
		for (int j=1;j<N;j++)
			scanf("%d",&a[i][j+(j>=i)]);
	memset(dp,127,sizeof(dp));
	dp[0][0]=0;
	for (int i=1;i<=N;i++){
		memset(Sum1,0,sizeof(Sum1));
		memset(Sum2,0,sizeof(Sum2));
		for (int j=1;j<=i;j++){
			int qwq=0;
			for (int k=i+1;k<=N;k++)				
				Sum1[j]+=a[k][j];
			if (j) Sum1[j]+=Sum1[j-1];
		}
		for (int j=i-1;j>=0;j--){
			int qwq=0;
			for (int k=j+1;k<=i;k++)
				Sum2[j]+=a[j+1][k];
			if (j+1<i-1) 
				Sum2[j]+=Sum2[j+1];
		}
		for (int j=0;j<i;j++)
			for (int k=0;k<=j;k++)
				dp[i][j]=min(dp[i][j],dp[j][k]+Sum1[j]-Sum1[k]+Sum2[j]);
	}
	long long ans=LLONG_MAX;
	for (int i=0;i<=N;i++)
		ans=min(ans,dp[N][i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 206592
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;

    lint res = 0;

    if (k % 2) {
        lint t = n;
        t /= k;
        res = t * t * t;
    }
    else {
        lint t = n;
        lint t1 = t / (k/2);
        lint t2 = t / k;
        res = t2 * t2 * t2;
        res += (t1 - t2) * (t1 - t2) * (t1 - t2);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define fail return puts("-1"), 0

const int N = 1e3 + 5;

int n, sz;
long long x[N], y[N], bin[33];

void solve(long long x, long long y) {
	for (int i = sz - 1; i >= 0; i--) {
		if (std::labs(x) > std::labs(y)) {
			putchar(x < 0 ? 'L' : 'R');
			x < 0 ? x += bin[i] : x -= bin[i];
		} else {
			putchar(y < 0 ? 'D' : 'U');
			y < 0 ? y += bin[i] : y -= bin[i];
		}
	}
	puts("");
}
int main() {
	scanf("%d", &n);
	bool flg1 = false, flg2 = false;
	for (int i = 1; i <= n; i++) {
		scanf("%lld %lld", &x[i], &y[i]);
		((x[i] + y[i]) & 1 ? flg1 : flg2) = true;
	}
	if (flg1 && flg2) fail;
	if (flg1) {
		printf("%d\n", sz = 32);
		for (int i = sz - 1; i >= 0; i--) {
			printf("%lld%c", bin[i] = 1LL << i, " \n"[i == 0]);
		}
	} else {
		printf("%d\n", sz = 33);
		for (int i = sz - 1; i >= 1; i--) {
			printf("%lld ", bin[i] = 1LL << (i - 1));
		}
		printf("%lld\n", bin[0] = 1);
	}
	for (int i = 1; i <= n; i++) solve(x[i], y[i]);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  string S; cin >> S;
  int N = S.size();
  vector<ll> A;
  int count = 1;
  rep(i,N) {
    if (i == 0) {
      if (S[0] == '>') A.emplace_back(0);
    } else {
      if (S[i] != S[i-1]) {
        A.emplace_back(count);
        count = 1;
      } else count++;
    } 
  }
  A.emplace_back(count);
  if (S[N-1] == '<') A.emplace_back(0);

  int M = A.size();
  ll ans = 0;
  rep(i,M) {
    if (i % 2 == 1) continue;
    ll k = max(A[i],A[i+1]);
    ll l = min(A[i],A[i+1]);
    ans += (k * (k+1) / 2 + (l-1) * l / 2);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3352
import itertools
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sum_a=list(itertools.accumulate(a))
sum_b=list(itertools.accumulate(b))
result=bisect.bisect_right(sum_b,k)

for i in range(n):
    if sum_a[i]<=k:
        result=max(result,i+1+bisect.bisect_right(sum_b,k-sum_a[i]))
print(result)

Measured memory_bytes: 47296
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <climits>
#include <map>
#include <unordered_map>
#include <string>
#include <ctime>
//#include <unistd.h>

using namespace std;
#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define mp make_pair
#define pb push_back
#define fi first
#define sd second
#define fu(A, B, C) for(ll (A) = (B); (A) < (C); (A)++)
#define fu0(A, B) fu((A), 0, (B))
#define fd(A, B, C) for(ll (A) = (B); (A) >= (C); (A)--)
#define mem(A, B) memset((A), (B), sizeof((A)))
#define vd(A, B, C) vector<ll> (A)((B), (C))
#define vd0(A, B) vector<ll> (A)((B), 0)
#define v2d(A, B, C) vector<vector<int>> (A)((B), vector<int> (C));
#define all(x) x.begin(), x.end()
#define print(A) fu0(i, (A).size()) cout << (A)[i] << " "; cout << endl;
//
#define readV(A) fu0(i, (A).size()) cin >> (A)[i]
#define read(A) ll (A); cin >> (A)
#define readStuff(A, B) read((A)); vd0((B), (A)); readV((B));
//
#define endl "\n"
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;

ll gcd(int a, int b){if(!a)return b;return gcd(b%a,a);}

void perform() {
    ll a, b; cin >> a >> b; cout << a * b << endl;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //cout << fixed;
  ll t = 1; //cin >> t;
  while(t--) {perform();}
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
template<typename T> void ckmax(T&a, T b) { if (b > a) a = b; }
template<typename T> void ckmin(T&a, T b) { if (b < a) a = b; }

const int N = 100000 + 5;
int vis[N];

int main ()
{
	vis[0] = 1;
	for (int i = 1; i <= 100000; ++i) {
		for (int j = 0; j <= 5; ++j) if (i - j - 100 >= 0) vis[i] |= vis[i - j - 100];
	}
	int x; scanf ("%d", &x);
	printf ("%d\n", vis[x]);
	return 0;
}







































Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b; cin >> a >> b;
    for(int i = 1; i <= 3; i++){
        if((a*b*i)&1){
            cout << "Yes" << endl; return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll N, ans = 0;
    cin >> N;
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i != 0)
        {
            continue;
        }
        ll t = N / i;
        t--;
        if (i < t)
        {
            ans += t;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int n, m, ans, i;
    scanf("%lld %lld", &n, &m);
    ans = 1;
    for (i=m/n; i>0; i--)
    {
        if (m%i == 0) {
            ans = i;
            break;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
def calc_gcd(a, b):
    r = a % b
    while (r != 0):
        a = b
        b = r
        r = a % b

    return b

a, b = list(map(int, input().split()))

if a < b:
    tmp = a
    a = b
    b = tmp

gcd = calc_gcd(a, b)
ans = int(a * b / gcd)

print(ans)


Measured memory_bytes: 3060
N, X, Y = map(int, input().split())
X, Y = X-1, Y-1
ans = {i:0 for i in range(1, N)}

for i in range(N-1):
    for j in range(i+1, N):
        d = min(j-i, abs(X-i)+1+abs(Y-j))
        ans[d] += 1
        
for _, v in ans.items():
    print(v)

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 
const int MAX_N = 200005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vl a(N); rep(i,N) cin >> a[i];
  sort(ALL(a));
  ll man = a[N-1];
  vector<Pl> b(N-1);
  rep(i,N-1) b[i] = P(min(a[i],man-a[i]),a[i]); 
  sort(ALL(b));
  cout << man << " " << b[N-2].second << endl;
  return 0;
}

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

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

    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
	
  if(s<t) cout<< "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	k := getNextInt(scanner)
	ans := solve(k)
	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func solve(k int) int {
	visited := make([]int, k)
	queue := make([][2]int, k*2)
	l := k
	r := l + 1
	queue[l] = [2]int{
		1, 1,
	}
	visited[1] = 1
	for l != r {
		p := queue[l]
		l = (l + 1 + k*2) % (k * 2)
		if p[0] == 0 {
			return p[1]
		}
		visited[p[0]] = 1

		to := (p[0] * 10) % k
		if visited[to] == 0 {
			l = (l - 1 + k*2) % (k * 2)
			queue[l] = [2]int{
				to,
				p[1],
			}
		}
		to = (p[0] + 1) % k
		if visited[to] == 0 {
			queue[r] = [2]int{
				to,
				p[1] + 1,
			}
			r = (r + 1 + k*2) % (k * 2)
		}
	}

	return 0
}


Measured memory_bytes: 4736
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int a, b;

  sc.scan(a, b);

  if ((a * b) % 2 == 0)
    writeln("Even");
  else
    writeln("Odd");
}


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

int main(void){
  int n,a,b;
  int passed=0, passedF=0;
  
  cin >> n >> a >> b;
  for (int i=0; i<n; i++){
    char c; cin >> c;
    if (passed>=a+b || c=='c' || (c=='b'&&passedF>=b)){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
      if (c=='a'){
        passed++;
      } if (c=='b'){
        passed++;
        passedF++;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){

	long long int a,b;
	long long int num;
	long long int buff;
	int count_a;
	int count_b;
	long long int ret;

	
	int j;
	int i = 0;
	ret =0;
	
	scanf("%lld %lld",&a,&b);

	num = 2;

	if ( a > b){
		buff = a;
		a = b;
		b = buff;
	}

	count_a = 0;
	while(a % num == 0){
		count_a++;
		a /= num;
	}
//	while(b % num == 0){
//		count_b++;
//		b /= num;
//	}
	if(count_a > 0){		
		if(b % num == 0){
			ret++;
		}
	}

//	if(count_a > 0 && count_b > 0){
//		ret++;
//	}

	for(num = 3;num * num <= a; num+=2){
		count_a = 0;
		while(a % num == 0){
			count_a++;
			a /= num;
		}
//		while(b % num == 0){
//			count_b++;
//			b /= num;
//		}

		if(count_a > 0){
			if(b % num == 0){
				ret++;
			}
		}
//		if(count_a > 0 && count_b > 0){
//			ret++;
//		}
	}
	if(a != 1){
		if(b % a == 0){
			ret++;
		}
	}


	printf("%lld\n",ret+1);



	return 0;
}

Measured memory_bytes: 128
s = input()
t = input()

## 辞書順の判定
# 文字列を任意に並び変える：
# s: abc順, t: cba順
s_dash = ''.join(sorted(s))
t_dash = ''.join(sorted(t, reverse=True))

if s_dash < t_dash:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
/*input
4 5
1 2
2 3
2 4
4 1
4 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
vector<int> v[maxn];
int prev1[maxn];
int main() {
    int n,m;
    cin>>n>>m;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        v[a].pb(b);
    }
    vector<int> ans;
    REP(i,n){
        queue<int> q;
        FILL(prev1,-1);
        int cnt=0;
        for(auto x:v[i]){
            prev1[x]=i;
            q.push(x);
        }
        while(!q.empty()){
            int u=q.front();
            q.pop();
            if(u==i){
            	
                vector<int> v;
                u=prev1[u];
                while(u!=i){
                    v.pb(u);
                    u=prev1[u];
                }
                v.pb(i);
                if(sz(ans)==0 or sz(v)<sz(ans)){
                    ans=v;
                }
                break;
            }
            for(auto x:v[u]){
                if(prev1[x]==-1){
                    prev1[x]=u;
                    q.push(x);
                }
            }
        }
    }
    if(sz(ans)){
        cout<<sz(ans)<<'\n';
        reverse(ALL(ans));
        for(auto x:ans) cout<<x+1<<'\n';
    }
    else cout<<-1;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;

 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int max = -2000000000;
    int nowmin = sc.nextInt();
    for(int i = 1; i < n; i++){
      int nowvalue = sc.nextInt();
      if(nowvalue - nowmin > max){
        max = nowvalue - nowmin;
      }
      if(nowvalue < nowmin){
        nowmin = nowvalue;
      }
    }
    System.out.println(max);
  }
 
  
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
//   setsu[i] = new LinkedList<Integer>();
// } 

 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 19072
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            String str=sc.next();
            if(str.equals("-"))
            break;
            int n=sc.nextInt();
            for(int i=0;i<n;i++){
                int length=sc.nextInt();
                str=str.substring(length)+str.substring(0,length); 
            }
            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26512
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b;
    cin >> a >> b;
    if(a%2==1&&b%2==1) cout << "Odd" << endl;
    else cout << "Even" << endl;
}

Measured memory_bytes: 256