akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define enter putchar('\n')
#define space putchar(' ')
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define MAXN 5005
#define mo 99994711
#define pb push_back
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;

struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE;
int dp[MAXN][MAXN][2],fac[MAXN],inv[MAXN],invfac[MAXN],p[MAXN],siz[MAXN],tmp[MAXN][2];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int C(int n,int m) {
    if(n < m) return 0;
    return mul(fac[n],mul(invfac[m],invfac[n - m]));
}

void dfs(int u,int fa) {
    dp[u][0][0] = 1;
    siz[u] = 0;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            dfs(v,u);
            for(int i = 0 ; i <= siz[u] + siz[v] ; ++i) tmp[i][0] = tmp[i][1] = 0;
            for(int i = 0 ; i <= siz[u] ; ++i) {
                for(int j = 0 ; j <= siz[v] ; ++j) {
                    for(int k = 0 ; k <= 1 ; ++k) {
                        for(int h = 0 ; h <= 1 ; ++h) {
                            update(tmp[i + j][k ^ h],mul(dp[u][i][k],dp[v][j][h]));
                        }
                    }
                }
            }
            for(int i = 0 ; i <= siz[u] + siz[v] ; ++i) {
                dp[u][i][0] = tmp[i][0];
                dp[u][i][1] = tmp[i][1];
            }
            siz[u] += siz[v];
        }
    }
    ++siz[u];
    if(fa) {
        for(int i = siz[u] - 1; i >= 0 ; --i) {
            for(int k = 0 ; k <= 1 ; ++k) {
                update(dp[u][siz[u]][k],mul(dp[u][i][k ^ 1],p[siz[u] - i]));
            }
        }
    }
}
void Solve() {
    read(N);
    int u,v;
    for(int i = 1 ; i < N ; ++i) {
        read(u);read(v);add(u,v);add(v,u);
    }
    inv[1] = 1;
    for(int i = 2 ; i <= N ; ++i) inv[i] = mul(inv[MOD % i],MOD - MOD / i);
    fac[0] = invfac[0] = 1;
    for(int i = 1 ; i <= N ; ++i) fac[i] = mul(fac[i - 1],i),invfac[i] = mul(invfac[i - 1],inv[i]);
    p[0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
        if(i & 1) p[i] = 0;
        else p[i] = mul(p[i - 2],i - 1);
    }
    dfs(1,0);
    int ans = 0;
    for(int i = 0 ; i <= N ; ++i) {
        ans = inc(ans,mul(dp[1][i][0],p[N - i]));
        ans = inc(ans,MOD - mul(dp[1][i][1],p[N - i]));
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 195072
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main() {
  int a, b;

  cin >> a >> b;
  if(b<0){
    if((b-a)%2 == 1){
      cout << "Positive" << endl;
    }else{
      cout << "Negative" << endl;
    }
  }else if(a<=0){
    cout << "Zero" << endl;
  }else{
    cout << "Positive" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s = 0
for i in range(N):
  if A[i]+A[i+1]<=B[i]:
    s = s + A[i] + A[i+1]
    A[i]=0
    A[i+1] = 0
  elif A[i] <= B[i] and A[i] + A[i+1] > B[i]:
    s = s + B[i]
    A[i+1] = A[i+1] + A[i] - B[i]
    A[i] = 0
  else:
    s = s + B[i]
    A[i] = B[i] - A[i]
    
print(s)
  

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

int main() {
    int n,w;    cin>>n>>w;
    long long ans=0;
    long long dp[w+1];
    memset(dp, -1, sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++){
        int wi,vi;cin>>wi>>vi;
        
        for(int j=w;j>=wi;j--){
            if(dp[j-wi]!=-1) 
                dp[j] = max ( dp[j] , dp[j-wi] + vi );
            ans=max(ans,dp[j]);
        }
    }   
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4376
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;

    vector<long> x(N);
    vector<long> y(N);
    vector<long> z(N);

    vector<long> PPP(N);
    vector<long> MPP(N);
    vector<long> PMP(N);
    vector<long> PPM(N);
    vector<long> MMP(N);
    vector<long> MPM(N);
    vector<long> PMM(N);
    vector<long> MMM(N);


    for(int i = 0;i<N;i++){
        cin >> x[i] >> y[i] >> z[i];
        PPP[i] =      x[i] + y[i] + z[i];
        MPP[i] = (-1)*x[i] + y[i] + z[i];
        PMP[i] =      x[i] - y[i] + z[i];
        PPM[i] =      x[i] + y[i] - z[i];
        MMP[i] = (-1)*x[i] - y[i] + z[i];
        MPM[i] = (-1)*x[i] + y[i] - z[i];
        PMM[i] =      x[i] - y[i] - z[i];
        MMM[i] = (-1)*x[i] - y[i] - z[i];
    }

    sort(PPP.rbegin(),PPP.rend());
    sort(MPP.rbegin(),MPP.rend());
    sort(PMP.rbegin(),PMP.rend());
    sort(PPM.rbegin(),PPM.rend());
    sort(MMP.rbegin(),MMP.rend());
    sort(MPM.rbegin(),MPM.rend());
    sort(PMM.rbegin(),PMM.rend());
    sort(MMM.rbegin(),MMM.rend());

    long Max1 = 0;
    long Max2 = 0;
    long Max3 = 0;
    long Max4 = 0;
    long Max5 = 0;
    long Max6 = 0;
    long Max7 = 0;
    long Max8 = 0;

    for(int i = 0;i<M;i++){
        Max1 = Max1 + PPP[i];
        Max2 = Max2 + MPP[i];
        Max3 = Max3 + PMP[i];
        Max4 = Max4 + PPM[i];
        Max5 = Max5 + MMP[i];
        Max6 = Max6 + MPM[i];
        Max7 = Max7 + PMM[i];
        Max8 = Max8 + MMM[i];
    }

    long ans = max(Max1,max(Max2,max(Max3,max(Max4,max(Max5,max(Max6,max(Max7,Max8)))))));

    cout << ans << endl;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};
bool dp[100010];

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

    dp[0] = 1;
    for(int i = 0; i < S.size(); ++i){
        if(!dp[i])continue; // そこまでで矛盾があったらとりあえず無視
        for(string s : divide){
            if(S.substr(i, s.size()) == s){ // うまく切れたら先に進む
                dp[i + s.size()] = 1;
            }
        }
    }
    cout << (dp[S.size()] ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
X,N = map(int,input().split())
P = list(map(int,input().split()))


P_n = [i for i in range(102) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Measured memory_bytes: 9100
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

// Author:: Subash Singha Roy
// Institution:: Jalpaiguri Government Engineering College

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) int t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf 999999999999999999
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}


ll dis[100005],indeg[100005];
vector<ll>adj[100005];
void bfs(ll no){
    queue<ll>q;
    q.push(no);
    while(!q.empty()){
        ll node=q.front();
        q.pop();
        for(auto next: adj[node]){
            indeg[next]--;
            if(indeg[next]==0){
                q.push(next);
            }
            dis[next]=max(dis[next],dis[node]+1);
        }
    }
}

int main(){
    fio
    ll n,m,maxi=0,x,y;
    cin>>n>>m;
    vector<ll>v;
    fr(i,0,m){
        cin>>x>>y;
        adj[x].pb(y);
        indeg[y]++;
    }
    fr(i,1,n+1){
        if(indeg[i]==0){
            v.pb(i);
        }
    }

    fr(i,0,(ll)v.size()){
        bfs(v[i]);
    }
    fr(i,1,n+1){
        maxi=max(maxi,dis[i]);
    }
    cout<<maxi<<"\n";
    rr;
}

Measured memory_bytes: 7296
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int i,ans=0;
  char S[4];
  scanf("%s",S);
  FOR(i,0,3)if(S[i]==S[i+1])ans=1;
  if(ans==1)printf("Bad");
  else printf("Good");

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


Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

int main(){
  ll N;
  ll ret = 1;
  ll lmax = 1e18;
  cin >> N;
  ll A[N];
  REP(n, N) cin >> A[n];
  REP(n, N){
    if(A[n] == 0){
      ret = 0;
      break;
    }
    if(ret == -1) continue;
    if(A[n] > lmax / ret){
      ret = -1;
      continue;
    }
    ret *= A[n];
    if(ret > lmax) ret = -1;
  }
  if(ret > lmax) ret = -1;
  cout << ret << endl;
  return 0;
}


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

#define endl '\n'

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

    int n; cin >> n;
    int freq[n+1];
    memset(freq, 0 ,sizeof freq);
    for (int i=1; i<n; i++){
        int x; cin >> x;
        freq[x]++;
    }
    for (int i=1; i<=n; i++) cout << freq[i] << endl;
}

Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a  << " " << b << endl;
	return 0;
}


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

string Expr;
int P;
map<int,int>Value[128];
int Size[128];
bool Error;

void program();
void declaration();
void assignment();
int expression();
int number();
char array_name();

void program(){
  if(Expr.find("=",0)==string::npos){
    declaration();
  }else{
    assignment();
  }
  return;
}
void declaration(){
  char name=array_name();
  P++;
  int n=number();
  P++;
  Size[name]=n;
}
void assignment(){
  char name=array_name();
  P++;
  int ex1=expression();
  P++;
  P++;
  int ex2=expression();
  if(ex1>=Size[name]){
    Error=true;
  }
  Value[name][ex1]=ex2;
}
int expression(){
  int n;
  if(isdigit(Expr[P])){
    n=number();
  }else{
    char name=array_name();
    P++;
    n=expression();
    P++;
    if(n>=Size[name]){
      Error=true;
    }
    if(Value[name].find(n)==Value[name].end()){
      Error=true;
    }
    n=Value[name][n];
  }
  return n;
}
int number(){
  string n;
  while(isdigit(Expr[P]))n+=Expr[P++];
  return atoi(n.c_str());
}
char array_name(){
  return Expr[P++];
}

int main()
{
  while(cin>>Expr,Expr!="."){
    int ans=0;
    for(int i=0;i<128;i++){
      Value[i].clear();
      Size[i]=-1;
    }
    Error=false;
    do{
      if(Error)continue;
      P=0;
      program();
      ans++;
    }while(cin>>Expr,Expr!=".");
    if(Error){
      cout<<ans<<endl;
    }else{
      cout<<"0"<<endl;
    }
  }
}

Measured memory_bytes: 0
# cook your dish here
n,k = map(int,input().split())
ass = 0

for i in range(k+1,n+1):
    jkl = ass
    ass += (i-1)-k+1
    w = (n-(i-1))//i
    if w >= 1:
        ass += ((i-1)-k+1)*w
    r = n-(w+1)*i
    if r >= k:
        ass += r-k+1
    #print(i,ass-jkl)
if k ==0:
    print(n**2)
else:
    print(ass)

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

int main(){ 
    int N, M; cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }

    int cnt = 0;
    rep(i,N){
        if(A[i] * 4 * M >= sum) cnt++;
    }

    if(cnt >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}

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

int main() {
  int N, X;
  cin >> N >> X;
  
  vector<int> m(N);
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
  }
  
  int sum;
  for (int i = 0; i < N; i++) {
    sum += m.at(i);
  }
  
  int min = m.at(0);
  for (int i = 0; i < N-1; i++) {
    if (m.at(i+1) < min) {
      min = m.at(i+1);
    }
  }
  
  int answer; 
  int b;
  
  b = (X - sum);
  answer = N;
  
  while (b >= min) {
    answer++;
    b -= min;
  }
  
  cout << answer << endl;
}


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

#define ll long long

signed main(){
   int n, x; 
   while (cin >> n >> x, n != 0 or x != 0){
      int ans = 0;
      for (int i = 1; i <= n - 2; i += 1){
         for (int j = i + 1; j <= n - 1; j += 1){
            for (int k = j + 1; k <= n; k += 1){
               if (i + j + k == x){
                  ans += 1;
               }
            }
         }
      }
      cout << ans << endl;
   }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int n;
int l,r,mid,ans;
int main()
{
	cin>>n;
	l=1;
	r=n;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(1.08*mid<1+n)
		{
			ans=mid;
			l=mid+1;
		}
		else
		r=mid-1;
	}
	if(1.08*ans>=1.0*n)
	printf("%d",ans);
	else
	printf(":(");
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#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 d(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
    string S;
    cin>>S;
    int flag=0;
    if(S[0]=='A'){
        FOR(i,2,S.size()-1){
            if(isupper(S[i])){
                if(S[i]=='C' && flag==0){
                    flag=1;
                }
                else{
                    cout<<"WA"<<endl;
                    return 0;
                }
            }
        }
    }
    else{
        cout<<"WA"<<endl;
        return 0;
    }
    if(flag && islower(S[1]) && islower(S[S.size()-1]))cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


vector<ll> memo;


ll dp(ll n, vvll &links){
    
    if (memo[n] != -1) return memo[n];
    ll res = 0;
    for(auto d: links[n]){
        res = max(res,dp(d,links)+1);
    }
    
    return memo[n] = res;
}

int main() {
    int N, M;
    cin >> N >> M;

    vector<vector<ll>> links(N);
    int s, t;
    for(auto i = 0; i<M; i++){
        cin >> s >> t;
        s--;
        t--;
        links[s].push_back(t);
    }
    
    memo.resize(N + 1, -1);
    
    ll ans = 0;
    
    for(auto i = 0; i<N; i++){
        ans = max(ans,dp(i,links));
    }
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,K;cin>>n>>K;
    vector<pair<ll,ll>> p(n);
    vector<ll> X(n),Y(n);
    rep(i,n){
        cin>>p[i].first>>p[i].second;
        X[i]=p[i].first;Y[i]=p[i].second;
    }
    ll res=(1e+18)*5;
    rep(i,n)rep(j,n)rep(l,n)rep(r,n){
        if(i>=l||j>=r)continue;
        ll x1=X[i],y1=Y[j],x2=X[l],y2=Y[r];
        if(x1>x2)swap(x1,x2);
        if(y1>y2)swap(y1,y2);
        ll buf=(y2-y1)*(x2-x1);
        ll tot=0;
        rep(k,n){
            ll x=p[k].first,y=p[k].second;
            if(x1<=x&&x<=x2&&y1<=y&&y<=y2)tot++;
        }
        if(tot>=K)chmin(res,buf);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    using P = tuple<int, int>;
    vector<P> drink(n);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        drink[i] = P(a, b);
    }
    sort(drink.begin(), drink.end());

    int64_t result = 0;
    rep(i, n)
    {
        int a, b;
        tie(a, b) = drink[i];

        int c = min(m, b);
        result += (int64_t)a * c;
        m -= c;
    }
    cout << result << endl;

    return 0;
}

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

struct list{
	char name[15];
	int time;
};
struct list node[100005];

int main()
{
	int n,ti,T=0;
	int i=0;
	scanf("%d%d",&n,&ti);
	int coun=n;
	while(coun--)
	{
		scanf("%s %d",&node[i].name,&node[i].time);
		i++;
	}
	for(int head=0,tail=n;head!=tail;head=(head+1)%(n+1))
	{
		i=head;
		if(node[i].time<=ti)
		{
			T+=node[i].time;
			printf("%s %d\n",node[i].name,T);
			node[i].time=0;
		}
		else
		{
			T+=ti;
			node[tail].time=node[i].time-ti;
			strcpy(node[tail].name,node[i].name);
			tail=(tail+1)%(n+1);
		}
	}
	return 0;
}



Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int ans = N*N*N;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
const int MAXN=100000+10;
int n,X,Y,Z;
ll ans,res,L[MAXN],R[MAXN];
struct node{
	int x,y,z;
	inline bool operator < (const node &A) const {
		return x-y>A.x-A.y;
	}
};
node coin[MAXN];
struct ext{
	int x,y,z;
	inline bool operator < (const ext &A) const {
		return x-z>A.x-A.z;
	};
	inline bool operator > (const ext &A) const {
		return y-z>A.y-A.z;
	};
};
std::priority_queue<ext> q1;
std::priority_queue< ext,std::vector<ext>,std::greater<ext> > q2;
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
	read(X);read(Y);read(Z);n=X+Y+Z;
	for(register int i=1;i<=n;++i)read(coin[i].x),read(coin[i].y),read(coin[i].z);
	std::stable_sort(coin+1,coin+n+1);
	for(register int i=1;i<=X;++i)res+=coin[i].x,q1.push((ext){coin[i].x,coin[i].y,coin[i].z});
	L[X]=res;
	for(register int i=X+1;i<=X+Z;++i)
	{
		if(coin[i].x-coin[i].z>q1.top().x-q1.top().z)
		{
			res+=coin[i].x-q1.top().x+q1.top().z;
			q1.pop();
			q1.push((ext){coin[i].x,coin[i].y,coin[i].z});
		}
		else res+=coin[i].z;
		L[i]=res;
	}
	res=0;
	for(register int i=n;i>=n-Y+1;--i)res+=coin[i].y,q2.push((ext){coin[i].x,coin[i].y,coin[i].z});
	R[n-Y+1]=res;
	for(register int i=n-Y;i>=X+1;--i)
	{
		if(coin[i].y-coin[i].z>q2.top().y-q2.top().z)
		{
			res+=coin[i].y-q2.top().y+q2.top().z;
			q2.pop();
			q2.push((ext){coin[i].x,coin[i].y,coin[i].z});
		}
		else res+=coin[i].z;
		R[i]=res;
	}
	for(register int i=X;i<=n-Y;++i)chkmax(ans,L[i]+R[i+1]);
	write(ans,'\n');
	return 0;
}


Measured memory_bytes: 4276
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.IntSlice(a))
	fmt.Println(a[n-1] - a[0])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<32;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n;cin>>n;
    double ans=0;
    for(int i=0;i<n;i++){
        double a;cin>>a;
        string s;cin>>s;
        if(s=="BTC"){
            ans+=a*380000.0;
        }else{
            ans+=a;
        }

    }
    printf("%.10lf\n",ans);
}

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

