akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define openfile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#define fastio
#else
#define openfile
#define deb(x...)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif
void init()
{
    
}
void solve()
{
    ll n,i,j;cin>>n;
    string s;
    map<string,ll>mp;
    mp["AC"]=0;
    mp["WA"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    fo(0,i,n)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}
int main()
{
    init();
    //openfile;fastio;
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, s1;
  cin >> s >> s1;
  for(int i = 0, j = 2; i < 3; i++, j--){
    if(s[i] != s1[j]){
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s)begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//------------------HEAD---------------------

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,3){
        int h,m,s;
        cin>>h>>m>>s;
        int b=h*3600+m*60+s;
        cin>>h>>m>>s;
        int a=h*3600+m*60+s;
        int t=a-b;
        cout<<t/3600<<" "<<t%3600/60<<" "<<t%60<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

ll N,M,K;
ll pow_mod(ll num,ll p,ll mod){
  ll mul=num;
  ll res=1;
  while(p){
    if(p%2)res=(res*mul)%mod;
    p/=2;
    mul=(mul*mul)%mod;
  }
  return res;
}

int appear[10]={};
ll GetCycleLen(){
  for(int i=0;i<10;i++)appear[i]=-1;
  int pm=pow_mod(N%10,M,10)%10;
  int cur=N%10;
  for(int ite=0;;ite++){
    if(appear[cur]!=-1)return ite;
    else{
      appear[cur]=ite;
      cur=(cur*pm)%10;
    }
  }
  return -1;
}

int main(){

  cin>>N>>M>>K;
  ll sz=GetCycleLen();
  ll res=0;
  // サイクルの長さから該当するものの数を計算
  for(int i=0;i<10;i++){
    if(appear[i]==-1)continue;
    else{
      ll tmp=(K-1)-appear[i];
      if(tmp<0)continue;
      ll cnt=(tmp/sz)+1;
      res=(res+cnt*i);
    }
  }
  cout<<res<<endl;
  
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> keta_retu(int x){
  
  vector<int> p;
  
  while(true){
    int r = x%10;
    p.push_back(r);
    x = x/10;
    if(x == 0) break;
  }
  
  return p;
  
}

int main(){
  int A,B;
  cin  >> A >> B;
  int ans = 0;
  
  for(int i = A;i<=B;i++){
   vector<int> q = keta_retu(i);
   vector<int> r = q;
   reverse(q.begin(),q.end());
   if(q == r) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long LL;
typedef double DB;
const LL MOD = 1e9+7;
const LL NMAX = 1e6+7;
const string NAME = "test";

int n;
int s[NMAX];
vector <int> ve;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen((NAME + ".inp").c_str(), "r", stdin);
    //freopen((NAME + ".out").c_str(), "w", stdout);
    char c;
    while(cin >> c) {
        s[++n] = c - '0';
    }
    if(s[1] == 0) {
        cout << -1;
        return 0;
    }
    if(s[n] == 1) {
        cout << -1;
        return 0;
    }
    for(int i = 1; i <= n; ++i)
    if(s[i] != s[n-i]) {
        cout << -1;
        return 0;
    }
    ve.push_back(0);
    for(int i = 2; i < n; ++i) {
        if(s[i] == 1) ve.push_back(i);
    }
    ve.push_back(n);
    int st = ve.size();
    for(int i = 1; i < ve.size(); ++i) {
        for(int j = st; j <= st + ve[i] - ve[i-1] - 2; ++j)
            cout << i << ' ' << j << '\n';
        if(i > 1)
            cout << i-1 << ' ' << i << '\n';
        st += ve[i] - ve[i-1] - 1;
    }
    return 0;
}


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

int main() {
  const long long mod=1e9+7;
  int n; cin>>n;
  long long power=1;
  for(int i=1;i<=n;i++){
    power*=i;
    power%=mod;
  }
  cout<<power<<endl;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

ans = [0 for _ in range(n)]
sum_rain = sum(a_list)
tmp = sum_rain
for a in a_list[:-1:2]:
    tmp -= a * 2
ans[-1] = tmp
ans[0] = a_list[-1] * 2 - tmp
tmp = ans[0]
for i in range(1, n-1):
    tmp = a_list[i-1] * 2 - tmp
    ans[i] = tmp
print(*ans)


Measured memory_bytes: 14940
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int g[1000];

int dfs(int d) {
    if (g[d] != -1)RT g[d];
    if (d == 0)RT g[d] = 0;

    set<int> S;
    int cur = 0;
    for (int i = 2; i <= d; ++i) {
        cur ^= dfs(d - i + 1);
        S.insert(cur);
    }
    int res = 1;
    for (; S.count(res); res++);
    RT g[d] = res;
}

const int ROOT = 0;
const int TREE_SIZE = 200005;
const int CHAR_SIZE = 2;
int dat[TREE_SIZE], cur = 1;
int chi[TREE_SIZE][CHAR_SIZE];
void put(const string &s) {
    int k = 0;
    for (size_t i = 0; i < s.size(); i++) {
        if (chi[k][s[i]] == 0)chi[k][s[i]] = cur++;
        k = chi[k][s[i]];
    }
    dat[k]++;
}

int N;
ll L;
string S[100000];

ll f(int k, int d) {
    ll len = L - d;
    ll res = 0;

    rep(i, 2) {
        if (!dat[k] && !chi[k][i]) {
            for (int j = 59; j >= 0; --j) {
                if (len % (1ll << j) == 0) {
                    res ^= 1ll << j;
                    break;
                }
            }
        }
        if (chi[k][i]) {
            res ^= f(chi[k][i], d + 1);
        }
    }

    RT res;
}

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

    //MEM(g, -1);
    //for (int i = 1; i <= 256; ++i) {
    //    cout << dfs(i) << endl;
    //}

    cin >> N >> L;
    rep(i, N) {
        cin >> S[i];
        each(c, S[i])c -= '0';
        put(S[i]);
    }

    ll ans = f(0, 0);
    cout << (ans ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 8272
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b,c = map(int, input().split())

c1 = abs(a-b)
c2 = abs(a-c)
c3 = abs(c-b)

print(c1+c2+c3-max(c1,c2,c3))



Measured memory_bytes: 8872
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define SG getchar()
#define P putchar
using namespace std;
signed main()
{
	P(65),P(66),P(67),P(SG),P(SG),P(SG);
	return P(10),0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

int main() {
  string s;
  cin >> s;
  int a, b;
  a = atoi(s.substr(0, 2).c_str());
  b = atoi(s.substr(2, 2).c_str());
  if(a >= 1 && a <= 12) {
    if(b >= 1 && b <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if(b >= 1 && b <= 12) {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

long cal(long n, long x){
	long f;
	if(n>=0) f=n/x+1;
	if(n==-1) f=0;
	return f;
}

int main(){
	long a, b, x;
	cin >> a >> b >> x;
	long ans=cal(b, x)-cal(a-1, x);
	cout << ans << endl;
}


Measured memory_bytes: 3552
import math
N, D = map(int, input().split())
X = []
Y = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

count = 0
for i in range(N):
    if (math.sqrt(X[i]**2 + Y[i]**2) <= D):
        count += 1

print(count)


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

int main() {
  int N;
  int count = 0;
  
  cin >> N;
  int A[N];
  for(int i = 0; i <= N; i++) {
    cin >> A[i];
  }
  bool judge = true;
  while(judge) {
    for(int j = 0; j < N; j++) {
      if(A[j] % 2 != 0) {
        judge = false;
        break;
      } else {
        A[j] /= 2;
      }
    }
    if(judge) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<limits.h>
#define MAX 500000
int count =0;
void merge(int A[],int left,int mid,int right);
void mergeSort(int A[],int left,int right);

int main(void){
	
	int n, i;
	int S[MAX];
	
	scanf("%d", &n);
	for(i = 0;i<n;i++){
		scanf("%d", &S[i]);
	}
	
	mergeSort(S, 0, n);
	
	for(i =0;i<n-1;i++){
		printf("%d ", S[i]);
	}
	printf("%d\n", S[n-1]);
	printf("%d\n", count);
	
	return 0;
}


void merge(int A[],int left,int mid,int right){
  	int n1 = mid - left;
  	int n2 = right - mid;
	int R[n1+1], L[n2+1];
	int i, j, k;
  //L[0...n1], R[0...n2] を生成
	for (i = 0;i <n1;i++){
		L[i] = A[left + i];
	}
	for (i = 0;i <n2;i++){
		R[i] = A[mid + i];
	}
 	L[n1] = INT_MAX;
  	R[n2] = INT_MAX;
	i = 0;
	j = 0;
	for (k = left ;k<right;k++){
		if( L[i] <= R[j]){
	      A[k] = L[i];
	      i = i + 1;
		  count++;
		}
		else {
	      A[k] = R[j];
	      j = j + 1;
			count++;
		}
	}
}
void mergeSort(int A[],int left,int right){
	if( left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans = 1ll<<61;
  REP(i,max(x,y)+1){
    ll tmp = c*i*2ll;
    tmp += max(0ll,x-i)*a;
    tmp += max(0ll,y-i)*b;
    CHMIN(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 764
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 998244353

def power(x, y):
   if y == 0:
       return 1
   elif y == 1:
       return x % mod
   elif y % 2 == 0:
       return power(x, y/2) ** 2 % mod
   else:
       return power(x, (y-1)/2) ** 2 * x % mod

N = INT()
a = np.array([INT() for _ in range(N)])

sum_a = np.sum(a)
dp = np.zeros((N+1, sum_a+1))
dp[0][0] = 1

dp2 = np.zeros((N+1, sum_a//2+1))
dp2[0][0] = 1

for i, x in enumerate(a):
	dp[i+1, :] += dp[i, :]*2 % mod # 赤以外に塗り分ける
	dp[i+1, x:] += dp[i, :-x] % mod # 赤に塗り分ける
	dp2[i+1,:] += dp2[i, :] % mod
	dp2[i+1, x:] += dp2[i, :-x] % mod
# print(dp)
# print(dp2)
if sum_a%2 == 0:
	print(int((power(3, N)-3*np.sum(dp[N,sum_a//2:])+3*dp2[N,sum_a//2])%mod))
else:
	print(int((power(3, N)-3*np.sum(dp[N,sum_a//2+1:]))%mod))


Measured memory_bytes: 328988
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl G(n);
    vpll vp;
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].eb(b);
        G[b].eb(a);
        vp.eb(a, b);
    } 
    
    vl cs(n);  // cs[i] : 頂点iとiの親を結ぶ辺の色
    vl used(n);  // used[i] : 頂点iを訪れたかどうか
    map<pll, ll> mp;
    queue<ll> Q;

    Q.emplace(0);
    used[0] = 1;
    ll K = 0;
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        if(K < G[v].size()) {
            K = G[v].size();
        }
        ll color = 1;
        for(auto u : G[v]) {
            if(used[u]) {
                continue;
            }
            if(color == cs[v]) {
                color++;
            }
            cs[u] = mp[make_pair(u, v)] = mp[make_pair(v, u)] = color++;
            used[u] = 1;
            Q.emplace(u);
        }
    }

    out(K);

    for(auto p : vp) {
        out(mp[p]);
    }

    re0;
}

Measured memory_bytes: 22128
price = []
while 1:
    a = []
    n,m = map(int,input().split())
    if n == 0 and m == 0:
        break
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    sum = -1
    for i in range(len(a)-1):
        for j in range(i+1,len(a)):
            if a[i] + a[j] <= m and sum <= a[i] + a[j]:
                sum = a[i] + a[j]
    if sum < 0:
        price.append(-1)
    else:
        price.append(sum)

for i in range(len(price)):
    if price[i] >= 0:
        print(price[i])
    else:
        print('NONE')



Measured memory_bytes: 5716
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	static Deque<Integer> mapStack;
	static Deque<Mizutamari> waterStack;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] graph = sc.nextLine().split("");
		sc.close();
		mapStack = new ArrayDeque<>();
		waterStack = new ArrayDeque<>();

		for (int i = 0; i < graph.length; i++) {
			switch (graph[i]) {
			case "\\":
				mapStack.offerLast(i);
				break;
			case "/":
				if (mapStack.isEmpty()) continue;
				int start = mapStack.pollLast();
				int tmpArea = i - start;
				while (!waterStack.isEmpty() && waterStack.peekLast().getStartIdx() > start) {
					tmpArea += waterStack.pollLast().getArea();
				}
				waterStack.offerLast(new Mizutamari(start, tmpArea));
				break;
			case "_":
				continue;
			}

		}

		System.out.println(waterStack.stream().map(m -> m.getArea()).reduce(0, (x, y) -> x + y));
		System.out.print(waterStack.size());
		int len = waterStack.size();
		for (int i = 0; i < len; i++) {
			System.out.print(" ");
			System.out.print(waterStack.pollFirst());
		}
		System.out.print("\n");
	}

}

class Mizutamari {
	private int startIdx;
	private int area;
	public Mizutamari(int start, int area) {
		this.startIdx = start;
		this.area = area;
	}
	public int getStartIdx() {
		return startIdx;
	}
	public int getArea() {
		return area;
	}
	public void addArea(int area) {
		this.area += area;
	}

	@Override
	public String toString() {
		return String.valueOf(area);
	}
}

Measured memory_bytes: 34656
import sys

nil = -1

def set_depth(v, depth):
    tree[v][2] = depth

    for child in tree[v][1]:
        set_depth(child, depth + 1)

n = int(input())

tree = [[nil, [], 0, 'leaf'] for i in range(n)]

for i in range(n):
    line = [int(i) for i in sys.stdin.readline().split()]
    t_id = line[0]
    children = line[2:]

    tree[t_id][1] = children

    if children:
        tree[t_id][3] = 'internal node'

    for child in children:
        tree[child][0] = t_id

for t_id in range(n):
    if tree[t_id][0] == nil:
        tree[t_id][3] = 'root'
        r = t_id
        break

# print(tree)

set_depth(r, 0)

for t_id in range(n):
    parent = tree[t_id][0]
    depth = tree[t_id][2]
    children = tree[t_id][1]
    type_t = tree[t_id][3]

    print('node {}: parent = {}, depth = {}, {}, {}'.format(
            t_id, parent, depth, type_t, children))

Measured memory_bytes: 37328
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, M = readnums()
H = list(readnums())
r = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]

flag = [1] * N

for x in r:
    if H[x[0]] < H[x[1]]:
        flag[x[0]] = 0
    elif H[x[1]] < H[x[0]]:
        flag[x[1]] = 0
    elif H[x[0]] == H[x[1]]:
        flag[x[0]] = 0
        flag[x[1]] = 0

print(sum(flag))


Measured memory_bytes: 32012
n = int(input())
s = input()
a = 0
b = 0

for c in s:
  if c == '(':
    a += 1
  elif c == ')' and a != 0:
    a -= 1
  else:
    b += 1
    
s = ('('*b) + s + (')'*a)

print(s)
    

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

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 


void solve(){
    int n,q; cin >> n >> q;
    // s-x,1,x
    // t-x,-1,x
    set<pair<int,pair<int,int>>> st;
    FOR(n){
        int s,t,x; cin >> s >> t >> x;
        st.insert({s-x,{1,x}});
        st.insert({t-x,{-1,x}});
    }

    FOR(q){
        int d; cin >> d;
        st.insert({d,{2,i}});
    }

    int ans[q];
    set<int> blocked;

    for(pair<int,pair<int,int>> xx : st){
        if(xx.second.first == 1){
            blocked.insert(xx.second.second);
        } else if(xx.second.first == -1){
            blocked.erase(xx.second.second);
        } else{
            if(blocked.empty()) ans[xx.second.second] = -1;
            else{
                ans[xx.second.second] = *(blocked.begin());
            }
        }
    }
    for(int yy : ans) cout << yy << '\n';
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


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

vector<pair<int, int>> v;
int dp[3030][3030];

int main() {
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> v(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    sort(v.begin(), v.end());
    int ans = 0;
    dp[0][0] = 0;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<=T-1; ++j) {
            dp[i+1][j] = dp[i][j];
            ans = max(ans, dp[i+1][j] + v[i].second);
            if (j - v[i].first >= 0) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-v[i].first] + v[i].second);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 35840
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int x;
    int ans = -1;
    cin >> x;
    if (x == 1)
    {
        cout << x << endl;
        return 0;
    }
    for (int i = 2; i <= sqrt(x); i++)
    {
        int tmp = i;
        while (tmp * i <= x)
        {
            tmp *= i;
        }
        ans = tmp > ans ? tmp : ans;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18

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

ll MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    if (N % 2 == 1) {
        PRINT(0);
        return 0;
    }
    ll t = 5;
    while(t <= N) {
        ans += N / (2*t);
        t *= 5;
    }
    PRINT(ans);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]

T = A = 1
for t, a in TA:
  r = max(A//a, T//t)
  if r*a >= A and r*t >= T:
    A = r*a; T = r*t
  else:
    A = (r+1)*a; T = (r+1)*t

print(T+A)

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

vll binary_convert(ll n){
    vll s;
    ll size = 0;

    while(n / (ll)(pow(2,size)) > 0)size++;
    rep(i,size + 1){
        s.pb(n / (ll)(pow(2,i)));
        n %= (ll)(pow(2,i));
    }

    return s;
}

ll fib(ll n){
    vll a(n+1);
    a[0] = 1;
    a[1]  = 1;

    REP(i,2,n+1){
        a[i] = a[i-1] + a[i-2];
        a[i] %= mod;
    }

    return a[n-1];
}

int main()
{
    ll n,k;
    cin >> n >> k;

    cout << n - k + 1 - (n/k) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, Time;
    int c, t, i;
    int minc=1100, mint=1100;

    scanf("%d %d", &N, &Time);

    for(i=0; i<N; i++){
        scanf("%d %d", &c, &t);
        if(t<=Time){
            if(c<minc){
                minc = c;
            }
        }
    }
    if(minc==1100){
        printf("TLE");

    }else{
        printf("%d", minc);
    }
    

    return 0;
}

Measured memory_bytes: 128
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2.0
            a,b,c,d,e,f=1.0,0.0,(x1+x2)/2.0,-a2,1.0,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a1*(x1+x2))/2.0
            a,b,c,d,e,f=-a1,1.0,b1,1.0,0.0,(x1+x3)/2.0
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2.0
        b2=((y3+y1)-a2*(x1+x3))/2.0
        a,b,c,d,e,f=-a1,1.0,b1,-a2,1.0,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

Measured memory_bytes: 4496
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 0;
	vector<int> d;
	
	cin>>N;
	
	d.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>d[i];
	}
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			ans += d[i] * d[j];
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
while line=gets
(m,f,r)=line.split().map(&:to_i)
  break if m==-1&&f==-1&&r==-1
  m=f=0 if m==-1 || f==-1
  case m+f
  when 80..100; puts "A"
  when 65...80 ; puts "B"
  when 50...65 ; puts "C"
  when 30...50 ; puts r >= 50 ? "C" : "D"
  else ; puts "F"
  end
end

Measured memory_bytes: 6100
#include <stdio.h>

#define swap(a,b) {long tmp=a;a=b;b=tmp;}

long gcm(long m, long n){
	long newm,newn;
	if(n==0)return m;
	newn = m%n;
	newm = n;
	return gcm(newm,newn);
}

int main(){
	long a,b;
	long g,l;
	while(scanf("%ld %ld", &a,&b)!=EOF){
		if(a<b)swap(a,b);
		g = gcm(a,b);
		l = a/g*b;
		printf("%d %d\n",g, l);
	}
	return 0;
}

Measured memory_bytes: 596
package main

import (
  "fmt"
)

func main() {
  var n, y int
  fmt.Scan(&n, &y)
  for i := 0; i <= n; i++ {
    for j := 0; j <= n - i; j++ {
      rem := y - 10000 * i - 5000 * j
      k := rem / 1000
      if k == n - i - j {
        fmt.Printf("%d %d %d\n", i, j, k)
        return
      }
    }
  }
  fmt.Printf("-1 -1 -1\n")
}


Measured memory_bytes: 512
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] brick = new int[N];

        for(int i = 0; i < N; i++)
          brick[i] = Integer.parseInt(sc.next());

        int count = 1;
        for(int i = 0; i < N; i++){
          if(brick[i] == count)
            count++;
        }

        if(count == 1)
          System.out.println(-1);
        else
          System.out.println(N-count+1);
    }
}

Measured memory_bytes: 50372
#include <stdio.h>


int  selectionSort(int A[], int N) {
	int i, j,minj, tmp, count = 0;
	
	for (i = 0; i < N - 1; i++) {
		minj = i;
		for (j = i; j < N ; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		tmp = A[i];
		A[i] = A[minj];
		A[minj] = tmp;;
		if (i != minj) count++;
	}
	return count;
}

int main(void) {
	int N;
	int A[100];
	int i;
	int kai;

	scanf("%d", &N);
	
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	
	kai = selectionSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");

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

	return 0;
}

Measured memory_bytes: 604
#include<iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(a == 5&&b == 5&&c == 7)
	{
		cout << "YES";
	}
	else if(a == 5&&b == 7&&c == 5)
	{
		cout << "YES";
	}
	else if(a == 7&&b == 5&&c == 5)
	{
		cout << "YES";
	}
	else{
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int pow2[30];

vector<int> f(int k){
    if(k==0) return vector<int>(1,0); 
    vector<int> res;
    int m=1;
    while(k>=2*m){
        m*=2;
    }
    vector<int> v=f(k-m);
    for(int a:v){
        res.push_back(a);
    }
    for(int a:v){
        res.push_back(a+m);
    }
    return res;
}

int n;
string s;
vector<int> v;

void solve(){
    cin >> n;
    cin >> s;
    vector<int> p=f(n-2);
    // for(int a:p){
    //     cout << a << " ";
    // }
    // cout << "" << endl;
    
    rep(i,n-1){
        v.push_back(abs(s[i]-s[i+1]));
    }
    // rep(i,n-1){
    //     cout << v[i] << " ";
    // }
    // cout << "" << endl;
    int t=0;
    for(int a:p){
        t+=v[a];
        t%=2;
    }
    if(t==1) {
        cout << 1 << endl;
        return;
    }
    else{
        rep(i,n-1){
            if(v[i]==1){
                cout << 0 << endl;
                return;
            }
            else{
                v[i]/=2;
            }
        }
        int t=0;
        for(int a:p){
            t+=v[a];
            t%=2;
        }
        if(t==1) {
            cout << 2 << endl;
            return;
        }
        else{
            cout << 0 << endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int t[110], v[110];
int vtable[440000];
signed main() {
    cin >> N;
    reps(i, N) {
        cin >> t[i];
        t[i] *= 2;
        t[i] += t[i - 1];
    }
    reps(i, N) {
        cin >> v[i];
        v[i] *= 2;
        vtable[t[i - 1]] = min(v[i - 1], v[i]);
        for (int j = t[i - 1] + 1; j < t[i]; j++) { vtable[j] = v[i]; }
    }
    int ans = 0, cur = 0;
    reps(i, t[N]) {
        int tmp = cur - 1, rest = LLONG_MAX;
        for (int j = i; j <= t[N]; j++) {
            chmin(rest, vtable[j] - tmp);
            tmp--;
        }
        int next = cur - 1;
        if (rest == 1) { next++; }
        if (rest > 1) { next += 2; }
        ans += cur + next;
        cur = next;
    }
    cout << ans / 8.0 << endl;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 1);
  vector<int> B(N);
  for (int i = 0; i < N + 1; i++)
  {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> B.at(i);
  }
  long long int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (B.at(i) < A.at(i))
      ans += B.at(i);

    else
    {
      ans += A.at(i);
      B.at(i) -= A.at(i);
      if (B.at(i) <= A.at(i + 1))
      {
        ans += B.at(i);
        A.at(i + 1) -= B.at(i);
      }
      else
      {
        ans += A.at(i + 1);
        A.at(i + 1) = 0;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(int z[]){
  int i;
  for(i=0;i<VMAX;i++){
    z[i]=0;
  }
}

int main(){
  unsigned short *a, *b;
  int c[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  a = malloc(sizeof(short)*n+1);
  b = malloc(sizeof(short)*n+1);
  /*for(i=0;i<VMAX;i++){
    c[i]=0;
  }*/

CountingSort(c);

  for(i=0;i<n;i++){
    scanf("%hu",&a[i+1]);
    c[a[i+1]]++;
  }for(i=1;i<VMAX;i++){
    c[i]=c[i]+c[i-1];
  }for(j=1;j<n+1;j++){
    b[c[a[j]]]=a[j];
    c[a[j]]--;
  }for(i=1;i<n+1;i++){
    if(i>1){
      printf(" ");
    }printf("%d",b[i]);
  }printf("\n");

  return 0;
}



Measured memory_bytes: 9592
#include<stdio.h>
int main()
{
    long int n,ara[10000];
    long int i,j,k,max,min,sum=0;
    scanf("%ld",&n);
    for(i=0;i<n;i++){
            scanf("%ld",&ara[i]);
            sum=sum+ara[i];
    }
    max=ara[0];
    for(i=1;i<n;i++){
            if(ara[i]>max){
                max=ara[i];
            }
    }
        min=ara[0];
        for(i=1;i<n;i++){
            if(ara[i]<min){min=ara[i];}
        }
        printf("%ld %ld %ld\n",min,max,sum);

        return 0;
}


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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

struct Vtx
{
	std::vector<std::pair<u32, u32>> adj;
	u32 din = 0;
	u32 dout = 0;
	bool vis = false;
};

void dfs(std::vector<Vtx>& g, u32 n, std::vector<u32>& col, u32 pc = 0)
{
	g[n].vis = true;
	u32 nc = 0;
	for(u32 i=0; i<g[n].adj.size(); ++i)
	{
		if (g[g[n].adj[i].first].vis) continue;

		nc++;
		if(nc==pc) nc++;
		col[g[n].adj[i].second] = nc;
		dfs(g, g[n].adj[i].first, col, nc);
	}
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	u32 n;

	std::cin >> n;

	std::vector<Vtx> g(n);

	for(u32 i=0; i<n-1; ++i)
	{
		u32 a;
		u32 b;
		std::cin >> a >> b;
		--a;
		--b;

		g[a].adj.emplace_back(b, i);
		g[a].dout++;
		g[b].din++;

		g[b].adj.emplace_back(a, i);
	}

	u32 dmax = 0;
	for(u32 i=0; i<n-1; ++i)
	{
		u32 td = g[i].din + g[i].dout;
		if(td > dmax)
		{
			dmax = td;
		}
	}

	std::cout << dmax << "\n";

	std::vector<u32> col(n-1, 0);

	dfs(g, 0, col);

	for(u32 i=0; i<n-1; ++i)
	{
		std::cout << col[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
 
#define A_MAX 1000000
#define A_MAX_HALF 500000
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
int N;
 
int main() {
 
    for (int i = 2; i <= A_MAX_HALF; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
        }
        int j = 0;
        for (int p = 2; ; p = primes[++j]) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
 
    char c = getchar_unlocked();
    while (c > 47) {
        N = 10 * N + c - 48;
        c = getchar_unlocked();
    }
 
    for (int i = 0; i < N; ++i) {
        int x = 0;
        c = getchar_unlocked();
        while (c > 47) {
            x = 10 * x + c - 48;
            c = getchar_unlocked();
        }
        ++a[x];
    }
 
    int is_pairwise_coprime = 1;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = 0;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

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

using namespace std;

#define mod 1000000007
// #define mod1 9982
#define int  long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define endl "\n"

const int maxn=2e5+5;

void solve()
{
    int n,d;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        if(x*x+y*y <= d*d)
            ans++;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve(); 
}

/*
./a.out <input.txt > output.txt
*/


Measured memory_bytes: 3692
c = [[int(x) for x in input().split()] for _ in range(3)]
ans = 0

da = [c[0][0] - c[0][1], c[0][1] - c[0][2]]
db = [c[0][0] - c[1][0], c[1][0] - c[2][0]]

for i in range(3):
    if da != [c[i][0] - c[i][1], c[i][1] - c[i][2]]:
        ans += 1

for i in range(3):
    if db != [c[0][i] - c[1][i], c[1][i] - c[2][i]]:
        ans += 1 


if ans == 0:
    print("Yes")
else:
    print("No")


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

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

    vector<vector<int>> dist(2, vector<int>(N+1, -1));
    vector<int> start = {1, N};

    for (int i = 0; i < 2; i++) {
        queue<int> q;
        q.push(start[i]);
        dist[i][start[i]] = 0;
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for (int u : G[v]) {
                if (dist[i][u] != -1) continue;
                q.push(u);
                dist[i][u] = dist[i][v] + 1;
            }
        }
    }
    int blacks = 0;
    for (int i = 1; i <= N; i++) {
        if (dist[0][i] <= dist[1][i]) {
            blacks++;
        }
    }
    cout << ((blacks > N/2) ? "Fennec" : "Snuke") << endl;
}


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

using namespace std;

const int SEEHT = 630;

int n, q;
vector<string> s;
vector<int> k, ans;
vector<vector<int> > permu, query;

struct Trie {
    struct Node {
        int child[26], cnt, lst;
        Node() { memset(child, 0, sizeof child); cnt = lst = 0; }
    };
    vector<Node> node;
    Trie() { node.assign(1, Node() ); }

    void addString(int i) {
        int iNode = 0;
        for (auto c : s[i]) {
            int ascii = c - 'a';
            if (!node[iNode].child[ascii]) {
                node[iNode].child[ascii] = (int)node.size();
                node.push_back(Node() );
            }
            iNode = node[iNode].child[ascii];
            ++node[iNode].cnt;
        }
        ++node[iNode].lst;
    }
} trie;

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

//    freopen("input", "r", stdin);

    cin >> n;
    s.assign(n, "");
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        trie.addString(i);
    }

    cin >> q;
    k.assign(q, 0);
    permu.assign(q, vector<int>(26, 0) );
    query.assign(n, vector<int>() );
    for (int i = 0; i < q; ++i) {
        cin >> k[i]; --k[i];
        for (int j = 0; j < 26; ++j) {
            char c; cin >> c;
            permu[i][j] = c - 'a';
        }
        if (s[ k[i] ].size() > SEEHT) query[ k[i] ].push_back(i);
    }

    ans.assign(q, 0);
    for (int i = 0; i < q; ++i) if ( (int)s[ k[i] ].size() <= SEEHT) {
        int iNode = 0;
        for (auto c : s[ k[i] ]) {
            int ascii = c - 'a';
            for (int j = 0; j < 26; ++j) {
                if (permu[i][j] == ascii) break ;
                ans[i] += trie.node[ trie.node[iNode].child[ permu[i][j] ] ].cnt;
            }
            iNode = trie.node[iNode].child[ascii];
            ans[i] += trie.node[iNode].lst;
        }
    }

    for (int i = 0; i < n; ++i) if ( (int)s[i].size() > SEEHT) {
        vector<vector<int> > tmp(26, vector<int>(26, 0) );
        int iNode = 0;
        for (auto c : s[i]) {
            int ascii = c - 'a';
            for (int j = 0; j < 26; ++j) {
                if (j != ascii) tmp[j][ascii] += trie.node[ trie.node[iNode].child[j] ].cnt;

            }
            iNode = trie.node[iNode].child[ascii];
            tmp[ascii][ascii] += trie.node[iNode].lst;
        }
        for (int iQ : query[i]) {
            for (int i1 = 0; i1 < 26; ++i1) {
                for (int j1 = i1; j1 < 26; ++j1) ans[iQ] += tmp[ permu[iQ][i1] ][ permu[iQ][j1] ];
            }
        }
    }

    for (int i = 0; i < q; ++i) cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 60772
def getval():
    n = int(input())
    a = list(map(int,input().split()))
    return n,a

def main(n,a):
    a.sort()
    c = a[n-1]
    R = c/2
    r = 0
    for i in a:
        if abs(R-i)<abs(R-r):
            r = i 
    print("{x} {y}".format(x=c,y=r))

if __name__=="__main__":
    n,a = getval()
    main(n,a)

Measured memory_bytes: 20100