akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
using namespace std;
typedef long long ll;

class Edge
{
	public:
	ll cost;
	int from;
	int to;

	Edge(int n,ll c)
	{
		to=n;
		cost=c;
	}

	Edge(int f,int t,int c)
	{
		from=f;
		to=t;
		cost=c;
	}
};

vector<Edge> g[2500];
ll dist[2500];
bool negative[2500];//negative loopから
void saiki(int now)
{
	if(!negative[now])
		return;
	for(int i=0;i<g[now].size();i++)
	{
		if(!negative[g[now][i].to])
		{
			negative[g[now][i].to]=true;
			saiki(g[now][i].to);
		}
	}
	return;
}
int main()
{
	int n,m,p;
	cin>>n>>m>>p;
	for(int i=0;i<m;i++)
	{
		int a,b;
		ll c;
		cin>>a>>b>>c;
		c-=p;a--;b--;
		g[a].push_back(Edge(b,-c));
	}
	//ベルマンフォード
	//始点から到達できるnegative loopも検出する
	fill(dist,dist+2500,1e14-1);
	fill(negative,negative+2500,false);
	dist[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<g[j].size();k++)
			{
				Edge e=g[j][k];
				if(dist[j]!=1e14-1 && dist[e.to]>dist[j]+e.cost)
				{
					dist[e.to]=dist[j]+e.cost;
					if(i==n-1)
					{
						negative[j]=true;
						negative[e.to]=true;
					}
				}
			}
		}
	}
	//negative loopのチェック
	for(int i=0;i<n;i++)
		saiki(i);
	if(negative[n-1])
		cout<<-1<<endl;
	else
		cout<<max(-dist[n-1],0LL)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,T;
int dp[2][2501][2501];

int main(){
  fill((int*)dp[0],(int*)dp[2],1e9);
  dp[0][0][0]=0;

  cin>>n;
  for(int k=0;k<n;k++){
    int a=k%2,b=1-a;
    cin>>T;
    fill(dp[b][0],dp[b][2501],1e9);
    for(int i=0;i<=2500;i++){
      for(int j=0;j<=2500;j++){
        if(dp[a][i][j]==1e9)continue;
        dp[b][i+T][j]=min(dp[b][i+T][j],dp[a][i][j]);
        dp[b][i][j+T]=min(dp[b][i][j+T],dp[a][i][j]);
        dp[b][i][j]=min(dp[b][i][j],dp[a][i][j]+T);
      }
    }
  }
  int ans=1e9;
  for(int i=0;i<=2500;i++){
    for(int j=0;j<=2500;j++){
      ans=min(ans, max(i,max(j,dp[n%2][i][j])) );
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 50032
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
                    
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            
            int answer = 0;
            
            if(op.equals("?")){
                break;
            }
            
            switch(op){
                case "+":
                    answer = a+b;
                    break;
                case "-":
                    answer = a-b;
                    break;
                case "*":
                    answer = a*b;
                    break;
                case "/":
                    answer = a/b;
                    break;
            }
            
            System.out.println(answer);
        }
    }
}


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

using namespace std;

int A[200002],B[200002];

int main(){
    int t=1;
//    cin >> t;
    while (t--) {
        int n, m ,ms;
        scanf("%d%d%d", &n, &m, &ms);
 
        for(int A_i = 0; A_i < n; A_i++){
            scanf("%d",&A[A_i]);
        }
        for(int B_i = 0; B_i < m; B_i++){
           scanf("%d",&B[B_i]);
        }

        long long sum = 0;
        int x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        int ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans <= x + y) {
                ans = x + y;
            }
        }

        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 5364
N = int(input())
*A, = [int(input()) for _ in [0]*N]

B = []
i = 0
for j,a in enumerate(A):
    if a == 0:
        B.append(A[i:j])
        i = j+1
else:
    B.append(A[i:])

def f(C):
    L = len(C)
    if L==0:return 0
    elif L==1:return C[0]//2
    ret = [0]*2
    for i in (0,1):
        c0 = i
        ret[i]+= (C[0]-c0)//2+c0
        for c in C[1:-1]:
            ret[i] += (c-c0)//2
            c0 = (c-c0)%2
            ret[i] += c0
        ret[i] += (C[-1]-c0)//2
    return max(ret)

ans = sum(map(f,B))
print(ans)

