akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;

typedef vector<int> vi;

// 強連結成分分解 (Strongly Connected Component)
struct SCCGraph: public vector<vi> {

	vector<int> order;    // 属する強連結成分の番号(トポロジカル順序になっている) まだ調べてない頂点は-1
	vector<int> vs;       // 帰りがけ順

	using vector::vector;	// 継承コンストラクタ
	SCCGraph(const vector<vi> &v): vector::vector(v) {}	// コピーコンストラクタを使用可能にする

	// a -> b の辺を追加する。push_back()でも同じ
	void add_edge(int a, int b){
		(*this)[a].push_back(b);
	}

	// scc()で使う
	void dfs(int n, int k, vector<vi> &v, vector<vi> &rv){
		order[n] = k;
		for(auto t: v[n]){
			rv[t].push_back(n);	// 逆辺のグラフを作成
			if( order[t] < 0 ) dfs(t, k, v, rv);
		}
		vs.push_back(n);
	}

	// 強連結成分分解を行う return:強連結成分の数
	int scc(){
		int N = size(), k = 0;
		vector<vi> rG(N), tmp(N);   // 辺を逆にしたグラフ用
		vs.clear();
		order.assign(N, -1);
		rep(n,N) if( order[n] < 0 ) dfs(n, n, (*this), rG);
		order.assign(N, -1);
		rrep(i,vs.size()) if( order[ vs[i] ] < 0 ) dfs(vs[i], k++, rG, tmp);
		return k;
	}

	// 属する強連結成分が同じかどうか判定
	bool find(int x, int y){
		return order[x] == order[y];
	}

};
// 関数としてsccを使う。戻り値は、各ノードが所属する強連結成分の番号
vector<int> scc(const vector<vi> &v){
	SCCGraph g(v);
	g.scc();
	return g.order;
}


int main(){
	ios_base::sync_with_stdio(false);
	ll N, M;

	cin >> N >> M;
	SCCGraph graph(N);
	rep(i, N-1+M){
		ll A, B;
		cin >> A >> B;
		A--; B--;
		graph.add_edge( A, B );
	}

	graph.scc();

	vector<pll> v;
	rep(i,graph.order.size()){
		int od = graph.order[i];
		v.emplace_back(od, i);
	}
	sort(all(v));

	vector<int> ans(N);
	for(auto p: v){
		int i = p.Y;
		for(auto t: graph[i]){
			ans[t] = i+1;
		}
	}

	for(auto a: ans){
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 19704
import sys
from operator import itemgetter
import collections

def r(n, p):
  m = n + 1
  count = 0
  for i in range(n):
    m = min([p[i], m])
    if m == p[i]:
      count += 1
  return count

def main():
    input = sys.stdin.readline
    n = int(input())
    p = list(map(int, input().split()))
    print(r(n,p))

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 23892
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		vector<pair<int,int> > d;
		rep(i,0,n){
			int name,m,s,sum=0;
			cin>>name;
			rep(i,0,4){
				cin>>m>>s;
				sum+=60*m+s;
			}
			d.push_back(make_pair(sum,name));
		}
		sort(all(d));
		o(d[0].second);
		o(d[1].second);
		o(d[n-2].second);
	}
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0 ;i < n;i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    for(int i = 0 ;i < n;i++){
        //cout << l[i] << " ";
    }
    //cout << endl;

    int sum = 0;
    for(int a = 0; a < n - 2; a++){
        for(int b = a + 1; b < n - 1; b++) {
            int minc = min(lower_bound(l.begin()+b+1,l.end(),l[a] - l[b]), lower_bound(l.begin()+b+1,l.end(),l[b] - l[a])) - l.begin();
            int maxc = upper_bound(l.begin()+b+1,l.end(),l[a]+l[b] -1) - l.begin();
            //cout<<  "(a,b) = ("<< a<<","<<b<<")" << minc << "~" << maxc<< endl;
            sum += maxc - minc;
        }
    }
    cout << sum << endl;
}


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

using namespace std;

int add(char c) {
    return ((c == '#') ? 1 : 0);
}

