akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1005;
int mn[N][N],mx[N][N],a[N*200],b[N*200],n,m;
vi e[N];

int vis[N];
void dfs(int u,int id,int from,int f){
	if(vis[u]||u==from)return; vis[u]=1;
	if(f)mx[from][u]=id;
	else mn[from][u]=id;
	for(auto v:e[u])
		if(!vis[v])dfs(v,id,from,f);
}

int main(){
	read(n),read(m);
	rep(i,1,m){
		read(a[i]),read(b[i]);
		e[a[i]].pb(b[i]);
	}
	rep(u,1,n){
		sort(e[u].begin(),e[u].end());
		int sz=e[u].size();
		memset(vis,0,sizeof vis);
		rep(i,0,sz-1)
			dfs(e[u][i],e[u][i],u,0);
		memset(vis,0,sizeof vis);
		per(i,sz-1,0)
			dfs(e[u][i],e[u][i],u,1);
	}
	rep(i,1,m)
		puts((!mx[b[i]][a[i]])==(mn[a[i]][b[i]]!=mx[a[i]][b[i]])
				?"diff":"same");
	return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007

        using namespace std;
         //int g[105][105];
        //vector < int > wt(100004);
       // vector < int > a;
        //vector < int > v(30500);
        //int cst[102][100005];
        //int ansr[100005];
     //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;


         /* rep(i,0,50)
          {
              if(ck[i]) cout<<i<< " o"<<endl;
              else cout<<i<<" e"<<endl;
          }*/
     bool isp( int n)
      {
          int k=sqrt(n); //cout<<k<<"K"<<endl;
          if(k*k==n) return true;
          return false;
      }

        void solve()
        {
           int  i,j=0,r=200,p,q,k=0,ans=0,d,y=0,h,flag=0,n,m=0,a,b,id,c,h1,h2,a1,b1;
           cin>>n>>d;
           vector < vector < int  > > v(n,vector < int > (d));
           rep(i,0,n)
             {
                 rep(j,0,d)
                   {
                       cin>>v[i][j];
                   }
             }
             rep(i,0,n)
                {
                    rep(j,i+1,n)
                       {   y=0;
                           rep(k,0,d)
                             {
                                 y+=((v[i][k]-v[j][k])*(v[i][k]-v[j][k]));

                             }
                            // cout<<y<<" ";
                             if(isp(y)) m++;
                             //cout<<m<<" ";
                       }
                }
      cout<<m;








        }


        int main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
          //  cin>>t;
            while(t--)
            solve();
        }

           /*

      void bfs( int i , int j)
           {
               vis[i][j]= true;
             queue < int > que;
             que.push(k);
             while(!que.empty())
             {
                int x= que.front();
                que.pop();
                 for ( int i=1;i<=n;i++)
                 {
                     if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                     {
                       if(!vis[i])
                       {
                           que.push(i);
                           level[i]=level[x]+1;
                           vis[i]= true;
                       }
                     }
                 }
             }
           }

          ll int por(ll int a,ll int b)
             {
                ll int k=1;
                while(b>0)
                {
                    if(b%2) k=k*a,k%=hell;
                    b/=2;
                    a*=a; a%=hell;
                }
                return k;
             } */


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