Measured memory_bytes: 10884
import bisect

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

    count = 0
    for target in target_list:
        target_idx = bisect.bisect_left(num_list, target)
        if(num_list[target_idx] == target):
            count += 1
    print(count)



Measured memory_bytes: 16736
/*************************************************************************
    > File Name: B.cpp
    > Author: Akira
    > Mail: qaq.febr2.qaq@gmail.com
    > Created Time: 2017年03月18日 星期六 20时30分11秒
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
#include<vector>
#include<set>
#include<list>
#include<ctime>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))

using namespace std;

#define MaxN 5005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1e9+7;
const int eps = 1e-8;
#define bug cout << 88888888 << endl;
int N;
LL K;
LL node[MaxN];
int main()
{
    while(~scanf("%d%lld", &N, &K))
    {
        LL sum = 0;
        for(int i=1;i<=N;i++)
        {
            scanf("%lld", node+i);
        }
        sort(node+1, node+1+N);
        for(int i=1;i<=N;i++)
        {
            if(sum<K)
            {
                sum += node[i];
            }
            else break;
        }
        if(sum<K) 
        {
            printf("%d\n", N);
            continue;
        }
        LL* it = (upper_bound(node+1,node+1+N, K));
        it -=1;
        int ans = 0;

        for(int i=1;i<=N;i++)
        {
            if(sum>=K)
            {
                sum -= node[i];
            }
            
            if(sum<K)
            {
                ans = i-1;
                break;
            }
        }
        LL* low = it;
        LL* high = it;
        int lim = ans;
        while( low!= node+lim )
        {
            int cnt = 0;
            for(LL* i = low;i<=high;i++)
            {
                cnt += *i;
            }
            while(cnt>=K)
            {
                cnt -= *high;
                high--;
            }
            //cout << cnt << endl;
            int i = ans;
            while(i>0)
            {
                int tmp = cnt+node[i];
                if(tmp>=K) ans--,i--;
                else
                {
                    int j = i-1;
                    for(j;j>0;j--)
                    {
                        tmp += node[j];
                        if(tmp>=K)
                        {
                            ans -= (i-j+1);
                            break;
                        }
                    }
                    i = j;
                }
            }
            if(ans==0) break;
            low--;
        }
        printf("%d\n", ans);

    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n,r;
    cin >> n >> r;
    if (n>=10) {
        cout << r << "\n";
    } else {
        r -=-100*(10-n);
        cout << r << "\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const int N = 1e6+5;
template <class T> inline void read(T &n) {
    n=0;register char ch;while(!isdigit(ch=getchar()));
    for(n=ch^48;isdigit(ch=getchar());n=(n<<3)+(n<<1)+(ch^48));
}

ll n,k,l,r,res,d,p,a[N],f[N],c[N];
int main() {
	read(n);read(k);
	f(i,1,n) read(a[i]);
	f(i,1,n) read(f[i]);
	sort(a+1,a+n+1);
	sort(f+1,f+n+1);
	f(i,1,n) {
		c[i] = a[i] * f[n-i+1];
		r = max(r, c[i]);
	}
	while(l<r) {
		d = (l+r)>>1; res = 0;
		f(i,1,n) if(c[i]>d)res+=(c[i]-d-1)/f[n-i+1]+1;
		if(res<=k)r=d;else l=d+1;
	}
	cout<<l;
    return 0;
}

Measured memory_bytes: 9984
#coding : utf-8　

import os
import sys

n = int(input())

p = list(map(lambda x: int(x), input().split(" ")))

cnt = 0

for i in range(1, n-1):
	if p[i-1] < p[i] and p[i] < p[i+1]:
		cnt += 1

	if p[i-1] > p[i] and p[i] > p[i+1]:
		cnt += 1

print(cnt)



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

int main() {
    int N;
    cin >> N;
    int maxPosition = 0, minPosition = 1000;
    vector<int> X;
    for (int i = 1; i <= N; ++i) {
        int buf;
        cin >> buf;
        maxPosition = max(maxPosition, buf);
        minPosition = min(minPosition, buf);
        X.emplace_back(buf);
    }
    int ans = 10000000;
    for (int p = minPosition; p <= maxPosition; ++p) {
        int buf = 0;
        for (int i = 0; i < N; ++i) {
            buf += pow(X[i] - p, 2);
        }
        ans = min(ans, buf);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=input()
if(N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9"):
    print("hon")
elif(N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8"):
    print("pon")
elif(N[-1]=="3"):
    print("bon")


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


int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }
    
    vector<ll> high(N,0), low(N, 0);
    vector<ll> A(M), B(M);
    for (ll i = 0; i < M; i++)
    {
        cin >> A.at(i) >> B.at(i);


        if (H.at(A.at(i) - 1) == H.at(B.at(i) - 1))
        {
            low.at(A.at(i) - 1)++;
            low.at(B.at(i) - 1)++;
            high[B[i]-1]=0;
            high[A[i]-1]=0;
        } else if (H.at(A.at(i) - 1) > H.at(B.at(i) - 1))
        {
            if (low.at(A.at(i) - 1) == 0)
            {
                high.at(A.at(i) - 1)++;
                
            }
            high[B[i]-1] =0;
            low.at(B.at(i) - 1)++;
            
        } else
        {
            if (low.at(B.at(i) - 1) == 0)
            {
                high.at(B.at(i) - 1)++;
            } 
            high[A[i]-1] =0;
            low.at(A.at(i) - 1)++;
        }        
    }
    
    int tower = 0;
    for (ll i = 0; i < N; i++)
    {
        if ((high.at(i) != 0) || ((low.at(i) == 0) && (high.at(i) == 0)))
        {
            tower++;
        } 
        
    }

    
    cout << tower << endl;

    return 0;

}

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

#define min(a,b) (((a)<(b))?(a):(b))

int main(void)
{
    int P,Q,R;
    scanf("%d",&P);
    scanf("%d",&Q);
    scanf("%d",&R);
    printf("%d\n",min(P+Q,min(P+R,Q+R)));
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<59;

// 前方の index
int former(const vector<long long> &v, long long x) {
    return (int)(upper_bound(v.begin(), v.end(), x) - v.begin()) - 1;
}

// 後方の index
int latter(const vector<long long> &v, long long x) {
    return (int)(lower_bound(v.begin(), v.end(), x) - v.begin());
}

int main() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<long long> s(A), t(B);
    for (int i = 0; i < A; ++i) cin >> s[i];
    for (int i = 0; i < B; ++i) cin >> t[i];
    s.push_back(INF); s.push_back(-INF); sort(s.begin(), s.end());
    t.push_back(INF); t.push_back(-INF); sort(t.begin(), t.end());
    
    for (int _ = 0; _ < Q; ++_) {
        long long x; cin >> x;
        long long res = INF;
        
        // 最初に s (前方に行くか後方に行くか場合分け)
        for (int fl = 0; fl < 2; ++fl) {
            int sid = (fl == 0 ? former(s, x) : latter(s, x));
            // 次に t (現在地 s[sid] の前後を見る)
            for (int fl2 = 0; fl2 < 2; ++fl2) {
                int tid = (fl2 == 0 ? former(t, s[sid]) : latter(t, s[sid]));
                chmin(res, abs(x - s[sid]) + abs(s[sid] - t[tid]));
            }
        }
        
        // 最初に t (前方に行くか後方に行くか場合分け)
        for (int fl = 0; fl < 2; ++fl) {
            int tid = (fl == 0 ? former(t, x) : latter(t, x));
            // 次に s (現在地 t[tid] の前後を見る)
            for (int fl2 = 0; fl2 < 2; ++fl2) {
                int sid = (fl2 == 0 ? former(s, t[tid]) : latter(s, t[tid]));
                chmin(res, abs(x - t[tid]) + abs(t[tid] - s[sid]));
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 2912
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vllint a(n);
	vllint b(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	llint cnta = 0, cntb = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			if ((b[i] - a[i]) % 2 == 0) {
				cnta += (b[i] - a[i]) / 2;
			}
			else {
				cnta += (b[i] - a[i]) / 2 + 1;
				cntb++;
			}
		}
		else {
			cntb += a[i] - b[i];
		}
	}
	Yes(cnta >= cntb);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int n,sum=0;
    cin>>n;
    for(ll int i=1;i<=n;i++)
    {
      if(i%3!=0&&i%5!=0)
        sum+=i;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int w,b;
  cin >> w >> b;
  w--;
  b--;
  cout << 100 << ' ' << 100 << endl;

  string whiteBoard = "", blackBoard="";
  rep(i,50){
    whiteBoard += ".";
    blackBoard += "#";
  }

  string dotBlackBoard,dotWhiteBoard;
  rep(i,100){
    if(i % 2 == 1){
      dotBlackBoard = whiteBoard;
      dotWhiteBoard = blackBoard;

      rep(j,20){
        if(j % 2 == 0) continue;
        else if(b > 0) {
          dotBlackBoard[j] = '#';
          b--;
        }
      }
      rep(j,20){
        if(j % 2 == 0) continue;
        else if(w > 0) {
          dotWhiteBoard[j] = '.';
          w--;
        }
      }
      cout << dotBlackBoard << dotWhiteBoard << endl;
    }else{
      cout << whiteBoard << blackBoard << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
const int infty = 1<<28;
using namespace std;
int main()
{
  while(true){
    int n,m;
    cin >> n >> m;
    if( n == 0 && m == 0 ) break;
    char C[n+2];
    fill(C,C+n+2,'#');

    //cout << " ---------- " << endl;
    for(int p = 0; p < m; ++p){
      char c;
      cin >> c;
      /*for(int i = 1; i < 1+n; ++i){
	cout << C[i];
      }
      cout << endl;
      */
      if(c=='A'){
	for(int i = 1; i < 1+n; ++i){
	  if( C[i] == '#' ){
	    C[i] = 'A';
	    break;
	  }
	}
      }else if(c=='B'){
	bool sc=false;
	for(int i = n; i >= 1; --i){
	  if( C[i] == '#' && C[i-1] != 'A' && C[i+1] != 'A' ){
	    C[i] = 'B';
	    sc=true;
	    break;
	  }
	}
	if(!sc){
	  for(int i = 1; i < n+1; ++i){
	    if( C[i] == '#' ){
	      C[i] = 'B';
	      break;
	    }
	  }
	}
      }else if(c=='C'){
	bool sc = false;
	for(int i = 1; i < 1+n; ++i){
	  if( C[i] != '#' ){
	    if( C[i+1] == '#' && i < n ){
	      C[i+1]='C';sc=true;break;
	    }else{
	      if( C[i-1] == '#' && i > 1 ){
		C[i-1]='C';sc=true;break;
	      }else continue;
	    }
	  }
	}
	if( !sc ){
	  if( n % 2 == 0 ){
	    C[ n/2 + 1 ] = 'C';
	  }else{
	    C[ (n+1)/2 ] = 'C';
	  }
	}
      }else if(c=='D'){
	int max_dist = -1;
	int nearest_dist[n+2];
	fill(nearest_dist,nearest_dist+n+2,infty);
	bool empty=true;
	for(int i = 1; i < 1+n; ++i){
	  if( C[i] != '#' ) empty=false;
	}
	if(empty){C[1]='D';continue;}
	
	for(int i = 1; i < 1+n; ++i){
	  if( C[i] != '#' ) continue;
	  int min_right = infty, min_left = infty;
	  for(int j = i - 1; j >= 1; --j){
	    if( C[j] != '#'){
	      min_left = i - j - 1;
	      break;
	    }
	  }
	  for(int j = i + 1; j < 1+n; ++j){
	    if( C[j] != '#' ){
	      min_right = j - i - 1;
	      break;
	    }
	  }

	  nearest_dist[i] = min( min_right, min_left );
	  max_dist = max( max_dist, nearest_dist[i] );
	}
	for(int i = 1; i < i+n; ++i){
	  //cout << nearest_dist[i] << ' ' << max_dist << endl;
	  if( nearest_dist[i] == max_dist ){
	    C[i] = 'D';
	    break;
	  }
	}
      }
    }
    for(int i = 1; i < 1+n; ++i){
      cout << C[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

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

int x;

void read_input()
{
    cin >> x;
}

void solve()
{
    cout << (x >= 30 ? "Yes" : "No") << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

vector<int> g[10010];
bool went[10010];
int topo[10010];
int c;

void dfs(int now) {
  went[now] = true;
  for (auto to : g[now])
    if (!went[to]) dfs(to);
  topo[now] = c;
  c++;
}

// ====================================================================

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    g[from].push_back(to);
  }

  for (int i = 0; i < n; i++) {
    if (!went[i])
      dfs(i);
  }

  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    v.push_back(make_pair(topo[i], i));
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < n; i++) {
    cout << v[i].second << endl;
  }
}



Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MAX 1003
#define ll long long 

