akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int Q; scanf("%d", &Q);


  int upper = 1e5;
  vector<int> primes(upper + 5, 1);
  primes[0] = primes[1] = 0;
  for (int i = 2; i * i <= upper; ++i) {
    if (not primes[i]) { continue; }
    for (int j = i * i; j <= upper; j += i) {
      primes[j] = 0;
    }
  }
  vector<int> sims(upper + 5, 0);
  for (int i = 3; i <= upper; i += 2) {
    if (primes[i] and primes[(i + 1) / 2]) {
      sims[i] = 1;
    }
  }
  for (int i = 1; i <= upper; ++i) {
    sims[i] += sims[i - 1];
  }

  while (Q-- > 0) {
    int l, r; scanf("%d %d", &l, &r);
    printf("%d\n", sims[r] - sims[l - 1]);
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#define eb emplace_back
#define mp make_pair
using namespace std;

const int inf = 1000000007;
vector < int > g[100010];
int dist[100010],outgoing[100010];
void dijk(int s) {
  multiset < pair< int,int> > q;
  dist[s] = 0;
  q.insert(mp(dist[s],s));
  while (!q.empty()) {
    pair <int,int> p = *q.begin();
    int d = p.first;
    int u = p.second;
    q.erase(q.begin());
    for (auto v: g[u]) {
      if ( d + 1 < dist[v]) {
        dist[v] = d + 1;
        outgoing[v] = u;
        q.insert(mp(dist[v],v));
      }
    }
  }
}
int main() {
  int n,m; cin >> n >> m;
  for (int i=0; i<m; i++) {
    int u,v; cin >> u >> v;
    g[u].eb(v);
    g[v].eb(u);
  }
  for (int i=1; i<=n; i++) dist[i] = inf;
  dijk(1);
  // for (int i=1; i<=n; i++) cout << dist[i] << " "; cout << endl;
  for (int i=1; i<=n; i++) {
    if (dist[i] == inf) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i=2; i<=n; i++) {
    cout << outgoing[i] << endl;
  }
}
  

Measured memory_bytes: 14444
//Code Author:-code_kika //
//Institution:-IIT(BHU)  //
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
	
using namespace std;

//io
#define sf(x) scanf("%d",&x);
#define sf2(x,y) scanf("%d %d",&x,&y);
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d",x,y);
#define pf3(x,y,z) printf("%d %d %d",x,y,z);
#define sfl(x) scanf("%lld",&x);
#define sfl2(x,y) scanf("%lld %lld",&x,&y);
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);
#define pfl(x) printf("%lld",x);
#define pfl2(x,y) printf("%lld %lld",x,y);
#define pfl3(x,y,z) printf("%lld %lld %lld",x,y,z);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//basic
#define pb push_back
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007LL

//typedefs
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vll vector<ll>
#define vi vector<int>

//functions
#define all(c) c.begin(),c.end()
#define fill(c,val) memset(c,val,sizeof(c))