void solve() {
    int h, w;
    cin >> h >> w;
    char s[h+2][w+2];
    for (int i=0;i<h+2;i++) {
        for (int j=0;j<w+2;++j) {
            s[i][j] = 0;
        }
    }
    for (int i=1;i<=h;i++) {
        for (int j=1;j<=w;++j) {
            cin >> s[i][j];
        }
    }
    for (int i=1;i<=h;i++) {
        for (int j=1;j<=w;++j) {
            if (s[i][j] == '.') {
                s[i][j] = add(s[i][j-1]) + add(s[i][j+1]);
                s[i][j] += add(s[i-1][j-1]) + add(s[i-1][j]) + add(s[i-1][j+1]);
                s[i][j] += add(s[i+1][j-1]) + add(s[i+1][j]) + add(s[i+1][j+1]);
                s[i][j] += '0';
            };
        }
    }
    for (int i=1;i<=h;i++) {
        for (int j=1;j<=w;++j) {
            cout << s[i][j];
        }
        putchar('\n');
    }
}

int main() {
	solve();
    return 0;
}


Measured memory_bytes: 3128
dg = input().split()
m = int(dg[0])
d = int(dg[1])
count = 0
for i in range(m + 1):
    if i !=0:
        for e in range(d + 1):
            if(len(str(e)) >= 2):
                ee = str(e)
                d1 = int(ee[0])
                d2 = int(ee[1])
                
                if d1*d2 == i and d1 >=2 and d2>=2:
                    count = count +1

                    
                    
print(count)

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