int main() {
  int N;
  cin>>N;
    vector<int> vec(N)  ;
  for(int i=0;i<N;i++) cin>>vec[i];
    sort(vec.begin(), vec.end()); 
    reverse(vec.begin(), vec.end()); 
  int a=0,b=0;
    for (int i = 0; i < N; i++) {
      if(i%2==0) a+=vec[i];
      else b+=vec[i];
    }
  cout<<a-b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int long long 


template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;

const int  M    = 1000000007;
const int  maxn =  100005 ;
const long long   inf  =  LONG_LONG_MAX    ;
const long double eps = 1.084202e-19;



int32_t main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL); 
     int d , s ,t ; 
     cin >> d >> s >> t ; 
     if(s*t>=d){
           cout <<"Yes";
     }
     else{
           cout <<"No";
     }

}
/*

*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define int long long
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
void foo(){
    int a, b;
    cin>>a>>b;
    if(1ll*(a*b)%2==0)cout<<"Even";
    else cout<<"Odd";   
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
        int N;
        int out;

        int flag = 0;

        scanf("%d", &N);

        for (int i = 1; i < 10; i++) {
                for (int j = 1; j < 10; j++) {
                        if (N == (i * j)) {
                                printf("Yes\n");
                                return 0;
                        }
                }
        }

        printf("No\n");

        return 0;
}

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int rn = 0, rnl = 0;
  rep(i, n){
    if(s[i] == 'R') rn++;
  }
  rep(i, rn){
    if(s[i] == 'R') rnl++;
  }
  cout << rn - rnl << endl;
  return 0;
}


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

int main(){
    int n,y;
    cin >> n >> y;
    int ans[]={-1,-1,-1};
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                ans[0]=i;
                ans[1]=j;
                ans[2]=n-i-j;
            }
        }
    }
    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string A,B,C;
    cin >> A >> B >> C;
    if(A.at(A.size()-1)==B.at(0)){
        if(B.at(B.size()-1)==C.at(0)){
            cout << "YES" << endl;
        }
          else  {
                cout  << "NO" << endl;
            
        }
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

constexpr size_t D = 365;
constexpr size_t type = 26;
constexpr int INF = (1 << 30);

array<int, type> c, last;
array<array<int, type>, D> s;
array<int, D> ans;

void input () {
	int buff;
	cin >> buff;
	for (int i = 0; i < type; i++) {
		cin >> c[i];
		last[i] = 0;
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < type; j++) {
			cin >> s[i][j];
		}
	}
}

int next_contest (int day) {
	int nxt = -1, score = -INF;
	for (int i = 0; i < type; i++) {
		int val = s[day - 1][i];
		for (int j = 0; j < type; j++) {
			if (i ^ j) val -= c[j] * (day - last[j]);
		}
		if (chmax(score, val)) nxt = i;
	}
	return nxt;
}

int main() {
	input();
	for (int i = 0; i < D; i++) {
		int nxt = next_contest(i + 1);
		last[nxt] = i + 1;
		ans[i] = nxt + 1;
	}
	
	for (int contest : ans) {
		cout << contest << '\n';
	}
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,k;
  cin >> n >>k;
  Vi plus(0),minus(0);
  int qw;
  rep(i,0,n){
    cin >> qw;
    if(qw>=0) plus.pb(qw);
    else minus.pb(-qw);
  }
  sort(ALL(plus));
  sort(ALL(minus));
  int ans = INF;
  int now = 0;
  
  if(plus.size()==0) {
    cout << minus[k-1] << endl;
    return 0;
  }
  
  else if(minus.size()==0) {
    cout << plus[k-1] << endl;
    return 0;
  }
  
  else {
    rep(i,0,k+1){
      if(i > plus.size()) continue;
      if(k-i > minus.size()) continue;
      now = min( plus[i-1]*2+minus[k-i-1] , plus[i-1]+minus[k-i-1]*2 );
      ans = min(ans,now);
      //cout << ans << ' ' << now << ' ' << plus[i-1] << ' ' << minus[k-i-1] << endl;
    }
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main()
{
	scanf("%d %d %d",&n,&a,&b);
	if ((b-a)%2==1)
	{
		if (a<b)
		{
			printf("Borys\n");
			return 0;
		}
		printf("Alice\n");
		return 0;
	}
	if (a<b)
	{
		printf("Alice\n");
		return 0;
	}
	printf("Borys\n");
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    int count = 0;
    int count2 = 0;
    for(int i = 0; i < n; i++){
        if(a.at(i) % 2 == 0){
            count++;
        }
    }
    for(int i = 0; i < n; i++){
        if(a.at(i) % 6 == 0){
            count2++;
        } else if(a.at(i) % 10 == 0){
            count2++;
        }
    }
    if(count == count2){
        cout << "APPROVED";
    } else {
        cout << "DENIED";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a;
  b = a / 1000;
  b = a-b*1000;
  b -= 1000;
  b *= -1;
  if (b == 1000) {
    cout << 0;
    exit(0);
  }
  cout << b;
}


Measured memory_bytes: 3628
import java.util.*;

/**
 * 2018.06.16 
 */