//debug
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
} 
int main(){
	ll n,m,i;
	string s,t;
	cin>>n>>m>>s>>t;
	ll p=(n*m)/gcd(n,m);
	ll q=p/n;
	ll r=p/m;
	map<ll,char> ma;
	for(i=0;i<n;i++){
		ma[q*i]=s[i];
	}
	for(i=0;i<m;i++){
		if(ma.find(r*i)!=ma.end()){
			//trace3(i,ma[r*i],r*i);
			if(ma[r*i]!=t[i]){
				cout<<"-1";
				return 0;
			}
		}
	}
	cout<<p;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <iostream>
#include <algorithm>

#define MAX_STATIONS 100+1
#define INF 1<<15

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



using namespace std;

class Stations{
private:
    int time[MAX_STATIONS][MAX_STATIONS];
    int cost[MAX_STATIONS][MAX_STATIONS];
public:
    void solve(int a[MAX_STATIONS][MAX_STATIONS], int r){
        //wayは文系をあらわす
        rep(way,MAX_STATIONS){
            rep(to,MAX_STATIONS){
                rep(from,MAX_STATIONS){
                    a[from][to] = min(a[from][to], a[from][way] + a[way][to]);
                    a[to][from] = a[from][to];
                }
            }
        }
        if(r==1){
            rep(i,MAX_STATIONS){
                rep(k,MAX_STATIONS){
                    time[k][i] = a[k][i];
                }
            }
        }
        else{
            rep(i,MAX_STATIONS){
                rep(k,MAX_STATIONS){
                    cost[k][i] = a[k][i];
                }
            }
        }
    }

    int getTime(int from, int to){
        return time[from][to];
    }

    int getCost(int from, int to){
        return cost[from][to];
    }
};

int main(void){
    int n,m;
    int t[MAX_STATIONS][MAX_STATIONS], c[MAX_STATIONS][MAX_STATIONS];
    while(cin >> n >> m,n+m){
        rep(i,MAX_STATIONS){
            rep(k,MAX_STATIONS){
                t[i][k] = INF;
                c[i][k] = INF;
            }
        }

        rep(i,n){
            int from,to,cost,time;
            cin >> from >> to >> cost >> time;
            t[from][to] = t[to][from] = time;
            c[from][to] = c[to][from] = cost;
        }

        Stations station;
        station.solve(c,0);
        station.solve(t,1);

        int q;
        cin >> q;

        rep(i,q){
            int from,to,r;
            cin >> from >> to >> r;
            if(r==1){
                cout << station.getTime(from,to) << endl;
            }else{
                cout << station.getCost(from,to) << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1316
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, X[int(1e5 + 5)];
int Count[int(1e5 + 5)], Same[int(1e5 + 5)];

int main(){
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> X[i];
  sort(X, X + N);

  int cnt = 1;
  for (int i = 0; i < N; i++){
    if (X[i] == X[i + 1]){
      cnt++;
      continue;
    }
    Count[X[i] % M] += cnt;
    Same[X[i] % M] += cnt / 2;
    cnt = 1;
  }

  int ans = Count[0] / 2;
  if (M % 2 == 0) ans += Count[M / 2] / 2;

  for (int i = 1; i < (M + 1) / 2; i++){
    int now = 0;
    for (int a = 0; a <= Same[i]; a++){
      for (int b = 0; b <= Same[M - i]; b++){
        now = max(now, min(Count[i] - 2 * a, Count[M - i] - 2 * b) + a + b);
      }
    }
    ans += now;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4784
#include<iostream>
#include<string>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<cassert>
using namespace std;


bool allsame(string s){
  char c=s[0];
  for(int i=0;i<s.size();i++){
    if(s[i]!=c)return 0;
  }
  return 1;
}

string toSortString(int n){
  string res="0000";
  int tmp[4]={0,0,0,0};
  for(int i=0;n!=0;i++){
    tmp[i]=n%10;
    n/=10;
  }
  for(int i=0;i<4;i++){
    res[i]=tmp[i]+'0';
  }
  sort(res.begin(),res.end());
  return res;
}

int make_l(string s){
  int res=0;
  for(int i=0;i<s.size();i++){
    res+=(s[i]-'0')*pow(double(10),i);
  }
  return res;
}

int make_s(string s){
  int res=0;
  for(int i=0;i<s.size();i++){
    res+=(s[s.size()-1-i]-'0')*pow(double(10),i);
  }
  return res;
}

int main(){
  int n;
  int ans=0;
  while(cin>>n,n!=0){
    ans=0;
    while(n!=6174){
      string tmp_n=toSortString(n);
      if(allsame(tmp_n)){
        cout<<"NA"<<endl;
        break;
      }
      ans++;
      int l,s;
      l=make_l(tmp_n);
      s=make_s(tmp_n);
      n=l-s;
      assert(ans<100);
    }
    if(n==6174){
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 1228
/***  بسم الله الرحمن ا لرحيم   ***/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl                         '\n'
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define test int t;cin>>t;while(t--)
const int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 2e5 + 5, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y)) * y); }
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int n,m;
vector<vector<int>>g;
int vis[N];
int dfs(int u) {
	if (vis[u] == -1) {
		vis[u] = 0;
		for (auto t : g[u]) {
			vis[u] = max(vis[u], dfs(t) + 1);
		}
	}
	return vis[u];

}
void solve() {
	cin >> n >> m;
	g = vector<vector<int>>(n + 1);
	int x, y; 
	for (int i = 1; i <= m; i++) {
		cin >> x >> y;
		g[x].push_back(y);
	}
	mem(vis, -1);
	int mx = 0;
	for (int i = 1; i <= n; i++) {
		mx = max(mx, dfs(i));
	}
	cout << mx;

}
int main() {
	file();
   
      solve();
    

	return 0;
}

Measured memory_bytes: 11508
n = int(input())
a = list(map(int,input().split()))

flag = True

for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 != 0 and a[i]%5 != 0:
            flag = False

if flag:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();

    let q: Vec<i32> = buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let (a, b, c, d) = (q[0], q[1], q[2], q[3]);

    if a + b > c + d {
        println!("Left");
    } else if a + b == c + d {
        println!("Balanced");
    } else {
        println!("Right");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,*a=map(int,open(0).read().split());b=[s//400for s in a if s<3200];c=len(set(b));print(c or 1,n-len(b)+c)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	string A,B;
  	cin >> A >> B;
	string s="EQUAL";
	if(A.length()>B.length()) s="GREATER";
  	else if(A.length()<B.length()) s="LESS";
  	else{
		REP(i,A.length()){
			if(A[i]>B[i]){s="GREATER"; break; }
          	else if(A[i]<B[i]){s="LESS"; break;}
          	else continue;
        }
    }
  	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
kosu = B - A + 1

amari_sita1 = A % C
sho_sita1 = A // C
amari_sita2 = A % D
sho_sita2 = A // D
amari_ue1 = B % C
sho_ue1 = B // C
amari_ue2 = B % D
sho_ue2 = B // D

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
kobaisu = lcm(C,D)
amari_sita3 = A % kobaisu
sho_sita3 = A // kobaisu
amari_ue3 = B % kobaisu
sho_ue3 = B // kobaisu

CD_warikirerukosu = sho_ue3 - sho_sita3
if amari_sita3 == 0:
    CD_warikirerukosu +=1

C_warikirerukosu = sho_ue1 - sho_sita1
if amari_sita1 == 0:
   C_warikirerukosu +=1

D_warikirerukosu = sho_ue2 - sho_sita2
if amari_sita2 == 0:
    D_warikirerukosu +=1


print(kosu - (C_warikirerukosu + D_warikirerukosu) + CD_warikirerukosu)

Measured memory_bytes: 5048
S = input()
N = len(S)

right = []
left = []

for i, s in enumerate(S):
    if s == "R":
        right.append(i)
    else:
        left.append(i)

acc_r = [-1] * N
acc_l = [-1] *N

for i in range(len(left)-1, 0, -1):
    l = left[i]
    l2 = left[i-1]
    for j in range(l2, l+1):
        acc_r[j] = l

for i in range(N):
    if acc_r[i] == -1:
        acc_r[i] = left[0]

for i in range(len(right) - 1):
    r = right[i]
    r2 = right[i+1]
    for j in range(r, r2+1):
        acc_l[j] = r

for i in range(N):
    if acc_l[i] == -1:
        acc_l[i] = right[-1]


ans = [0] * N

for i, s in enumerate(S):
    if s == "R":
        tar = acc_r[i]
        if (tar - i) % 2 == 0:
            ans[tar] += 1
        else:
            ans[tar-1] += 1
    else:
        tar = acc_l[i]
        if (tar - i) % 2 == 0:
            ans[tar] += 1
        else:
            ans[tar + 1] += 1

for a in ans:
    print(a, end=" ")


Measured memory_bytes: 10368
#include <stdio.h>

int main(void)
{
    int i, j;
    int a[4], b[4];
    int h, l;

    while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) {
        scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
        h = 0;
        l = 0;

        for (i = 0; i < 4; i++) {
            for (j = 0; j < 4; j++) {
                if (a[i] == b[j]) {
                    if (i == j) {
                        h++;
                    } else {
                        l++;
                    }
                }
            }
        }

        printf("%d %d\n", h, l);
    }

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[1010][1010];

int main(){
  int h,w;
  cin>>h>>w;
  char a[h+1][w+1];
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>a[i][j];
    }
  }

  dp[1][1]=1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(i<h&&a[i+1][j]=='.') dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
      if(j<w&&a[i][j+1]=='.') dp[i][j+1]=(dp[i][j+1]+dp[i][j])%MOD;
    }
  }

  cout<<dp[h][w]<<endl;


  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 160090;

int par[MAX_N], Rank[MAX_N], size[MAX_N];
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        Rank[i] = 0;
        size[i] = 1;
    }
}
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (Rank[x] < Rank[y])
    {
        par[x] = y;
        size[y] += size[x];
    }
    else
    {
        par[y] = x;
        size[x] += size[y];
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}
int main()
{
    int H, W;
    cin >> H >> W;
    string S[H];
    init(MAX_N);
    for (int i = 0; i < H; i++)
    {
        cin >> S[i];
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                int nx = i + dx[k];
                int ny = j + dy[k];
                if (0 <= nx && nx < H && 0 <= ny && ny < W)
                {
                    if (S[i][j] != S[nx][ny])
                    {
                        unite(i * W + j, nx * W + ny);
                    }
                }
            }
        }
    }
    map<long long, long long> white;
    map<long long, long long> black;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (S[i][j] == '#')
            {
                white[find(i * W + j)]++;
            }
            else
            {
                black[find(i * W + j)]++;
            }
        }
    }
    long long sum = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            sum += white[i * W + j] * black[i * W + j];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 22400
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int m=0;
            if(b>=1&&b<=9)
               m=a*10+b;
            else if(b>=10&&b<=99){
                m=a*100+b;
            }
            else if(b==100)
                m=a*1000+b;