int main() {
    int N; cin >> N;
    vector<int> s(N);
    rep(i, 0, N) cin >> s[i];
    long long ans = 0;
    rep(i, 1, N) {
        int l = 0, r = N - 1;
        long long res = 0;
        long long sum = 0;
        if((N - 1) % i == 0) {
            for(; l < r; l += i, r -= i) {
                sum += s[l] + s[r];
                res = max(res, sum);
            }
        } else {
            for(; l < N - 1 && r - i > 0; l += i, r -= i) {
                sum += s[l] + s[r];
                res = max(res, sum);
            }
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long 
const int MAXN = 1e6 + 100 ; 
bool vis[MAXN] ; 
int par[MAXN] , b = -1 ; 
vector<int> ver[MAXN] ; 
void dfs(int v,  int p){
	int deg = 0 ; 
	par[v] = p ; vis[v] = true ; 
	for(auto u : ver[v]){
		if(vis[u])continue ; 
		deg ++ ; 
		dfs(u , v) ; 
	}
	if(deg == 0)b = v ; 
}
int32_t main() {
	ios_base::sync_with_stdio(0) ; 
	cin . tie(0) ; cout . tie(0) ; 
	
	int n ; cin >> n ;
	int m ; cin >> m ; 
	for(int i= 0 ; i < m ; i ++){
		int x , y ; cin >> x >> y ; 
		x -- , y -- ; 
		ver[x] . push_back(y) ; 
		ver[y] . push_back(x) ; 
	}
	dfs(0 , -1) ;
	memset(vis , 0 , sizeof vis) ; 
	vector<int> ans1 ; 
	while(b != -1){
		ans1 . push_back(b) ;
		vis[b] = true ;
		b = par[b] ; 
	}
	dfs(0 , -1) ;
	vector<int> ans2 ;  
	while(b){
		ans2 . push_back(b) ;
		vis[b] = true ;
		b = par[b] ; 
	}
	cout << ans1 . size() + ans2 . size() << '\n' ; 
	for(auto u : ans1)cout << u + 1 << ' ' ; 
	while(ans2 . size()){
		cout << ans2 . back() + 1 << ' '  ; 
		ans2 . pop_back() ; 
	}
}

Measured memory_bytes: 34676
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
v64 ncw,ncb,fw,fb,p2;
vv64 dp;
// v64 fact;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll ans = mpow(a,b/2);
	ans *= ans;
	ans %= MOD;
	if(b%2 == 1) ans *= a;
	ans %= MOD;
	return ans;
}

ll inv(ll v){
	return mpow(v,MOD-2);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll b,w;
    cin >> b >> w;
    ll tot = b+w;
    ncb.resize(tot+5);
    ncw.resize(tot+5);
    fw.resize(tot+5);
    // pfw.resize(tot+5);
    fb.resize(tot+5);
    // pfb.resize(tot+5);
    p2.resize(tot+5);
    forn(i,tot+5){
    	if(i==0) p2[i]=1;
    	else{
    		p2[i]=p2[i-1]*2;
    		p2[i]%=MOD;
    	}
    }
    forn(i,tot+5){
    	if(w==0) ncw[i]=0;
    	else if(i<w-1) ncw[i]=0;
    	else if(i==w-1) ncw[i]=1;
    	else{
    		ncw[i]=i*inv(i-w+1);
    		ncw[i]%=MOD;
    		ncw[i]*=ncw[i-1];
    		ncw[i]%=MOD;
    	}
    }
    forn(i,tot+5){
    	if(b==0) ncb[i]=0;
    	else if(i<b-1) ncb[i]=0;
    	else if(i==b-1) ncb[i]=1;
    	else{
    		ncb[i]=i*inv(i-b+1);
    		ncb[i]%=MOD;
    		ncb[i]*=ncb[i-1];
    		ncb[i]%=MOD;
    	}
    }
    // forn(i,tot+1){
    // 	cout << ncw[i] << ' ' << ncb[i] << ln;
    // }
    forn(i,tot+5){
    	if(w==0){
			fw[i]=1;    		
    	}
    	else if(i<w){
    		fw[i]=0;
    		// pfw[i]=0;
    	}
    	else{
    		if(i==0) fw[i]=0;
    		else fw[i]=2*fw[i-1]+ncw[i-1];
    		// pfw[i]=fw[i]+ncw[i];
    	}
    	fw[i]%=MOD;
    }
    forn(i,tot+5){
    	if(b==0){
    		fb[i]=1;
    	}
    	else if(i<b){
    		fb[i]=0;
    		// pfb[i]=0;
    	}
    	else{
    		if(i==0) fb[i]=0;
    		else fb[i]=2*fb[i-1]+ncb[i-1];
    		// pfb[i]=fb[i]+ncb[i];
    	}
    	fb[i]%=MOD;
    }
    forn(i,tot){
    	ll a,b;
    	a = fw[i];
    	b = fb[i];
    	// cout << a << " " << b << ln;
    	ll ans = 2*a;
    	ans %= MOD;
    	ans += (p2[i]-a-b);
    	ans %= MOD;
    	if(ans < 0) ans += MOD;
    	// cout << ans << " " << p2[i+1] << ln;
    	ans *= inv(p2[i+1]);
    	ans %= MOD;
    	while(ans < 0) ans += MOD;
    	cout << ans << ln;
    }
    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  char temp=0;
  int ans=0;
  for(int i=0;i<n;i++) {
    if(s.at(i)!=temp) {
      ans++;
      temp=s.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
import sys

def solve():
    N, Ma, Mb = map(int, input().split())
    table = [tuple(map(int, input().split())) for i in range(N)]

    g1 = half_rekkyo(N, Ma, Mb, table, 0, N // 2)
    g2 = half_rekkyo(N, Ma, Mb, table, N // 2, N - N // 2)

    inf = 100 * 40 + 1
    ans = inf

    if 0 in g1:
        ans = min(ans, g1[0])
    if 0 in g2:
        ans = min(ans, g2[0])

    for v1, c1 in g1.items():
        if -v1 in g2:
            tmp = c1 + g2[-v1]
            ans = min(ans, tmp)

    if ans < inf:
        print(ans)
    else:
        print(-1)

def half_rekkyo(N, Ma, Mb, table, s, m):
    res = dict()

    for comb in range(1, 2**m):
        v = 0
        cost = 0

        for i in range(m):
            if comb & (1 << i):
                a, b, c = table[s + i]
                v += b * Ma - a * Mb
                cost += c

        if v in res:
            res[v] = min(res[v], cost)
        else:
            res[v] = cost

    return res

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 42348
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    csf = [tuple(in_nn()) for _ in range(N - 1)]

    for i in range(N - 1):
        c, s, f = csf[i]
        time = c + s
        for j in range(i + 1, N - 1):
            c, s, f = csf[j]
            if time <= s:
                time = s + c
            else:
                r = (time - s) % f
                if r != 0:
                    time += f - r
                time += c
        print(time)
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9244
#include<iostream>
using namespace std;
int main()
{
    int N,X;
    while (cin>>N>>X)
    {
        int a[N+1];
        int k=0,b;
        for (int i=0;i<N;i++)
        {
            cin>>a[i];
            k+=a[i];
        }
        for (int i=1;i<N;i++)
        {
            if (a[0]>a[i])
            {
                a[0]=a[i];
            }
        }
        b=(X-k)/a[0];
        cout<<b+N<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

double r;

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> r;
	printf("%.11f\n", 2 * r * 3.14159265358979);
	
	return 0;
}

Measured memory_bytes: 3776
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
#define DEBUG
#ifdef DEBUG
#endif

int main()
{
    std::ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    for(int x = 0; x <= n; x++)
    {
    	for(int y = 0; y <= m; y++)
    	{
    		int sum = m*x+n*y-2*x*y;
    		if(sum==k)
    		{
    			puts("Yes");
    			return 0;
    		}
    	}
    }
    puts("No");























    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int x,y;

		Scanner stdIn = new Scanner(System.in);

		while (true) {
			x = stdIn.nextInt();
			y = stdIn.nextInt();

			if(x == 0 && y == 0) {
				break;
			}

			if(x < y) {
				System.out.println(x + " " + y);
			} else {
				System.out.println(y + " " + x);
			}

		}


	}

}

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

int main(void){
  int i,n = 0;
  char w[11], t[1001];

  scanf("%s", w);

  do{
    scanf("%s",t);
    if(!strcmp(t,"END_OF_TEXT")) break;
      for(i=0;t[i]!='\0';i++)
        if(t[i]<91) t[i] += 32;
    if( !strcmp(w,t) ) n++;
  }while(1);

  printf("%d\n",n);

  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
int ara[3001][3001];
int main()
{
    string s,t;
    cin>>s>>t;
    for(int i=0;i<=s.size();i++)
    {
        for(int j=0;j<=t.size();j++)
        {
            if(i==0||j==0){ara[i][j]=0;continue;}
            if(s[i-1]==t[j-1])ara[i][j]=ara[i-1][j-1]+1;
            else ara[i][j]=max(ara[i][j-1],ara[i-1][j]);

        }
    }
    string ss;
    int j=t.size(),i=s.size();
    while(i!=0&&j!=0)
    {
        if(ara[i][j]==ara[i-1][j-1]+1&&s[i-1]==t[j-1]){ss+=s[i-1];i--;j--;}
         else if(ara[i][j]==ara[i][j-1])j--;
         else i--;

    }
    reverse(ss.begin(),ss.end());
    cout<<ss<<endl;
}


Measured memory_bytes: 35584
#include<stdio.h>
typedef struct{

  int k;
  char mozi;
  }card;
  
  int main(){
  int i,j,m,min;
  card num[36],suit[36],temp;
  
  scanf("%d",&m);
  for(i = 0; i < m; i++){
  scanf(" %c%d", &num[i].mozi, &num[i].k);
   suit[i].mozi = num[i].mozi;
    suit[i].k = num[i].k;
   }

  for(i = 0; i < m; i++){
    for(j = m-1; j > i; j--){

      if(num[j].k < num[j-1].k){
     temp = num[j];
     num[j] = num[j-1];
     num[j-1] = temp;
      }
    }
   }
    
    for(i = 0; i < m-1; i++){
     printf("%c%d ",num[i].mozi, num[i].k);
  }
  printf("%c%d\nStable\n",num[i].mozi, num[i].k);

   for(i = 0; i < m-1; i++){
    min = i;
    for(j = i; j <= m-1; j++){
     if(suit[j].k < suit[min].k) min = j;
     }
    temp = suit[i];
    suit[i]=suit[min];
    suit[min]=temp;
   }

   for(i = 0; i < m-1; i++){
    printf("%c%d ",suit[i].mozi,suit[i].k);
   }
   printf("%c%d\n",suit[i].mozi,suit[i].k);

   for(i = 0; i < m; i++){
    if(suit[i].mozi != num[i].mozi) {
      printf("Not stable\n");
       break;
     }
   }
   if(i == m)printf("Stable\n");
   return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)

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

void Main(){
  double A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  int a, b, c, d;
  double max = -1;
  int gross = 0, sugar = 0;
  a = 0;
  while(true){
    if(100 * A * a > F) break;
    b = 0;
    if(a == 0 && b == 0) b++;
    while(true){
      if(100 * A * a + 100 * B * b > F) break;
      c = 0;
      while(true){
        if(100 * A * a + 100 * B * b + C * c > F) break;
        d = 0;
        while(true){
          if(100 * A * a + 100 * B * b + C * c + D * d > F) break;
          if((C * c + D * d) / (100 * A * a + 100 * B * b + C * c + D * d) > max && (C * c + D * d) / (A * a + B * b) <= E){
            max = (C * c + D * d) / (100 * A * a + 100 * B * b + C * c + D * d);
            gross = 100 * A * a + 100 * B * b + C * c + D * d;
            sugar = C * c + D * d;
          }
          d++;
        }
        c++;
      }
      b++;
    }
    a++;
  }
  cout << gross << " " << sugar << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC133_C
{
    class Program
    {
        static void Main(string[] args) {
            string[] input = Console.ReadLine().Split();
            long l = long.Parse(input[0]);
            long r = long.Parse(input[1]);
            List<long> list = new List<long>();

            if(r - l >= 2019) {
                Console.WriteLine(0);
                return;
            }
            long ans = 2019;
            for (long number1 = l; number1 <= r - 1; number1++) {

                for(long number2 = number1 + 1; number2 <= r; number2++) {
                    long mod = (number1 * number2) % 2019;
                    if (mod < ans)
                        ans = mod;
                }

                if (ans == 0)
                    break;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, v[50];
double ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> v[i];
	sort(v, v + n);
	ans = (v[0] + v[1]) / 2.0;
	for (int i = 2; i < n; i++)ans = (ans + v[i]) / 2.0;
	printf("%.10f", ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, op, x;
	
	while(1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if(op == '+')
			printf("%d\n", a + b);
		else if(op == '-')
			printf("%d\n", a - b);
		else if(op == '*')
			printf("%d\n", a * b);
		else if(op == '/')
			printf("%d\n", a / b);
		else if(op == '%')
			printf("%d\n", a % b);
		else break;
	}
	
	return 0;
}

Measured memory_bytes: 600
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + j*100 + 50*k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static final long INF = (long) 1e17;
    static int n, a[], maxskips;
    static Long memo[][];

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        n = sc.nextInt();
        a = sc.nextIntArray(n);
        maxskips = 1 + (n % 2);
        memo = new Long[3][n];
        long ans = dp(0, 0);
        out.println(ans);
        out.flush();
        out.close();
    }

    static long dp(int skip, int i) {
        if (skip > maxskips) return -INF;
        if (i >= n) return 0;
        if (memo[skip][i] != null) return memo[skip][i];
        long max = a[i] + dp(skip, i + 2);
        if (i != n - 1) max = Math.max(max, dp(skip + 1, i + 1));
        return memo[skip][i] = max;
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

    }
}


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


int main() {
  int n, a, b, c; cin >> n >> a >> b >> c;
  vector<string> s(n); rep(i,n) cin >> s[i];

  if (a + b + c == 0 || s[0]=="AB"&&a+b==0 || s[0]=="AC"&&a+c==0 || s[0]=="BC"&&b+c==0) {
    cout << "No" << endl;
  } else if (a+b+c == 1) {
    string t = "";
    rep(i,n) {
      if (s[i] == "AB") {
        if (a < b) {
          a++; b--;
          t.push_back('A');
        } else {
          a--; b++;
          t.push_back('B');
        }
      } else if (s[i] == "AC") {
        if (a < c) {
          a++; c--;
          t.push_back('A');
        } else {
          a--; c++;
          t.push_back('C');
        }
      } else if (s[i] == "BC") {
        if (b < c) {
          b++; c--;
          t.push_back('B');
        } else {
          c++; b--;
          t.push_back('C');
        }
      }
      if (a < 0 || b < 0 || c < 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    rep(i,n) {
      cout << t[i] << endl;
    }
  } else {
    cout << "Yes" << endl;
    rep(i,n) {
      if (s[i] == "AB") {
        if (a < b || a == 1 && b == 1 && c == 0 && i != n-1 && s[i+1] == "AC") {
          a++; b--;
          cout << "A" << endl;
        } else {
          a--; b++;
          cout << "B" << endl;
        }
      } else if (s[i] == "AC") {
        if (a < c || a == 1 && b == 0 && c == 1 && i != n-1 && s[i+1] == "AB") {
          a++; c--;
          cout << "A" << endl;
        } else {
          a--; c++;
          cout << "C" << endl;
        }
      } else if (s[i] == "BC") {
        if (b < c || a == 0 && b == 1 && c == 1 && i != n-1 && s[i+1] == "AB") {
          b++; c--;
          cout << "B" << endl;
        } else {
          c++; b--;
          cout << "C" << endl;
        }
      }
    }
  }

}


Measured memory_bytes: 6692
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
   int n,k;
   cin >> n >> k;
   vector<int> vec(n);
   for(int i=0;i<n;i++){
       int x;
       cin >> x;
       vec[i]=x;
   }
   sort(vec.begin(),vec.end());
   int count = 1e9;
   for(int i=0;i<n-k+1;i++){
       count = min(count,vec[i+k-1]-vec[i]);
   }
   cout<<count<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

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

  string s;
  cin >> s;
  ll n=s.size();
  ll dp[n+1][4];
  
  rep(i,n+1)rep(j,4) dp[i][j]=0;
  dp[0][0]=1;
  rep1(i,n){
    dp[i][0]=dp[i-1][0];
    if(s[i-1]=='?') dp[i][0] = mu(dp[i][0],3LL);
    
    dp[i][1]=dp[i-1][1];
    if(s[i-1]=='?') dp[i][1] = mu(dp[i][1],3LL);    
    if(s[i-1]=='A'||s[i-1]=='?'){
      dp[i][1]+=dp[i-1][0];
      dp[i][1]%=mod;
    }

    dp[i][2]=dp[i-1][2];
    if(s[i-1]=='?') dp[i][2] = mu(dp[i][2],3LL);
    if(s[i-1]=='B'||s[i-1]=='?'){
      dp[i][2]+=dp[i-1][1];
      dp[i][2]%=mod;
    }

    dp[i][3]=dp[i-1][3];
    if(s[i-1]=='?') dp[i][3] = mu(dp[i][3],3LL);
    if(s[i-1]=='C'||s[i-1]=='?'){
      dp[i][3]+=dp[i-1][2];
      dp[i][3]%=mod;
    }
    //    cout << dp[i][0] << " " << dp[i][1] <<	" "<< dp[i][2] <<	" "<< dp[i][3] <<	" " << endl;
  }
  cout << dp[n][3] << endl;


  
  return 0;
    

}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	char s[3];
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}
	int ans = 700;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o') {
			ans += 100;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
ll a[200001];
bool mark[200001];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	while(t--)
	{
	ll n,k;
	cin>>n>>k;
	//ll a[n+1];
	for(ll i=1;i<=n;i++)
        cin>>a[i];
        //bool mark[n+1]={0};
        mark[1]=1;
        ll g=1;
        ll i=1;
        ll s[n+1]={0};
    for(;i<=n;i++){

        g=a[g];
    //cout<<g<<endl;
        if(mark[g]){

            break;
        }
        mark[g]=1;
        s[g]=i;
    }
    ll r=i-s[g];
    if(k-s[g]>=0){
        k-=s[g];
        k%=r;
        ll start=g;
        //cout<<start<<" "<<k<<" "<<r<<endl;
        for(ll i=1;i<=k;i++){
            start=a[start];
        }
        cout<<start;
        return 0;
    }
    ll start=1;
    for(ll i=1;i<=k;i++)
        start=a[start];

	cout<<start;}
return 0;
}


Measured memory_bytes: 6968
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn main() {
    println!{"{}", match &read_trim()[..] {
        "a"|"i"|"u"|"e"|"o" => "vowel",
        _ => "consonant"
        }};
}

fn read_trim() -> String {
    read_line!().trim().to_owned()
}

Measured memory_bytes: 4352
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let d = read_vec::<usize>();
    let max_diff = 100000;
    let mut count = vec![0; max_diff];
    for num in d {
        count[num - 1] += 1;
    }
    let half = n / 2;
    let mut ans = 0;
    let mut accum = 0;
    for di in 0..max_diff {
        accum += count[di];
        if accum == half {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 3852
N = int(input())
A = [int(i) for i in input().split()]

# A = [5, 3, 2, 4, 1]

def bubbleSort(arr):
    arr_len = len(arr)
    flg = True
    cnt = 0
    while flg:
        flg = False
        for i in range(arr_len -1, 0, -1):
            if arr[i] < arr[i-1]:
                arr[i], arr[i-1] = arr[i-1], arr[i]
                flg = True
                cnt = cnt + 1
                
    print(' '.join([str(x) for x in arr]))
    print(cnt)

bubbleSort(A)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int inv[2005];
ll qpow(ll a, ll n = mod - 2) {
	ll res = 1;
	while (n)
	{
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

ll C(ll m, ll n) {
	//if (m < 0 || n < 0 || n < m) return 0;
	ll r = 1;
	for (int i = 1; i <= m; ++i) {
		r = (n - i + 1) % mod * r % mod * inv[i] % mod;
	}
	return r;
}
int main() {
	ll n, x, d;
	for (int i = 1; i < 2005; ++i)
		inv[i] = (int)qpow(i);
	while (cin >> n >> d >> x, n) {
		ll ans = 0;
		for (ll i = 0; i <= n / x && i <= d; ++i) {
			ll a = C(i, d);
			ll b = C(n - i * x, n - i * x + d - 1);
			ll flag = (i & 1) ? -1 : 1;
			ans = (ans + flag * a * b % mod) % mod;
		}
		cout << (ans + mod) % mod << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
S = input()
def ACGT(S):
    for d in S:
        if not d in "AGCT":
            return False
    return True
def solve(S):
    res = 0
    for i in range(len(S)):
        for j in range(i,len(S)+1):     
            if (ACGT(S[i:j])):
                res = max(j-i,res)
    return res
print(solve(S))


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int n; cin >> n;
	V<int> a(n); REP(i, n) cin >> a[i];
	sort(ALL(a));
	int c = a[n - 1],d = 0;
	int maxi = 0;
	REP(i,n-1){
		int mini = min(a[i], c - a[i]);
		if(mini > maxi){
			maxi = mini;
			d = a[i];
		}
	}
	cout << c << " " << d << endl;
	

	return 0;
}



Measured memory_bytes: 640
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define mod 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


main()
{
    optimize();
ll n,t,c,y,i;
cin>>n>>t;
vector<pair<ll,ll>>v;

for(i=1;i<=n;i++)
{
    cin>>c>>y;
    v.PB({c,y});
}
sort(all(v));
c=-1;
for(auto u:v)
{
    if(u.S<=t){
      c=u.F;
      break;}
}
if(c==-1)
    cout<<"TLE"<<endl;
else
cout<<c<<endl;















    return 0;
}












































Measured memory_bytes: 3620
s = int(input())

a = [s]
n = 1
while True:
    if a[n-1] % 2 == 0:
        next_a = a[n-1] // 2
    else:
        next_a = 3*a[n-1] + 1 
    if next_a in a:
        print(len(a)+1)
        break
    a.append(next_a)
    n += 1

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

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

  if (x == "A"){
    cout << "T" << endl;
  }

  if (x == "C") {
    cout << "G" << endl;
  }

  if (x == "T") {
    cout << "A" << endl;
  }
  if (x == "G") {
    cout << "C" << endl;
  } 

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#define ll long long
#define INF 10000000

using namespace std;

//ifstream cin ("input.txt"); ofstream cout ("output.txt");

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;
    vector <int> g(n);
    for(int i=0; i<n;i++){
        cin >> g[i];
    }
    for(int i = 0; i < n; i++){
        if(g[i] == i+1){
            ans++;
            if(i == n-1){
                swap(g[i], g[i-1]);
            }else{
                swap(g[i], g[i+1]);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<int> p(m,0);
    vector<int> y(m,0);
    vector<vector<int>> yd(n+1,vector<int>(0));
    REP(i, m){
        cin >> p[i] >> y[i];
        yd[p[i]].push_back(y[i]);
    }
    REP(i, n){
        SORT(yd[i+1]);
    }
    REP(i, m){
        int n = distance(yd[p[i]].begin(),lower_bound(ALL(yd[p[i]]),y[i]))+1;
        printf("%06d%06d\n", p[i], n);
    }
}

Measured memory_bytes: 7808
#include <cstdio>
#include <cstdint>
#include <vector>
#include <stdexcept>

template <class Weight>
class potentialized_union_find {
  std::vector<intmax_t> tree;
  std::vector<Weight> cost;

public:
  potentialized_union_find(size_t n): tree(n, -1), cost(n) {}

  size_t find(size_t v) {
    if (tree[v] < 0) return v;

    size_t r = find(tree[v]);
    cost[v] += cost[tree[v]];
    return (tree[v] = r);
  }

  bool unite(size_t u, size_t v, Weight w) {
    size_t ru = find(u);
    size_t rv = find(v);
    if (ru == rv) {
      if (cost[u]-cost[v] != w) throw std::logic_error("inconsistent potentials");
      return false;
    }

    w -= cost[u]-cost[v];
    if (-tree[ru] >= -tree[rv]) {
      std::swap(ru, rv);
      std::swap(u, v);
      w = -w;
    }
    tree[rv] += tree[ru];
    tree[ru] = rv;
    cost[ru] = w;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  Weight potential(size_t u, size_t v) {
    if (!connected(u, v)) throw std::logic_error("an indefinite potential");
    return cost[u]-cost[v];
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t n, q;
  scanf("%zu %zu", &n, &q);

  potentialized_union_find<intmax_t> uf(n);
  for (size_t i = 0; i < q; ++i) {
    int t;
    scanf("%d", &t);

    if (t == 0) {
      // relate(x, y, z)
      size_t x, y;
      intmax_t z;
      scanf("%zu %zu %jd", &x, &y, &z);
      uf.unite(x, y, z);
    } else if (t == 1) {
      // diff(x, y);
      size_t x, y;
      scanf("%zu %zu", &x, &y);
      try {
        printf("%jd\n", uf.potential(x, y));
      } catch (std::logic_error) {
        puts("?");
      }
    }
  }
}



Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main() {
    int N, X, a;
    vector<int>x;
    int pre, ans;
    cin >> N >> X;

    for (int i = 0; i < N; i++) {
        cin >> a;
        x.push_back(a);
    }
    
    x.push_back(X);

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

    //pre = gcd(x[0]-x[1], x[2]-x[1]);
    pre = x[0] - x[1];

    for (int i = 0; i < N; i++) {
        ans = gcd(pre, x[i]-x[i+1]);
        pre = ans;
    }
    cout << ans << endl; 
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int H;
   cin >> H;
   int ans = 0;
   int c = 0;
   while(H){
      ans += (1ll<<c);
      // cout << ans << '\n';
      c++;
      H /= 2;
   }
   cout << ans << '\n';
   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 REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, x; cin >> N >> x;
    vl a(N); REP(i, N) cin >> a[i];
    ll ans = 0;
    REP(i, N-1)
    {
        if(a[i] + a[i+1] > x)
        {
            ans += max(a[i]+a[i+1]-x, 0LL);
            a[i+1] = max(a[i+1]-(a[i]+a[i+1]-x), 0LL);
            a[i] = max(a[i]-(a[i]+a[i+1]-x), 0LL);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4000
n,k,*v=map(int,open(0).read().split())
m=0
r=range
for i in r(n+1):
 for j in r(min(k,n)-i+1):
  t=sorted(v[:i]+v[-j:]*(j>0))[::-1];c=k-i-j
  while t and c*t[-1]<0:t.pop();c-=1
  m=max(m,sum(t))
print(m)

Measured memory_bytes: 3060
#include<iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

struct coin{
	double money;
	string jb;
};

int main()
{
	int n;
	double h;
	cin >> n;
	coin a[n+1];
	
	for(int i=1; i<=n; i++)
	{
		cin >> a[i].money >> a[i].jb;
		if(a[i].jb=="BTC")
			a[i].money=a[i].money*380000;
		h+=a[i].money;
	}
	cout << h << endl;
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
using namespace std;
long long f(long long a,long long b){
	int c=0,d=0;
	for(long long i=a;i>0;i/=10)c++;
	for(long long i=b;i>0;i/=10)d++;
	return max(c,d);
}
int main(){
    long long n;
    cin>>n;
    long long ans=100000000;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0)ans=min(ans,f(i,n/i));
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

  int x; cin>>x;
  int nh = x / 100;
  int mh = x % 100;
  int nf = mh / 5 + (mh%5 > 0 ? 1 : 0);
  if (nf <= nh) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h, w;
    cin >> h >> w;

    vector<vector<char>> colors(w, vector<char>(h));
    for (auto i : irange(0L, h)) {
        string s;
        cin >> s;
        for (auto j : irange(0L, w)) {
            colors[j][i] = s[j];
        }
    }

    int64_t ans = 0;
    for (auto i : irange(0L, w - 1)) {
        vector<vector<int64_t>> dp(h + 1, vector<int64_t>(h + 1)),
                dp2(h + 1, vector<int64_t>(h + 1));

        for (auto j : irange(1L, h + 1)) {
            for (auto k : irange(1L, h + 1)) {
                dp[j][k] = dp[j - 1][k - 1] +
                           (colors[i][j - 1] == colors[i + 1][k - 1]);
                dp2[j][k] = dp[j][k] + min(dp2[j - 1][k], dp2[j][k - 1]);
            }
        }

        ans += dp2[h][h];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1840
#include <stdio.h>
int main(void){
    
int H,W;

while(1){
    scanf("%d %d" ,&H,&W);
    if(H==0&&W==0){
        break;
    }
    int i,j;
    for( i = 1; i <= H ; i++){
    for( j = 1; j <= W ; j++){
        if(i==1  || i==H)
       putchar('#');
       else if(j==1 || j==W)
        putchar('#');
        else
        putchar('.');
    }
    putchar('\n');
    }
    putchar('\n');
    }
 return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>

int main(void){
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(n == 4*i+7*j){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}


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


int main()
{
	string s;
	cin>>s;
	//vector<int>  v;
	map<string,int> day;
	day["SUN"]=7;
	day["MON"]=6;
	day["TUE"]=5;
	day["WED"]=4;
	day["THU"]=3;
	day["FRI"]=2;
	day["SAT"]=1;
	cout<<day[s]<<endl;
	return 0;
}


Measured memory_bytes: 256