int main(){
  int a,b,c; cin>>a>>b;
  cout << max(a + b , max(a-b,a*b))<<endl;

    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
int main(){
    string S, T;
    cin >> S >> T;
    VL v1(26, 0), v2(26, 0);
    for(auto s : S) v1[s-'a']++;
    for(auto t : T) v2[t-'a']++;
    sort(ALL(v1));
    sort(ALL(v2));
    rep(i, 0, v1.size()){
        if(v1[i] != v2[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int kaibunsu(int n) {
    int a, b, c, d, e;
    e = n % 10;
    n /= 10;
    d = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    b = n % 10;
    n /= 10;
    a = n % 10;
    if(a == e && b == d)
        return(1);
    else
        return(0);
}
int main() {
    int A, B;
    int i;
    int sum = 0;
    cin >> A >> B;
    for(i = A;i <= B;i++) {
        sum += kaibunsu(i);
    }
    cout << sum << endl;
}


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

int main(){
	int N;
	int a[200][3];
	map<int, int> mp1, mp2, mp3;
	cin >> N;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 3; j++){
			cin >> a[i][j];
			if(j == 0) mp1[a[i][j]]++;
			if(j == 1) mp2[a[i][j]]++;
			if(j == 2) mp3[a[i][j]]++;
		}
	}
	for(int i = 0; i < N; i++){
		cout << (mp1[a[i][0]] == 1 ? a[i][0] : 0) + (mp2[a[i][1]] == 1 ? a[i][1] : 0) + (mp3[a[i][2]] == 1 ? a[i][2] : 0) << endl;
	}
	return 0;
}


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

using namespace std;

bool compare(int a, int b)
{
    if(a>b)
        return 1;
    return 0;
}

int main()
{
    int k, t, v[110];
    cin>>k>>t;
    for(int i=0; i<t; i++)
        cin>>v[i];

    sort(v, v+t, compare);

    while(k>1 && t>1)
    {
        k-=2*v[1];
        v[0] -= v[1];
        v[1] = 0;
        sort(v, v+t, compare);
        t--;
    }

    cout<<max(v[0] - 1, 0);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

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

#define M 1000010



int main(){
	IOS;
	ll n,s=0;cin>>n;
	ll a[n];rep(i,0,n){cin>>a[i];s+=a[i];}
	ll ans=inf,val=0;
	rep(i,0,n){
		val+=a[i];
		ans=min(ans,abs(s-2*val));
	}
	cout<<ans;
	
}



Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
c_nega = 0
flag = False
for i in range(n):
  if d[i] == 0:
    flag = True
    break

if flag:
  print(0)
else:
  a = 1
  for i in range(n):
    a *= d[i]
    if a > 10**18:
      flag = True
      break
  if flag:
    print(-1)
  else:
    print(a)

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

int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<int> A(N);

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.at(a - 1)++;
  }

  sort(A.rbegin(), A.rend());

  int ans = 0;

  for (int i = 0; i < N; i++) {
    if (i >= K) ans += A.at(i); 
  }

  cout << ans << "\n";
}

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

const int MOD = 998244353;
const int kMaxValue = 1000 * 1000;

int main() {
    int n; cin >> n;
    
    vector<int> f(kMaxValue + 1, 0);

    for(int i = 0; i < n; i += 1) {
        int x; cin >> x;
        f[x] += 1;
    }

    vector<int> sum(kMaxValue + 1, 0);
    
    auto add = [&] (int &a, int b) {
        a += b;
        while(a >= MOD)
            a -= MOD;
        while(a < 0)
            a += MOD;
    };

    for(int d = kMaxValue; d >= 1; d -= 1) {
        int part = 0;
        for(int i = d; i <= kMaxValue; i += d) {
            if(i > d)
                add(sum[d], -sum[i]);
            int term = 1LL * f[i] * i % MOD;
            term = 1LL * term * part % MOD;
            
            int same_value = 1LL * i * i % MOD;
            int coef = (1LL * f[i] * (f[i] - 1) / 2) % MOD;
            same_value = 1LL * same_value * coef % MOD;
            
            add(sum[d], term);
            add(sum[d], same_value);
            
                add(part, 1LL * f[i] * i % MOD);
        }    
    }
    
    vector<int> inv(kMaxValue + 1, 1);

    for(int i = 2; i <= kMaxValue; i += 1) {
        inv[i] = (MOD - 1LL * inv[MOD % i] * (MOD / i) % MOD);
    }
    
    int ans = 0;

    for(int i = 1; i <= kMaxValue; i += 1) {
        add(ans, 1LL * sum[i] * inv[i] % MOD);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 11904
# -*- coding: utf-8 -*-
"""
C - String Transformation
https://atcoder.jp/contests/abc110/tasks/abc110_c

"""
import sys

def sovle(S, T):
    st_d = dict()
    ts_d = dict()
    for s, t in zip(S, T):
        if s not in st_d:
            st_d[s] = t
        else:
            if st_d[s] != t:
                return 'No'
        if t not in ts_d:
            ts_d[t] = s
        else:
            if ts_d[t] != s:
                return 'No'
    return 'Yes'


def main(args):
    S = input()
    T = input()
    ans = sovle(S, T)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{  
  gearup;
  ll k,t; cin >> k >> t;
  vl a(t);
  rep(i,t)cin >> a[i];
  ll sum = accumulate(all(a),0LL);
  sort(all(a));
  int dif = sum - a[t-1];
  ll res;
  if(dif > a[t-1])res=0;
  else res = a[t-1] - dif - 1;
  out(res);
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  
  int ans = INT_MAX;
  for(int k=0; k<2; k++){
    int count = 0;
    for(int i=0; i<n; i++){
      if(s[i] != '0' + (i+k)%2){
        count++;
      }
    }
    ans = min(ans,count);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 512
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [[] for _ in range(N)]
for i in range(N):
    a = ri()
    l = []
    for j in range(a):
        x, y = rl()
        l.append((x, y))
    A[i] = l

answer = 0

for i in range(2 ** N):
    honest = [False] * (N+1)
    bool = True
    for j in range(N):
        if ((i >> j) & 1):
            honest[N - j] = True
    for k in range(1, N+1):
        if honest[k] == True:
            #k番目の人は正直者
            for x, y in A[k-1]:
                if y == 1 and honest[x] == False:
                    bool = False
                    break
                if y == 0 and honest[x] == True:
                    bool = False
                    break
    if bool and sum(honest) > answer:
        answer = max(answer, sum(honest))

print(answer)


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

int main()
{
    int N;
    int64_t a;
    int64_t sum = 0;
  	int64_t ans = 0;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> a;
        A.at(i) = a;
        sum = sum ^ a;
    }

    for(int i = 0; i < N; i++){
        a = A.at(i);
      	ans = sum ^ a;
        cout << ans << ' ';     
    }
    
    
}

Measured memory_bytes: 4052
#include<stdio.h>

int fibo(int);
int fi[45];
int main(){
  int n,ans;
  scanf("%d",&n);
  ans=fibo(n);
  printf("%d\n",ans);
  return 0;
}

int fibo(int a){
  if(a==0|| a==1)return 1;
  else if(fi[a]!=NULL)return fi[a];
  return fi[a]=fibo(a-1)+fibo(a-2);
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

const int inf = 1 << 30;
int H, W;
int dp[310][310];
char mat[310][310];
int ans;

int solve(int l){
    int r = l + 1;
    for(int i = 0; i <= H + 1; i++){
        for(int j = 0; j <= H + 1; j++){
            dp[i][j] = inf;
        }
    }
    for(int i = 0; i <= H; i++){//差
        for(int j = 0; j + i <= H; j++){//片割れの高さ
            if(j == 0) dp[j][j + i] = dp[j + i][j] = 0;
            //lが低い
            chmin(dp[j][j + i], dp[j - 1][j + i - 1] + (mat[j - 1][l] == mat[j + i - 1][r] ? 1 : 0));
            //rが低い
            chmin(dp[j + i][j], dp[j + i - 1][j - 1] + (mat[j + i - 1][l] == mat[j - 1][r] ? 1 : 0));
        }
    }

    for(int i = H; i >= 0; i--){
        for(int j = H; j >= 0; j--){
            if(i == H && j == H) continue;
            dp[i][j] += min(dp[i + 1][j], dp[i][j + 1]);
        }
    }
    return dp[0][0];
}


int main(){
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> mat[i][j];
        }
    }

    for(int l = 0; l + 1 < W; l++){
        ans += solve(l);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

struct edge {
  int to;
  int id;
  ll dst;
  bool operator<(const edge &another) const{
    return id < another.id;
  };
};

vector<pair<int, vector<edge>>> tree;

int main(){
  int N;
  cin >> N;
  tree.resize(N);
  vector<int> a(N-1), b(N-1);
  vector<ll> c(N-1);
  rep(i, N-1){
    cin >> a.at(i) >> b.at(i) >> c.at(i);
    a.at(i)--;
    b.at(i)--;
    tree.at(a.at(i)).first = a.at(i);
    tree.at(b.at(i)).first = b.at(i);
    tree.at(a.at(i)).second.push_back({ b.at(i), i, c.at(i) });
    tree.at(b.at(i)).second.push_back({ a.at(i), i, c.at(i) });
  }
  vector<ll> d(N, 200000000900000);
  int Q, K;
  cin >> Q >> K;
  d.at(K-1) = 0;
  vector<int> x(Q), y(Q);
  rep(i, Q){
    cin >> x.at(i) >> y.at(i);
    x.at(i)--;
    y.at(i)--;
  }
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
  pq.push(make_pair(0, K-1));
  while(!pq.empty()){
    int v = pq.top().second;
    int ds = pq.top().first;
    pq.pop();
    rep(i, sz(tree.at(v).second)) {
      if(chmin(d.at(tree.at(v).second.at(i).to), d.at(v)+tree.at(v).second.at(i).dst)){
        pq.push(make_pair(d.at(tree.at(v).second.at(i).to), tree.at(v).second.at(i).to));
      }
    }
  }
  rep(i, Q){
    cout << d.at(x.at(i)) + d.at(y.at(i)) << endl;
  }
}

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

int dp[2][2000][3000];
signed main() {
	int a, b, c;
	while (cin >> a >> b >> c, a || b || c) {
		a *= a;
		c -= a*(a + 1) / 2;
		b -= a;
		memset(dp, 0, sizeof(dp));
		dp[0][0][0] = 1;
		for (int d = 1; d <= a; d++) {
			memset(dp[d & 1], 0, sizeof(dp[d & 1]));
			for (int e = 0; e <= b; e++) {
				for (int f = 0; f <= c; f++) {
					dp[d & 1][e][f] = dp[(d + 1) & 1][e][f];
					if (e >= 1 && f >= (a - d + 1)) {
						dp[d & 1][e][f] = (dp[d & 1][e][f] + dp[d & 1][e - 1][f - (a - d + 1)])%100000;
					}
				}
			}
		}
		int sum = 0;
		for (int i = 0; i <= b; i++) {
			sum = (sum+dp[a & 1][i][c])%100000;
		}
		cout << sum << endl;
	}
}

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

typedef struct pp{
  char name[100];
  int t;
}P;

P *Q;
int head = 1, tail, n;

void enqueue(P x){
  tail++;
  if(tail >= n+1) tail = 1;
  Q[tail] = x;
}

P dequeue(){
  head++;
  if(head > n+1) head = 2;
  return Q[head-1];
}


int main(){
  int elaps = 0, c = 0;
  int i, q;
  P u;

  scanf("%d %d", &n, &q);
  tail = n;

  Q = malloc((n + 1) * sizeof(P));

  for ( i = 1; i <= n; i++){
    scanf("%s%d", Q[i].name, &Q[i].t);
  }

  i = 1;
  while(c != n){
    u = dequeue();
    if(u.t != 0){
        if(u.t > q){
            elaps += q;
            u.t -= q;
            enqueue(u);

        }else{
            elaps += u.t;
            u.t = 0;
            c++;
            printf("%s %d\n",u.name,elaps);
        }
    }
  }

  free(Q);

  return 0;
}



Measured memory_bytes: 6508
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略
 
int main(){
  int ans=0;
  int n,a,b;
  cin >> n >> a >> b;
  int temp =  (a+b)-n;
  if(temp<0){temp=0;}
  cout << a+b-max(a,b) <<" " << temp <<endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

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

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let a: i32 = read(&mut s).unwrap();
    let b: i32 = read(&mut s).unwrap();
    let aa: String = (0..b).map(|_| a.to_string()).collect::<String>();
    let bb: String = (0..a).map(|_| b.to_string()).collect::<String>();

    if aa >= bb {
        println!("{}", bb);
    } else {
        println!("{}", aa);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int N;
long long a[101010];

bool isPrime(int N)
{
  if(N<=1) return false;
  if(N==2) return true;
  if(N%2==0) return false;
  for(int i=3; i*i<=N; i+=2)
    if(N%i==0) return false;
  return true;
}

int main(){
  scanf("%d", &N);
  long long g = 0;
  for(int i=N; i>=0; --i)
  {
    scanf("%lld", a+i);
    g = __gcd(g, abs(a[i]));
  }
  int rg = g;
  vector<int> f;
  for(int i=1; i*i<=g; ++i)
  {
    if(g%i==0 && isPrime(i))
    {
      f.push_back(i);
      while(g%i==0) g /= i;
    }
  }
  if(g != 1) f.push_back(g);
  for(int i=0; i<=N; ++i) a[i] /= rg;
  for(int p=2; p<=N; ++p) if(isPrime(p) && a[0]%p == 0)
  {
    bool flag = true;
    for(int i=0; i<p-1; ++i)
    {
      long long s = 0;
      for(int j=i; j<=N; j += p-1)
        s += a[j];
      if(s%p != 0)
      {
        flag = false; break;
      }
    }
    if(flag) f.push_back(p);
  }
  sort(f.begin(), f.end());
  f.resize(unique(f.begin(), f.end())-f.begin());
  for(auto x: f) cout << x << endl;
  return 0;


}


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

count = 0

while True:
    if min(A, B, C) == C:
        C = C * 2
        count+=1
        if count==K:
            break
    if min(A, B, C) == B:
        B = B * 2
        count+=1
        if count==K:
            break
    if min(A, B, C) == A:
        C = C * 2
        count+=1
        if count==K:
            break
if C > B and B > A:
    print('Yes')
else:
    print('No')

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

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

#define ROW_MAX 6
#define COL_MAX 6
using Board = array<array<int, COL_MAX>, ROW_MAX>;

bool get_row(int row, int H, int W, unsigned int state) {
  return (state & (1 << (row + W))) != 0;
}

bool get_col(int col, int H, int W, unsigned int state) {
  return (state & (1 << (col))) != 0;
}

int count_true(int H, int W, Board &board) {
  int retv = 0;
  for (size_t row = 0; row < H; row++) {
    for (size_t col = 0; col < W; col++) {
      if (board[row][col]) {
        retv++;
      }
    }
  }
  return retv;
}

int solve(int H, int W, int K, Board &board) {
  int retv = 0;

  for (unsigned int state = 0; state < (1<<(H + W)); state++) {
    Board board_tmp = board;

    for (size_t row = 0; row < H; row++) {
      if (get_row(row, H, W, state)) {
        for (size_t i = 0; i < W; i++) {
          board_tmp[row][i] = false;
        }
      }
    }
    for (size_t col = 0; col < W; col++) {
      if (get_col(col, H, W, state)) {
        for (size_t i = 0; i < H; i++) {
          board_tmp[i][col] = false;
        }
      }
    }

    if (count_true(H, W, board_tmp) == K) {
      retv++;
    }
  }
  return retv;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H, W, K;
  cin >> H >> W >> K;

  Board board;
  for (size_t row = 0; row < H; row++) {
    string row_str;
    cin >> row_str;
    for (size_t col = 0; col < W; col++) {
      board[row][col] = (row_str[col] == '#');
    }
  }

  // main procedure
  int ans = solve(H, W, K, board);

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

using namespace std;

typedef long long LL;

struct edge {
	int to;
	int cost;
};

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n;
	cin >> n;
	vector<string>s(n);
	map<string, int>m, a, r, c, h;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i][0] == 'M') {
			m[s[i]]++;
		}
		if (s[i][0] == 'A') {
			a[s[i]]++;
		}
		if (s[i][0] == 'R') {
			r[s[i]]++;
		}
		if (s[i][0] == 'C') {
			c[s[i]]++;
		}
		if (s[i][0] == 'H') {
			h[s[i]]++;
		}
	}
	LL ans = 0;
	ans += m.size()*a.size()*r.size();
	ans += m.size()*a.size()*c.size();
	ans += m.size()*a.size()*h.size();
	ans += m.size()*r.size()*c.size();
	ans += m.size()*r.size()*h.size();
	ans += m.size()*c.size()*h.size();
	ans += a.size()*r.size()*c.size();
	ans += a.size()*r.size()*h.size();
	ans += a.size()*c.size()*h.size();
	ans += r.size()*c.size()*h.size();
	cout << ans;
	return 0;
}

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

int main() {
  int n, i, a, ans = 0, key, value;
  map<int, int> mp;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    mp[a]++;
  }
  for (auto p = mp.begin(); p != mp.end(); p++) {
    key = p->first;
    value = p->second;
    if (value < key) {
      ans += value;
    } else {
      ans += value - key;
    }
  }
  cout << ans << "\n";
  return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, A[22], B[22], C[22];
	
	cin >> N;
	
	rep(i, N){
		cin >> A[i];
		A[i]--;
	}
		
	rep(i, N)
		cin >> B[i];
		
	rep(i, N - 1)
		cin >> C[i];
		
	int ans = 0;	
		
	rep(i, N){
		ans += B[A[i]];
		if(i > 0 && A[i - 1] + 1 == A[i])
			ans += C[A[i] - 1];
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
def main():
    n=int(input())
    p=[int(i) for i in input().split(' ')]
    p_sorted = sorted(p)
    cnt = 0
    for i,j in zip(p,p_sorted):
        if i != j:
            cnt += 1
    if cnt ==2 or cnt == 0:
        print('YES')
    else:
        print('NO')
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def main():
    n = int(input())
    abc = [list(map(int, input().split())) for _ in range(n)]

    dp = [[- float('inf') for i in range(3)] for j in range(n + 1)]
    dp[0] = [0] * 3
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if (j == k):
                    continue
                dp[i + 1][k] = max(dp[i + 1][k],
                                   dp[i][j] + abc[i][k])
    print(max(dp[-1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 47332
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  ll count = 0;
  for (int i = 1; i <= N; i++) {
    if (i / 10 == 0)
      count++;
    else if (i / 100 == 0)
      continue;
    else if (i / 1000 == 0)
      count++;
    else if (i / 10000 == 0)
      continue;
    else if (i / 100000 == 0)
      count++;
  }
  cout << count << '\n';
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i];
  int f = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i == j) continue;
      if(w[i] == w[j]) f = 1;
    }
  }
  
  for(int i = 1; i < N; i++){
    if(w[i-1][w[i-1].length() - 1] != w[i][0]) f = 1;
  }
  if(f) cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 256
# abc166_c.py
'''
道でつながっている展望台のうち一番高いものを探す問題。
高さが同じ場合を考える必要があるかもしれないが、結局のところ「連結されたグラフ内で最大の値を探し出す」問題。
ということはいくつ連結グラフがあるかだけでいい…?ここがコーナーケースかな?
'''
N, M = map(int,input().split())
H = list(map(int,input().split()))
glaph = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    glaph[a-1].append(b-1) 
    glaph[b-1].append(a-1)
highest = [False for i in range(N)]
for i in range(N):
    now = H[i]
    is_highest = True
    for neiber in glaph[i]:
        # print("now is",i,"neiber is",neiber,"Hi,Hneiber",H[i] , H[neiber])
        if highest[neiber] or H[i] <= H[neiber]:
            is_highest = False
            continue
    if is_highest:
        highest[i] = True
print(highest.count(True))


Measured memory_bytes: 100320
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int k;
        cin >> k;
        string s;
        cin >> s;
        int n = s.length();
        if(n <= k){
            cout << s << '\n';
        }else{
            cout << s.substr(0, k);
            cout << "...\n";
        }
    }
}


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

char s[105],t[105];
int ns,nt;

int main(){

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

cin>>s>>t;

for(int i=0; s[i]!='\0'; ++i) ns++;
for(int i=0; t[i]!='\0'; ++i) nt++;

sort(s,s+ns);
sort(t,t+nt,greater<char>());

string ss=s;
string tt=t;

if(ss<tt) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int n,m,flag;
string str,kari;
string c;
struct DATA{
	string b,a;
};
DATA data[256];

int main(){
	while(1){
		str=kari;
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>data[i].b>>data[i].a;
		}
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>c;
			for(int j=0;j<n;j++){
				flag=0;
				if(data[j].b==c){str+=data[j].a;flag++;break;}
			}
			if(flag==0){str+=c;}
		}
		cout<<str<<endl;
	}
	return 0;
}

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

int main() {


    int a,b;
    cin>>a>>b;
    if(a==1 && b==2)
    {
        cout<<"3";
    }
    if(a==1 && b==3)
    {
        cout<<"2";
    }
    if(a==2 && b==3)
    {
        cout<<"1";
    }
    if(a==2 && b==1)
    {
        cout<<"3";
    }
    if(a==3 && b==1)
    {
        cout<<"2";
    }
    if(a==3 && b==2)
    {
        cout<<"1";
    }

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$A = explode(" ", trim(fgets(STDIN)));

$array = array_count_values($A);

for ($i = 0; $i < $N; $i++) {
  if (array_key_exists($i + 1, $array)) {
    echo $array[$i + 1] . "\n";
  } else {
    echo 0 . "\n";
  }
}

Measured memory_bytes: 37876
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
int a,b,c;
int keep = 0;
cin >> a >> b >> c;

if(a<b){
}else{
keep = a;
a = b;
b = keep;
}

if(a<c){
}else{
keep = a;
a = c;
c = keep;
}

if(b<c){
}else{
keep = b;
b = c;
c = keep;
}

cout << a << " " << b << " " << c << endl;
return 0;
}


Measured memory_bytes: 3104
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = new int[]{1,2,3};

            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var n = new int[]{a, b};

            Console.WriteLine(l.Except(n).First());
        }
    }
}