//            System.out.println(m);
//            System.out.println(Math.sqrt(m));
            if((int)Math.sqrt(m)*(int)Math.sqrt(m)==m){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }


        }
        
    }
    



Measured memory_bytes: 23124
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k;
  int 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(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
struct graph{
  int N;
  int *es;
  int **edge;
  void setEdge(int N__, int M, int A[], int B[], void **mem = &wmem){
    int i;
    N = N__;
    walloc1d(&es, N, mem);
    walloc1d(&edge, N, mem);
    for(i=(0);i<(N);i++){
      es[i] = 0;
    }
    for(i=(0);i<(M);i++){
      es[A[i]]++;
      es[B[i]]++;
    }
    for(i=(0);i<(N);i++){
      walloc1d(&edge[i], es[i], mem);
    }
    for(i=(0);i<(N);i++){
      es[i] = 0;
    }
    for(i=(0);i<(M);i++){
      edge[A[i]][es[A[i]]++] = B[i];
      edge[B[i]][es[B[i]]++] = A[i];
    }
  }
  void getDist(int root, int res[], void *mem = wmem){
    int i;
    int j;
    int k;
    int*q;
    int s;
    int z;
    walloc1d(&q, N, &mem);
    for(i=(0);i<(N);i++){
      res[i]=-1;
    }
    res[root]=0;
    s=0;
    z=1;
    q[0]=root;
    while(z){
      i=q[s++];
      z--;
      for(j=(0);j<(es[i]);j++){
        k=edge[i][j];
        if(res[k]>=0){
          continue;
        }
        res[k]=res[i]+1;
        q[s+z++]=k;
      }
    }
  }
}
;
int N;
int A[100000];
int B[100000];
int d1[100000];
int d2[100000];
int main(){
  int i;
  wmem = memarr;
  int res = 0;
  graph g;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N-1);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
    }
  }
  g.setEdge(N,N-1,A,B);
  g.getDist(0,d1);
  g.getDist(N-1,d2);
  for(i=(0);i<(N);i++){
    if(d1[i] <= d2[i]){
      res++;
    }
    else{
      res--;
    }
  }
  if(res>0){
    wt_L("Fennec");
    wt_L('\n');
  }
  else{
    wt_L("Snuke");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// int N, A[1d5], B[1d5];
// int d1[1d5], d2[1d5];
// {
//   int res = 0;
//   graph g;
//   rd(N,(A--,B--)(N-1));
//   g.setEdge(N,N-1,A,B);
//   g.getDist(0,d1);
//   g.getDist(N-1,d2);
//   rep(i,N) if[d1[i] <= d2[i], res++, res--];
//   wt( if[res>0, "Fennec", "Snuke"] );
// }


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

int main() {
  int N;
  cin >> N;
  vector <int> house (N) ;
  
  for (int i = 0;i<N; i++) cin >> house.at(i);
  sort (house.begin(),house.end());
  
  int a;
  int min_cost = 0;
  for (int i = house.at(0); i < house.at(N-1); i ++){
    int cost = 0;
    
    for (int j = 0; j < N; j ++){
      a = house.at(j) - i;
      cost += a*a;
    }
    if (i == house.at(0)) min_cost = cost;
    if (min_cost > cost) min_cost = cost;
  }
  cout << min_cost << endl;
}

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

int main() {
  int A, B, T;
  int X = 0;
  cin >> A >> B;
  if (A > B) {
    if (A - 1 > B)
      X += A + A - 1;
    else
      X += A + B;
  }
  else {
    if (A > B - 1)
      X += A + B;
    else
      X += B + B - 1;
  }
  cout << X << endl;
}

Measured memory_bytes: 256
<?php

$menu = [];

// 入力
for ($i = 0; $i < 5; $i++) {
    fscanf(STDIN, "%d", $input);
    $key = ($input % 10 == 0) ? 10 : ($input % 10);
    $menu[] = [
        'key' => $key,
        'value' => $input,
    ];
}

usort($menu, function ($a, $b) {
    return $a['key'] - $b['key'];
});

$t = 0;
foreach (array_slice($menu, 1, 4) as $m) {
    $t = $t + ((int) (($m['value'] + 9) / 10)) * 10;
}

$t = $t + $menu[0]['value'];

echo $t . "\n";


Measured memory_bytes: 4728
BLACK = '#'

N = gets.chomp.to_i
S = gets.chomp

# 黒の数の累積和
black_cumulative = [0]

N.times do |i|
  black_cumulative[i + 1] =
      if S[i] == BLACK
        black_cumulative[i] + 1
      else
        black_cumulative[i]
      end
end

# 白の数の累積和
white_cumulative = black_cumulative.map.with_index do |blacks, i|
  i - blacks
end

costs =
  (N + 1).times.map do |i|
    change_blacks = black_cumulative[i]
    change_whites = white_cumulative.last - white_cumulative[i]
    change_blacks + change_whites
  end

puts costs.min


Measured memory_bytes: 6988
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, k, i, pn;
    string s;

    cin >> s;
    scanf("%d", &k);

    n = s.size();
    i = 0;
    while (i < n - 1)
    {
        if (s[i] != 'a')
        {
            pn = 'z' - s[i] + 1;
            if (pn <= k)
            {
                s[i] = 'a';
                k -= pn;
            }
        }
        i++;
    }

    if (k > 0)
    {
        s[n - 1] = (s[n - 1] - 'a' + k % 26) % 26 + 'a';
    }

    cout << s << '\n';

    return 0;
}