int n,m;
ll dp[MAX][MAX];
string s[MAX];

ll solve(int i, int j)
{
    if(i>=n || j>=m || s[i][j]=='#') return 0;
    if(i+1==n && j+1==m) return 1LL;
    if(~dp[i][j]) return dp[i][j];
    return dp[i][j]=(solve(i+1, j)%MOD+solve(i, j+1)%MOD)%MOD;
}

int main()
{
    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        cin>>s[i];
    }
    memset(dp, -1, sizeof dp);
    cout<<solve(0,0)<<endl;
    return 0;
}

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

static vector<int> adj[100005];
int ans = 0;

int dp(int u, int p){
	int cnt[20];
	fill(cnt,cnt+20,0);
	for(int v : adj[u]){
		if(v == p) continue;
		int mask = dp(v, u);
		for(int i = 0;i < 20;i++){
			if(((1 << i) & mask)) cnt[i]++;
		}
	}
	
	int bit = 19;
	for(;bit >= 0 && cnt[bit] <= 1;bit--) continue;
	for(bit++;cnt[bit] > 0;bit++) continue;
	ans = max(ans,bit);
	int mask = 1 << bit;
	for(int i = bit;i < 19;i++){
		if(cnt[i] > 0) mask |= (1 << i);
	}

	return mask;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	for(int i = 1;i < n;i++){
		int a, b; cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	} 
	dp(1,0);
	cout << ans;
}