Measured memory_bytes: 13280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) {
            System.out.println("a < b");
        } else if(a == b) {
            System.out.println("a == b");
        } else {
            System.out.println("a > b");
        }
    }
}



Measured memory_bytes: 26360
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    a = list(geta(int))

    d = defaultdict(int)
    s = sum(a)
    for i in a:
        d[i] += 1

    for _ in range(gete(int)):
        b, c = geta(int)

        if b in d:
            s += (c-b) * d[b]
            d[c] += d[b]
            d[b] = 0

        print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, s;
  cin >> k >> s;

  int ans = 0;
  for(int x=0; x<=k; x++) {
    for(int y=0; y<=k; y++) {
      int z = s - (x + y);
      // cout << x << ' ' << y << ' '<< z << endl;
      ans += (0 <= z && z <= k);
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string;

long[] make_prime_sum_stream(int n) {
  int i = 2;
  long[] prime_stream = [2];
  long[] sum_stream = [2];
  int sum = 2;
  do {
  next:
    i += 1;
    for(int j = 0; prime_stream[j] * prime_stream[j] <= i; j++) {
      if ((i % prime_stream[j]) == 0) goto next;
    }
    sum += i;
    sum_stream ~= sum;
    prime_stream ~= i;
  } while(prime_stream.length <= n);
  return sum_stream;
}

void main() {
  long[] primes = make_prime_sum_stream(10000);
  for(int n; readf("%d\n", &n), n != 0;)
    writeln(primes[n - 1]);
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    cout<<char(toupper(a[0]))<<char(toupper(b[0]))<<char(toupper(c[0]))<<endl;
    return 0;
}

Measured memory_bytes: 256
# pypy

N, K = map(int, input().split())
P = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))