Measured memory_bytes: 3784
input = gets.chomp.split.sort
longest ,frequent = "",""
frequent_num = 0
(input.size).times do |i|
  longest = input[i] if longest.size < input[i].size
  if frequent_num < input.select{|x| x==input[i]}.size
    frequent_num = input.select{|x| x==input[i]}.size
    frequent = input[i]
  end
end
puts frequent + " " + longest

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

signed main() {
	int K, X;
	cin >> K >> X;
	for (int k = X-K+1; k <= X+K-1; ++k) {
		if (k > X-K+1) cout << " ";
			cout << k;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,sum=0;;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<k;i++){
       sum+=a[i];
    }
    cout<<sum<<'\n';
    return 0;
}

Measured memory_bytes: 3440
#include<stdio.h>
int main(void)
{
	long x,yokin,i=0;
	scanf("%ld",&x);
	yokin=100;
	while(1) {
		yokin=yokin*(1.01);
		i++;
		if(yokin>=x) {
			printf("%ld",i);
			break;
		}
	}
	return 0;
}
	

Measured memory_bytes: 1716
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    default:
      cout << "bon" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;

inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) putchar('0');
  else{
    if(x < 0) putchar('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) putchar(s[k]);
  }
  putchar(suf);
}
inline void putll(ll x,char suf){
  if(!x) putchar('0');
  else{
    if(x < 0) putchar('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) putchar(s[k]);
  }
  putchar(suf);
}
inline char get_char(){
  char c;
  for(c = getchar();c == ' ' || c == '\n';c = getchar());
  return c;
}

int main(){
  int h = getint(), w = getint(), a = getint(), b = getint();
  for(int i = 1;i <= b;i++){
    for(int j = 1;j <= a;j++) printf("1");
    for(int j = a + 1;j <= w;j++) printf("0");
    printf("\n");
  }
  for(int i = b + 1;i <= h;i++){
    for(int j = 1;j <= a;j++) printf("0");
    for(int j = a + 1;j <= w;j++) printf("1");
    printf("\n");
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N + 1);
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) {
      V.at(j)++;
    }
  }
  long ans = 0;
  for (int i = 1; i < N + 1; i++) {
    ans += (long)V.at(i) * i;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 42332
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int N = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) != T.at(i)) {
            N++;
        }
    }
    cout << N << endl;
}