Measured memory_bytes: 14848
#include <iostream>
using namespace std;
int main (){


int x ;
int z ;
int c ;
cin >> x>>z>>c;
if (x*z>c){
    cout << c;
}
else if (x*z<c){
    cout << x*z;
}
else if (x*z==c){
    cout << x*z;
}




return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $w);
$W = []; $V = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $x, $y);
    $W[] = $x; $V[] = $y;
}
const V_MAX = 100005;
$dp = array_fill(0, $n, array_fill(0, V_MAX, PHP_INT_MAX));
$dp[0][$V[0]] = $W[0];
$dp[0][0] = 0;

for ($i = 1; $i < $n; ++$i) {
    $dp[$i][0] = 0;
    for ($j = 0; $j < V_MAX; ++$j) {
        chmin($dp[$i][$j], $dp[$i - 1][$j]);

        if ($j - $V[$i] >= 0 && $dp[$i - 1][$j - $V[$i]] != PHP_INT_MAX) chmin($dp[$i][$j], $dp[$i - 1][$j - $V[$i]] + $W[$i]);
    }
}

function chmin(&$a, $b) { if ($a > $b) $a = $b; }

$max = 0;
for ($j = 0; $j < V_MAX; ++$j) {
    if ($dp[$n - 1][$j] <= $w) {
        $max = max($max, $j);
    }
}
echo $max;


