akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <iostream>
#include <set>
#include <cstring>

using namespace std;
typedef long long ll;

#define SIZE 500010
#define INF 1000000000

int term(char* &s);
int number(char* &s);
int factor(char* &s);
int expr(char* &s);

int term(char* &s){
  int res = factor(s), r;
  if(res == -INF) return res;
  while(1){
    if(*s == '*'){
      r = factor(++s);
      if(r == -INF) return r;
      res *= r;
    }else{
      break;
    }
  }
  return res;
}

int number(char* &s){
  int res = 0;

  if(!(*s)) return -INF;
  
  if(!('0' <= *s && *s <= '1')) return -INF;

  if(*s == '0' && (*(s+1) == '0' || *(s+1) == '1')) return -INF;
  
  while('0' <= *s && *s <= '1')
    res = res*2 + (*s++ - '0');

  return res;
}


int factor(char* &s){
  if(*s == ')') return -INF;
  
  if(*s == '-'){
    int r = factor(++s);
    if(r == -INF) return r;
    return r * -1;
  }
  if(*s != '(') return number(s);
  
  int res = expr(++s);
  if(*s != ')') return -INF;
  s++;
  return res;
}

int expr(char* &s) {
  int res = term(s), r;
  if(res == -INF) return res;
  while(1){
    if(*s == '+'){
      r = term(++s);
      if(r == -INF) return r;
      res += r;
    }else if(*s == '-'){
      r = term(++s);
      if(r == -INF) return r;
      res -= r;
    }else{
      if(*s == '(') return -INF;
      break;
    }
  }
  return res;
}

bool check(char *s){
  int counter = 0;
  while(*s){
    counter += (*s == '(') - (*s == ')');
    if(counter < 0) return false;
    s++;
    if(*s == ')' && (*(s+1) == '1' || *(s+1) == '0')) return false;
  }
  return counter == 0;
}

bool isop(char x){
  return x == '*' || x == '-' || x == '+' || x == '=' ||
    x == '(' || x == ')' || x == '0' || x == '1';
}

int main(){
  char s[50];
  vector<char> vec;
  map<char,int> dic;
  
  scanf("%s", s);

  for(int i=0;s[i];i++){
    if(!isop(s[i]))
      vec.push_back(s[i]);
  }

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  //for(int i=0;i<vec.size();i++) cerr << vec[i] << endl;
  
  if(vec.size() > 8){
    puts("0");
    return 0;
  }

  for(int i=0;i<vec.size();i++) dic[vec[i]] = i;

  char op[] = "01+-*()=";
  sort(op, op+8);

  int n = strlen(s);
  int ans = 0;
  
  char d[50];
  d[n] = '\0';

  set<string> ss;
  
  do{
    string r = op;
    r = r.substr(0, vec.size());
    if(ss.find(r) != ss.end()) continue;
    ss.insert(r);
    
    int eq = -1;
    
    for(int i=0;s[i];i++){
      if(isop(s[i])) d[i] = s[i];
      else d[i] = op[dic[s[i]]];

      if(d[i] == '='){
        if(eq == -1) eq = i;
        else eq = -2;
      }
    }
    
    if(eq < 0 || eq == 0 || eq == n-1) continue;
    d[eq] = '\0';
    
    char *p = d, *q = d + eq + 1;
    if(!check(p) || !check(q)) continue;
    
    int res1 = expr(p);
    int res2 = expr(q);

    //if(res1 != -INF) cerr << d << endl;
    //if(res2 != -INF) cerr << d + eq + 1 << endl;
    
    if(res1 != -INF && res1 == res2){
      ans++;
      d[eq] = '=';
    }
  }while(next_permutation(op, op+8));
 
  printf("%d\n", ans);
}



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/05/20  Problem: ARC 074 D / Link: http://arc074.contest.atcoder.jp/tasks/arc074_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----


最小カット　流れるアレ


----解説ここまで---- */

ll N;

ll ans = 0LL;

struct FordFulkerson {
#define max_flow_MAX 1005

	struct edge {
		int to, cap, rev;
		edge() {}
		edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
	};
	vector<edge> G[max_flow_MAX];
	bool used[max_flow_MAX];

	void add_edge(int from, int to, int cap) {
		G[from].emplace_back(edge(to, cap, (int)G[to].size()));
		G[to].emplace_back(edge(from, 0, (int)G[from].size() - 1));
	}