Measured memory_bytes: 3916
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(n):
        if n < 4:
            return [1,n]
        res = [1]
        i = 2
        while i*i <= n:
            if n%i == 0:
                res.append(i)
                m = n//i
                if m != i:
                    res.append(m)
            i += 1
        res.append(n)
        return res

    n = I()
    l = f(n)
    ans = float("inf")
    for x in l:
        m = x+n//x-2
        if m < ans:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39664
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datM) = readLine.split(" ").map(_.toInt)
    val data = for(i <- 1 to datM) yield (readLine.split(" ").map(_.toInt))
    (1 to datN).foreach (i =>
      println( data.flatten.filter(_ == i).length )
    )
  }
}


Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N, K; cin >> N >> K;
    vector<int> l(N);
    rep(i, 0, N) cin >> l[i];
    sort(ALL(l), greater<int>());
    int ans = 0;
    rep(i, 0, K) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import numpy as np

h, w, k = map(int, input().split())
c = [input() for _ in range(h)]

count = 0
for ph in itertools.product([0, 1], repeat=h):
    for pw in itertools.product([0, 1], repeat=w):
        squares = np.array([[1 if cell == '#' else -1 for cell in row] for row in c])
        squares[np.array(ph) == 1, :] *= 0
        squares[:, np.array(pw) == 1] *= 0
        count += np.count_nonzero(squares == 1) == k