Measured memory_bytes: 638672
fn solve() {
    let n = read();
    let mut csf = vec![];
    for i in 0..n - 1 {
        let (c, s, f): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
        csf.push((c, s, f));
    }
    let mut res = vec![0; n - 1];
    for i in 0..n - 1 {
        let mut tmp = 0;
        for j in i..n - 1 {
            let mut k = 0;
            while tmp > csf[j].1 + k * csf[j].2 {
                k += 1;
            }
            tmp = csf[j].1 + k * csf[j].2;
            tmp += csf[j].0;
            // println!("{:?}", (i, j));
            // println!("{:?}", csf[j]);
            // println!("{:?}", tmp);
        }
        res[i] = tmp;
    }
    res.push(0);
    for i in 0..n {
        println!("{}", res[i]);
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2200
h, w = map(int, input().split())
s = []
for i in range(h):
  s.append(input())
  # print(s[i])

l = [[0 for _ in range(w)] for _ in range(h)]
r = [[0 for _ in range(w)] for _ in range(h)]
u = [[0 for _ in range(w)] for _ in range(h)]
d = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
  for j in range(1, w):
    if not s[i][j] == '#' and s[i][j-1] == '.':
      l[i][j] = l[i][j-1] + 1

for i in range(h):
  for j in range(w-2, -1, -1):
    if not s[i][j] == '#' and s[i][j+1] == '.':
      r[i][j] = r[i][j+1] + 1

for j in range(w):
  for i in range(1, h):
    if not s[i][j] == '#' and s[i-1][j] == '.':
      u[i][j] = u[i-1][j] + 1

for j in range(w):
  for i in range(h-2, -1, -1):
    if not s[i][j] == '#' and s[i+1][j] == '.':
      d[i][j] = d[i+1][j] + 1

ret = 0
for i in range(h):
  for j in range(w):
    if not s[i][j] == '#':
      t = l[i][j] + r[i][j] + u[i][j] + d[i][j]
      if ret < t:
        ret = t

print(ret+1)


Measured memory_bytes: 184212
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 座標数
        int dataCount = sc.nextInt();
        int[] points = new int[dataCount];

        for (int i = 0; i < dataCount; i++) {
            points[i] = sc.nextInt();
        }

        Arrays.sort(points);

        // 最大座標 - 最小座標 = 最短の移動距離
        System.out.println(points[points.length - 1] - points[0]);
    }
}

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