def do(start, k):
    score = 0
    max_score = -10 ** 10
    visited = set()
    now = start
    count = 0
    while True:
        next_node = P[now]
        if next_node in visited:
            if score <= 0:
                return max_score
            else:
                n = k // count
                score = score * (n-1)
                max_score = score
                k %= count; k += count
                for _ in range(k):
                    next_node = P[now]
                    score += C[next_node]
                    max_score = max(max_score, score)
                    now = next_node
                return max_score
        
        score += C[next_node]
        count += 1
        max_score = max(max_score, score)
        now = next_node
        visited.add(now)
        if count == k:
            return max_score

ans = -10 ** 10
for start in range(1, N+1):
    ans = max(ans, do(start, K))

print(ans)

Measured memory_bytes: 124164
using System;

namespace Main
{
  class Program
  {
    static void Main(string[] args)
    {
      var lines = Console.ReadLine().Split(' ');
      var a = int.Parse(lines[0]);
      var b = int.Parse(lines[1]);
      var k = int.Parse(lines[2]);

      if (b - a < k * 2)
      {
        for (var i = a; i <= b; i++)
          if (a <= i && i < a + k || b - k < i && i <= b)
            Console.WriteLine(i);
      }
      else
      {
        for (var i = a; i < a + k; i++)
          Console.WriteLine(i);
        for (var i = b - k+1; i <= b; i++)
          Console.WriteLine(i);
      }
    }
  }
}


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


