akhauriyash/Code-Regression huggingface dataset:
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
    template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e3+10;

    ll fac[N],facinv[N];ll C(int n,int m){return (n<0 or n<m)?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
    int ct[N],pw[N][N];
    int f[N][N],g[N][N];
    void main()
	{
        fac[0]=1;fo(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
        facinv[N-1]=invm(fac[N-1]);fd(i,N-1,1) facinv[i-1]=facinv[i]*i%MOD;
        int n=qread(),X=qread();fo(i,1,n) ct[qread()]++;g[0][0]=1;
        fo(i,0,X) fo(j,0,n) pw[i][j]=qpower(i,j);
        fd(now,X,1)
        {
            fo(cnt,0,(X+1)/2) fo(len,cnt*(now+1),X-(cnt-1)) if(g[cnt][len])
                fo(i,0,min((X-cnt+1-len)/now,(X+1)/2-cnt))
                // for(int i=0;cnt+i<=(X+1)/2 and len+i*now<=X-cnt+1;i++) 
                    add(f[cnt+i][len+i*now],1ll*g[cnt][len]*facinv[i]%MOD );  
            fo(cnt,0,(X+1)/2) fo(len,cnt*now,X-(cnt-1))
            {
                g[cnt][len]=1ll*f[cnt][len]*pw[len+cnt*(-now+1)][ct[now]]%MOD;
                f[cnt][len]=0;
            }
        }
        ll ans=0;fo(cnt,0,X) fo(len,0,X)
            add(ans, fac[cnt]*g[cnt][len]%MOD*C(X-len+2-1,cnt)%MOD*((X-len)&1?MOD-1:1)%MOD );write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 9472
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let b: i32 = input();
    println!("{}", std::cmp::max(std::cmp::max(a+b, a-b), a*b));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
const int MAX_N=10010;
int par[MAX_N];
int rnk[MAX_N];

void init_uftree(int n){
  REP(i,n){
    par[i]=i;
    rnk[i]=0;
  }
}
int find(int x){
  if(par[x]==x) return x;
  else return par[x] = find(par[x]);
}
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(rnk[x]<rnk[y]) par[x]=y;
  else{
    par[y]=x;
    if(rnk[x]==rnk[y]) rnk[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}
struct edge{int to,dist,cost;};
using Triple=pair<pair<int,int>,int>;
#define T(i,j,k) make_pair(make_pair((i),(j)),(k))
#define Dist first.first
#define Cost first.second
#define To second
const int INF=1<<29;
const int MAX_V=10010;
vector<edge> G[MAX_V];
int d[MAX_V];
int c[MAX_V];
int V,E;
//O(E*logV)
long long dijkstra(int s){
  init_uftree(V);
  long long result=0;
  priority_queue<Triple,vector<Triple>,greater<Triple>> que;
  fill(d,d+V,INF);
  fill(c,c+V,INF);
  d[s]=0;
  c[s]=0;
  que.push(T(0,0,s));
  while(!que.empty()){
    Triple p=que.top();que.pop();
    int v=p.To;
    if(d[v]<p.Dist)continue;
    if(!same(s,v)){
      unite(s,v);
      result+=p.Cost;
    }
    REP(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>=d[v]+e.dist){
	d[e.to]=d[v]+e.dist;
	c[e.to]=c[v]+e.cost;
	que.push(T(d[e.to],e.cost,e.to));
      }
    }
  }
  return result;
}
int main(){ _;
  int u,v,d,c;
  while(cin>>V>>E,(V|E)){
    REP(i,MAX_V) G[i].clear();
    REP(i,E){
      cin>>u>>v>>d>>c;
      u--;v--;
      G[u].push_back(edge{v,d,c});
      G[v].push_back(edge{u,d,c});
    }
    cout<<dijkstra(0)<<endl;
  }
}

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

using ll = long long int;
constexpr int INF = 1 << 30;

int solve(){
    int n;
    cin >> n;
    if(n==0) return 1;
    vector<ll> a(n);
    vector<bool> broken(n);
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s=="x") broken[i] = true;
        else a[i] = stol(s);
    }
    ll low = -INF, up = INF;
    bool valid = true;
    for(int i=0;i<n-1;i++){
        if(broken[i]){
            if(i%2){
                if(!broken[i+1]) low = max(low, a[i+1]+1);
                else valid = false;
            }else{
                if(!broken[i+1]) up = min(up, a[i+1]);
                else valid = false;
            }
        }else{
            if(!broken[i+1]){
                valid &= (i%2 ? a[i]>a[i+1] : a[i]<a[i+1]);
            }else{
                if(i%2){
                    up = min(up, a[i]);
                }else{
                    low = max(low, a[i]+1);
                }
            }
        }
    }
    if(!valid || low >= up){
        cout << "none" << endl;
    }else if(up-low >= 2){
        cout << "ambiguous" << endl;
    }else{
        cout << low << endl;
    }
    return 0;
}

int main(){
    while(solve()==0);
    return 0;
}


Measured memory_bytes: 3012
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
	int64_t x;
	mint(int64_t x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(int64_t t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	//for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
	vector<mint> frac, ifrac;
	combination(int n):frac(n+1), ifrac(n+1) {
		assert(n < mod);
		frac[0] = 1;
		for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
		ifrac[n] = frac[n].inv();
		for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return frac[n]*ifrac[k]*ifrac[n-k];
	}
} c(1000000);

//head



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	int a, b;
	cin >> a >> b;
	mint ans;
	for(int i = b; i < w; i++) {
		ans += c(i+h-a-1, i) * c(a-1+w-i-1, a-1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 18592
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int X = scan.nextInt();
                int Y = scan.nextInt();
                
                if(Y%2==1){
                    System.out.println("No");
                }else{
                    if(X*2<=Y && Y<=X*4){
                         System.out.println("Yes");
                    }else{
                        System.out.println("No");
                    }
                }
        }
}

Measured memory_bytes: 35340
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int main() {
	int N;
	cin >> N;
	vi a(N);
	vll sum(N + 1);
	sum[0] = 0;
	rep(i, N) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	ll ans = INFL;
	repl(i, 1, N) {
		ans = min(ans, abs(sum[N] - 2*sum[i]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long res=0;
		
		
			res = (b/x) - (a/x);
			if (a%x==0) {
				res++;}
			
		
		System.out.println(res);
	}

}


Measured memory_bytes: 35632
#include <bits/stdc++.h>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))

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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    int cnt = 0;
    for(int i = max(a,b); i > 0; --i){
        if(a % i == 0 && b % i == 0) {
            ++cnt;
            
            if(cnt == k) {
                cout << i;
                exit(0);
            }
        }
    }
    
}

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

int main(){
  string n;
  cin >> n;
  for(int i = 0; i < 3; i++) {
    switch(n[i]) {
    case '1':
      n[i] = '9';
      break;
    case '9':
      n[i] = '1';
      break;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int INF = 1e8 + 5;
const int MAX_V = 500;

void init(int m[MAX_V][MAX_V]){
	rep(i,MAX_V) rep(j,MAX_V) m[i][j] = INF;
	rep(i,MAX_V) m[i][i] = 0;
}

void warshallFloyd(int m[MAX_V][MAX_V], int n){
	rep(k,n){
		rep(i,n){
			rep(j,n){
				m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
			}
		}
	}
}

//i番目のビットを返す
bool getBit(int num, int i){
	return ((num & (1 << i)) != 0);
}

//i番目を1にする
int setBit(int num, int i){
	return num | (1 << i);
}

//i番目を0にする
int clearBit(int num, int i){
	int mask = ~(1 << i);
	return num & mask;
}

//i番目をvで置き換える
int updateBit(int num, int i, int v){
	int mask = ~(1 << i);
	return (num & mask) | (v << i);
}

int main(){
	int n, m, l, s, t;
	while(cin >> n >> m >> l >> s >> t, n){
		s--;

		int g[MAX_V][MAX_V];
		init(g);
		rep(i,m){
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			g[a][b] = g[b][a] = c;
		}
		warshallFloyd(g, n);

		vector<pair<int, int>> r(l + 1);
		rep(i,l){
			cin >> r[i].first >> r[i].second;
			r[i].first--;
		}
		r[l] = make_pair(s, 0);

		//rep(i,n){ rep(j,n){ cout << g[i][j] << ' '; } cout << endl; }

		l++;
		vector<vector<int>> dp(1 << l, vector<int>(l, INF));
		rep(i,l){
			dp[1 << i][i] = g[s][r[i].first] + r[i].second;
			//dp[1 << i][i] = g[s][r[i].first] + r[i].second;
		}

		//rep(b, 1 << l){ rep(i,l){ cout << dp[b][i] << ' '; } cout << endl; }
		//cout << endl;
		rep(b, 1 << l){
			rep(i,l){
				if(not getBit(b, i)) continue;
				//dp[setBit(b, i)][i] = min(dp[setBit(b, i)][i], dp[b][i] + r[i].second);
				rep(j,l){
					if(getBit(b, j)) continue;
					dp[setBit(b, j)][j] = min(dp[setBit(b, j)][j], dp[b][i] + g[r[i].first][r[j].first] + r[j].second);
				}
			}
		}

		//rep(b, 1 << l){ rep(i,l){ cout << dp[b][i] << ' '; } cout << endl; }

		int ans = 0;
		rep(b, 1 << l){
			if(dp[b][l - 1] <= t) ans = max<int>(ans, bitset<20>(b).count());
			//rep(i,l){
			//	if(dp[b][i] + g[r[i].first][s] <= t) ans = max<int>(ans, bitset<20>(b).count());
			//}
		}
		cout << ans - 1 << endl;
	}
}



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

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    for (int i=0;i<N;i++){
        cin>>a.at(i);
    }
    int cost=0,ans=0;
    for (int i=0;i<N;i++){
        ans += (100-a.at(i))*(100-a.at(i));
    }
    for(int j=-100;j<101;j++){
        for (int i=0;i<N;i++){
            cost += (j-a.at(i))*(j-a.at(i));
        }
        if (cost<=ans){
            ans = cost;
        }
        cost = 0;
        }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int S;
	scanf("%d", &S);
	
	if (S % 100 > 12) 
	{
		if (S > 1299|| S < 100) 
		{
			printf("NA");
		}
		else
		{
			printf("MMYY");
		}
		return 0;
	}
	if (S % 100 < 1) 
	{
		if (S > 1299 || S < 100)
		{
			printf("NA");
		}
		else 
		{
			printf("MMYY");
		}
		return 0;
	}
	if (S % 100 < 13) 
	{
		if (S > 1299 || S < 100)
		{
			printf("YYMM");
		}
		else 
		{
			printf("AMBIGUOUS");
		}
	}


	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    bool flag = false;
    while (n) {
        int x = n % 10;
        n /= 10;
        if (x == 7) flag = true;
    }
    if (flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, A, B, C, D;
    
    cin >> N >> A >> B >> C >> D;
    
    for (ll m = 0; m < N; m++) {
        ll n = N - 1 - m;
        if (C * n - D * m <= B - A && B - A <= D * n - C * m) {
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define N 1001

  
int main()
{
  int i,n,keta;
  int ans;
  int c;
  char str[N],tmp[N];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&c);
      str[i]=c+'0';
    }
  str[n]='\0';
  for(ans=0;;ans++)
    {
      if(ans) keta=(int)(log10(ans))+1;
      else keta=1;
      for(i=0;i<n-keta+1;i++)
	{
	  strcpy(tmp,str+i);
	  tmp[keta]='\0';
	  if(ans==atoi(tmp)) break;
	}
      if(i==n-keta+1) break;
    }
  printf("%d\n",ans);
  return 0;
}




Measured memory_bytes: 2140
n, m = map(int, input().split())
h = list(map(int, input().split()))

check = [1]*n

for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        check[b-1] = 0
    elif h[b-1] > h[a-1]:
        check[a-1] = 0
    else:
        check[a-1] = 0
        check[b-1] = 0

print(check.count(1))

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


public class Main {
	
	public static class edge {
		
		node l;
		node r;
		int d;
		
		public edge(node l, node r, int d) {
			this.l = l;
			this.r = r;
			this.d = d;
		}
		
	}	
	public static class node {
		
		boolean assigned; //have we ever given this a val?
		LinkedList<edge> edg;
		boolean cleared; //processed
		int loc;
		
		public node() {
			assigned = false;
			loc = 0;
			cleared = false;
			edg = new LinkedList<edge>();
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] rd;
		rd = in.readLine().split("\\s++");
		int n = Integer.parseInt(rd[0]);
		int m = Integer.parseInt(rd[1]);
		node[] nodes = new node[n];
		for(int i = 0; i < n; i++) {
			nodes[i] = new node();
		}
		for(int i = 0; i < m; i++) {
			rd = in.readLine().split("\\s++");
			int l = Integer.parseInt(rd[0]);
			int r = Integer.parseInt(rd[1]);
			int d = Integer.parseInt(rd[2]);
			edge t = new edge(nodes[l-1], nodes[r-1], d);
			nodes[l-1].edg.offer(t);
			nodes[r-1].edg.offer(t);
		}
		boolean gucci = true;
		for(int i = 0; i < n; i++) {
			if(nodes[i].cleared) continue;
			LinkedList<node> q = new LinkedList<node>();
			q.offer(nodes[i]);
			nodes[i].assigned = true;
			while(!q.isEmpty()) {
				node nod = q.poll();
				for(edge e : nod.edg) {
					node oth = e.l;
					int dir = -1;
					if(e.l == nod) {
						oth = e.r;
						dir = 1;
					}
					if(oth.cleared) continue;
					else {
						if(!oth.assigned) {
							q.offer(oth);
							oth.loc = nod.loc + dir * e.d;
							oth.assigned = true;
						} else {
							if(oth.loc != nod.loc + dir * e.d) gucci = false;
						}
					}
				}
				nod.cleared = true;
			}
		}
		System.out.println(gucci ? "Yes" : "No");
	}
}

Measured memory_bytes: 117628
from math import sqrt
n,d=map(int,input().split())
a=[]
ans=0
for i in range(n):
  a.append(list(map(int,input().split())))
for i in range(n-1):
  for j in range(i+1,n):
    t=0
    for k in range(d):
      t+=(a[i][k]-a[j][k])**2
    rt=sqrt(t)
    if rt-rt//1==0:
      ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;

int n,m;
int ans;
int main() {
	cin >> n >> m;
	for (int i =1;i*i <= m; i++) {
		if (m % i == 0) {
			int fac = m / i;
			if (i >= n) ans = max(ans,fac);
			if (fac >= n) ans = max(ans,i);
		}
	}
	cout << ans;
}
	
	

	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
using namespace std;

string s;

void solve()
{
	cin>>s;
	if(s=="ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
}


Measured memory_bytes: 3612
import math

x1,y1,x2,y2=map(int,input().split())
sub=[x2-x1,y2-y1]
x3=x2-(y2-y1)
y3=y2+(x2-x1)
x4=x3-(x2-x1)
y4=y3-(y2-y1)
print(x3,y3,x4,y4)

Measured memory_bytes: 38256
I=lambda:map(int,input().split())
n,m=I()
l=[[]for _ in range(n+1)]
for i in range(m):
  p,y=I()
  l[p].append([y,i])
a=[]
for p in range(1,n+1):
  l[p].sort()
  for i,t in enumerate(l[p]):
    a.append([t[1],'%06d'%p+'%06d'%-~i])
a.sort()
for t in a:
  print(t[1])

Measured memory_bytes: 92960
S = input()
T = input()

s_dict, t_dict = {}, {}

for i in range(len(S)):
    if S[i] in s_dict.keys():
        if s_dict[S[i]] != T[i]:
            print("No")
            exit()
    else:
        s_dict[S[i]] = T[i]

    if T[i] in t_dict.keys():
        if t_dict[T[i]] != S[i]:
            print("No")
            exit()
    else:
        t_dict[T[i]] = S[i]

print("Yes")


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

using v1 = vector<int>;
using v2 = vector<vector<int>>;
using ll = long long;

int main(){
	int h1, m1, h2, m2, k;
	cin >> h1>> m1>>h2>> m2>>k;
	int time = (h2-h1)*60 + (m2-m1);
	cout << time - k << endl;

}


Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int sml=1e9,sum,ans1;
int main(){
	int n;
	string s;
	cin>>n>>s;
	for (int i=0;i<n;i++){
		if (s[i]=='(') sum++;
		else sum--;
		sml=min(sum,sml);
	}
	if (sml<0) ans1=-sml;
	int ans2=ans1+sum;
	for (int i=0;i<ans1;i++) printf("(");
	cout<<s;
	for (int i=0;i<ans2;i++) printf(")");
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for _ in range(H)]

def check() :
    for y in range(H) :
        for x in range(W) :
            if s[y][x] == '.' :
                continue
                
            for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)) :
                if not (0 <= (y + dy) < H and 0 <= (x + dx) < W) :
                    continue
                if s[y+dy][x+dx] == '#' :
                    break
            else :
                return 'No'
    return 'Yes'
    
print(check())

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


const int MOD = 1E9 + 7;
void _main() {
        int n; cin >> n;
        ll ans = 1;
        for (int i = 1; i <= n; i++) ans *= 10, ans %= MOD;
        ll x = 1;
        for (int i = 1; i <= n; i++) x *= 9, x %= MOD;
        ans = (ans - x + MOD) % MOD;
        ans = (ans - x + MOD) % MOD;
        x = 1;
        for (int i = 1; i <= n; i++) x *= 8, x %= MOD;
        cout << (ans + x) % MOD;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define PI 3.14159265358979323846264338327950288l
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  double a, b,x,ans,h,m;
  cin >> a >> b >> h >> m;
  x = abs(PI * h / 6.0l+PI*m/360.0l - PI * m / 30.0l);
  ans = sqrtl(a * a + b * b - 2.0l * a * b * cosl(x));
  cout  <<setprecision(15) <<ans<<  "\n";
  return 0;
}


Measured memory_bytes: 4172
from collections import deque

def bfs():
    move=[[1,0],[0,1],[-1,0],[0,-1]]
    visited=[[-1]*yoko for i in range(tate)]
    queue=deque()
    queue.append([sy,sx]) #queue=deque([[sy,sx]])でもよい
    visited[sy][sx]=0 #スタート地点の距離は0
    while queue:
        y,x=queue.popleft()
        if [y,x]==[gy,gx]: #終了条件
            return visited[gy][gx]
        for dy,dx in move:
            my,mx=y+dy,x+dx
            if not(0<=my<tate) or not(0<=mx<yoko):
                continue
            if maze[my][mx]=="." and visited[my][mx]==-1:
                queue.append([my,mx])
                visited[my][mx]=visited[y][x]+1 # visitedは距離も兼ねてる
    return -1 #たどり着けないとき

tate,yoko=map(int,input().split())
maze=[]
black=0
for i in range(tate):
    line=list(input())
    maze.append(line)
    black+=line.count('#')
sy,sx=0,0
gy,gx=tate-1,yoko-1
white=1+bfs()
if white==0: #たどり着けないとき1+-1=0
    ans=-1
else:
    ans=tate*yoko-black-white
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

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

    long * a =new long [n+1];
    long *b= new long [n];

    for(int i=0;i<n+1;i++)
    {
        cin>>a[i];
    }
    for(int j=0;j<n;j++)
        cin>>b[j];
    long long res=0;

        for(int i=0;i<n;i++)
    {
            if(a[i]<=b[i])
            {
                res+=a[i];
                b[i]-=a[i];
                a[i]=0;

                if(a[i+1]<=b[i])
                {
                res+=a[i+1];
                a[i+1]=0;
               // b[i]-=a[i+1];
                }
                else{
                    a[i+1]-=b[i];
                    res+=b[i];
                }

            }
            else{

                res+=b[i];
                a[i]-=b[i];

            }


    }
    cout<<res;

return 0;}






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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int w, h, n;
	cin >> w >> h >> n;

	int xb = 0;
	int xe = w;
	int yb = 0;
	int ye = h;
	for(int i=0; i<n; i++){
		int x, y, a;
		cin >> x >> y >> a;

		if(a == 1){
			xb = max(xb, x);
		}else if(a == 2){
			xe = min(xe, x);
		}else if(a == 3){
			yb = max(yb, y);
		}else if(a == 4){
			ye = min(ye, y);
		}
	}

	if(xe < xb || ye < yb){
		puts("0");
	}else{
		cout << (xe - xb) * (ye - yb) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define res register int
#define ll long long
using namespace std;
ll a[3];
inline ll read(){
	res X=0,w=0;char ch=0;
	while(!isdigit(ch)){w|ch=='-';ch=getchar();}
	while(isdigit(ch)){X=(X<<1)+(X<<3)+(ch^48);ch=getchar();}
	return w?-X:X;
}
int main(){
	for(res i=0;i<3;i++)
	  a[i]=read();
	sort(a,a+3);
	if(a[2]&1)
		printf("%lld\n",a[1]*a[0]);
	else
	   printf("%lld\n",0LL);
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

class UnionFind {
	vector<int>parent;
public:
	vector<int>sz;
	UnionFind(int num) {
		num++;
		parent.resize(num);
		sz.resize(num);
		for (int i = 0; i < N; i++)sz[i] = 1;
		for (int i = 0; i < num; i++) {
			parent[i] = i;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (u < v)swap(u, v);
		parent[v] = u;
		sz[u] += sz[v];
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

struct Edge {
	int a, b, cost;
	bool operator<(const Edge&n)const {
		return cost < n.cost;
	}
	Edge(const int aa, const int bb, const int cc) {
		a = aa, b = bb, cost = cc;
	}
};

void Search(vector<long long int>&ans, vector<vector<pair<int, long long int>>>&edge, int node = N * 2 - 2) {
	ans[node] = M;
	for (auto i : edge[node]) {
		M += i.second;
		Search(ans, edge, i.first);
		M -= i.second;
	}
}

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

	cin >> N;
	vector<Edge>edge;
	for (int i = 1; i < N; i++) {
		cin >> L >> R >> K;
		L--, R--;
		edge.emplace_back(L, R, K);
	}
	sort(edge.begin(), edge.end());
	reverse(edge.begin(), edge.end());
	vector<vector<pair<int, long long int>>>t_edge(N * 2 - 1);
	int cnt = N;
	UnionFind uf(N * 2 - 1);
	for (auto i : edge) {
		int a = uf.Find(i.a);
		int b = uf.Find(i.b);
		t_edge[cnt].emplace_back(a, 1LL * uf.sz[uf.Find(i.b)] * i.cost);
		t_edge[cnt].emplace_back(b, 1LL * uf.sz[uf.Find(i.a)] * i.cost);
		uf.Unite(cnt, i.b);
		uf.Unite(cnt, i.a);
		cnt++;
	}
	vector<long long int>ans(N*2-1);
	Search(ans, t_edge);
	for (int i = 0; i < N; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 20084
solv a b c ls = minimum $ go ls ((0,0),(0,0),(0,0))where
  go [] ((sa,la),(sb,lb),(sc,lc))
    | la==0 || lb==0 || lc==0 = []
    | otherwise = [(la+lb+lc-3)*10 + abs (a-sa) + abs (b-sb) + abs (c-sc)]
  go (x:xs) ((sa,la),(sb,lb),(sc,lc))
    = concat [ go xs ((sa+x,la+1),(sb,lb),(sc,lc))
             , go xs ((sa,la),(sb+x,lb+1),(sc,lc))
             , go xs ((sa,la),(sb,lb),(sc+x,lc+1))
             , go xs ((sa,la),(sb,lb),(sc,lc))
             ]

main = do
  [n,a,b,c] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getContents :: IO [Int]
  print $ solv a b c xs


Measured memory_bytes: 892
import collections
n = int(input())
v = [int(i) for i in input().split()]
kisu = []
gusu = []

kisu = v[::2]
gusu = v[1::2]

kisu_cnt = collections.Counter(kisu)
gusu_cnt = collections.Counter(gusu)

kisu_cnt = kisu_cnt.most_common(2)#引数にnを用意すると，出現回数の多い順にn子だけ呼び出せる
gusu_cnt = gusu_cnt.most_common(2)
kisu_most  = 0
gusu_most = 0
if kisu_cnt[0][0]!=gusu_cnt[0][0]:
    print(n-kisu_cnt[0][1]-gusu_cnt[0][1])
    exit()
else:
    if len(kisu_cnt)==1 or len(gusu_cnt)==1:
        print(n//2)
        exit()
    else:
        print(n-max(kisu_cnt[0][1]+gusu_cnt[1][1],kisu_cnt[1][1]+gusu_cnt[0][1]))

Measured memory_bytes: 23452
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Pair[] P = new Pair[N];
		for(int i=0;i<N;i++){
			P[i] = new Pair(A[i],i);
		}
		Array.Sort(P, (p,q) => p.V.CompareTo(q.V));
		
		var UF = new UnionFind(N);
		for(int i=0;i<N-1;i++){
			if(P[i+1].Idx > P[i].Idx){
				UF.Unite(i, i + 1);
			}
		}
		
		int max = 1;
		for(int i=0;i<N;i++){
			if(UF.IsRoot(i)){
				max = Math.Max(max, UF.MemCnt(i));
			}
		}
		
		Console.WriteLine(N - max);
		
	}
	class Pair {
		public int V, Idx;
		public Pair(int v, int idx){
			V = v; Idx = idx;
		}
	}
	
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = new int[N];
		for(int i=0;i<N;i++) A[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class UnionFind{
	
	int[] parent;
	int[] mem;
	int compo;
	int N;
	
	public UnionFind(UnionFind v){
		// copy constructor
		N = v.N;
		parent = new int[N];
		mem = new int[N];
		for(int i=0;i<N;i++){
			parent[i] = v.parent[i];
			mem[i] = v.mem[i];
		}
		compo = v.compo;
	}
	public UnionFind(int n_){
		Initialize(n_);
	}
	
	public void Initialize(int n_){
		N = n_;
		parent = new int[N];
		mem=new int[N];
		for(int i=0;i<N;i++){
			parent[i] = i;
			mem[i] = 1;
		}
		compo = N;
	}
	
	public int Parent(int a){
		if(parent[a] == a)return a;
		return parent[a] = Parent(parent[a]);
	}
	
	public bool IsUnited(int a,int b){
		return Parent(a) == Parent(b);
	}
	
	public void Unite(int a,int b){
		a = Parent(a); b = Parent(b);//Parent()を呼ぶことでa以上のノードは全てparentがrootになる
		if(a == b)return;
		parent[a] = b;
		mem[b] += mem[a];
		compo -= 1;
	}
	
	public bool IsRoot(int x){
		return x == parent[x];
	}
	public int MemCnt(int x){
		return mem[Parent(x)];
	}
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i == 0 ? "{0}" : " {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
	public int Compo{
		get{
			return compo;
		}
	}
	
}


Measured memory_bytes: 23768
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;


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

	int max_ws=100*a;
	int max_s=0;

	for (int wa = 0; wa <=f; wa+=100*a) {
		for (int wb = 0; wb <= f; wb+=100*b) {
			int water = wa + wb;
			if (water > 0 && water <= f) {
				for (int sc = 0; sc <= water/100*e;sc+= c) {
					for (int sd = 0; sd <=(water / 100 * e) - sc; sd += d) {
						int suger = sc + sd;
						if (suger + water <= f) {
							if (suger *max_ws > max_s*(water + suger)) {
								max_ws = water + suger;
								max_s = suger;
							}
						}
						else {
							break;
						}
					}
						
					
				}
			}
			else if (water > f) {
				break;
			}
		}
	}
	cout << max_ws << " " << max_s << endl;
}

Measured memory_bytes: 256
l=a=0;r=len(s:=input())-1;c='x'
while l<r:
  X=((L:=s[l])==(R:=s[r]))
  l+=((L:=(L==c))+X>0)
  r-=((R:=(R==c))+X>0)
  a+=(X<1 and (L+R>0))
  if X+L+R<1:a=-1;break
print(a)

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

int main(){
  int r,c;
  cin>>r>>c;
  int m[r][c];
  int sum_col[c];
  int sum_row;

  for(int j=0;j<c;j++){
      sum_col[j] = 0;
  }

  int tmp;
  for(int i=0;i<r;i++){
    sum_row=0;
    for(int j=0;j<c;j++){
      cin>>tmp;
      sum_col[j]+=tmp;
      sum_row+=tmp;
      cout<<tmp<<' ';
    }
    cout<<sum_row<<endl;
  }
  sum_row=0;
  for(int i=0;i<c;i++){
    cout<<sum_col[i]<<' ';
    sum_row+=sum_col[i];
  }
  cout<<sum_row<<endl;
  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    double D,T,S;
    cin >> D >> T >> S;
    cout << ((D/S <= T) ? "Yes" : "No") << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)

inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
int h[100010];
int main(){
  int n=read(),a=read(),b=read(),max_el=0;
  a-=b;
  rep(i,n){
    h[i]=read();
    max_el=max(h[i],max_el);
  }
  int left=0,right=max_el/b+1,mid;
  ll temp,cnt=0;
  while (right>left) {
    mid=(right+left)>>1;
    cnt=0;
    rep(i,n){
      temp=h[i]-b*mid;
      if(temp>0)cnt+=ceil(1.0*temp/a);
    }
    if(cnt<=mid)right=mid;
    else left=mid+1;
  }
  printf("%d\n",left);
  return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include<iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		double W, H, x, y;

		cin >> W >> H >> x >> y;
		if (cin.fail()) break;

		cout << W * H / 2.0 << ((W / 2.0 == x && H / 2.0 == y) ? " 1" : " 0") << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque

N, M = map(int, input().split())
edges = defaultdict(list)
for _ in range(M):
    a, b = map(lambda x:int(x)-1, input().split())
    edges[a].append(b)
    edges[b].append(a)

go_to = [None] * N

q = deque()
q.append((0, -1))
is_visited = set()

while q:
    node, prev = q.popleft()
    if node in is_visited:
        continue
    is_visited.add(node)
    go_to[node] = prev + 1
    for dest in edges[node]:
        q.append((dest, node))

print('Yes')
for i in range(1, N):
    print(go_to[i])



Measured memory_bytes: 62320
// Problem : F - Range Set Query
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int N = 1e6+7;
int a[N],belong[N],cnt[N],res[N];
int quasize,bnum,now;
struct _Node
{
	int l,r,id;
	bool operator<(const _Node& b)	const
	{
		if(belong[l] == belong[b.l])	return r < b.r;
		return belong[l] < belong[b.l];
	}
}q[N];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	quasize = sqrt(n);
	bnum = ceil(double(n) / quasize);
	
	for(int i = 1;i <= bnum;++i)
		for(int j = (i - 1) * quasize + 1;j <= i * quasize;++j)
			belong[j] = i;
	for(int i = 1;i <= n;++i)	scanf("%d",&a[i]);
	for(int i = 1;i <= m;++i)	scanf("%d%d",&q[i].l,&q[i].r),q[i].id = i;
	sort(q+1,q+m + 1);
	
	int l = 1,r = 0;
	for(int i = 1;i <= m;++i)
	{
		int ql = q[i].l,qr = q[i].r;
		while(l < ql) now -= !--cnt[a[l++]];
		while(l > ql) now += !cnt[a[--l]]++;
		while(r < qr) now += !cnt[a[++r]]++;
		while(r > qr) now -= !--cnt[a[r--]];
		res[q[i].id] = now;
	}
	for(int i = 1;i <= m;++i)	printf("%d\n",res[i]);
	return 0;
}


Measured memory_bytes: 17424
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  ll n,a,b;cin>>n>>a>>b;
  vector<ll>mons(n);
  for(int i=0;i<n;i++)
    cin>>mons[i];
  ll left=1,right=1000000000;
  ll mid=(left+right)/2;
  while(left!=right){
    if(right-left==1)
      break;
    mid=(left+right)/2;
    ll noko=mid;
    // cout<<left<<" "<<right<<endl;
    for(int i=0;i<n;i++){
      ll minus;
      if(mons[i]-b*mid<=0)continue;
      if((mons[i]-b*mid)%(a-b)!=0)
	minus=(mons[i]-b*mid)/(a-b)+1;
      else
	minus=(mons[i]-b*mid)/(a-b);
      noko-=minus;
    }
    if(noko<=0){
      left=mid;
    }else if(noko>0){
      right=mid;
    }
  }
  if(right-left==1){
    ll noko=left;
    for(int i=0;i<n;i++){
      ll minus;
      if(mons[i]-b*left<=0)continue;
      if((mons[i]-b*left)%(a-b)!=0)
	minus=(mons[i]-b*left)/(a-b)+1;
      else
	minus=(mons[i]-b*left)/(a-b);
      noko-=minus;
    }
    if(noko>=0)
      cout<<left<<endl;
    else
      cout<<right<<endl;
  }else
    cout<<left<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n,a[101],flag=0;
	scanf("%d",&n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if(a[i]%2==0)
	{
		if (a[i]%3==0||a[i]%5==0)
		{
			flag=0;
		}
		else
		{
			flag=1;
			break;
		}
	}
	}
	if(flag==0) printf("APPROVED\n");
	else printf("DENIED\n");
	return 0;
}

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

int main(){
    int N;
    cin >> N;

  vector<string> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }



    map<string,int> mp;
    for (string x :A) {

        if(mp.count(x)){
            mp[x] ++;
        }
        else mp[x] =1;
    }

  int max_cnt = 0; 
   
    
        for (string x : A) {
        if (max_cnt < mp[x]) {
        max_cnt = mp[x];
        
        
        }
    }
       for(auto p:mp){

        auto key =p.first;
        auto value = p.second;
        if(value == max_cnt)        cout<< key << endl;
    }
     



     






}

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

using namespace std;

typedef long long ll;

#define siz 100001
#define mod 1000000001

int main(){
	
	ll t;
	cin >> t;
	map<string, int> mp;
	while(t--){
		string s;
		cin >> s;
		
		if(!mp.count(s)){
			mp[s] = 1;
		}else {
			mp[s]++;
		}
	}
	
	cout << "AC x " << mp["AC"] << "\n";
	cout << "WA x " << mp["WA"] << "\n";
	cout << "TLE x " << mp["TLE"] << "\n";
	cout << "RE x " << mp["RE"] << "\n";
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	cout << (((g * 10 + b) % 4 != 0) ? "NO" : "YES") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt(), sy = sc.nextInt(), tx = sc.nextInt(), ty = sc.nextInt();
		StringBuilder sb = new StringBuilder();

		/* s to t (1st) */
		for(int i = 0; i < ty - sy; i++) sb.append("U");
		for(int i = 0; i < tx - sx; i++) sb.append("R");

		/* t to s (1st) */
		for(int i = 0; i < ty - sy; i++) sb.append("D");
		for(int i = 0; i < tx - sx; i++) sb.append("L");

		/* s to t (2nd) */
		sb.append("L");
		for(int i = 0; i < ty - sy + 1; i++) sb.append("U");
		for(int i = 0; i < tx - sx + 1; i++) sb.append("R");
		sb.append("D");

		/* t to s (2nd) */
		sb.append("R");
		for(int i = 0; i < ty - sy + 1; i++) sb.append("D");
		for(int i = 0; i < tx - sx + 1; i++) sb.append("L");
		sb.append("U");

		System.out.println(sb.toString());
	}
}

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

typedef long long ll;

const int MAX = 200005;
const int MOD = 1000000007;
vector<int> g[MAX];

int pow2[MAX];

int add(int a, int b) { return (a+b)%MOD; }
int sub(int a, int b) { return ((ll)a-(ll)b+2*(ll)MOD)%MOD; }
int mult(int a, int b) { return ((ll)a*(ll)b)%MOD; }
int sq(int a) { return mult(a, a); }
int exp(int a, int b) {
	if (b == 0) { return 1; }
	if (b%2 == 1) { return mult(a, sq(exp(a, b/2))); }
	else { return sq(exp(a, b/2)); }
}
int inv(int a) { return exp(a, MOD-2); }
int divi(int a, int b) { return mult(a, inv(b)); }

int d[MAX], dep[MAX];

struct trip {
	int v[3];
	trip(int a, int b, int c) { v[0] = a; v[1] = b; v[2] = c; }
};

trip comb(trip a, trip b) {
	trip c = trip(0, 0, 0);
	for (int i=0; i<=2; i++) {
		for (int j=0; j<=2; j++) {
			int n = min(2, i+j);
			c.v[n] = add(c.v[n], mult(a.v[i], b.v[j]));
		}
	}
	return c;
}

trip comp(trip a) {
	return trip(add(a.v[0],a.v[2]), a.v[1], 0);
}

void print(trip a) {
	cout << a.v[0] << " " << a.v[1] << " " << a.v[2] << endl;
}

vector<trip> dp[MAX];
int ct[MAX];
void dfs(int u) {
	dep[u] = 1;
	int maxd = -1; int id = 0;
	for (int i : g[u]) {
		d[i] = d[u] + 1;
		dfs(i);
		dep[u] = max(dep[u], dep[i]+1);
		if (dep[i] > maxd) {
			maxd = dep[i]; id = i;
		}
	}

	int maxsz = 0;
	for (int i : g[u]) {
		if (i == id) { continue; }
		maxsz = max(maxsz, (int)dp[i].size());
		// merge i with id
		for (int j=0; j<dp[i].size(); j++) {
			int offset = (int)dp[id].size() - (int)dp[i].size();
			// dp[i][k]
			// the depth number is dp[i].size() - 1 - k
			// so dp[u].size() - dp[i].size() + k

			dp[id][j+offset] = comb(dp[id][j+offset], dp[i][j]);
		}
	}
	swap(dp[u], dp[id]);
	
	for (int i=1; i<=maxsz; i++) {
		dp[u][dp[u].size()-i] = comp(dp[u][dp[u].size()-i]);
	}
	dp[u].push_back(trip(inv(2), inv(2), 0));
}


int main() {
	// freopen("a.in", "r", stdin);

	pow2[0] = 1;
	for (int i=1; i<MAX; i++) { pow2[i] = (pow2[i-1]*2)%MOD; }
	int n; scanf("%d", &n);
	for (int i=1; i<=n; i++) {
		int p; scanf("%d", &p);
		g[p].push_back(i); 
	}
	d[0] = 1;
	dfs(0);
	for (int i=0; i<=n; i++) {
		ct[d[i]]++;
	}
	reverse(dp[0].begin(), dp[0].end());
	int ans = 0;
	for (int i=0; i<dp[0].size(); i++) {
		ans = add(ans, mult(pow2[n+1], dp[0][i].v[1]));
	}
	printf("%d\n", ans);
	/*
	d[0] = 1;
	dfs(0);
	for (int i=1; i<=n+1; i++) {
		process(n, i);
	}
	printf("%d\n", ans);
	*/
}

Measured memory_bytes: 47092
#include<iostream>
int main()
{
    int n;
    while(std::cin>>n)
    {
        int k = n%10;
        if(k==0||k==1||k==6||k==8)
            std::cout<<"pon\n";
        else if(k==3)
            std::cout<<"bon\n";
        else
            std::cout<<"hon\n";
    }
    return 0;
}


Measured memory_bytes: 3616