int main(){
  int r,c,k;
  cin>>r>>c>>k;
  vector<vector<vector<ll>>> vec(3100,vector<vector<ll>>(3100,vector<ll>(4)));
  vector<vector<ll>> p(3100,vector<ll>(3100));
  for(int i=0;i<3100;i++){
    for(int j=0;j<3100;j++){
      vec[i][j][0]=0;
      vec[i][j][1]=0;
      vec[i][j][2]=0;
      vec[i][j][3]=0;
      p[i][j]=0;
    }
  }
  for(int i=0;i<k;i++){
    int a,b;
    ll point;
    cin>>a>>b>>point;
    p[a][b]=point;
  }
  for(int i=1;i<=r;i++){
    for(int j=1;j<=c;j++){
      vec[i][j][0]=max(vec[i][j][0],vec[i][j-1][0]);
      vec[i][j][0]=max({vec[i][j][0],vec[i-1][j][0],vec[i-1][j][1],vec[i-1][j][2],vec[i-1][j][3]});
      vec[i][j][1]=max({vec[i][j][1],vec[i][j-1][0]+p[i][j],vec[i][j-1][1]});
      vec[i][j][1]=max({vec[i][j][1],max({vec[i-1][j][0],vec[i-1][j][1],vec[i-1][j][2],vec[i-1][j][3]})+p[i][j]});
      vec[i][j][2]=max({vec[i][j][2],vec[i][j-1][1]+p[i][j],vec[i][j-1][2]});
      //vec[i][j][2]=max({vec[i][j][2],max({vec[i][j-1][0],vec[i][j-1][1],vec[i][j-1][2],vec[i][j-1][3]})+p[i][j]});
      vec[i][j][3]=max({vec[i][j][3],vec[i][j-1][2]+p[i][j],vec[i][j-1][3]});
      //vec[i][j][3]=max({vec[i][j][1],max({vec[i][j-1][0],vec[i][j-1][1],vec[i][j-1][2],vec[i][j-1][3]})+p[i][j]});
    }
  }
  cout<<max(vec[r][c][0],max(vec[r][c][1],max(vec[r][c][2],vec[r][c][3])))<<endl;
}

Measured memory_bytes: 754312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n];
    int mx = -1;
    rep(i, 0, n) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    int ans = 0;
    int tmp = INF;
    rep(i, 0, n) {
        if (a[i] == mx) continue;
        if (abs(mx / 2 - a[i]) < tmp) {
            ans = a[i];
            tmp = abs(mx / 2 - a[i]);
        }
    }

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