int main() {
	
	string a, b, c;
	cin >> a >> b >> c;

	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	
	else {
		cout << "NO" << endl;
	}

	return 0;

}




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

int n;
std::vector<int> h;

void input(){
    std::cin>>n;
    h.resize(n);
    for(int i=0;i<n;i++)std::cin>>h[i];
}

int main(){
    input();
    int max = 0;
    int tmp = 0;
    for(int i=0;i<n-1;i++){
        if(h[i+1]<=h[i])tmp++;
        else tmp = 0;
        max = std::max(tmp,max);
    }
    std::cout<<max<<std::endl;

}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

bool bmap[1001] [1001];
int vmap[1001][1001];

struct P {
	int x;
	int y;
	int v;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int h, w; cin >> h >> w;
	int ch, cw; cin >> ch >> cw;
	ch--; cw--;
	int dh, dw; cin >> dh >> dw;
	dh--; dw--;

	FOR_LT(y, 0, h) {
		FOR_LT(x, 0, w) {
			char c; cin >> c;
			if (c == '#') bmap[y][x] = true;
		}
	}

	vector<P> cs;
	queue<P> s;
	cs.push_back({ cw, ch, 1 });
	s.push({ cw, ch, 1});
	vmap[ch][cw] = 1;
	do {
		while (!s.empty()) {
			P cp = s.front();
			//cout << cp.x << " " << cp.y << endl;
			s.pop();

			const int dd[4][2] = {
				{ -1, 0},
				{ 1, 0},
				{ 0, -1},
				{ 0, 1},
			};
			FOR_LT(i, 0, 4) {
				int nx = cp.x + dd[i][0];
				int ny = cp.y + dd[i][1];
				if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
				if (!bmap[ny][nx] && vmap[ny][nx] == 0) {
					vmap[ny][nx] = cp.v;
					P np = { nx, ny, cp.v };
					cs.push_back(np);
					s.push(np);
				}
			}
		}

		vector<P> ncs;
		for (auto& p : cs) {
			FOR_LE(dy, -2, 2) {
				FOR_LE(dx, -2, 2) {
					int nx = p.x + dx;
					int ny = p.y + dy;
					if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
					if (!bmap[ny][nx] && vmap[ny][nx] == 0) {
						vmap[ny][nx] = p.v + 1;
						P np = { nx, ny, p.v + 1 };
						s.push(np);
						ncs.push_back(np);
					}
				}
			}
		}
		cs = ncs;
		//cout << s.size() << endl;
	} while (!s.empty());

