akhauriyash/Code-Regression huggingface dataset:
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let [a,b]=tnn(2),c=0
  for(let i=a;i<=b;i++){
    let s=String(i)
    if(s[0]==s[4]&&s[1]==s[3])c++
  }
  to(c)
}
main()


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

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


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

struct point { double x, y; };
struct line { point p, q; };

int N, M, L, X[100], Y[100], A[100], R[100];
double d[100][100];

bool intersect(line l1, line l2) {
  double ax = l1.p.x, ay = l1.p.y;
  double bx = l1.q.x, by = l1.q.y;
  double cx = l2.p.x, cy = l2.p.y;
  double dx = l2.q.x, dy = l2.q.y;
  double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
  double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
  double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
  double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
  return tc * td < 0 && ta * tb < 0;
}

double distance(line l, point p) {
  double x0 = p.x, y0 = p.y;
  double x1 = l.p.x, y1 = l.p.y;
  double x2 = l.q.x, y2 = l.q.y;
  double a = x2 - x1;
  double b = y2 - y1;
  double a2 = a * a;
  double b2 = b * b;
  double r2 = a2 + b2;
  double tt = -(a*(x1 - x0) + b*(y1 - y0));
  if(tt < 0) return sqrt((x1 - x0)*(x1-x0) + (y1 - y0)*(y1-y0));
  if(tt > r2) return sqrt((x2 - x0)*(x2 - x0) + (y2 - y0)*(y2 - y0));
  double f1 = a*(y1 - y0) - b*(x1 - x0);
  return sqrt((f1*f1)/r2);
}

double distance_star(int a, int b) {
  point pa[5], pb[5];
  REP(i, 0, 5) {
    double xa = X[a] + R[a] * cos((double) (A[a] + 72 * i + 90) / 180 * M_PI);
    double ya = Y[a] + R[a] * sin((double) (A[a] + 72 * i + 90) / 180 * M_PI);
    double xb = X[b] + R[b] * cos((double) (A[b] + 72 * i + 90) / 180 * M_PI);
    double yb = Y[b] + R[b] * sin((double) (A[b] + 72 * i + 90) / 180 * M_PI);
    pa[i] = (point) { xa, ya };
    pb[i] = (point) { xb, yb };
  }

  REP(i, 0, 5) REP(j, 0, 5) {
    line la = (line) { pa[i], pa[(i + 2) % 5] };
    line lb = (line) { pb[j], pb[(j + 2) % 5] };
    if(intersect(la, lb)) return 0;
  }

  double dist = 1e10;
  REP(i, 0, 5) REP(j, 0, 5) {
    line la = (line) { pa[i], pa[(i + 2) % 5] };
    line lb = (line) { pb[i], pb[(i + 2) % 5] };
    dist = min(dist, distance(la, pb[j]));
    dist = min(dist, distance(lb, pa[j]));
  }

  return dist;
}

int main(void) {
  while(cin >> N >> M >> L, N || M || L) {
    M--;
    L--;
    REP(i, 0, N) cin >> X[i] >> Y[i] >> A[i] >> R[i];

    REP(i, 0, N) REP(j, 0, N) d[i][j] = distance_star(i, j);
    REP(k, 0, N) REP(i, 0, N) REP(j, 0, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    printf("%.8lf\n", d[M][L]);
  }

  return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <algorithm>

using namespace std;


int main(){
	int n,minimum,tmp;
	scanf("%d",&n);
	int table[n][n];
	int data[n][2];

	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++)table[i][k] = 0;
		scanf("%d %d",&data[i][0],&data[i][1]);
	}

	for(int i=n-2;i>=0;i--){
		for(int k=0;k<=i;k++){
			if(i==n-2){
				table[n-i-1][k] = data[k][0]*data[k][1]*data[k+1][1];
		}else{
				minimum = 2147483647;
				for(int p=0;p<=n-i-2;p++){
					tmp=(table[p][k]+table[n-i-p-2][k+p+1])+(data[k][0]*data[k+p][1]*data[k+n-i-1][1]);
					minimum = min(minimum,tmp);
				}
				table[n-i-1][k] = minimum;
			}
		}
	}

	printf("%d\n",table[n-1][0]);

    return 0;
}