Measured memory_bytes: 640
// finish date: 2018/07/17
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
//    vi eee(87260);
//    eee[0] = 3797326;
//    eee[1] = eee[0]+98569467;
//    eee[2] = eee[1]+98569467;
//    FOR(i,3,eee.size()){
//        eee[i] = eee[i-1] + 98570272- 98569467;
//    }
//    cout<<eee[eee.size()-1]<<endl;


    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    ll diff = abs(A - B);
    N--;
    if ((ll) N * D < diff) {
        cout << "NO" << endl;
        return 0;
    } else if ((ll) N * C <= diff) {
        cout << "YES" << endl;
        return 0;
    } else if (N % 2 == 1 && C <= diff && diff <= D) {
        cout << "YES" << endl;
        return 0;
    } else {
        ll diff2 = abs(A - B);
        if (N % 2 == 1) {
            diff = abs(diff - D);
            diff2 = abs(diff2 - C);
            N--;
        }
        rep(i, N / 2 + 1) {
            ll n = N - 2 * i;
            if (n == 2) {
                int a = 1;
            }
            if ((n * C <= diff && diff <= n * D)
                || (n * C <= diff2 && diff2 <= n * D)) {
                cout << "YES" << endl;
                return 0;
            }
            if ((min(abs(diff - n * C), abs(diff - n * D)) <= i * (D - C)) ||
                (min(abs(diff2 - n * C), abs(diff2 - n * D)) <= i * (D - C))) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 256
using System;

class A{
  static void Main(){
    int S = int.Parse(Console.ReadLine());
    if (S == 25) Console.WriteLine("Christmas");
    else if (S == 24) Console.WriteLine("Christmas Eve");
    else if (S == 23) Console.WriteLine("Christmas Eve Eve");
    else Console.WriteLine("Christmas Eve Eve Eve");
  }
}

Measured memory_bytes: 17440
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

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

	vector<int> data(n);

	rep(i, 0, n) {
		int p;

		cin >> p;
		data[i] = abs(p-x);
	}

	int ans = data[0];
	rep(i, 1, n) {

		ans = gcd(ans, data[i]);

	}
	
	cout << ans << endl;
}
	

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

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

  // S = spade
  // H = heart
  // C = club
  // D = diamond
  vector<char> suits = {'S', 'H', 'C', 'D'};

  map<char, vector<int>> cards;
  for (int i = 0; i < 4; i++) {
    char suit = suits.at(i);
    cards[suit] = vector<int>(13, 0);
  }

  for (int i = 0; i < n; i++) {
    char suit;
    int num;
    cin >> suit >> num;

    num--; // 0-indexed
    cards.at(suit).at(num) = 1;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      char suit = suits.at(i);

      if (cards.at(suit).at(j) == 0) {
        // j + 1 ... 1-indexed
        cout << suit << " " << (j + 1) << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> e(n);
    e[0] = s[0] == 'E' ? 1 : 0; 
    repi(i, n) {
        e[i] = e[i-1] + (s[i] == 'E' ? 1 : 0);
    }

    int res = 1e8;
    rep(i, n) {
        int num = e[n-1] - e[i];
        num += i - 1 >= 0 ? i - e[i - 1] : 0;
        res = min(num, res);
     //   put(num)
    }
    put(res);
    return 0;
}

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

//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)
//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();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a , b;
    cin >> a >> b;

    if( a > b){
        cout << a-1 << endl;
    }
    else{
        cout << a << endl;
    }

    //dump(a);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] c = s.split("");
    if(c[0].equals(c[1]) || c[1].equals(c[2]) || c[2].equals(c[3])) {
      System.out.println("Bad");
    } else {
      System.out.println("Good");
    }

  }

}


Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import deque

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, ia, ib = getList()
nums = getList()

if n == 1:
    print(abs(ib - nums[0]))
    sys.exit()

ans = abs(nums[-1] - nums[-2])
if abs(nums[-1] - ib) > ans:
    ans = abs(nums[-1] - ib)

print(ans)

Measured memory_bytes: 38896
H, W, N = map(int, input().split())
xy = []
for i in range(N):
    x, y = map(int, input().split())
    xy.append((x, y))
xy.sort()

ans = H
d = 0
for x, y in xy:
    if x-d>y:
        ans = x-1
        break
    if x-d == y:
        d+=1
print(ans)






Measured memory_bytes: 65632
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Map<String, Integer>> m = new ArrayList<Map<String, Integer>>();
        for (int i = 0; i < 5; i++) {
            m.add(new TreeMap<String, Integer>());
        }
        for (int i = 0; i < n; i++) {
            String p = sc.next();
            int x = sc.nextInt();
            if (m.get(p.length() - 1).containsKey(p)) {
                x += m.get(p.length() - 1).get(p);
            }
            m.get(p.length() - 1).put(p, x);
        }
        for (int i = 0; i < 5; i++) {
            for (Entry<String, Integer> e : m.get(i).entrySet()) {
                System.out.println(e.getKey() + " " + e.getValue());
            }
        }
    }
}