public class Main {

	public static void main(String[] args) {	
		Scanner scanner = new Scanner(System.in);
	    int A = scanner.nextInt();
	    int B = scanner.nextInt();
	    
	    //入力チェック
	    if((A + B) > 16){
	    	//error
	    }else if(A > 8){
	    	System.out.println(":(");
	    }
	    else if (B > 8){
	    	System.out.println(":(");
	    }else{
	    	System.out.println("Yay!");
	    }
	}

}


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

using namespace std;

int main()
{
    int64_t N, K;
    vector<int64_t> H;
    cin >> N >> K;
    H.resize(N);
    for (int64_t i = 0; i < N; ++i) {
        cin >> H[i];
    }
    int64_t ans = 0;
    for (const auto h: H) {
        if (h >= K) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
  int n,res = 0;string s;char oc = '1';
  cin >> n >> s;
  for(int i = 0;i < n;i++){
    if(oc != s[i]){
      res++;
      oc = s[i];
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
#define NMAX 105
#define WMAX 100005
#define DIAGONAL 1
#define TOP 0

struct Item {
    int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int &maxValue, vector<int> &selection) {
    for (int w = 0; w <= W; w++) {
        C[0][w] = 0;
        G[0][w] = DIAGONAL;
    }

    for (int i = 1; i <= N; i++) C[i][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int w = 1; w <= W; w++) {
            C[i][w] = C[i - 1][w];
            G[i][w] = TOP;
            if (items[i].weight > w) continue;
            if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
                C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
                G[i][w] = DIAGONAL;
            }
        }
    }

    maxValue = C[N][W];
    selection.clear();
    for (int i = N, w = W; i >= 1; i--) {
        if (G[i][w] == DIAGONAL) {
            selection.push_back(i);
            w -= items[i].weight;
        }
    }

    reverse(selection.begin(), selection.end());
}

void input() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> items[i].value >> items[i].weight;
    }
}

