akhauriyash/Code-Regression huggingface dataset:
// ------------------------------------
// Date:2018/ 3/17
// Problem:sand glass 2 a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

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

  CIN(X, t);
  int ans = X - t;
  if (ans < 0) ans = 0;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
H = inputlist()
graph = [[] for _ in range(N)]

for i in range(M):
    A,B = inputlist()
    A -=1
    B -=1
    graph[A].append(B)
    graph[B].append(A)
ans = 0
for i in range(N):
    h = H[i]
    k = 0
    for j in graph[i]:
        k = max(k,H[j])
    if h > k:
        ans +=1
print(ans)


Measured memory_bytes: 29576
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,small=0;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,now=0;
    //vector <int> v;
    //float f,g,h;
    //char now,pre;
    //string a;
    cin>>n>>k;
    int a[ten5];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    small=a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]==small) continue;
        else
        {
            now++;
            if(now==k-1)
            {
                sum++;
                now=0;
            }
        }
    }
    if(now!=0) sum++;
    cout<<sum;
    return 0;
}





Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

int main(){
    stack<int> s;
    int a, b;
    string com;
    
    while(cin >> com){
        if(com[0] == '+'){
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            s.push(a+b);
        } else if (com[0] == '-'){
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            s.push(a-b);
        } else if (com[0] == '*'){
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            s.push(a*b);
        } else {
            s.push(stoi(com));
        }
    }
    
    cout << s.top() << endl;
    return 0;
}


Measured memory_bytes: 3180
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Main me = new Main();
		long a,b,gcd;
		while(in.hasNext()){
			a = in.nextInt();
			b = in.nextInt();
			gcd = me.GCD(a,b);
			System.out.printf("%d %d\n",gcd,a*b/gcd);
			
		}
	}
	private long GCD(long a,long b){
		if(b == 0)
			return a;
		else
			return GCD(b,a%b);
	}
}

Measured memory_bytes: 18132
#include<bits/stdc++.h>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;


void solve() {
	ll n; 
	cin >> n;
	string ans = "";
	char ch = 'a' - 1;
	while(n > 0) {
		ll x = n % 26;
		n /= 26;
		if(x == 0) {
			ans += 'z';
			n -= 1;
			continue;
			}
		else  
		ans += (ch + x);
		}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
		solve();
	return 0;
}
 
 
 
 
 
 


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define V 10003
#define E 30003
int v;
vector<int> g[V];
vector<int> rg[V];
vector<int> ord;

bool used[V];
int group[V];
void dfs(int s) {
  used[s] = true;
  rep(i, g[s].size()) {
    int t = g[s][i];
    if(!used[t]) {
      dfs(t);
    }
  }
  ord.push_back(s);
}

void rdfs(int s, int col) {
  group[s] = col;
  used[s] = true;
  rep(i, rg[s].size()) {
    int t = rg[s][i];
    if(!used[t]) {
      rdfs(t, col);
    }
  }
}

int strongly_connected_components() {
  rep(i, v) used[i] = false;
  rep(i, v) {
    if(!used[i]) dfs(i);
  }
  rep(i, v) used[i] = false;
  assert(ord.size() == v);
  int cnt = 0;
  repr(i, v) {
    int s = ord[i];
    if(!used[s]) rdfs(s, cnt++);
  }
  return cnt;
}