Measured memory_bytes: 49256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}



int main(){
    ll n; cin >> n;
    cout << (n-1)/2 << endl;
}

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

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

bool used[5];

int main(void){
	int N,M;
	cin >> N >> M;
	used[N] = true; used[M] = true;
	REP(i,4)
		if(used[i] == false && i != 0){
			cout << i << endl;
			return 0;
		}
	return 0;
}


Measured memory_bytes: 256
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, l = [int(x) for x in input().rstrip().split(" ")]

    s_list = [input().rstrip() for _ in range(n)]
    s_list = sorted(s_list)
    print("".join(s_list))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61992
a, b = map(int, input().split())

def small(a,b) :
    return a < b
    
def big(a,b) :
    return a > b
    
def equal(a,b) :
    return a == b
    
if small(a,b):
    print('a < b')
    
elif big(a,b) :
    print('a > b')
    
elif equal(a,b) :
    print('a == b')


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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
double ans;
int res;
int cur;

int main () {
	cin >> n >> m >> k;
	ans = inf;
	for (int i = 1; i <= n; i ++) {
		double x;
		cin >> x;
		x = m - x * 0.006l;
		if (ans > fabs(x - k)) {
			ans = fabs(x - k);
			res = i;
		} 
	}

	cout << res;
	return Accepted;
}

// B...a

Measured memory_bytes: 18688
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>

#define PI  2*acos(0.0)
#define pb push_back


using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;


int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);


ll n;
cin>>n;

if(n%1000==0)
{
	cout<<0<<"\n";
}

else
{
	cout<<((n/1000)+1)*1000 - n<<"\n";
}












	
	
	return 0;
	
	
}

Measured memory_bytes: 3652
n, m = map(int, input().split())
ac = [0] * n
wa = [0] * n

for i in range(m):
  [p, s] = input().split()
  if s == "AC":
    ac[int(p)-1] = 1
  elif ac[int(p)-1] != 1:
    wa[int(p)-1] += 1

for i in range(n):
  if ac[i] == 0:
    wa[i] = 0

print(sum(ac), sum(wa))

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
  
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> k >> n;
	for(ll i=n-k+1;i<n;i++) cout<<i<<" ";
	cout<<n<<" ";
	for(ll i=n+1;i<n+k;i++) cout<<i<<" ";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<map>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int a, b;
	cin >> a >> b;
	a += 1;
	cout << a - b << endl;


	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <stack>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    stack<int>S1;
    char c;

    stack<pair<int, int>>S2;
    int i=0,j,sub,sum=0;
    while(cin >> c){
        if(c=='\\'){
            S1.push(i);
        }
        else if(c=='/' && !S1.empty()){
            j=S1.top();S1.pop();
            sum += i-j;
            sub = i-j;
            while(!S2.empty() && S2.top().first > j){
                sub += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,sub));
        }
      i++;
    }

    stack<int>ans;
    while(!S2.empty()){
        ans.push(S2.top().second);
        S2.pop();
    }
    cout << sum << endl;
    cout << ans.size();
    while(!ans.empty()){
        cout << " " << ans.top() ;
        ans.pop();
    }
  cout << endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
 
int main() {
    int A;
    std::cin >> A;
    std::string str;
    std::cin >> str; 
    std::string substr = str.substr(0, A);
  
    if(A < str.size()){
    std::cout << substr << "..." << std::endl;
    }
  
    if(A >= str.size()){
    std::cout << str << std::endl;
    }
    return 0;
    }


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> a){
    int ans = 0;
    REP(i, N) {
        while(a[i] % 2 == 0) {
            ans++;
            a[i] /= 2;
        }
    }

    cout << ans << endl;
}

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


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  set<string> st;
  while(n--){
    string s;cin>>s;
    st.insert(s);
  }
  cout<<st.size()<<endl;
  
  return 0;
}


Measured memory_bytes: 19212
import math


if __name__ == "__main__":
    while True:
        dataset_num = int(input())
        if dataset_num == 0:
            break
        dataset = list(map(lambda x: float(x), input().split()))
        mean = sum(dataset) / dataset_num
        variance = sum(map(lambda x: (x - mean) ** 2, dataset)) / dataset_num
        print(f"{math.sqrt(variance)}")



Measured memory_bytes: 5780