Measured memory_bytes: 2764
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        for(i=0; i<h; i++){
            for(j=0; j<w; j++){
                if(i==0 || i==h-1){
                    printf("#");
                }else if(j==0 || j==w-1){
                    printf("#");
                }else{
                    printf(".");
                }
                
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

int main()
{
  int N;
  cin >> N;
  
  ld pi = 3.141592653589793;
  cout << fixed << (2*pi*N) << endl;
  return 0;
}

Measured memory_bytes: 3784
import sys
from collections import deque
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, input().split())


def permutation(n,r):
    import math
    return math.factorial(n)//math.factorial(n-r)

cal_lst = [None] * (K)
def calc(n):
    if cal_lst[n] != None:
        return cal_lst[n]
    if n == 0:
        cal_lst[n] = 1
        return cal_lst[n]
    if n > K-2:
        return 0;
    cal_lst[n] = permutation(K-2, n)
    return cal_lst[n]

g = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    g[a] += [b]
    g[b] += [a]

# print (g)

s = 1
Q = deque([s])
ans = K
searced = [0] * (N+1)
searced[s] = 1
cand = K-1
while len(Q) != 0:
    tmp = 1
    v = Q.popleft()
    for i in g[v]:
        if searced[i] == 1:
            continue
        else:
            searced[i] = 1
            tmp = (tmp * cand) % MOD
            cand -= 1
            Q.append(i)
    ans = (ans * tmp) % MOD
    cand = K-2
print (ans % MOD)

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

template<typename T>
bool isprime(T x) {
    if(x == 1)return false;
    if(x == 2)return true;
    if(x%2 == 0)return false;

    for(LL i = 3;i*i <= x;i += 2)
        if(x%i == 0)return false;
    return true;
}

namespace modCalc {
    LL add() {
        return 0;
    }
    template<typename H, typename... T>
    LL add(H h, T... t) {
        return (h + add(t...))%mod;
    }

    template<typename H, typename... T>
    LL sub(H h, T... t) {
        return (h - add(t...) + mod)%mod;
    }

    LL mul() {
        return 1;
    }
    template<typename H, typename... T>
    LL mul(H h, T... t) {
        return (h*mul(t...))%mod;
    }

    LL pow(LL x, LL y) {
        LL res = 1;
        while(y != 0) {
            if(y%2) {
                res = mul(x, res);
                y--;
            }else{
                x = mul(x, x);
                y /= 2;
            }
        }
        return res;
    }

    LL div(LL x, LL y) {
        return mul(x, pow(y, mod - 2));
    }

    LL fact(LL n) {
        LL res = 1;
        FOR(i, 1, n + 1)
            res = mul(res, i);
        return res;
    }
}

int main() {
    LL N;
    cin >> N;
    vector<LL> v(N + 1, 0);
    FOR(i, 2, N + 1) {
        LL x = i;
        for(;1 < x;) {
            FOR(j, 2, N + 1) {
                if(x%j == 0) {
                    x /= j;
                    v[j]++;
                    break;
                }
            }
        }
    }
    LL res = 1;
    FOR(i, 1, N + 1) {
        res = modCalc::mul(res, v[i] + 1);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <queue>
#include <cmath>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
using namespace std;

// typedef long long li;
// const li infl = ~0LLU >> 2;

template <class T>
inline void Min(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void Max(T &x, T y) {
  if (y > x) x = y;
}

// const int mod = 1e9 + 7;
// inline int Add(int x) { return x >= mod ? x - mod : x; }
// inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
// inline int Sub(int x) { return x < 0 ? x + mod : x; }
// inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
// inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
// inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
// int Pow(int x, int y) {
//   int z = 1;
//   for (; y; y >>= 1) {
//     if (y & 1) z = Mul(z, x);
//     x = Mul(x, x);
//   }
//   return z;
// }
// int Inv(int x) {
//   return Pow(x, mod - 2);
// }

// ----------------------------------------

const int maxn = 1e5;

char buf[maxn + 1];
int n, n1, c0[maxn], c1[maxn];
vector<int> g[maxn];

int deg[maxn];
bool rm[maxn];

int dp[maxn], best;

void Dfs(int x, int p) {
  dp[x] = 0;
  for (int y : g[x]) {
    if (!rm[y] && y != p) {
      Dfs(y, x);
      Max(dp[x], dp[y]);
    }
  }
  dp[x] += c1[x];

  int v1 = 0, v2 = 0;
  for (int y : g[x]) {
    if (!rm[y] && y != p) {
      if (dp[y] > v1) {
        v2 = v1;
        v1 = dp[y];
      } else if (dp[y] > v2) {
        v2 = dp[y];
      }
    }
  }
  Max(best, c1[x] + v1 + v2);
}

int main(void) {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
    ++deg[x]; ++deg[y];
  }
  scanf("%s", buf);
  for (int i = 0; i < n; ++i) {
    c0[i] = (buf[i] == 'W');
  }
  if (count(c0, c0 + n, 1) == 0) {
    puts("0");
    return 0;
  }

  queue<int> que;
  for (int i = 0; i < n; ++i) {
    if (deg[i] == 1 && c0[i] == 0) {
      que.push(i);
    }
    rm[i] = false;
  }
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    rm[x] = true;
    for (int y : g[x]) {
      if (!rm[y] && --deg[y] == 1 && c0[y] == 0) {
        que.push(y);
      }
    }
  }

  n1 = count(rm, rm + n, false);
  if (n1 == 1) {
    puts("1");
    return 0;
  }
  int cost = 2 * (n1 - 1);
  for (int x = 0; x < n; ++x) {
    if (rm[x]) {
      continue;
    }
    c1[x] = c0[x] ^ (deg[x] & 1);
    cost += c1[x];
  }

  int r;
  for (int x = 0; x < n; ++x) {
    if (!rm[x]) {
      r = x;
      break;
    }
  }
  best = 0;
  Dfs(r, 0);
  cost -= 2 * best;
  printf("%d\n", cost);
  return 0;
}


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

int main(){
  int n,p;
  cin >> n >> p;
  string s;
  cin >> s;
  
  ll ans=0;
  if(p==2 or p==5){
    rep(i,n) if((s[i]-'0')%p==0) ans+=i+1;
    cout << ans << "\n";
    return 0;
  }
  vector<ll> a(p);
  int x=0;
  int ten=1;
  a[0]++;
  rep(i,n){
    x+=(s[n-1-i]-'0')*ten;x%=p;
    ten*=10;ten%=p;
    ans+=a[x];
    a[x]++;
  }
  cout << ans;
  return 0;
}

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

using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;for (int tt = 1;tt <= t;tt++)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;	
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;

int main(int argc, char const *argv[])
{
	fast;

	string s;
	cin >> s;

	ll ans = 0;
	int b = 0;
	for (auto c : s) {
		if (c == 'B') {
			b++;
		} else {
			ans += b;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

map<int, int> mp;
vector<int> v,ans;
vector<P> g[100100];

int b[100100],one[100100];
bool visited[100100];

void dfs(int u){
	int i;
	visited[u] = true;
	for(i=(g[u].l_ength()-1); i>=0; --i){
		if(visited[g[u][i].first]){
			continue;
		}
		dfs(g[u][i].first);
		if(b[g[u][i].first]){
			b[g[u][i].first] ^= 1;
			b[u] ^= 1;
			ans.push_back(g[u][i].second);
		}
	}
}

int main(void){
	int n,m,i,a,x,l,r;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> a >> b[i];
		mp[a] = b[i];
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(i=0; i<n; ++i){
		b[i] = mp[v[i]];
	}
	for(i=n-1; i>0; --i){
		b[i] ^= b[i-1];
	}
	for(i=0; i<m; ++i){
		cin >> l >> r;
		l = (int)(lower_bound(v.begin(),v.end(),l)-v.begin());
		r = (int)(upper_bound(v.begin(),v.end(),r)-v.begin());
		if(l==r){
			continue;
		}else if(r==n){
			one[l] = i+1;
		}else{
			g[r].push_back(P(l,i+1));
			g[l].push_back(P(r,i+1));
		}
	}
	for(i=0; i<n; ++i){
		if(!one[i]){
			continue;
		}
		if(visited[i]){
			continue;
		}
		dfs(i);
		if(b[i]){
			b[i] ^= 1;
			ans.push_back(one[i]);
		}
	}
	for(i=0; i<n; ++i){
		if(visited[i]){
			continue;
		}
		dfs(i);
		if(b[i]){
			cout << "-1" << endl;
			return 0;
		}
	}
	sort(ans.begin(),ans.end());
	cout << (ans.l_ength()) << endl;
	for(i=0; i<(ans.l_ength()); ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 18296
s = int(input())
flg = True
t = [0 for i in range(1000000)]
i = 0
while flg:
  if i == 0:
    temp = s
    t[temp] += 1
  else:
    if temp % 2 == 0:
      temp = int(temp/2)
    else:
      temp = int(3*temp + 1)
    if t[temp] > 0:
      break
    else:
      t[temp] += 1
  i += 1
print(i+1)
    

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

int main(){
  int d,g;
  cin>>d>>g;
  vector<int> p(d), c(d);
  for(int i=0; i<d; i++)cin>>p[i]>>c[i];

  int ans=1e9;
  for(int i=0; i<pow(2,d); i++){
    int sum=0, num=0, rest=-1;
    for(int j=0; j<d; j++){
      if(i>>j&1){
        sum+=100*(j+1)*p[j]+c[j];
        num+=p[j];
      }else rest=j;
    }
    if(sum<g){
      int ss=100*(rest+1);
      int need=(g-sum+ss-1)/ss;
      if(need>=p[rest])continue;
      num+=need;
    }
    ans=min(ans,num);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = s.size();
    int m = 0;
    int p = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            m++;
            p = max(m, p);
        }
        else {
            m = 0;
        }
    }
    cout << p;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

vl v;

ll doCalc(ll l, ll r){
  if(l-r == 0) return 0;
  if(r-l == 1) return v[l];
   // cout <<"l and r " << l <<" : "<<r<<endl;
  ll mn = INF;
  FOR(i,l,r) {
    if(mn > v[i]) mn = v[i];
  }
  FOR(i,l,r) v[i] -= mn;
  ll ans = mn;
  ll lastl = l;
  ll cnt = 0;
  FOR(i,l,r){
    if(v[i] == 0){
      ans += doCalc(lastl,i);
      lastl = i+1;
    }
    else if(i == r-1) {
      ans += doCalc(lastl,i+1);
    }
  }
  return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;
    ll n;
    cin >> n;
    ll temp;
    F0R(i,n){
      cin >> temp;
      v.pb(temp);
    }

    cout << doCalc(0,n)<<endl;




    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    if (s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  for(int i=0; i<100; i++){
    c = c-b;
    if(c<1){
      cout << "Yes" << endl;
      break;
    }
    a = a-d;
    if(a<1){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	bool approve = true;
	int n;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		if ((a % 2 == 0) && (a % 3 && a % 5))
			approve = false;
	}
	if (approve) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}


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

using ll = long long;
const int MOD = 1000000007;
#ifdef LOCAL_ENV
    #define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
    #define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

/*-----8<-----8<-----*/


int main(){
    int a,b,t;
    cin >> a >> b >> t;
	int aa=t/a;
  	p(aa*b);
  
	
    return 0;
}



Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])
def graph():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=inpm()
        a-=1
        b-=1
        g[a].append(b)
        g[b].append(a)
    return n,m,g
 
def main():
    n,q=inpm()
    g=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=inpm()
        a-=1
        b-=1
        g[a].append(b)
        g[b].append(a)
    tuple(g)
    px=[]
    for _ in range(q):
        px.append(tuple(inpl()))
    ans=[0 for _ in range(n)]
    went=[False for _ in range(n)]
    went[0]=True
    for i in range(q):
        ans[px[i][0]-1]+=px[i][1]
    que=deque()
    que.append(0)
    while que:
        par = que.pop()
        for chi in g[par]:
            if went[chi]:
                continue
            else:
                went[chi]=True
                ans[chi]+=ans[par]
                que.append(chi)
    
    print(*ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 121260
/*
ID: sstfmsc1
TASK: milk2
LANG: C++
*/
#include <bits/stdc++.h>
 
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( int i = 0; i < (int)n; ++i )
#define MAXN 50000
#define INF 1000000
typedef long long ll;
const char nl = '\n';
ll MOD = (ll)(1e9 + 7);
 
void solve()
{
    string num; 
    cin >> num;

    int suma = 0;
    for(auto x : num) suma += (int)( x - '0' );

    cout << ( ( suma % 9 == 0 ) ? "Yes" : "No" ) << nl;
    return;
}
 
int main()
{
    //freopen("milk2.in", "r", stdin);
    //freopen("milk2.out", "w", stdout);
    //IOS
    //int q; cin >> q;
    //while(q--) 
    solve();
        
    return 0;
}

Measured memory_bytes: 3692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    string s,t;
    ll k;
    cin >> s;
    cin >> k;
    int n = s.size();
    if(n==1){
        cout << k/2 << endl;
        return 0;
    }
    bool flag = 1;
    rep(i,n-1){
        if(s[i]!=s[i+1])flag = 0;
    }
    if(flag){
        ll K = k*n;
        cout << K/2 << endl;
        return 0;
    }
    t = s+ s;
    ll a = 0;
    ll b = 0;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            s[i+1] = '?';
            a++;
        }
    }
    rep(i,2*n-1){
        if(t[i]==t[i+1]){
            t[i+1] = '?';
            b++;
        }
    }
    ll c = b-a;
    cout << a + (k-1)*c << endl;
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) {
    cout << "YES" << endl;
  }
  
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int dp[n];
    dp[0]=0;
    for(int i=1;i<n;i++){
        if(fabs(a[i]/2-a[dp[i-1]])>fabs(a[i]/2-a[dp[i-1]+1])){
            int j=dp[i-1];
            while(j<i&&fabs(a[i]/2-a[j])>fabs(a[i]/2-a[j+1])){
                j++;
            }
            dp[i]=j;
        }else{
            dp[i]=dp[i-1];
        }
    }
    /*
    cout << a[0] << endl;
    for(int i=1;i<n;i++){
        cout << a[i] << " " << dp[i] << endl;
    }
    */
    cout << static_cast<int>(a[n-1]) << " " << static_cast<int>(a[dp[n-1]]) << endl;
    return 0;
}


Measured memory_bytes: 1408
import sys
import numpy as np

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


def main():
    N = int(input())
    A = np.array(input().split(), np.int64)
    A = np.sort(A)
    Acum = np.cumsum(A)
    ans = 1
    for i in range(N-2,-1,-1):
        if Acum[i]*2 >= A[i+1]:
            ans += 1
        else:
            break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}
ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}
bool prime[1000000];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=1000000;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(1000000);j+=i)
           { prime[j]=false;}

    }
    }

}