int main() {
  int e;
  cin >> v >> e;
  rep(i, e) {
    int s, t;
    cin >> s >> t;
    g[s].push_back(t);
    rg[t].push_back(s);
  }
  strongly_connected_components();
  int q;
  cin >> q;
  rep(_, q) {
    int u, v;
    cin >> u >> v;
    cout << (group[u] == group[v] ? 1 : 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 2780
#include<iostream>
using namespace std;
void fibo(int n);
int main() {
    int n;
    cin >> n;
    fibo(n);
    return 0;
}
void fibo(int n) {
    if (n == 0) cout << "1" << endl;
    else if (n == 1) cout << "1" << endl;
    else if (n == 2) cout << "2" << endl;
    int cnt;
    int f1 = 1, f2 = 1, f3;
    f3 = f1 + f2;
    cnt = 2;
    while (cnt <= n) {
        f1 = f2 + f3;
        cnt++;
        if (cnt == n) cout << f1 << endl;
        f2 = f3 + f1;
        cnt++;
        if (cnt == n) cout << f2 << endl;
        f3 = f1 + f2;
        cnt++;
        if (cnt == n) cout << f3 << endl;
    }
    
    
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int n;
    cin >> n;
    ll path[n][n];
    ll road[n][n];
    Rep(i,n){
        Rep(j,n){
            cin >> path[i][j];
            road[i][j] = path[i][j];
        }
    }
    Rep(i,n){
        Rep(j,n){
            Rep(k,n){
                if(path[i][j] > (path[i][k] + path[k][j])){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    Rep(i,n){
        Rep(j,n){
            Rep(k,n){
                if(i == k || j == k);
                else if(path[i][j] == (path[i][k] + path[k][j])){
                    //cout << i << sp << j << sp << k << endl;
                    road[i][j] = 0;
                }
            }
        }
    }
    ll ans = 0;
    Rep(i,n){
        Rep(j,n){
            ans += road[i][j];
        }
    }
    cout << ans/2 << endl;
    //cin >> n;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
#define N 101
struct edge{
	int to,cost;
};
int par[N];
int a,n,ans=0;
priority_queue< pair<int,pair<int,int> > > Q;

void init(int n){
	FOR(i,1,n+1)par[i]=i;
}

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

void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	init(n);
	FOR(i,1,n+1){
		FOR(j,1,n+1){
			cin>>a;
			if(a==(-1))a=2001;
			Q.push(make_pair(-a,make_pair(i,j)));
		}
	}
	while(Q.size()){
		pair<int,int> e;
		int cost,x,y;
		pair<int,pair<int,int> > q;
		q=Q.top();
		e=q.second;
		cost=-q.first;
		x=e.first;
		y=e.second;
		Q.pop();
		if(root(x)==root(y))continue;
		unite(x,y);
		ans+=cost;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3224
#!/usr/bin/env python3
# DSL_2_D: Range Update Query


class SegmentTree:
    INITIAL_VALUE = 2**31 - 1
    DIVIDED = -1

    def __init__(self, n):
        size = 1
        while size < n:
            size *= 2
        self.size = 2*size - 1
        self.data = [-1] * self.size
        self.data[0] = self.INITIAL_VALUE

    def set_range(self, lo, hi, v):
        def _set_range(r, i, j, vv):
            if j < lo or i > hi:
                if vv != self.DIVIDED:
                    self.data[r] = vv
            elif lo <= i and j <= hi:
                self.data[r] = v
            else:
                if self.data[r] != self.DIVIDED:
                    if vv == self.DIVIDED:
                        vv = self.data[r]
                    self.data[r] = self.DIVIDED
                mid = i + (j - i)//2
                _set_range(r*2 + 1, i, mid, vv)
                _set_range(r*2 + 2, mid+1, j, vv)

        _set_range(0, 0, self.size//2, self.DIVIDED)

    def get(self, i):
        def _get(r, lo, hi):
            if self.data[r] != self.DIVIDED:
                return self.data[r]
            mid = lo + (hi - lo)//2
            if i <= mid:
                return _get(r*2 + 1, lo, mid)
            else:
                return _get(r*2 + 2, mid+1, hi)

        return _get(0, 0, self.size//2)


def run():
    n, q = [int(x) for x in input().split()]
    t = SegmentTree(n)

    for _ in range(q):
        com, *args = [x for x in input().split()]
        if com == '0':
            i, j, v = [int(x) for x in args]
            t.set_range(i, j, v)
        elif com == '1':
            i = int(args[0])
            print(t.get(i))


if __name__ == '__main__':
    run()



Measured memory_bytes: 8700
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
using namespace std;
const int mo=998244353;
const int N=500005;
int fac[N],inv[N];
int n,m,ans;
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int C(int x,int y){
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	scanf("%d%d",&n,&m);
	if (n>m) swap(n,m);
	fac[0]=inv[0]=inv[1]=1;
	For(i,2,m) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,m) inv[i]=1ll*inv[i-1]*inv[i]%mo;
	For(i,1,m) fac[i]=1ll*fac[i-1]*i%mo;
	For(i,0,min(n,m))
		ans=(ans+1ll*(i&1?mo-1:1)*C(n,i)%mo*C(m,i)%mo*fac[i]%mo*power(m+1,n-i)%mo*power(n+1,m-i))%mo;
	printf("%d\n",ans);
}

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

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

int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

const ll INF = 1LL << 60;

int main() {
  int N; cin >> N;
  ll h[100010]; REP(i, N) cin >> h[i];
  ll dp[100010]; REP(i, N) dp[i] = INF; // カエルが足場iへ移動するコスト
  dp[0] = 0;
  for(int i=0; i<N; i++){
    chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
    if(i>1) {
      chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdio> 
using namespace std;


int main()
{
	string s1,s2;
	cin>>s1>>s2;
	if(s1.size()==s2.size())
	{
		for(int i=0;i<s1.size();i++)
		{
			cout<<s1[i]<<s2[i];	
		}
		cout<<endl;
	}
	else
	{
		for(int i=0;i<s2.size();i++)
		{
			cout<<s1[i]<<s2[i];	
		}
		cout<<s1[s1.size()-1];
		cout<<endl;
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
ll pw(ll n, ll m){
	ll res = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * n % mod;
		n = n * n % mod;
	}
	return res;
}
ll inv(ll n){
	return pw(n, mod - 2);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, k; cin >> n >> k;
	set<int> d;
	for(int i = 1; i * i <= n; i++) if(n % i == 0){
		d.insert(i);
		d.insert(n / i);
	}
	ll ans = 0;
	map<int, int> cnt;
	for(int i : d){
		if(i % 2) cnt[i] = pw(k, i / 2 + 1);
		else cnt[i] = pw(k, i / 2);
	}
	
	for(auto &i: cnt){
		for(auto j : cnt){
			if(i.first <= j.first) break;
			if(i.first % j.first == 0) i.second = (i.second + mod - j.second) % mod;
		}
		ll x = i.second * (ll)i.first % mod;
		ans += i.first % 2 ? x : x * inv(2) % mod;
	}
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    vector<ll> pre(n+1, 0);
    for(int i = 0; i < n; i++)
        pre[i+1] = pre[i] + arr[i];
    vector<vector<ll>> dp(n, vector<ll>(n, ll(INT_MAX)*ll(1000000)));
    for(int i = 0; i < n; i++)
        dp[i][i] = 0;
    for(int len = 2; len <= n; len++) {
        for(int i = 0; i <= n-len; i++) {
            int j = i+len-1;
            ll cost = pre[j+1] - pre[i];
            for(int k = i; k < j; k++) {
                // merge dp[i..k][k+1..j]
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]+cost);
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}




Measured memory_bytes: 1536
#include<stdio.h>

int main(void){
  int W,H,x,y;
  scanf("%d%d%d%d",&W,&H,&x,&y);
  
  double s;
  s=(double)W*H/2;
  printf("%lf ",s);
  
  if(W==x*2&&H==y*2){
    printf("1");
  }
  else{
    printf("0");
  }
  
  return 0;
}


Measured memory_bytes: 128
i, j = map(int,input().split())
a = []
b = []
result = 0
for _ in range(i):
    a.append([row for row in map(int, input().split())])
for _ in range(j):
    b.append(int(input()))
for row in range(i):
    for col in range(j):
        result += a[row][col] * b[col]
    print(result)
    result = 0


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define stp setprecision(20)
#define endl '\n'
int main()
{  
    fastio;
    /*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
    //*/
    ll n,k;cin>>n>>k;
    vll a;
    bool zp=0;
    for(ll i=0;i<n;i++)
    {
    	ll x;
    	cin>>x;
    	a.pb(x);
    	if(a[i]==0)
    	{
    		zp=1;
    		k--;
    	}
    }
    if(!zp)
    	a.pb(0);
    sort(a.begin(), a.end());
    ll z=0;
    for(ll i=0;i<a.size();i++)
    	if(a[i]==0)
    	{
    		z=i;break;
    	}
    vll l,r;
    l.pb(0);
    r.pb(0);
    ll cnt=0;
    for(ll i=z-1;i>=0;i--)
    {
    	l.pb(abs(a[i]));
    	cnt++;
    }
    cnt=0;
    for(ll i=z+1;i<a.size();i++)
    {
    	r.pb(abs(a[i]));
    	cnt++;
    }
    ll ans=inf;
    for(ll i=0;i<=k;i++)
    {
    	ll lx=l.size();
    	ll rx=r.size();
    	ll le=min(i,lx-1);
    	ll ri=min(k-i,rx-1);
    	if(le+ri!=k)
    		continue;
    	ans=min(ans,l[le]+r[ri]+min(l[le],r[ri]));
    	//cout<<i<<" "<<l[le]+r[ri]+min(l[le],r[ri])<<endl;
    }
    cout<<ans;
} 



Measured memory_bytes: 2804
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    string s, t; cin >> s >> t;
    vector<string>cand;
    REP(i, s.length() - t.length() + 1) {
        bool foo = true;
        for (ll di = 0; di < t.length(); ++di) {
            foo &= s[i + di] == '?' || s[i + di] == t[di];
        }
        if (foo) {
            string sc = s;
            REP(di, t.length())sc[i + di] = t[di];
            replace(ALL(sc), '?', 'a');
            cand.push_back(sc);
        }
    }
    if (cand.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(ALL(cand));
        cout << cand[0] << endl;
    }
}

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int w, h;
int a[50][50];
bool b[2][50][50];

void f(int c, int i, int j) {
	b[c][i][j] = true;
	for (int k = 0; k < 4; k++) {
		if (i + dy[k] >= 0 && i + dy[k] < h && j + dx[k] >= 0 && j + dx[k] < w) {
			if (a[i + dy[k]][j + dx[k]] == -1 && !b[c][i + dy[k]][j + dx[k]]) {
				f(c, i + dy[k], j + dx[k]);
			}
		}
	}
}

int main() {
	while (cin >> w >> h, w) {
		for (int i = 0; i < h; i++) {
			string s;
			cin >> s;
			for (int j = 0; j < w; j++) {
				if (s[j] == 'B') {
					a[i][j] = 0;
				} else if (s[j] == 'W') {
					a[i][j] = 1;
				} else {
					a[i][j] = -1;
				}
			}
		}
		for (int c = 0; c < 2; c++) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					b[c][i][j] = false;
				}
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] != -1) {
					f(a[i][j], i, j);
				}
			}
		}
		int p = 0, q = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] == -1) {
					if (b[0][i][j] && !b[1][i][j]) {
						p++;
					} else if (!b[0][i][j] && b[1][i][j]) {
						q++;
					}
				}
			}
		}
		cout << p << ' ' << q << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

bool check(ll n)
{
    ll ld = n%10; n = n/10;
    while(n>0)
    {
        if(abs(ld-n%10)>1) return false;
        ld = n%10; n /= 10;
    }
    return true;
}

int main()
{
fast;
ll q=1,t;
//cin >> q;
ll i ,j;
while(q--)
{
    ll n,m,k,l,r,a,b,c=0,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> k;
    queue<ll> Q;
    for(i=1;i<=9;i++) Q.push(i);
    while(k>0)
    {
        ll x = Q.front();Q.pop();
        k--;
        if(k==0){ cout << x; return 0;}
        d = x%10;
        if(d==0) {Q.push(x*10+0); Q.push(x*10+1);}
        else if(d==9) {Q.push(x*10+8); Q.push(x*10+9);}
        else {Q.push(x*10+d-1); Q.push(x*10+d);Q.push(x*10+d+1);}
    }


}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%tmod;}
    else{return (b*((temp*temp)%tmod))%tmod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


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

int main() {
  int N, F;
  cin >> N;
  F = 0;

  for (int i = 0; i < N; i++){
    string C;
    cin >> C;
    
    if (C == "Y"){
      F = 1;
      break;
    }
  }
  if(F){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}


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

C,S,F=[],[],[]
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)


for i in range(N-1):
    ct=0
    for j in range(i,N-1):
        if ct<=S[j]:
            ct=S[j]
        else:
            if ct%F[j]!=0:
                ct+=F[j]-(ct%F[j])
        ct+=C[j]
    print(ct)
print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
};


template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n==0) {return 1;}
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return (halfpower*halfpower) % modd;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (((halfpower*halfpower)%modd)*a)%modd;
      }
  }
};


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        map<string,int> freq;
        vector<string> names{"AC", "WA", "TLE", "RE"};
        forr(i,0,n) {
            readstring(s);
            freq[s]++;
        }

        for(auto x : names) {
            cout << x << " x " << freq[x] << endl;
        }
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int g[50][50];
bool visited[50];
void bfs(int idx,int N){
    visited[idx]=true;
    REP(i, N){
        if(idx!=i && !visited[i] && g[idx][i]==1){
            bfs(i, N);
        }
    }
    return;
}

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    REP(i,N)REP(j,N)g[i][j]=0;
    REP(i,M)g[a[i]-1][b[i]-1] = g[b[i]-1][a[i]-1] = 1;
    int cnt=0;
    REP(i, M){
        int A, B;
        A = a[i]-1; B = b[i]-1;
        g[A][B] = 0; g[B][A] = 0;
        REP(j,N)visited[j]=false;
        bfs(0,N);
        REP(j, N){
            if(!visited[j]){
                debug(A);debug(B);
                cnt++;break;
            }
        }
        g[A][B] = 1; g[B][A] = 1;
    }
    cout<<cnt<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        n: usize,
        sum: usize,
    }
    for i in 0..n+2 {
        for j in i+1..n+2 {
            // println!("{},{}", i, j);
            let x = i;
            let y = j - i - 1;
            let z = n+1-j;
            if sum == 10000 * x + 5000 * y + 1000 * z {
                println!("{} {} {}", x, y, z);
                return;
            }
        }
    }
    println!("{} {} {}", -1, -1, -1);
}


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

int main() {
  string A;
  cin >> A;
  bool N=false,E=false,W=false,S=false;
  for(int i=0;i<A.size();i++){
    if(A.at(i)=='N'){
      N=true;
    }
    else if(A.at(i)=='E'){
      E=true;
    }
    else if(A.at(i)=='W'){
      W=true;
    }
    else{
      S=true;
    }
  }
  if((N && E && W && S) || (!N && E && W && !S) || (N && !E && !W && S)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    
    
  


Measured memory_bytes: 3628
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let C1 = read::<String>();
    let C1 = C1.chars().collect::<Vec<char>>();
    let C2 = read::<String>();
    let C2 = C2.chars().collect::<Vec<char>>();
    let C3 = read::<String>();
    let C3 = C3.chars().collect::<Vec<char>>();

    println!("{}{}{}", C1[0], C2[1], C3[2]);

}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void)
{
    int a,b,c,i,count=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(a>0&&a<=10000&&b>0&&b<=10000&&c>0&&c<=10000)
        {
            if(a<=b)
            {
                if(c%i==0)
                {
                    count++;
                }
            }
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VP A, B;
	VS S(N);
	int sum = 0;
	REP(i, N) {
		cin >> S[i];
		string s = S[i];
		int cnt = 0;
		int mi = 0;
		REP(j, s.size()) {
			if (s[j] == '(')cnt++;
			else cnt--;
			chmin(mi, cnt);
		}
		sum += cnt;
		if (cnt <= 0)B.push_back(pii(mi - cnt, -cnt));
		else A.push_back(pii(mi, cnt));
	}
	int now = 0;
	rSORT(A);
	rSORT(B);
	REP(i, A.size()) {
		int a = A[i].first, b = A[i].second;
		if (now + a < 0) {
			cout << "No" << endl;
			return 0;
		}
		now += b;
	}
	int nnow = 0;
	REP(i, B.size()) {
		int a = B[i].first, b = B[i].second;
		if (nnow + a < 0) {
			cout << "No" << endl;
			return 0;
		}
		nnow += b;
	}
	//cout << now << " " << nnow << endl;
	if (now == nnow)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 50316
a,b = map(int,input().split())
print("40 100")

kuro = [["#" for i in range(100)] for j in range(20)]
siro = [["." for i in range(100)] for j in range(20)]

cou = 0
flag = False
for i in range(0,20,2):
    if flag:
        break
    for j in range(0,100,2):
        if cou >= a-1:
            flag = True
            break
        elif cou < a-1:
            cou += 1
            kuro[i][j] = "."

cou = 0
flag = False
for i in range(1,20,2):
    if flag:
        break
    for j in range(0,100,2):
        if cou >= b-1:
            flag = True
            break
        elif cou < b-1:
            cou += 1
            siro[i][j] = "#"

for i in range(20):
    for j in range(100):
        print(kuro[i][j],end="")
    print()
for i in range(20):
    for j in range(100):
        print(siro[i][j],end="")
    print()

Measured memory_bytes: 74736
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/ICPC/Prelim/1624?year=2018

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;

    while (cin >> n, n) {
        vector<int> a(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            int t;
            cin >> t;
            sum += t;
            a[i] = t * n;
        }
        sort(a.begin(), a.end());

        cout << upper_bound(a.begin(), a.end(), sum) - a.begin() << endl;
    }

    return 0;
}

/*
 * 除算による誤差が怖いので，a[i]<=S/nのかわりに
 * n*a[i]<=Sを調べた。
 * 
 */


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

const int N = 50 + 5;
int n,a, x[N];
ll dp[N][N*50];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>a;
    for (int i = 0; i < n; i++)cin>>x[i];
    
    dp[0][0] = 1;
    for (int  i = 0; i < n; i++){
        int temp = x[i];
        for (int j = i; j >= 0; j--){
            for (int k = 0; k <= j*50; k++){
                dp[j+1][k+temp] += dp[j][k];
            }
        }
    }
    
    ll ans = 0;
    for (int i = 1; i <= n; i++){
        ans += dp[i][i*a];
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 896
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main(){
	long long S;
	scanf("%lld",&S);
	long long x=(long long)(sqrtl(S));
	long long x_1=x;
	long long y_2=x;
	while (x_1*y_2<S){
		  if (x_1<y_2){
			 x_1++;
		  }
		  else{
			   y_2++;
		  }
	}
	long long y_1=1,x_2=x_1*y_2-S;
	printf("0 0 %lld %lld %lld %lld",x_1,y_1,x_2,y_2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int n, a, b, c = 0, c2 = 0;
	string s;
	cin >> n >> a >> b >> s;
	for (auto i : s) {
		switch (i) {
		case 'a':
			if (c < a + b) {
				cout << "Yes" << endl;
				c++;
			}
			else {
				cout << "No" << endl;
			}
			break;
		case 'b':
			if (c < a + b && c2 < b) {
				cout << "Yes" << endl;
				c++;
				c2++;
			}
			else {
				cout << "No" << endl;
			}
			break;
		default:
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;


int32_t main() {
    input;
    int n, x;
    cin >> x >> n;
    set<int> s;
    int a[20000];
    for(int i = 0; i <= 2000; i++) {
        a[i] = 1;
    }
    for(int i = 0; i < n; i++) {
        int k;
        cin >> k;
        a[k] = 0;
    }
    int ans = 0, cnt = 0, cnt2 = 0;
    for(int i = x; i <= 2000; i++) {
        cnt++;
        if(a[i] == 1) {
            ans = i;
            break;
        }
    }
    for(int i = x; i >= 0; i--) {
        cnt2++;
        if(a[i] == 1 and cnt2 <= cnt) {
            ans = i;
            break;
        }
    }
    cout << ans;

}

Measured memory_bytes: 3688
#!/usr/bin/env python

Num =list(input())
ope = ["+", "-"]

for i in range(8):
    key = list(str(("{0:03b}".format(i,'b'))))
    formula = Num[0] + ope[int(key[0])] + Num[1] + ope[int(key[1])] + Num[2] + ope[int(key[2])] + Num[3]
    result = eval(formula)
    if(result == 7):
        print("".join([formula,"=7"]))
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define maxn 800010
#define ll long long
const double pi=acos(-1);
typedef complex<double> cp;
int n,rev[maxn];
cp omega[maxn],iomega[maxn];
void init(int n)
{
        for(int i=0;i<n;i++)
        {
                omega[i]=cp(cos(2*pi/n*i),sin(2*pi/n*i));
                iomega[i]=conj(omega[i]);
        }
        int k=log2(n);
        for(int i=0;i<n;i++)
        {
                int t=0;
                for(int j=0;j<k;j++)if(i&(1<<j))t|=(1<<(k-j-1));
                rev[i]=t;
        }
}
void transform(vector<cp>& a,cp* omega,int n)
{
        for(int i=0;i<n;i++)if(i<rev[i])swap(a[i],a[rev[i]]);
        for(int len=2;len<=n;len<<=1)
        {
                int mid=len>>1;
                for(int j=0;j<n;j+=len)for(int i=0;i<mid;i++)
                {
                        cp t=omega[n/len*i]*a[j+mid+i];
                        a[j+mid+i]=a[j+i]-t;
                        a[j+i]+=t;
                }
        }
}
void fft(vector<cp>& a,int n)
{
        transform(a,omega,n);
}
void ifft(vector<cp>& a,int n)
{
        transform(a,iomega,n);
        for(int i=0;i<n;i++)a[i]/=n;
}
vector<ll> mul(vector<ll> a,vector<ll> b)
{
        int n=1;
        int n1=(int)a.size(),n2=(int)b.size();
        while(n<n1+n2)n<<=1;
        vector<cp> tmp_a(n),tmp_b(n);
        for(int i=0;i<n1;i++)tmp_a[i]=cp(a[i],0);
        for(int i=0;i<n2;i++)tmp_b[i]=cp(b[i],0);
        init(n);
        fft(tmp_a,n),fft(tmp_b,n);
        for(int i=0;i<n;i++)tmp_a[i]*=tmp_b[i];
        ifft(tmp_a,n);
        vector<ll> ans(n);
        for(int i=0;i<n;i++)ans[i]=round(tmp_a[i].real());
        while((int)ans.size()>1 && ans.back()==0)ans.pop_back();
        return ans;
}
vector<ll> a,b;
vector<ll> s;
vector<int> ans;
char c[maxn];
int main()
{
        bool flag=0;
        scanf("%s",c);
        int n=strlen(c);
        if(c[0]=='-')flag^=1;
        for(int i=0;i<n;i++)
        {
                if(c[i]!='-')a.push_back(c[i]-'0');
        }
        reverse(a.begin(),a.end());
        scanf("%s",c);
        if(c[0]=='-')flag^=1;
        n=strlen(c);
        for(int i=0;i<n;i++)
        {
                if(c[i]!='-')b.push_back(c[i]-'0');
        }
        reverse(b.begin(),b.end());
        s=mul(a,b);
        n=(int)s.size();
        int cur=0;
        for(int i=0;i<n;i++)
        {
                cur=cur/10+s[i];
                ans.push_back(cur%10);
        }
        cur/=10;
        if(cur)ans.push_back(cur);
        reverse(ans.begin(),ans.end());
        if(!flag || ((int)ans.size()==1 && ans[0]==0))
        {
                for(int i=0;i<(int)ans.size();i++)printf("%d",ans[i]);puts("");
        }
        else
        {
                putchar('-');
                for(int i=0;i<(int)ans.size();i++)printf("%d",ans[i]);puts("");
        }
        return 0;
}



Measured memory_bytes: 57460
n = gets.to_i
a = Array.new(n+1)
for i in 1..n
  a[i] = gets.split.map(&:to_i)
end

ids = Array.new(n+1, 0)
days = 0
flag = 0
preid = Array.new(0)
continue = 1
while continue == 1
  flag = 0
  incid = Hash.new(0)
  if days == 0
    for i in 1..n
      if ids[i] <= n-2
        if a[a[i][ids[i]]][ids[a[i][ids[i]]]] == i
          flag = 1
          incid[i] += 1
        end
      end
    end
  else
    preid.each do |id|
      if ids[id] <= n-2
        if a[a[id][ids[id]]][ids[a[id][ids[id]]]] == id
          flag = 1
          incid[id] += 1
          incid[a[id][ids[id]]] += 1
        end
      end
    end
  end   
  days += 1
  preid = []
  if flag == 0
    break
  else
    incid.each do |k,v|
      ids[k] += 1
      preid.push(k)
    end
    for i in 1..n
      if ids[i] <= n-2
        break
      end
      if i == n
        continue = 0
      end
    end
  end
end

if flag == 0
  puts -1
else
  puts days
end

Measured memory_bytes: 68348
A, B = map(int, input().split())
Nmax = int(100//0.08)
ans = -1
for N in range(1, Nmax + 1):
    ja = int(N * 0.08)
    jb = int(N * 0.1)
    if ja == A and jb == B:
        ans = N
        break
    else:
        pass
print(ans)



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

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

int main(){
  int dx[] = {1,1,0,-1,-1,-1,0,1};
  int dy[] = {0,1,1,1,0,-1,-1,-1};
   
  string S[60];
  
  int x, y;
  cin >> x >> y;
  
  rep(i,x) cin >> S[i];
  
  rep(i,x){
    rep(j,y){
      if(S[i][j] =='.'){
        int count = 0;
        rep(k,8){
          int x = i + dx[k];
          int y = j + dy[k];
          if(x >= 0 && y >= 0 && S[x][y] == '#') count ++;
        }
        S[i][j] = '0' + count;
      }
    }
  }
  rep(i,x) cout << S[i] << endl;
}

Measured memory_bytes: 256
/**
 * Problem:	E. 
 * Author:	hkxadpall. 
 * Date:	2018-08-25. 
 * Upload:	AtCoder. 
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue> 
#include <map>
#include <set>
using namespace std;

namespace AuthorName { 
    template <typename _TpInt> inline _TpInt read();
    template <typename _TpRealnumber> inline double readr();
    template <typename _TpInt> inline void write(_TpInt x);
//	template <typename _TpSwap> inline void swap(_TpSwap &x, _TpSwap &y);
	
#	define Max_N 100007
	
	int n, k, a[Max_N];
	
	int main() 
	{
		n = read<int>();
		k = read<int>() - 1;
		for (int i = 1; i <= n; i++)
			a[i] = read<int>();
		int minn = 0x7fffffff;
		for (int i = 1; i <= n - k; i++) {
			if (a[i + k] > 0 && a[i] < 0)
				minn = min(minn, a[i + k] - a[i] + min(-a[i], a[i + k]));
			else if (a[i] < 0)
				minn = min(minn, -a[i]);
			else
				minn = min(minn, a[i + k]);
		}
		write(minn);
	    return 0;
	}

#	define Getchar() getchar()

    template <typename _TpInt>
    inline _TpInt read()       
    {
        register int flag = 1;
        register char c = Getchar();
        while ((c > '9' || c < '0') && c != '-') 
            c = Getchar();
        if (c == '-') flag = -1, c = Getchar();
        register _TpInt init = (c & 15);
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = (init << 3) + (init << 1) + (c & 15);
        return init * flag;
    }

    template <typename _TpRealnumber>
    inline double readr()       
    {
        register int flag = 1;
        register char c = Getchar();
        while ((c > '9' || c < '0') && c != '-') 
            c = Getchar();
        if (c == '-') flag = -1, c = Getchar();
        register _TpRealnumber init = (c & 15);
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = init * 10 + (c & 15);
        if (c != '.') return init * flag;
        register _TpRealnumber l = 0.1;
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = init + (c & 15) * l, l *= 0.1;
        return init * flag;
    }

    template <typename _TpInt>
    inline void write(_TpInt x)
    {
        if (x < 0) {
            putchar('-');
            write<_TpInt>(~x + 1);
        }
        else {
            if (x > 9) write<_TpInt>(x / 10);   
            putchar(x % 10 + '0');
        }
    }

//	template <typename _TpSwap>
//	inline void swap(_TpSwap &x, _TpSwap &y)
//	{
//	    _TpSwap t = x;
//	    x = y;
//	    y = t;
//	}
}

int main()
{
    AuthorName::main();
    return 0;
}

Measured memory_bytes: 640