	int ans = vmap[dh][dw] - 1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8672
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    
    if (a > b+1){
        cout << a+(a-1);
    }
    
    else if (a+1 < b){
        cout << b+(b-1);
    }
    
    else{
        cout << a+b;
    }
    return 0;
}

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

testimony = [[] for _ in range(N)]

for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))
print(honest)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  ok = false;
  rep(i, 111)rep(j, 111) {
	if (i * 4 + j * 7 == n) ok = true;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll r;
	ll res = 0;
	cin >> r;
	cout << double(2 * r * M_PI) << endl;
	return(0);
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  int n,i;
  long long t,res;
  vector<long long> v;
  decltype(v)::iterator it;
  size_t pos;
  cin >> n;
  cin >> t;
  v.push_back(t);
  for(i=1;i<n;i++){
    cin >> t;
    v.push_back(v[i-1]+t);
  }
  t=v[n-1]/2;
  it=lower_bound(v.begin(),v.end(),t);
  pos=distance(v.begin(),it);
  t=*it;
  res=max(v[n-1]-2*t,2*t-v[n-1]);
  i=(int)pos-1;
  res=min(res,v[n-1]-2*v[i]);
  cout << res << endl;
  return 0;
}

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


int main(){

 string s;
 cin>>s;

 set<char>ani;

 for(int i=0;i<s.length();i++){
    ani.insert(s[i]);
 }

  if(ani.size() == s.length())
    cout<<"yes"<<endl;
  else
    cout<<"no"<<endl;

return 0;
}