int main() {
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue, selection);

    cout << maxValue << endl;

    return 0;
}


Measured memory_bytes: 11860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int ka[32][32];
int hanbetu[32] = {0};

int main(){
    int n,m; cin >> n >> m;
    rep(i, n){
        int k; cin >> k;
        rep(j, k){
            int a; cin >> a;
            hanbetu[a - 1]++;
        }
    }
    int ans = 0;
    rep(i, m){
        if(hanbetu[i] == n) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
let n = Int(readLine()!)!
let devider = 1000_000_000 + 7

func powerOfTwo(num: Int, multiply: Int) -> Int {
    var result = 1
    for _ in 0..<num {
        result = (result * multiply) % devider
    }
    return result
}

let universe = powerOfTwo(num: n, multiply: 10)
let nWithoutZero = powerOfTwo(num: n, multiply: 9)
let nWithoutNine = powerOfTwo(num: n, multiply: 9)
let nWIthoutZeroAndNine = powerOfTwo(num: n, multiply: 8)

if n == 1 {
    print(0)
} else {
    let ans = (universe - nWithoutZero - nWithoutNine + nWIthoutZeroAndNine) % devider
    print((ans+devider)%devider)
}




Measured memory_bytes: 7764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int card[4][13];

int main()
{
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        char c;
        int num;
        cin >> c >> num;
        num--;
        if(c == 'S'){
            card[0][num]++;
        }else if(c == 'H'){
            card[1][num]++;
        }else if(c == 'C'){
            card[2][num]++;
        }else{
            card[3][num]++;
        }
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(card[i][j] == 0){
                if(i == 0){
                    cout << 'S' << ' ' << j+1 << endl;
                }else if(i == 1){
                    cout << 'H' << ' ' << j+1 << endl;
                }else if(i == 2){
                    cout << 'C' << ' ' << j+1 << endl;
                }else{
                    cout << 'D' << ' ' << j+1 << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 3076
A,B,C=map(int,input().split())

Ans=set()

def solve(a,b,c,ans):
  res=0
  while True:
    if a%2!=0 or b%2!=0 or c%2!=0:
      print(res)
      return
    cnt=len(ans)
    d=b//2+c//2
    e=a//2+c//2
    f=a//2+b//2
    ans.add((d,e,f))
    if len(ans)==cnt:
      print(-1)
      return
    else:
      a=d
      b=e
      c=f
      res+=1
      
solve(A,B,C,Ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<int,int> mp;
  rep(i,n){
    mp[a[i]]++;
  }
  int ans=0;
  for(auto c:mp){
    if(c.first!=c.second){
      ans+=c.second-c.first>0?c.second-c.first:c.second;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int sum =700;
		for (int i=0;i<3;i++) {
			if (s.charAt(i)=='o') {
				sum +=100;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21972
#include<stdio.h>

int n, A[50];

int main() {
  int q, m, i;
  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for(i=0; i<q; i++) {
    scanf("%d", &m);
    if(Exhaustive(0, m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int Exhaustive(int i, int m){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  
  res = Exhaustive(i+1, m) || Exhaustive(i+1, m-A[i]);
  return res;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}


inline ll count_sum(ll n, ll d) {
    ll count = (n / d);
    ll resp = (count * (count + 1) );
    resp >>= 1;
    resp *= d;
    return resp;
}

// End of template code!
int main() 
{
    buff();
    ll n;
    cin >> n;
    ll soma = n * (n + 1);
    soma >>= 1;
    
    soma -= count_sum(n, 3);
    soma -= count_sum(n, 5);
    soma += count_sum(n, 15);

    cout << soma << '\n';
    return 0;
}



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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M),cnt(N);
    rep(i, M){
        cin >> a.at(i) >> b.at(i);
        cnt.at(a.at(i)-1)++;
        cnt.at(b.at(i)-1)++;
    }
    rep(i, N) cout << cnt.at(i) << endl;

    return 0;
}


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

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

    map<pair<char, char>, int> cnt;
    for (int i = 1; i <= n; i++)
    {
        string si = to_string(i);
        pair<char, char> p = make_pair(si.front() - '0', si.back() - '0');
        cnt[p] += 1;
    }

    int64_t res = 0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            res += cnt[make_pair(i, j)] * cnt[make_pair(j, i)];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(3);
    string s,s1,s2;
    cin >> a; 
    if(a==25) cout << "Christmas" <<endl;
    else if (a==24) cout << "Christmas Eve" <<endl;
    else if (a==23) cout << "Christmas Eve Eve" <<endl;
    else cout << "Christmas Eve Eve Eve" <<endl;
    return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<vector>

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

using namespace std;

struct P{ int x,y; };

char g[500][501];

bool checkH(int x1,int x2,int y,char c){
	for(int x=x1;x<=x2;x++) if(g[y][x]!='.' && g[y][x]!=c) return false;
	return true;
}

bool checkV(int y1,int y2,int x,char c){
	for(int y=y1;y<=y2;y++) if(g[y][x]!='.' && g[y][x]!=c) return false;
	return true;
}

int main(){
	int m,n; scanf("%d%d",&m,&n);
	vector<P> pos[26];
	rep(i,m){
		scanf("%s",g[i]);
		rep(j,n) if(g[i][j]!='.') {
			 pos[g[i][j]-'A'].push_back((P){j,i});
		}
	}

	int ans=0;
	while(1){
		bool change=false;

		rep(i,26) if(pos[i].size()==2) {
			P p=pos[i][0],q=pos[i][1];

			bool ok=false;
			if(p.x!=q.x && p.y!=q.y){
				if(checkH(min(p.x,q.x),max(p.x,q.x),p.y,'A'+i)
				&& checkV(min(p.y,q.y),max(p.y,q.y),q.x,'A'+i)
				|| checkH(min(p.x,q.x),max(p.x,q.x),q.y,'A'+i)
				&& checkV(min(p.y,q.y),max(p.y,q.y),p.x,'A'+i)) ok=true;
			}
			else if(p.y==q.y){
				int mn=min(p.x,q.x),mx=max(p.x,q.x);
				if(mx-mn>1 && checkH(mn,mx,p.y,'A'+i)) ok=true;
			}
			else{ // p.x==q.x
				int mn=min(p.y,q.y),mx=max(p.y,q.y);
				if(mx-mn>1 && checkV(mn,mx,p.x,'A'+i)) ok=true;
			}

			if(ok){
				g[p.y][p.x]=g[q.y][q.x]='.';
				pos[i].erase(pos[i].begin(),pos[i].end());
				ans+=2;
				change=true;
			}
		}

		if(!change) break;
	}

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

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i,n)        for(int i=0; i<(int)(n); ++i)
#define sor(vec)        sort((vector<int>)(vec).begin(), vec.end())
#define rever(vec)     reverse((vector<int>)(vec).begin(), vec.end())
int main() {
  double  a,b,c;
  cin>>a;
  vector<int>d(a);
  rep(i,a)cin>>d.at(i);
  sort(d.begin(), d.end());
  b=d[0];
  rep(i,a-1){
    b=(b+d[i+1])/2;
  }
  cout<<b;
}

Measured memory_bytes: 256