	int dfs(int v, int t, int f) {
		if (v == t)return f;
		used[v] = true;
		FOR(i, 0, (int)G[v].size()) {
			edge &e = G[v][i];
			if (!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int max_flow(int s, int t) {
		const int INF = INT_MAX;
		int flow = 0;
		for (;;) {
			memset(used, 0, sizeof(used));
			int f = dfs(s, t, INF);
			if (f == 0)return flow;
			flow += f;
		}
		return -1;
	}
#undef max_flow_MAX
};

ll W, H;
string s[102];

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

	cin >> H >> W;
	int sx, sy, tx, ty;
	FOR(i, 0, H) {
		cin >> s[i];
		FOR(j, 0, W) {
			if (s[i][j] == 'S')sx = j, sy = i;
			if (s[i][j] == 'T')tx = j, ty = i;
		}
	}
	if (sx == tx || sy == ty) {
		cout << -1 << endl;
		return 0;
	}
	FordFulkerson flow;
	int S = H + W;
	int T = H + W + 1;
	flow.add_edge(S, sy, INF);
	flow.add_edge(S, H + sx, INF);
	flow.add_edge(ty, T, INF);
	flow.add_edge(H + tx, T, INF);

	FOR(i, 0, H) {
		FOR(j, 0, W) {
			if (s[i][j] == 'o')	flow.add_edge(i, H + j, 1), flow.add_edge(H + j, i, 1);
		}
	}
	ans = flow.max_flow(S, T);
	if(ans<=INF)
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
using namespace std;

int main(){
    long long X, Y;
    cin >> X >> Y;

    long long ml = X;
    int res = 1;
    for(long long i=0;i<1000;i++){
        if(ml*2 <= Y){
            ml = ml * 2;
            res++;
        }else{
            break;
        }
    }
    cout << res << endl;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    ll ans = n;
    for (int i = 1; i < n; i++) {
        ans += (ll)(n + 1 - i) * i;
        ll u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (n + 1 - v);
    }
    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 3656
s[1<<20];main(n,i,j,a){for(;scanf("%d",&n)*n;printf("%d\n",n)){for(*s=i=0;i<n;i++)for(j=scanf("%d",&a)<<i;j--;)s[j|1<<i]=s[j]+a;i=1<<n;for(n=a=s[i-1];i--;j<n?n=j:0)j=abs(a-s[i]*2);}}

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

using namespace std;
#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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[i] == L[j] || L[j] == L[k] || L[i] == L[k])
                    continue;
                if (L[k] < L[i] + L[j]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

aa = []
for i,ai in enumerate(a):
    aa.extend([i+1] * ai)

grid = [[0]*W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if h % 2 == 0:
            grid[h][w] = aa.pop()
        else:
            grid[h][-w-1] = aa.pop()
#         print(grid)

for g in grid:
    print(*g)



Measured memory_bytes: 3956
// https: //onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_C
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

bool CheckPrimeNumber(int num)
{
    if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
        for (int i = 3; i <= sqrt((double)num); i += 2)
            if (num % i == 0) return false;

    return true;
}

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

    int n, num, cnt = 0;
    std::cin >> n;
    for (int i = 0; i < n; i++)
    {
        std::cin >> num;
        if (CheckPrimeNumber(num))
            cnt++;
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 3180
#include <iostream>

using namespace std;

int main() {
  long long n,d,ans=0;
  cin>>n>>d;
  for(int i=0;i<n;i++){
      long long x,y,val;
      cin>>x>>y;
      val = x*x + y*y;
      if(val <= d*d) ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
     char s1[100],s2[100],s3[100];
     int a,b;
     cin>>s1>>s2>>a>>b>>s3;
     if(strcmp(s1,s3)==0)
     {
         cout<<(a-1)<<" "<<b<<endl;
     }
     else
     {
         cout<<(a)<<" "<<(b-1)<<endl;
     }
     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;


int main(void) {
  int p,q,r;
  cin >> p >> q >> r;
  cout << min({p+q,p+r,q+r}) << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int h = a/3600;
		int m = (a%3600)/60;
		int s = a%60;
		
		System.out.println(h + ":" + m + ":" + s);
	}

}

Measured memory_bytes: 26240
local mmi, mma = math.min, math.max
local n, m, s = io.read("*n", "*n", "*n")
local edge = {}
for i = 1, n do
  edge[i] = {}
end
local line = {}
for i = 1, m do
  local u, v, a, b = io.read("*n", "*n", "*n", "*n")
  edge[u][v] = {a, b}
  edge[v][u] = {a, b}
  line[i] = {u, v, a, b}
end
local coin = {}
local changetime = {}
for i = 1, n do
  coin[i], changetime[i] = io.read("*n", "*n")
end
local dp = {}
for i = 1, n do
  dp[i] = {}
  for j = 1, 2501 do
    dp[i][j] = -1
  end
end
s = mmi(s, 2500)
dp[1][s + 1] = 0
local function updateCity()
  for i = 1, n do
    for j = 1, 2501 do
      if 0 <= dp[i][j] then
        local dst = mmi(2501, j + coin[i])
        if dp[i][dst] < 0 then
          dp[i][dst] = dp[i][j] + changetime[i]
        else
          dp[i][dst] = mmi(dp[i][dst], dp[i][j] + changetime[i])
        end
      end
    end
  end
end
local function moveOn()
  for il = 1, m do
    local u, v, a, b = unpack(line[il])
    for i = 1 + a, 2501 do
      if 0 <= dp[u][i] then
        if dp[v][i - a] < 0 then
          dp[v][i - a] = dp[u][i] + b
        else
          dp[v][i - a] = mmi(dp[v][i - a], dp[u][i] + b)
        end
      end
      if 0 <= dp[v][i] then
        if dp[u][i - a] < 0 then
          dp[u][i - a] = dp[v][i] + b
        else
          dp[u][i - a] = mmi(dp[u][i - a], dp[v][i] + b)
        end
      end
    end
  end
end
for i = 1, 111 do
  updateCity()
  moveOn()
end
for i = 2, n do
  local ret = -1
  for j = 1, 2501 do
    if 0 <= dp[i][j] then
      if ret < 0 then
        ret = dp[i][j]
      else
        ret = mmi(ret, dp[i][j])
      end
    end
  end
  print(ret)
end


Measured memory_bytes: 4572
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string s;
    cin >> s;
    int a, z;
    REP(i, s.length()){
        if(s[i] == 'A'){
            a = i;
            break;
        }
    }
    RREP(i, s.length()){
        if(s[i] == 'Z'){
            z = i;
            break;
        }
    }
    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
N, M = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(M)]
c = []
d = []
ans = "IMPOSSIBLE"
for i in range(M):
    if ab[i][0] == 1:
        c.append(ab[i][1])
    elif ab[i][1] == N:
        d.append(ab[i][0])
e = list(set(c + d))
if len(e) < len(c)+ len(d):
    ans = "POSSIBLE"
print(ans)
        

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	ll x;
	cin >> x;

	for(ll a = -118; a < 120 ; a++){
		for(ll b = -119; b < 119; b++){
			ll A = a*a*a*a*a;
			ll B = b*b*b*b*b;
			if(A - B == x){
				cout << a << " " << b << endl;
				return;
			} 
		}
	}

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int F[100];
int P[100][11];
int bc[1024];
int main(){
  int i, j, k, mask, res=-1073709056, tmp;
  rd(N);
  for(i=0;i<(N);i++){
    for(j=0;j<(10);j++){
      rd(k);
      if(k){
        F[i] |= (1<<j);
      }
    }
  }
  for(i=0;i<(N);i++){
    {
      int Lj4PdHRW;
      for(Lj4PdHRW=0;Lj4PdHRW<(11);Lj4PdHRW++){
        rd(P[i][Lj4PdHRW]);
      }
    }
  }
  for(mask=0;mask<(1<<10);mask++){
    for(i=0;i<(10);i++){
      if(mask & 1<<i){
        bc[mask]++;
      }
    }
  }
  for(mask=(1);mask<(1<<10);mask++){
    tmp = 0;
    for(i=0;i<(N);i++){
      tmp += P[i][bc[mask&F[i]]];
    }
    chmax(res, tmp);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// int N, F[100], P[100][11];
// 
// int bc[1024];
// {
//   int i, j, k, mask;
//   int res = -int_inf, tmp;
// 
//   rd(N);
//   rep(i,N){
//     rep(j,10){
//       rd(k);
//       if(k) F[i] |= (1<<j);
//     }
//   }
//   rep(i,N) rd(P[i](11));
// 
//   rep(mask,1<<10){
//     rep(i,10) if(mask & 1<<i) bc[mask]++;
//   }
// 
//   rep(mask,1,1<<10){
//     tmp = 0;
//     rep(i,N) tmp += P[i][bc[mask&F[i]]];
//     res >?= tmp;
//   }
// 
//   wt(res);
// }


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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int i = 1;
    int ans = 0;
    while(y*i+z*(i+1) <= x) {
        ans++;
        i++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int i, j;
	int h, w;

	while (1) {
		scanf("%d %d", &h, &w);
		if (!(h||w))break;
		for (i = 0; i < h; i++) {
			if (i == 0 || i == h - 1)for (j = 0; j < w; j++)printf("#");
			else {
				printf("#");
				for (j = 1; j < w - 1; j++)printf(".");
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;

}

Measured memory_bytes: 2528
#include<stdio.h>

int main(){

 int a, b;

 scanf("%d %d", &a, &b);

 if(a < b){
  printf("a < b\n");
 }

 else if(a > b){
  printf("a > b\n");
 }

 else{
  printf("a == b\n");
 }

 return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int N;

int main(void){
    int x, y, ok, cnt;
    while(scanf("%d", &N) && N){
        ok = cnt = 0;
        for(x = 0; x < N; x++){
            scanf("%d", &y);
            if(y > 0) ++cnt;
            if(y > 1) ok = 1;
        }
        if(!ok){
            puts("NA");
        }else{
            printf("%d\n", cnt+1);
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int a, b, c;
string str;

void solve() {
    cin >> a >> b >> c;
    if (a <= 30) {
        cout << str << " " << a << " " << b << " " << c << endl;
    } else if (a > 31) {
        cout << "? " << a-30 << " " << b << " " << c << endl;
    } else {
        if (b <= 4) {
            cout << str << " " << a << " " << b << " " << c << endl;
        } else {
            cout << "? " << a-30 << " " << b << " " << c << endl;
        }
    }
}

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
    cout.precision(20);
    cerr << fixed;
    cerr.precision(6);
#ifdef LOCAL
    //freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif  
    while (cin >> str) {
        if (str == "#") break;
        solve();
    }
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}



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


int main(){
	int n, W; cin >> n >> W;
	long long dp[n+10][W+10];
	int w[n+10];
	int v[n+10];

	w[0] = 0;
	v[0] = 0;
	for(int i = 1; i < n+1; i++){
		int a,b;
		cin >> a >> b;
		w[i] = a;
		v[i] = b;
	}

	for(int i = 0; i < n+1; i++){
		for(int j = 0; j < W+1; j++){
			if(i == 0){
				dp[i][j] = 0;
			}else{
				if(j - w[i] < 0 )dp[i][j] = dp[i-1][j];
				else dp[i][j] = max(dp[i-1][j - w[i]] + v[i], dp[i-1][j]);
			}
		}
	}
	cout << dp[n][W] << endl; 

}

Measured memory_bytes: 80000
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


# --------------------------------------------

dp = None


def main():
    print("ABC" + input())


main()


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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define SORTA(v,n) sort(v, v + n)
#define SZ(v) (int) v.size()
#define sc(x) scanf("%d",&x)

void open(){
	freopen("D:/Code/in.txt","r",stdin);
	freopen("D:/Code/out.txt", "w", stdout);
}

int main(void){
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll arr[100010];
	FOR(i,n){
		cin >> arr[i];
	}

	sort(arr, arr + n);
	ll tot[100010];
	tot[0] = arr[0];

	for(int i = 1;i<n;i++){
		tot[i] = tot[i-1] + arr[i];
	}
	int bs = 1;
	for(int i = n-2;i>=0;i--){
		if(tot[i] * 2 < arr[i+1]){
			break;
		}
		bs++;
	}

	cout << bs;

    return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
  string S; cin >> S;
  
  stack<char> s;
  for(int i = 0; i < S.length(); i++) {
    char c = S[i];
    if (!s.empty() && c != s.top()) {
      s.pop();
    } else {
      s.push(c);
    }
  }

  cout << S.length() - s.size() << endl;
  return 0;
}


Measured memory_bytes: 512
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;

int v[201][201];

void upd2(int i, int x) {
  for(; x <= 200; x += (x & -x))
    v[i][x]++;
}

int get2(int i, int x) {
  int sum = 0;
  for(; x; x -= (x & -x))
    sum += v[i][x];
  return sum;
}

void upd(int i, int x) {
  for(; i <= 200; i += (i & -i))
    upd2(i, x);
}

int get(int i, int y, int x) {
  int sum = 0;
  for(; i; i -=(i & -i))
    sum += get2(i, y) - get2(i, x - 1);
  return sum;
}

void solve() {
  int n, ans = 0;
  cin >> n;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int x = 0, a = 0, b = 0;
    for(int i = 0; i < s.size(); i++) {
      if(s[i] == '.') {
        for(int j = i + 1; j < s.size(); j++)
          x = x * 10 + s[j] - '0';
        a = b = - s.size() + 1 + i;
        break;
      }
      x = x * 10 + s[i] - '0';
    }
    while(x % 2 == 0) {
      a++;
      x /= 2;
    }
    while(x % 5 == 0) {
      b++;
      x /= 5;
    }
    ans += get(200, 200, 100 - b) - get(99 - a, 200, 100 - b);
    upd(a + 100, b + 100);
  }
  cout << ans << "\n";
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll d,g;
    cin>>d>>g;
    g/=100;
    ll p[d+5],c[d+5];
    for(int a=0;a<d;a++){
        cin>>p[a]>>c[a];
        c[a]/=100;
    }
    ll ans=INT_MAX;
    for(ll a=0;a<(1<<d);a++){
        ll sum=0,last,jwb=0;
        for(ll b=0;b<d;b++){
            if(a&(1<<b)){

                jwb+=p[b];
                sum=sum+(b+1)*p[b]+c[b];//cout<<sum<<endl;
            }
            else last=b;
        }
        int cnt=0;
        while(sum<g){
            sum+=(last+1);
            cnt++;
            jwb++;
            if(cnt>=p[last]) break;
        }
        if(sum<g) continue;
        else{
            //cout<<a<<" "<<sum<<" "<<jwb<<" "<<last<<endl;
            //printf("%lld %lld %lld %lld\n",a,sum,jwb,last);
            ans=min(ans,jwb);
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
def siritori(N, W):
    if len(set(W)) < N:
        return False

    for i in range(N-1):
        word = W[i]
        following_word = W[i+1]

        if word[-1] != following_word[0]:
            return False

    return True

N = int(input())
W = [input() for i in range(N)]

if siritori(N, W):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n = int(input())
a = [[int(x) for x in input().split()] for _ in range(2)]
res = 0
for i in range(n):
    cnt = 0
    for j in range(n):
        if j < i:
            cnt += a[0][j]
        else:
            cnt += a[1][j]
    cnt += a[0][i]
    res = max(res, cnt)
print(res)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static int K;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
        System.out.println( solve() );
    }

    private static long solve() {
        // うまく消化できないので別途処理してる
        // (a,b) = (n,n) to (1,1) で全部成立する
        if( K == 0 ) return (long)N * N;

        // a = bq + r
        // r >= Kとなる場合のbにのみ興味がある
        // ということで、K+1 <= b <= N について調べる
        long ans = 0;
        for (int b = K+1; b <= N; b++) {
            // a=1 -> r=1
            // a=2 -> r=2
            // a=b-1 -> r=b-1
            // a=b -> r=0
            // a=b+1 -> r=1
            // a=2b -> r=0
            // a=qb+r -> r=r
            // というような感じで循環するっぽい

            // (b-1から1までの間でKより大きくなる数) = K to (b-1) = (b-K)
            // (rから1までの数でKより大きくなる数) = K to r = r - K + 1(マイナスにはならない)
            int q = N / b;
            int r = N % b;

            ans += q*(b-K) + Math.max(0,(r-K+1));
        }
        return ans;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

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

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S;
    cin >> S;
    bool ok = 0;
    string k = "keyence";
    REP(i,8){
        if(S.substr(0,i) == k.substr(0,i) && S.substr(S.size()-7+i) == k.substr(i))ok = 1;
    }
    cout << (ok ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,a[110][2],ans;
int read()
{
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i][0]=read();
	for(int i=1;i<=n;i++)
		a[i][1]=read();
	for(int i=1;i<=n;i++)
		a[i][0]+=a[i-1][0];
	for(int i=n;i;i--)
		a[i][1]+=a[i+1][1];
	for(int i=1;i<=n;i++)
		ans=max(ans,a[i][0]+a[i][1]);
	printf("%d",ans);				
	return 0;
}

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

int main()
{
    double x1,x2,y1,y2,d;
	cin>>x1>>y1>>x2>>y2;
	d=sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
	//cout<<d<<endl;
	printf("%10f\n",d);
    return 0;
}

Measured memory_bytes: 1244
import sys

readline = sys.stdin.buffer.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, v = map(int, readline().split())
    b, w = map(int, readline().split())
    t = int(input())

    dist = abs(b - a)
    vel = v - w

    if vel * t >= dist:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61700
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    string n;
    cin >> n;
    int N = 0;
    REP(i, n.size()) N += (n[i] - '0');
    int M = ((int)n[0] - (int)'0' - 1) + ((n.size() - 1) * 9);
    cout << max(N, M) << endl;;//入力値か, 最大桁数を1減らしてからそれより一桁下全ての桁を9とした場合
    return 0;
}

Measured memory_bytes: 256
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, ary, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < #ary do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, #ary do self.stage[stagenum][i] = ary[i] end
  for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local tasks = {{start_stage, left, right}}
  while 0 < #tasks do
    local task = tasks[#tasks]
    table.remove(tasks)
    local stage, l, r = task[1], task[2], task[3]
    if (l - 1) % self.size[stage] ~= 0 then
      local newr = mce((l - 1) / self.size[stage]) * self.size[stage]
      table.insert(tasks, {stage + 1, l, mmi(r, newr)})
      l = newr + 1
    end
    if self.size[stage] <= r + 1 - l then
      local pos = mce(l / self.size[stage])
      ret = self.func(ret, self.stage[stage][pos])
      l = l + self.size[stage]
    end
    if l <= r then
      table.insert(tasks, {stage + 1, l, r})
    end
  end
  return ret
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(ary, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(ary, func, emptyvalue)
  return obj
end
local function getgcd(x, y)
  while 0 < x do
    x, y = y % x, x
  end
  return y
end
local n = io.read("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
local mma = math.max
local st = SegTree.new(a, function(x, y) return getgcd(x, y) end, 0)
local ret = 1
for i = 1, n do
  local tmp = a[i]
  st:setValue(i, 0)
  ret = mma(ret, st:getRange(1, n))
  st:setValue(i, tmp)
end
print(ret)


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

using namespace std;
#define maxn 100000+5
int arr[maxn];
int d[maxn];
int main(void)
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>arr[i];
  d[0]=0;
  d[1]=0;
  d[2]=abs(arr[1]-arr[2]);
  for(int i=3;i<=n;i++){
    d[i]=min(d[i-1]+abs(arr[i]-arr[i-1]),d[i-2]+abs(arr[i]-arr[i-2]));
  }
  cout<<d[n];
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            int[] W = ReadIntArray();
            int sum = W.Sum();

            int ans = sum;
            int current = sum;
            for (int i = 0; i < W.Length; i++)
            {
                current -= W[i];
                ans = Min(ans, Abs(current - (sum - current)));
            }

            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

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

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	for (int i = 0; h > i; i++) {
		for (int j = 0; w > j; j++) cout << ((i < b) ^ (j < a));
		cout << endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 200005, M = 100005, mod = 998244353 , mxLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(6), cout << fixed;

    int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << '\n';
    } else {
        cout << b - a << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#include <stdlib.h>
#include <vector>
#define pi acos(-1)
#define MOD 1000000007
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
///s1.substr(1,3);///STARTING FROM INDEX 1, 3 LNEGTH SUBSTRING.
///s1.find("adn")///RETURNS STARTING INDEX OF THE SUBSTRING
///"adn" IF IT EXISTS IN THE STRING S1.///
///s1.find("adn",int pos);///RETURNS STARTING INDEX OF THE
///SUBSTRING "adn" SEARCHING FROM INDEX POS OF STRING s1.///
///string::npos returns a garbage value if not found...
///reverse(s1.begin(),s1.end())-> to reverse a string.
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd(a,b)
using namespace std;



//vector<int>prime(8000000,0);
vector<bool>mark(100000000,false);
int prime[8000000];
int nprime;

void sieve(int n)
{
    int limit=sqrt(n*1.0)+1,s=0;nprime=0;
    mark[1]=true;///1 if not prime.
    mark[2]=false;prime[nprime++]=2;//cout<<2<<endl;
    for(int i=4;i<=n;i+=2)mark[i]=true;
    for(int i=3;i<=n;i+=2){
        if(!mark[i]){prime[nprime++]=i;//cout<<i<<endl;
        if(i<=limit){///karon limit er upor theke n porjonto not prime gula already cuta hoise.
            for(int j=i*i;j<=n;j+=i*2){
                mark[j]=true;
            }
          }
        }
    }
    //puts("2");
    //cout<<nprime<<endl;
    for(int i=1;i<=nprime;i+=100)cout<<prime[i-1]<<endl;
    //return nprime;
}
ll l1[200005],l2[100005];
int main()
{
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    ll t,i,q,n,k,l,c,d,p,nl,np,a,e,m,b=0,x1=1000000005,x3=0,x4=0,x5=0,x6=0;
    //double x10=0;
    //string s2,s3,s4,s5,s6,s7;
    map<ll,ll>m1,m2;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l1[i];
    }
    for(int i=1;i<=n;i++){
        x1=min(x1,l1[i]);
        if(x1==l1[i])b++;
    }
    cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 15744
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
res = 0
res += B[A[0]-1]
for i in range(1, N):
    res += B[A[i]-1]
    if A[i - 1] == A[i] - 1:
        res += C[A[i - 1]-1]

print(res)

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n;
int a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ForE(i, 2, n){
        int x; cin >> x; a[x]++;
    }
    PrintA(a, 1, n);
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int a,b; cin>>a>>b;
    cout<<max(0,a-b*2)<<endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input().strip())
    s_dict = {"AC": 0,
              "WA": 0,
              "TLE": 0,
              "RE": 0}

    for i in range(n):
        s = input().strip()
        s_dict[s] += 1
    print("AC x {}".format(s_dict["AC"]))
    print("WA x {}".format(s_dict["WA"]))
    print("TLE x {}".format(s_dict["TLE"]))
    print("RE x {}".format(s_dict["RE"]))


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

vector<ll> hp;
int n;
ll a, b;
//t回で倒せるか
bool enough(ll t){
  ll cnt = 0;
  ll bigger_count  = 0;
  rep(i,n){
    if(hp[i] - b * t >0){
      bigger_count++;
    }
  }
  rep(i,bigger_count){
    ll rest = hp[i] - b * t;
    if(rest % (a-b) != 0){
      cnt += rest / (a - b) + 1;
    }else {
      cnt += rest / (a - b);
    }
  }
  if(cnt <= t){
    return true;
  }else {
    return false;
  }
}

int main() {
  cin >> n >> a >> b;
  hp.assign(n, 0);
  rep(i, n) cin >> hp[i];
  sort(hp.begin(), hp.end(), greater<ll>());
  ll high = 1000000010;
  ll low = 0;
  ll ans = 0;
  while(high - low > 0){
    ll mid = (high + low) / 2;
    if(high - low == 1){
      if(enough(mid)) ans = low;
      else ans = low + 1;
      break;
    }
    if(enough(mid)){
      high = mid;
    }else {
      low = mid;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;

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>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    int N;cin>>N;
    vector<int> a(N);
    cin>>a;
    int res=0;
    for(int i=0;i<N;i++)
        if(a[a[i]-1]-1==i)res++;
    cout<<res/2<<endl;
    return 0;
}


Measured memory_bytes: 640
X, N = map(int, input().split())
p = list(map(int, input().split()))

d = {i: 1 for i in p}
idx = X
while True:
    if d.get(idx) is None:
        ans_plus = idx
        break
    else:
        idx += 1

idx = X
while True:
    if d.get(idx) is None:
        ans_minus = idx
        break
    else:
        idx -= 1

if abs(X - ans_plus) < abs(X - ans_minus):
    print(ans_plus)
else:
    print(ans_minus)

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

int main() {
	int a[] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x,y;cin >> x >> y;
	if(a[x]==a[y])cout << "Yes"  << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256