Measured memory_bytes: 256
s=list(input())
if s[0]=='0':
  t=int(s[1])
  
else:
  t=int(''.join(s[:2]))
if s[2]=='0':
  u=int(s[3])
else:
  u=int(''.join(s[2:]))

if t>=1 and t<=12:
  if u>=1 and u<=12:
    print('AMBIGUOUS')
    
  else:
    print('MMYY')
    
else:
  if u>=1 and u<=12:
    print('YYMM')
    
  else:
    print('NA')

Measured memory_bytes: 3064
n, y = map(int, input().split(' '))

def main(n, y):
    if y > (n * 10000):
        return('-1 -1 -1')

    if y < 5000:
        if int(y / 1000) == n:
            return('0 0 ' + str(n))
        else:
            return('-1 -1 -1')
        
    elif 5000 <= y and y < 10000:
        for i in range((y // 5000) + 1):
            if (i + (y - 5000 * i) // 1000) == n:
                return('0 ' + str(i) + ' ' + str(n - i))
        
        return('-1 -1 -1')
    
    else:
        for i in range((y // 10000) + 1):
            for j in range(((y - 10000 * i) // 5000) + 1):
                if (i + j + (y - (10000 * i) - (5000 * j)) // 1000) == n:
                    return(str(i) + ' ' + str(j) + ' ' + str(n - i - j))
        
        return('-1 -1 -1')
    
print(main(n, y))

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int[] input = new int[n];

		String[] tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}

		int count = 0;

		for(int i = 1; i <= n - 2; i++){
			if((input[i] > input[i - 1] && input[i] < input[i + 1]) ||
					(input[i] < input[i - 1] && input[i] > input[i + 1])){
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 22612
import java.io.*;
import java.util.*;

public class Main {
    static BufferedReader in;

    public static void solve() throws IOException {
        int n = nextInt();
        Integer[][] games = new Integer[n][3];
        for(int i = 0;i<n;i++){
            games[i] = nextArray(3);
        }

        Integer[] dp = new Integer[3];
        dp = games[0];

        for(int i = 1;i<n;i++){
            Integer[] tmp = new Integer[3];
            Arrays.fill(tmp,-1);
            for(int k = 0;k<3;k++){
                for(int j = 0;j<3;j++){
                    if(k == j)
                        continue;

                    tmp[k] = Math.max(tmp[k], games[i][k] + dp[j]);
                }
            }

            dp = tmp;
        }

        System.out.println(Math.max(dp[0], Math.max(dp[1],dp[2])));


    }



//    static int calc(Integer[] arr , int i, int j){
//        return Math.abs(arr[i] - arr[j]);
//    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(in.readLine().trim());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(in.readLine().trim());
    }

    static Integer[] nextArray(int n) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

}



Measured memory_bytes: 52224
#include<bits/stdc++.h>
using namespace std;
int main(){
	char b;
	scanf("%c",&b);
	if(b=='A'){
		printf("T\n");
		return 0;
	}
	if(b=='T'){
		printf("A\n");
		return 0;
	}
	if(b=='G'){
		printf("C\n");
		return 0;
	}
	if(b=='C'){
		printf("G\n");
		return 0;
	}

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
  var S, T string
  fmt.Scan(fmt.Scan(&S,&T))
  correct := 0
  for i:=0; i<3; i++ {
    if S[i] == T[i] {
      correct++
    }
  }
  fmt.Println(correct)
}


Measured memory_bytes: 512