print(count)


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

double v[100000];
int main(){
    for(int i=1;i<100000;i++)v[i]=sqrt((5*i-5)/4.9)*9.8;

    double r;
    while(cin>>r)cout<<lower_bound(v,v+100000,r)-v<<endl;

    return 0;
}

Measured memory_bytes: 2004
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

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

    if (a + b == c || b + c == a || c + a == b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

const int SIZE = 300000 + 1;
int N;
bool P[SIZE];

int main(void) {
  REP(i, 0, SIZE) P[i] = (i % 7 == 1 || i % 7 == 6);
  REP(i, 2, SIZE) if(P[i]) for(int j = i * 2; j < SIZE; j += i) P[j] = false;

  while(cin >> N, N != 1) {
    cout << N << ":";
    REP(i, 2, N + 1) {
      if(P[i] && N % i == 0) cout << " " << i;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
  int ans = 0;
  if(a + b > c * 2){
   	int w = min(x,y);
    x -= w;
    y -= w;
    ans += w * c * 2;
    if(x == 0 && y == 0){
      cout << ans << endl;
      return 0;
    }
  }
  if(a > c * 2){
    ans += x * c * 2;
    x = 0;
    if(x == 0 && y == 0){
      cout << ans << endl;
      return 0;
    }
  }
  if(b > c * 2){
    ans += y * c * 2;
    y = 0;
    if(x == 0 && y == 0){
      cout << ans << endl;
      return 0;
    }
  }
  ans += x * a + y * b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  vector<ll> a(3);
    rep(i, 3) cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(0) + a.at(1) << endl;
}


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

int main(){
	int n;
	cin>>n;
	string s="";
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	while(n!=0){
		if(n%2==0){
			s+='0';
			n=n/-2;
		}
		else if(n%2!=0){
			s+='1';
			n=(n-1)/-2;
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace abc162_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            
            if(n.Substring(0,1) == "7" || n.Substring(1, 1) == "7" || n.Substring(2, 1) == "7")
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            return;
        }
    }
}


Measured memory_bytes: 25852
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n,i=0,cnt=0;
  cin >> n;
  vector<int>d(n);
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  while(i<=500000){
    size_t  id= distance(d.begin(),lower_bound(d.begin(),d.end(),i));
    if(id==n/2){
      cnt++;
    }
    i++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

typedef long long ll;

int main(){
      int N, M;
      std::cin >> N >> M;
      int A, B;
      std::vector<std::vector<int> > AB(M);
      for(int i=0; i<N; ++i){
	 std::cin >> A >> B;
	 if(A>M) continue;
	 AB[M-A].push_back(B);
      }
		        
      ll ans = 0;
      std::priority_queue<int> que;
      for(int i=M-1; i>=0; --i){
	 for(int b : AB[i]) que.push(b);
	 if(!que.empty()){
	    ans += que.top();
	    que.pop();
	 }
      }
      std::cout << ans << std::endl;
      return 0;
}



Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <atcoder/convolution>

int main(){
    using namespace std;
    using fp = atcoder::static_modint<998244353>;
    cout << []{
        const unsigned long N{[]{unsigned long ret; cin >> ret; return ret;}()};
        const auto semifact{[&N]{
            vector<fp> ret(N + 1);
            ret[0] = 1;
            for(unsigned long i{1}; i <= N; ++i)ret[i] = ret[i - 1] * (2 * i - 1);
            return ret;
        }()};
        vector<fp> r{[&N, &semifact]{
            const auto fact{[&N]{
                vector<fp> ret(2 * N + 1);
                ret[0] = 1;
                for(unsigned long i{1}; i <= 2 * N; ++i)ret[i] = ret[i - 1] * i;
                return ret;
            }()};
            const auto ifact{[&N, &fact]{
                vector<fp> ret(2 * N + 1);
                ret.back() = 1 / fact.back();
                for(unsigned long i{2 * N}; i--; )ret[i] = ret[i + 1] * (i + 1);
                return ret;
            }()};
            const auto& binom{[&fact, &ifact](const unsigned long n, const unsigned long r) -> fp {
                return ifact[r] * ifact[n - r] * fact[n];
            }};
            const auto& comp{[](const vector<fp>& a, const vector<fp>& b) -> bool {
                return a.size() == b.size() ? &a < &b : a.size() > b.size();
            }};
            priority_queue<vector<fp>, vector<vector<fp>>, decltype(comp)> pq(comp, move([&N, &binom, &semifact]{
                vector<unsigned long> hist(100000);
                for(unsigned long i{0}, h; i < 2 * N; ++i){
                    cin >> h;
                    ++hist[h - 1];
                }
                vector<vector<fp>> ret;
                for(const auto& i : hist)if(i){
                    const auto& sz{i / 2 + 1};
                    vector<fp> tmp(sz);
                    for(unsigned long j{0}; j < sz; ++j)tmp[j] = binom(i, 2 * j) * semifact[j];
                    ret.emplace_back(move(tmp));
                }
                return ret;
            }()));
            while(pq.size() > 1){
                vector<fp> f{pq.top()};
                pq.pop();
                vector<fp> g{pq.top()};
                pq.pop();
                pq.emplace(move(atcoder::convolution(move(f), move(g))));
            }
            return pq.top();
        }()};
        fp ret{0};
        for(unsigned long i{size(r)}; i--;)ret = r[i] * semifact[N - i] - ret;
        return ret;
    }().val() << endl;
    return 0;
}


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

#define ll long long
#define INF INT_MAX

using namespace std;

int main() {
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }else if(n == 1){
            cout << "1 1" << endl;
            continue;
        }

        //??\???
        vector< pair<int,int> > v = vector< pair<int,int> >(n);
        int nn,dd;
        v[0] = make_pair(0,0);
        for(int i = 1;i < n;i++){
            cin >> nn >> dd;
            int x,y;
            if(dd == 0){        //???
                y = 0,x = -1;
            }else if(dd == 1){  //???
                y = 1,x = 0;
            }else if(dd == 2 ){ //???
                y = 0,x = 1;
            }else{              //???
                y = -1,x = 0;
            }
            y = v[nn].first + y, x = v[nn].second + x;
            v[i] = make_pair(y,x); 
        }

        // for(int i = 0;i < n;i++){
        //     cout << "y:" << v[i].first << " x:" << v[i].second << endl;
        // }

        int maxY,maxX;
        int minY,minX;
        maxY = maxX = 0;
        minY = minX = INF;

        for(int i = 0;i < n;i++){
            int x = v[i].second,y = v[i].first;
            minY = min(minY,y);
            maxY = max(maxY,y);
            minX = min(minX,x);
            maxX = max(maxX,x);
        }

        //cout << maxY - minY + 1 << " " << maxX - minX + 1 << endl;
        printf("%d %d\r\n",maxX - minX + 1,maxY - minY + 1);
    }
	return 0;
}        

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, x = 0, y = 0, t = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (a - t >= abs(b - x) + abs(c - y)) {
            if ((abs(b - x) + abs(c - y)) % 2 != (a - t) % 2) {
                cout << "No" << endl;
                return 0;
            }
            t = a;
            x = b;
            y = c;
            continue;
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
vec(a,5);
a=getv<ll>(5);
ll ans=0;
ll Ans=LLONG_MAX;
rep(j,5){
  ans=0;
  rep(i,5){
    if(i!=j){
      if(a[i]%10){
        ans+=(a[i]/10+1)*10;
      }else ans+=a[i];
    }
   
  }
  ans+=a[j];

  Ans=min(Ans,ans);
}
op(Ans);
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include<map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)
#define  max(x,y) ((x)>(y)?(x):(y))
#define  min(x,y) ((x)>(y)?(y):(x))






int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	
	if (a >= b) cout << "delicious";
	else if (a < b && b <= a + x) cout << "safe";
	else if (b > a + x) cout << "dangerous";

	return 0;
}
	




Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_13
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Slist();

            var sum = Ai.Sum();
            var max = Ai.Max();
            if (0 == max)
            {
                WriteLine(0);
                return;
            }
            var dc = yaku(sum).OrderByDescending(e => e.Key);
            var ans = 0L;
            foreach (var pk in dc)
            {
                Ai.Sort((l, r) => (int)(r % pk.Key - l % pk.Key));
                var pls = new long[N + 1];
                var mns = new long[N + 1];
                for (var i = 1; i < N + 1; ++i)
                {
                    pls[i] = pls[i - 1] + (pk.Key - Ai[i - 1] % pk.Key);
                }
                for (var i = N - 1; 0 <= i; --i)
                {
                    mns[i] = mns[i + 1] + Ai[(int)i] % pk.Key;
                }
                for (var i = 1; i < N; ++i)
                {
                    if (pls[i] == mns[i] && pls[i] <= K)
                    {
                        WriteLine( pk.Key);
                        return;
                    }
                }
            }
            WriteLine(1);
        }
        static Dictionary<long, long> yaku(long n)
        {
            var ret = new Dictionary<long, long>();
            for (long i = 1; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    ret[i] = 1;
                    ret[n / i] = 1;
                }
            }
            return ret;
        }
    }
}


Measured memory_bytes: 18016
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define COUT(x) cout << (x) << endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll LINF = 1e17;
const int INF = 1001001001;
const int MOD = 1000000007;

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
    int h, a;
    cin >> h >> a;
    if(h % a == 0) COUT(h / a);
    else COUT(h / a + 1);
    
    return 0;
}

Measured memory_bytes: 256