int main()
{
   int n,m;
   cin>>n>>m;
   vector<string>c(n);
   int flag1=0,flag2=0;
   for(int i=0;i<n;i++)
   {
    //   string s;
       cin>>c[i];

   }
   while(1)
   { //cout<<"Da";
       vector<int>v;
   int f=0;
   //cout<<c.size()<<" "<<c[0].size();
   for(int i=0;i<c.size();i++)
   {  f=0;
         for(int j=0;j<c[0].size();j++)
       {
           if(c[i][j]!='.') { f= 1; break;}

       }
       if(f==0)
       {
           v.push_back(i);
       }
   }
   if(v.empty()) flag1=1;
   vector<string>temp;
   for(int i=0;i<v.size();i++)
   {
       c[v[i]]="lol";

   }
   for(int i=0;i<c.size();i++)
   {
       if(c[i]=="lol") continue;
       else temp.push_back(c[i]);
   }
    c=temp;
    //cout<<endl;
     //for(int i=0;i<c.size();i++) cout<<c[i]<<endl;
    f=0;
    v.clear();
    for(int j=0;j<c[0].size();j++)
    { f=0;
        for(int i=0;i<c.size();i++)
        {

            if(c[i][j]!='.') { f=1; break;}
        }
        if(f==0) {v.push_back(j); }

    }

    if(v.empty()) flag2=1;
    if(flag1&&flag2) break;
    int s = c[0].size();
    for(int i=0;i<c.size();i++)
    {

        for(int j=0;j<v.size();j++)
            c[i][v[j]]='b';
        string output="";
        for(int j=0;j<s;j++)
        {
            if(c[i][j]!='b') output+=c[i][j];
        }
        c[i]=output;

    }
    f=0; v.clear(); flag1=0; flag2=0;
     //cout<<endl;
     //for(int i=0;i<c.size();i++) cout<<c[i]<<endl;
  // cout<<endl;
  
   }
  for(int i=0;i<c.size();i++) cout<<c[i]<<endl;
}



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

int main()
{
	int tou;
	vector<int> ans(120);
	for (int i = 0; i < 120; i++)ans[i] = 0;
	int n, x = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int b, c, d;
		cin >> tou >> b >> c >> d;
		ans[(((tou - 1) * 3 + (b - 1)) * 10 + c) - 1] += d;
	}
	for (int i = 0; i < 120; i++)
	{
		if (i % 10 == 0)
		{
			cout << " ";
		}
		cout << ans[i];
		if (i % 10 != 9)
		{
			cout << " ";
		}
		if (i % 30 == 29)
		{
			cout << endl;
			if (i == 119)
			{
				break;
			}
			cout << "####################";
		}
		if (i % 10 == 9)
		{
			cout << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
char ch[100];
char a[20] = "AKIHABARA";
char c[20] = "KIHBR";
char b[20];
int main()
{
    cin >> ch;
    int len = strlen(ch);
    bool ok = true;
    bool ok2 = false;
    if(len > 9)ok = false;
    int ji = 0;
    FOR(i,0,len-1)
    {
        if(ch[i] == ch[i+1])ok = false;
        if(ch[i] == 'K' && ch[i+1] == 'I' && ch[i+2] == 'H')ok2 = true;
        if(ch[i] == 'A')continue;
        b[ji++] = ch[i];
    }
    b[ji] = '\0';
    if(strcmp(b, c) != 0)ok = false;
    if(ok && ok2)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	ll n, x[200000], y[200000];
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x[i];
		y[i]=x[i];
	}
	sort(x, x+n);
	ll mae=x[n/2-1];
	ll ato=x[n/2];
	for(int i=0; i<n; i++){
		if(y[i]<=mae){
			cout << ato << endl;
		} else {
			cout << mae << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 5376
package main

import (
	"fmt"
	"math"
)

func main() {
	var x1, y1, x2, y2 float64
	fmt.Scan(&x1, &y1, &x2, &y2)
	fmt.Println(math.Sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))
}



Measured memory_bytes: 1156
#include <cstdio>
#define rep(i,n,m) for(int i = (n); i<(m); i++)

int main(void){
  int n,k;
  if (!scanf("%d%d", &n, &k))
    return 0;
  int count = 0;
  rep(i,0,n){
    int input;
  if (!scanf("%d", &input))
    return 0;
    if (input >= k)
      count++;
  }
  printf("%d\n", count);
  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	int k;
	cin >> k;
	int cnt = 1;
	vector<bool> isc(k);
	ll md = 7 % k;
	while (1) {
		if (md == 0) {
			pv(cnt);
			return 0;
		}
		else {
			if (isc[md]) {
				ps(-1);
				return 0;
			}
			else {
				isc[md] = true;
			}
		}
		md = (md * 10 + 7) % k;
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 3732
#include <iostream>
using namespace std;
int t[255],f[255],g[255],n,m;
int hantei(int x,int d) {
	int i,j,c,a;
	for (i=0;i<=n+1;i++) f[i]=0; f[x]=1; c=1;
	while(c==1) {
	c=0;	
	for (i=0;i<=n;i++) {
		if (f[i]==1) {
			for (j=i+1;j<=i+m;j++) {
				a=j+t[j];
				if (a<0) a=0; if (a>n+1) a=n+1;
				if (d==1 && a==n+1) return 2;
				if (f[a]==0) { f[a]=1; c=1;}
			}
			f[i]=2;
		}
	  }
  }
  return 0;	
  }
int main() {
int i,c;
 while(cin >> m && m!=0) {
	 cin >> n;
	 for (i=1;i<=n;i++) cin >> t[i];
	 c=hantei(0,0);
	 for (i=0;i<=n;i++) g[i]=f[i];
	 for (i=0;i<=n;i++) if (g[i]>0) {c=hantei(i,1); if (c==0) break;}
	 if (c==0) cout << "NG"; else cout << "OK";
	 cout << endl;
	} 			   
 return 0;
 } 

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j>>k>>l>>m>>n;
  cout<<a-b<<endl;
  cout<<c-d<<endl;
  cout<<e-f<<endl;
  cout<<g-h<<endl;
  cout<<i-j<<endl;
  cout<<k-l<<endl;
  cout<<m-n<<endl;
        return 0;
    
    
}



Measured memory_bytes: 3088
import math
n = int(input())
ar = [0 for i in range(n)]
r = int(math.sqrt(n))
for i in range(1,r+1):
    for j in range(1,r+1):
        for k in range(1,r+1):
            m = i ** 2 + j ** 2 + k ** 2 + i * j + i * k + j * k
            if m <= n:
                ar[m-1] += 1
for r in ar:
    print(r)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y;
  cin >> x >> y;
  
  if (x == 2 || y == 2) 
    cout << "No" << endl;
  
  else if (x == 4 || x == 6 || x == 9 || x == 11) {
    if (y == 4 || y == 6 || y == 9 || y == 11)
      cout << "Yes" << endl;
    
    else
      cout << "No" << endl;
  }
  
  else {
    if (y == 4 || y == 6 || y == 9 || y == 11)
      cout << "No" << endl;
    
    else
      cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {


		//long[] a = new long[n];




		//int n = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		char[] c = s.ToCharArray();



		for (int i = 0; i < c.Length - 1; i++)
		{
            if(c[i] == 'A'&&c[i+1]=='C')
            {
                Console.WriteLine("Yes");
                return;
            }

		}
        Console.WriteLine("No");
        return;
		//Console.WriteLine("");

	}
}


Measured memory_bytes: 11092
package main
 
import (
  "fmt"
)
 
func main() {
  var a, b int
  fmt.Scanf("%d %d", &a, &b)
  
  ans := a + b
  if a - b > ans {
    ans = a - b
  }
  if a * b > ans {
    ans = a * b
  }
  
  fmt.Printf("%d\n", ans)
}

Measured memory_bytes: 1832
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;


vector<vector<pii> > G(N);
void print(int x,int y){
    cout<<x<<" "<<y<<endl;
}
main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"No";return 0;
    }
    else{
        rep(i,20){
            if(n==(1<<i)){
                cout<<"No";return 0;
            }
        }
        cout<<"Yes"<<endl;
        int nn=1;
        while(nn*2<=n+1)nn*=2;
        

        if(n%2){
            rep2(i,1,nn-2){
            print(i,i+1); 
            print(i+n,i+1+n);
            }
            print(nn-1,1+n);
            for(int i=nn;i<=n;i+=2){
                print(i,1);
                print(i,i+1);
                print(n+i+1,1);
                print(n+i+1,n+i);
            }
        }
        else{
            int res=n-nn;
            vec pos={1,res};
            rep2(i,2,nn-1){
                if(i!=res)pos.pb(i);
            }
            rep2(i,0,nn-3){
                print(pos[i],pos[i+1]); 
                print(pos[i]+n,pos[i+1]+n);
            }
            print(nn-1,1+n);
            for(int i=nn;i<n;i+=2){
                print(i,res);
                print(i,i+1);
                print(n+i+1,nn-1);
                print(n+i+1,n+i);
            }
            print(n,nn);
            print(n*2,res);
        }
    }
}



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

using namespace std;

int main(){
    int N,ans=0;
    cin >> N;
    vector<vector<pair<int,int>>> graph(N);
    queue<pair<int,int>> Q;
    map<int,pair<int,int>> M;
    map<pair<int,int>,int> color;

    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back({b,-1});
        graph[b].push_back({a,-1});
        M[i] = {a,b};
    }

    for(int i=0;i<N;i++){
        ans = max(ans,(int)graph[i].size());
    }

    cout << ans << endl;

    for(int i=0;i<graph[0].size();i++){
        Q.push({graph[0][i].first,i+1});
        color[make_pair(0,graph[0][i].first)] = i+1;
        color[make_pair(graph[0][i].first,0)] = i+1;
    }

    while(!Q.empty()){
        pair<int,int> P;
        P = Q.front();
        Q.pop();
        int to = P.first;
        int out = P.second;
        int now = 1;
        for(int i=0;i<graph[to].size();i++){
            if(now==out){
                now++;
            }
            if(color[{to,graph[to][i].first}]==0){
                color[{to,graph[to][i].first}]=now;
                color[{graph[to][i].first,to}]=now;
                Q.push({graph[to][i].first,now});
                now++;
            }
        }
    }

    for(int i=0;i<N-1;i++){
        cout << color[M[i]] << endl;
    }
}

Measured memory_bytes: 25344
#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
#include <math.h>
#include <cstdio>
#include <cstring>
#include <iomanip>

using namespace std;

int main(void) {
    int a, b, c, k;

    cin >> a >> b >> c >> k;

    if (a >= k) {
        cout << k << endl;
    }
    else {
        if (a + b >= k) {
            cout << a << endl;
        }
        else {
            cout << 2 * a + b - k << endl;
        }
    }
}


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

int N;
const int MAX = 1e9 + 10;

class D{
public:
  int e,s,in;
};

vector<D>vec;

void write(){
  int a,b;
  cin >> a >> b;

  int pre = 0;
  vector<D>nv;
  for(int i = 0 ; i < vec.size() ; i++){
    if(vec[i].s - pre != 0 && b > 0){
      D d;
      d.s = pre;
      d.e = pre + min(b,vec[i].s - pre);
      d.in = a;
      nv.push_back(d);
      b -= (vec[i].s - pre);
    }
    nv.push_back(vec[i]);
    pre = vec[i].e;
  }
  vec = nv;
}

void del(){
  int a;
  cin >> a;
  vector<D>nv;
  for(int i = 0 ; i < vec.size() ; i++){
    if(vec[i].in == a)continue;
    nv.push_back(vec[i]);
  }
  vec = nv;
}

void read(){
  int a;
  cin >> a;
  for(int i = 0 ; i < vec.size() ; i++){
    if(vec[i].s <= a && a < vec[i].e){
      cout << vec[i].in << endl;
      return;
    }
  }
  cout << -1 << endl;
}

void solve(){
  vec.clear();
  
  D d;
  d.s = 0;
  d.e = 0;
  d.in = -1;
  vec.push_back(d);

  d.s = MAX;
  d.e = MAX;
  d.in = -1;
  vec.push_back(d);

  for(int i = 0 ; i < N ; i++){
    char c;
    cin >> c;
    switch(c){
    case 'W':
      write();
      break;
    case 'D':
      del();
      break;
    case 'R':
      read();
      break;
    }
  }
}

int main(){
  while(cin >> N,N){
    solve();
    cout << endl;
  }
  return 0;
}

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

public class Main {


	 // 柄を数値化して多次元配列に使えるようにする
	static enum Mark {
	    S(0), H(1), C(2), D(3);//柄を数値化
	    //enumのコンストラクタはprivate以外だとコンパイルエラー
		private int id;//数値として指定
	    public int getId() {//取り出し用　getメソッドとコンストラクタの値はid指定が必須
	      return this.id;
	    }

	    private Mark (int id) {
	      this.id = id;
	    }
	  }


	public static void main(String[] args) throws NumberFormatException, IOException {
	    // 入力用
	    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

	    // 柄と数字で多次元配列
	    boolean[][] checkInput = new boolean[4][13];//前者：柄　後者：数字

	    // 枚数用
	    int inputCards = Integer.parseInt(input.readLine());//合計枚数
	    int inputNumberOfCards; // 数字用

	    // 入力された合計枚数分ループ
	    for (int i = 0; i < inputCards; i++) {

	    	// 入力されたものを柄と数字に分ける
	      String[] inputCardsArray = (input.readLine()).split("\\s");//スペースで分割
	      // カードの数字
	      inputNumberOfCards = Integer.parseInt(inputCardsArray[1]);//数字部分を改めて配列化

	      // 柄ごとに場合分け
	      switch(Mark.valueOf(inputCardsArray[0])) {//文字列からenumへの変換
	      case S: // スペード
	        checkInput[0][(inputNumberOfCards -1)] = true;//数字は13だが0スタートなので-1
	        break;
	      case H: // ハート
	        checkInput[1][(inputNumberOfCards -1)] = true;
	        break;
	      case C: // クラブ
	        checkInput[2][(inputNumberOfCards -1)] = true;
	        break;
	      case D: // ダイヤ
	        checkInput[3][(inputNumberOfCards -1)] = true;
	        break;
	      }
	    }

	    // 柄のループ
	    for (int i = 0; i < Mark.values().length; i++) {
	      // 数字のループ
	      for (int j = 0; j < checkInput[1].length; j++) {
	        // 入力されなかったものを表示
	        if (!checkInput[i][j]) {//場合分けでcheckInputに入力「されていない」として抽出
	        	//前者：enumから対応する柄を取得　後者：ループ番目の抜けから取得(0スタートの為+1)
	          System.out.println(Mark.values()[i] + " " + (j +1));
	        }
	      }
	    }
	  }
	}




Measured memory_bytes: 24732
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    if A <= K:
        K -= A
        A = 0
        if B <= K:
            B = 0
        else:
            B-=K
    else:
        A -= K
    print(A,B)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;



int main(){

    string s;
    cin >> s;
    s[3] = '8';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def main():
    a = list(map(int, input().split()))
    inputs = [input().split() for i in range(a[1])]
    num_ac = 0
    results = defaultdict(int)
    results_wa = defaultdict(int)
    for i in inputs:
        if not results[i[0]]:
            if i[1] == "WA":
                results_wa[i[0]] += 1
            elif i[1] == "AC":
                num_ac += 1
                results[i[0]] = 1
    
    for k in results.keys():
        if results[k] == 0:
            results_wa[k] = 0
    
    num_wa = sum(results_wa.values())
    print(num_ac, num_wa)


if __name__ == "__main__":
    main()


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

map<lli,lli> makePrimeList2(lli n){
	map<lli,lli> m;
	lli a = 2;
	while(n>=a*a){
		if(n%a==0){
			m[a]++;
			n /= a;
		}
		else a++;
	}
	if(n!=1)m[n]++;
	return m;
}

set<lli> makeYaku(lli n){
	set<lli> s;

	for(lli i=1;i*i<=n;i++){
		if(n%i==0){
			s.insert(i);
			s.insert(n/i);
		}
	}
	return s;
}

bool ok(lli n,lli k){
	if(n==1)return true;
	else if(n<k)return false;
	if(n%k==0)return ok(n/k,k);
	else return ok(n%k,k);
}

signed main(){

	lli n,k;
	cin>>n;
	set<lli> yaku = makeYaku(n-1);
	set<lli> yaku2=makeYaku(n);

	//候補を絞ったので試す

	lli cnt=0;

	for(auto e:yaku){
		if(e==1)continue;
		if(ok(n,e))cnt++;
	}

	for(auto e:yaku2){
		if(e==1)continue;
		if(yaku.find(e)!=yaku.end())continue;
		if(ok(n,e))cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

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

int a[300][300];
int c[10][10];

int main(){
    int h,w; cin >> h >> w;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin >> c[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    bool update=true;
    while(update){
        update=false;
        for(int i=0;i<=9;i++){
            for(int j=0;j<=9;j++){
                for(int k=0;k<=9;k++){
                    int nc=c[i][k]+c[k][j];
                    if(nc<c[i][j]){
                        update=true;
                        c[i][j]=nc;
                    }
                }
            }
        }
    }

    int ans=0;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]==-1) continue;
            ans+=c[a[i][j]][1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  String po=sc.next();
  String s[]=po.split("-",0);
  System.out.println((s.length==2)?(s[0].length()==a&&s[1].length()==b)?"Yes":"No":"No");
}}


Measured memory_bytes: 23892
def main():
    D, N = input().split()
    D = int(D)
    N = int(N)

    if D == 0:
        if N == 100:
            print(101)
        else:
            print(N)
    elif D==1:
        if N ==100:
            print(10100)
        else:
            print(N*100)
    elif D==2:
        if N ==100:
            print(1010000)
        else:
            print(N*10000)

if __name__ == "__main__":
        main()


Measured memory_bytes: 3060