akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll a; string b;
    cin >> a >> b;
    if (stod(b) == 0.0) {
        cout << 0 << endl;
        return 0;
    }
    b[1] = b[2];
    b[2] = b[3];
    b[3] = '0';
    ll ib = stoi(b)/10;

    cout << a*ib/100 << endl;
    return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        if(s<=w){
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }
    }
}

Measured memory_bytes: 35772
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String W = sc.nextLine().trim();
    while (true) {
      String[] T = sc.nextLine().split(" ");
      if (T[0].equals("END_OF_TEXT"))
        break;
      for (int i = 0; i < T.length; i++) {
        if (T[i].equalsIgnoreCase(W))
          count++;
      }
    }
    System.out.println(count);
    sc.close();
  }
}


Measured memory_bytes: 26100
N, X, M = map(int, input().split())
mod = M
A = [X]
AS = set()
AS.add(X)
cnt = 0
loop = -1
tail = -1
loop_sum = X
tail_sum = 0
while True:
    cnt += 1
    nex = pow(A[-1], 2, mod)
    if nex in AS:
        break
    A.append(nex)
    loop_sum += nex
    AS.add(nex)

for i, a in enumerate(A):
    if a == nex:
        tail = i
        loop = cnt - tail
        A = A[i:]
        break
    tail_sum += a
    loop_sum -= a

ans = tail_sum + (N - tail)//loop * loop_sum
N -= tail
N %= loop

for i in range(N):
    ans += A[i]

print(ans)

Measured memory_bytes: 76944
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>s>>q; n=s.size();
  for(int i=0;i<n;i+=q){
    cout<<s[i];
  }
}


Measured memory_bytes: 3636
// arock - 2019-03-09

#include <iostream>

using i64 = long long;

template <class T> T xor_sum(T n) {
    return (n & 1? n - 1 : 0) + (n & 2 ? 1 : 0);
}

int main() {
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);

    i64 A, B;
    std::cin >> A >> B;

    std::cout << (xor_sum(A) ^ xor_sum(B + 1)) << '\n';
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  ll res = 0;
  for (int k = 40; k >= 0; k--) {
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
      if ((1LL << k) & A[i]) cnt++;
    }
    if (cnt < (N + 1) / 2 && K >= (1LL << k)) {
      cnt = N - cnt;
      K -= 1LL << k;
    }
    res += cnt * (1LL << k);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

using namespace std;

const int MAX_N = 100000;
int par[MAX_N + 1];
int rnk[MAX_N + 1];
int dis[MAX_N + 1];

int root(int x)
{
	if(par[x]==x)return x;
	return root(par[x]);
}

int find(int x)
{

	if(x==par[x]) return 0;
	dis[x]=dis[x]+find(par[x]);
	par[x]=root(x);
	return dis[x];
}

int merge(int L,int R,int D)
{
	int x = L,y = R;
	L = root(L);
	R = root(R);
	int L_d = find(x);
	int R_d = find(y);
	if(L==R){
		if(R_d-L_d==D) return 1;
		else return 0;
	}
	if(rnk[L]<rnk[R])
	{
		par[L] = R;
		dis[L] = R_d - D - L_d;
	}
	else {
		par[R] = L;
		dis[R] = L_d + D - R_d;
		if(rnk[L]==rnk[R])rnk[L]++;
	}
	return 1;
}

int main()
{
	int n,m,i;
	scanf("%d %d",&n,&m);

	for(i=1;i<=n;i++)par[i]=i;

	for(i=0;i<m;i++)
	{
		int L,R,D;
		scanf("%d %d %d",&L,&R,&D);
		if(!merge(L,R,D)){
			printf("No"); return 0;
		}

	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9+7

N = int(input())
# memo[i]: i番目の文字まで作った時の候補数
memo = [{} for _ in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i > 0:
            t[i-1],t[i] = t[i],t[i-1]
        if 'AGC' in ''.join(t):
            return 0
    return 1

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    res = 0
    for c in 'AGCT':
        if ok(last3 + c):
            res = (res + dfs(cur+1, last3[1:]+c)) % m
    memo[cur][last3] = res
    return res

print(dfs(0,'TTT'))

Measured memory_bytes: 9968
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(a, k);
    k -= min(a, k);
    k -= min(b, k);
    ans -= min(c, k);
    cout << ans << endl;
}


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

N, A, B = map(int, input().split())
H = tuple(int(input()) for _ in range(N))


def ceil(a, b):
    return (a + b - 1) // b


def f(x):
    lst = (max(0, h - x * B) for h in H)
    S = sum(ceil(i, A - B) for i in lst)
    return S <= x


l, r = 0, 10 ** 9
while r - l > 1:
    m = (r + l) // 2
    if f(m):
        r = m
    else:
        l = m
print(r)


Measured memory_bytes: 7208
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>

using namespace std;
int main() {
	int n; cin >> n;
	vector<double>v(n);
	for (auto& e : v)cin >> e;
	sort(v.begin(), v.end());
	for (int i = 0; i < n - 1; ++i) {
		v[i+1] = (v[i]+v[i+1]) / 2.0;
	}
	printf("%.5f\n",v[n-1]);

	return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
N, K = map(int, input().split())
print(N-K+1)
i = 2
C1 = N-K+1
C2 = 1
while i <= K:
  C1 *= ((N-K+1-(i-1))*pow(i, mod-2, mod))%mod
  C2 *= ((K-(i-1))*pow(i-1, mod-2, mod))%mod
  print((C1*C2)%mod)
  i += 1

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


//選択ソート
int selectionSort(int A[], int N) {
    int minj, sw = 0, t;
    for ( int i = 0; i < N - 1; i++ ) {
        minj = i;
        for ( int j = i; j < N; j++ ) {
            if ( A[j] < A[minj] ) minj = j;
        } 
        t = A[i]; A[i] = A[minj]; A[minj] = t;
        if ( i != minj ) sw++;
    }
    return sw;
}

int main(){
    int A[100], N, sw;

    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    sw = selectionSort(A, N);

    for (int i = 0; i < N; i++) {
        if (i>0) cout << " " ;
        cout << A[i];
    }
    cout << "\n" << sw << endl;

    
    return 0;
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(int i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
   int n;
   string s;
   cin >> n >> s;
   vector<int>cntw(n),cnte(n);
   int p = 0, q = 0;
   rep(i, 0, n){
       if(s[i]=='W')p++;
       else q++;
       cntw[i] = p;
       cnte[i] = q;
   }
   int ans = inf;
   rep(i, 1, n){
       ans = min(cntw[i-1]+(cnte[n-1]-cnte[i]),ans);
   }
   ans = min(ans,cnte[n-1]-cnte[0]);
   cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n, x, t; cin >> n >> x >> t;

    int cnt = (n + x - 1) / x;
    cout << cnt * t << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int x, num;
    cin >> x;

    int pre_x = x, cur_x = x;
    while(1){
        for(int i = 2; i <= cur_x/2; i++){
            if (cur_x % i == 0){
                 cur_x++;
                 break;
            }
        }
        if ( cur_x == pre_x ) break;
        pre_x = cur_x;
    }
    cout << cur_x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*void mayank()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}*/
#define ll long long
#define inf 1e9
const int mxN = 1e6;
ll a[mxN + 10], b[mxN + 1];
int main()
{
	//mayank();
	string s, t;
	cin >> s >> t;

	ll ans = INT_MAX;
	for (int i = 0; i <= s.length() - t.length(); i++) {
		ll count = 0;
		for (int j = 0; j < t.length(); j++) {
			if (s[i + j] != t[j]) {
				count++;
			}
		}
		ans = min(count, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll sum=0;
    ll j;
    rep(i,n+1){
        sum+=i;
        if(sum>=n){j=i;break;}
    }
    while(n>0){
        if(n-j>=0){
            n-=j;
            cout<<j<<endl;
        }
        j--;
    }

}

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

int main(){

ll n;
cin>>n;

ll a[n];
for(int i=0;i<n;i++)cin>>a[i];
ll dp[n];
dp[0]=0;
dp[1]=abs(a[1]-a[0]);
for(ll i=2;i<n;i++)
{
	dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
}
cout<<dp[n-1];
return 0;



}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int A[5];
    cins(A, A + 5);
    int hasu = 0, ans = 0;
    for(int i = 0; i < 5; i++){
        hasu = max(hasu, (1000 - A[i]) % 10);
        ans += (A[i] + 9) / 10 * 10;
    }
    cout << ans - hasu << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<cctype>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stack>
#include<ctime>
#define mst(a,b) memset(a,b,sizeof(a))
#define foreasy(i,a,b) for(i=a;i<b;i++)
#define IN 1
#define OUT 0
//#define LOCAL
const double PI = acos(-1.0);
const int maxn=500000+5;

int s[205];
int a[205];
using namespace std;

bool cmp(int a, int b)
{
    return a>b;
}

int solve(int n)
{
    if(n<=0) return 1;
    else  return n*solve(n-1);
}
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())

int main()
{
#ifdef LOCAL
    freopen("test.txt", "r", stdin);
#endif // LOCAL
    int n, minn = 1e9, temp, add;
    scanf("%d", &n);
    for(int i = 0;i<n;i++)
    {
        scanf("%d", &s[i]);
    }
    for(int i = 0;i<n;i++)
    {
        add = 0;
        temp = s[i];
        while(temp/2*2 == temp)
        {
            temp/=2;
            add++;
        }
        a[i] = add;
    }
    for(int i = 0;i<n;i++)
    {
        if(minn>a[i])
            minn = a[i];
    }
    printf("%d", minn);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string.h>
#include <algorithm>
//#include <bits/stdc++.h>
#include    <vector>
#define INF 999999999
# include <cstdio>
# include <cstdlib>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int n ,k ,num=0, fa =0;
struct shi{
    int x ;
    int y ;
    int next;
}S[200010];
int head[200010];
int dfs(int yy,  int a){
    if(yy==n&&a==2)
    {
        return 1;
    }
    for(int i = head[yy];i!=-1;i=S[i].next)
    {
        int k = S[i].y;
        if(dfs(k,a+1))
            return 1;
    }
    return 0;
}
int main(){
   cin >>n>>k;memset(head,-1,sizeof(head));
   for(int i=1;i<=k;i++)
   {

       int t , l;
       cin>>t >>l;
       S[num].x = t , S[num].y = l;
       S[num].next = head[t];
       head[t] = num++;
   }
   if(dfs(1 , 0 ))
    cout<<"POSSIBLE"<<endl;
   else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
using namespace std;
class Dice4{
public:
    int number[6];
    
    void roll(char dst){
        switch(dst){
            case 'E':
                setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
                break;
            case 'N':
                setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
                break;
            case 'S':
                setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
                break;
            case 'W':
                setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
                break;
        }
    };
    
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
    
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
    
};

int main(){
    int n,k,j;
    cin >> n;
    Dice4 array[n];
    for(int i = 0; i < n; i++){
        cin >> array[i].number[0] >> array[i].number[1] >> array[i].number[2] >> array[i].number[3] >> array[i].number[4] >> array[i].number[5];
    }
    for(k = 0; k < n-1; k++){
        for(j = k+1; j < n; j++){
            if(array[k].isSameDice(array[j].number))
                break;
        }
        if(j < n) break;
    }
    if(k == n-1){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 3108
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  F0R(i, M) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  vector<bool> vs(N, false);
  int result = 0;
  F0R(i, N) {
    if (vs[i]) continue;
    result++;
    auto dfs = [&](auto dfs, int v, int p)->void {
      vs[v] = true;
      for (auto c : G[v]) {
        if (vs[c]) continue;
        dfs(dfs, c, v);
      }
    };
    dfs(dfs, i, -1);
  }
  cout << result;
}
#endif


Measured memory_bytes: 15068
#include<iostream>

using namespace std;

int main(void)
{
	int N,K,Q,i,a;

	cin >> N >> K >> Q;

	int S[N];

	int A[Q];

	for(i=0;i<Q;i++)
	{

		cin >> A[i];
	}

	for(i=0;i<N;i++)
	{

		S[i]=K-Q;

	}

	for(i=0;i<Q;i++)
	{

		a=A[i]-1;

		S[a]=S[a]+1;

	}

	for(i=0;i<N;i++)
	{
		
		if(S[i]>0)
			cout << "Yes" << endl;

		else
			cout << "No" << endl;

	}


}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> P;

ll INF = 1000000000000;
 
ll N, M, L[200000], R[200000], D[200000];
vector< vector<P> > G(100001);
vector<ll> num(100001);
string ans;
 
void dfs(int now){    
 
    for(int i=0;i<G[now].size();i++){
        P nextP = G[now][i];
        int nextNode = nextP.first;
        int nextCost = nextP.second;
 
        if(num[nextNode] == INF){
            num[nextNode] = num[now] + nextCost;
            dfs(nextNode);
        } else {
            if(num[nextNode] != num[now] + nextCost)  ans = "No";
        }
        
    }
}
 
int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++)    cin >> L[i] >> R[i] >> D[i];
 
    for(int i=0;i<M;i++){
        G[ L[i] ].push_back( P(R[i], D[i]) );
        G[ R[i] ].push_back( P(L[i], -1 * D[i]) );
    }
    
    for(int i=1;i<=N;i++)   num[i] = INF;
 
    ans = "Yes";
    for(int i=1;i<=N;i++){
        if(num[i] == INF){
            num[i] = 0;
            dfs(i);
        }
        if(ans == "No") break;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 20224
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[][] a = new long[n][2];
		int add = 0;
		for (int i = 0; i < n; ++i) {
			a[i][0] = sc.nextInt() - k;
			a[i][1] = i;
			if (i > 0) {
				a[i][0] += a[i - 1][0];
			}
			if (a[i][0] >= 0) {
				++add;
			}
		}
		Arrays.sort(a, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				return Long.compare(o1[0], o2[0]);
			}
		});

		int[] arr = new int[n];
		int p = 0;
		for (int i = 0; i < n; ++i) {
			if (i > 0) {
				if (a[i][0] != a[i - 1][0]) {
					++p;
				}
			}
			arr[(int)a[i][1]] = p;
		}
		solve(n, arr, add);
	}

	void solve(int n, int[] arr, int add) {
		int[][] e = new int[n][2];
		for (int i = 0; i < n; ++i) {
			e[i][0] = arr[i];
			e[i][1] = i;
		}
		Arrays.sort(e, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				if (o1[0] != o2[0]) {
					return Integer.compare(o1[0], o2[0]);
				} else {
					return Integer.compare(o1[1], o2[1]);
				}
			}
		});
		Seg seg = new Seg(n);
		long ans = 0;
		for (int i = 0; i < n; ++i) {
			ans += seg.sum(0, e[i][1]);
			seg.set(e[i][1]);
		}
		System.out.println(ans + add);
	}

	class Seg {
		int n;
		int[] v;

		public Seg(int n) {
			this.n = 1;
			while (this.n < n) {
				this.n *= 2;
			}
			v = new int[2 * this.n - 1];
		}

		void set(int k) {
			k += n - 1;
			v[k] = 1;
			while (k > 0) {
				k = (k - 1) / 2;
				v[k] = v[2 * k + 1] + v[2 * k + 2];
			}
		}

		int sum(int a, int b) {
			return sum(a, b, 0, n, 0);
		}

		// [a,b),[l,r)
		int sum(int a, int b, int l, int r, int k) {
			if (a >= r || b <= l) {
				return 0;
			} else if (a <= l && r <= b) {
				return v[k];
			} else {
				int vl = sum(a, b, l, (l + r) / 2, 2 * k + 1);
				int vr = sum(a, b, (l + r) / 2, r, 2 * k + 2);
				return vl + vr;
			}
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

int main(void)
{
    int x,ans=8;
    cin >> x;
    if(x>=600)ans--;
    if (x >= 800)
        ans--;
    if (x >= 1000)
        ans--;
    if (x >= 1200)
        ans--;
    if (x >= 1400)
        ans--;
    if (x >= 1600)
        ans--;
    if (x >= 1800)
        ans--;
    cout << ans << endl;
    return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    from math import gcd
    a,b=MI()
    print((a*b)//gcd(a,b))
    

main()


Measured memory_bytes: 62212
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  string s, t;
  int a,b;
  string u;

  while(cin >> s >> t >> a >> b >> u){

    if(s == u){
      --a;
    }else{
      --b;
    }

    cout << a << " " << b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define deb(a) cout<<a<<endl
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int n;
	scanf("%d",&n);
	
	int gaku=100000;
	
	rep(q,n){
		gaku*=1.05;
		
		if(gaku%1000 > 0){
			gaku-=gaku%1000;
			gaku+=1000;
		}
	}
	out(gaku);
}

Measured memory_bytes: 0
#include <stdio.h>


int main ()
{
  int x,y,a = 0;
  scanf("%d %d",&x,&y);
  if(x >= y)
    {
      while(1)
	{
	  a = x % y;
	  if(x % y == 0) break;
	  x = y;
	  y = a;
	}
      printf("%d",y);
    } else if(x <= y)
    {
      while(1)
	{
	  a = y % x;
	  if(y % x == 0) break;
	  y = x;
	  x = a;
	}
      printf("%d",x);
    
    } 
  printf("\n");
  return 0;
}



Measured memory_bytes: 2068
s = input()
o1e0 = 0
o0e1 = 0

for n, i in enumerate(s):
    if n % 2 == 0:
        if i == "0":
            o1e0 += 1
        else:
            o0e1 += 1

    else:
        if i == "1":
            o1e0 += 1
        else:
            o0e1 += 1

print(min(len(s) - o1e0, len(s) - o0e1))

Measured memory_bytes: 3188
import java.util.*;

class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    if(n == 1 && m == 1) {
    	System.out.println(1);
    } else if(n == 1) {
    	System.out.println(m-2);
    } else if(m == 1) {
    	System.out.println(n-2);
    } else {
    	System.out.println((n-2) * (m-2));
    }
}
}

Measured memory_bytes: 21844
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

int n;

void zalgo(string &s, vector<int> &da, int le, int ri){
	da[le] = ri - le;
	int i = le + 1, j = 0;
	while(ri > i){
		while(i + j < ri && s[le + j] == s[i + j]){
			j++;
		}
		da[i] = j;
		if(j == 0){
            i++;
            continue;
        }
		int k = 1;
		while(ri > i + k && k + da[k + le] < j){
			da[i + k] = da[le + k]; ++k;
		}
		i += k; j -= k;
	}
	return;
}

int main(){
	int n;string s; cin >> n >> s;
	int ans = 0;
	rip(i, n, 0){
		vector<int> da(n);
		zalgo(s, da, i, n);
		rip(j, n, i){
			ans = max(ans, min(j - i, da[j]));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>

 using namespace std ;

 int main()

{

short int c=0;

char s[3];

cin>>s;

if(((s[0]=='a')&&(s[1]=='b')&&(s[2])=='c')||

  ((s[0]=='a')&&(s[1]=='c')&&(s[2])=='b')||

  

((s[0]=='b')&&(s[1]=='a')&&(s[2])=='c')||

((s[0]=='b')&&(s[1]=='c')&&(s[2])=='a')||

((s[0]=='c')&&(s[1]=='b')&&(s[2])=='a')||

((s[0]=='c')&&(s[1]=='a')&&(s[2])=='b'))

 cout<<"Yes";

else

cout<<"No";

}

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

typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define __m int mid=(l+r)>>1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

template<class T>
inline bool rd(T &num) {
    char in;bool IsN = false;
    while(in = getchar(), in != '-' && (in < '0' || in > '9'))if(in == EOF)return false;
    in == '-' ? (IsN = true, num = 0) : num = in - '0';
    while(in = getchar(), in >= '0' && in <= '9')num = num * 10 + in - '0';
    return IsN ? num = -num : num, true;
}
template<class T, class S>
inline bool rd(T &num1, S &num2){return rd(num1)&&rd(num2);}
template<class T, class S, class Z>
inline bool rd(T &num1, S &num2, Z &num3){return rd(num1)&&rd(num2)&&rd(num3);}
template<class T>
inline void _wr(T num){if(num>9)_wr(num/10);putchar('0'+num%10);}
template<class T>
inline void wr(T num){if(num < 0)putchar('-'),num=-num;_wr(num);}

void debug_out(){cerr<<endl;}
string to_string(string s){return '\"'+s+'\"';}
string to_string(char* s){return to_string((string)s);}
string to_string(bool s){return s?"true":"false";}
template<class T>
string to_string(T array);
template<class T,class S>
string to_string(pair<T,S>s){return '('+to_string(s.first)+','+to_string(s.second)+')';}
template<class T>
string to_string(T array){
    bool first=true;string res="[";
    for(const auto&e : array){
        if(!first)res+=",";first=false;res+=to_string(e);
    }
    return res+=']';
}
template<class Head, class... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}

string nico = "NicoNicoNi";
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define infile(x) freopen(x,"r",stdin)
#define outfile(x) freopen(x,"w",stdout)
#define io ios::sync_with_stdio(0)
#else
#define debug(...)
#define infile(x)
#define outfile(x)
#define io ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#endif

#define rep(a,b,c) for(register int (a)=(b);(a)<(c);++(a))
#define per(a,b,c) for(register int (a)=(b);(a)>=(c);--(a))
#define none(a) memset(a,-1,sizeof(a))
#define clr(a) memset(a,0,sizeof(a))
#define inf(a) memset(a,0x3f,sizeof(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define space putchar(' ')
#define enter puts("")
#define endl '\n'
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define lowbit(x) (x&-x)

const int maxn = 26000;
const int inf  = 0x3f3f3f3f;
const ll  linf  = (1ll*inf)<<32|inf;
const int mod  = 1e9 + 7;
const int none = -1;
const double eps = 1e-7;


int main(){
    io;
    int num[3];
    rep(i,0,3)
        cin>>num[i];
    if(num[0]==num[1]&&num[1]==num[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main(){
  long long n,k;
  cin>>n>>k;
  int v[n][2];
  for(int i=0;i<n;i++){
    cin>>v[i][0];
    v[i][1]=-1;
  }
  v[0][1]=0;
  long long cnt=1;
  int t=v[0][0];  
  int a,b;  
  while(true){
    if(cnt==k){
      cout<<t;
      return 0;
    }
    if(v[t-1][1]==-1){
      v[t-1][1]=cnt;
      t=v[t-1][0];
    }else{
      a=v[t-1][1];
      b=cnt-v[t-1][1];
      break;
    }
    cnt++;
  }
  int m=(k-a)%b;
  for(int i=0;i<m;i++) t=v[t-1][0];
  cout<<t;  
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pll pair < ll , ll >
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ld long double
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;


int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    ll nd1 = c/b, nd2 = a/d;
    if(c%b)
    {
        nd1++;
    }
    if(a%d)
    {
        nd2++;
    }
    if(nd1<=nd2)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 3616
import math

n = int(input())
x = list(map(int, input().split()))
avr = sum(x) / n
avr_min = int(avr)
avr_max = math.ceil(avr)

ans = 0
a = 0
b = 0

if avr_min == avr_max:
  for j in range(n):
    ans += (x[j] - avr_min)** 2
  print(ans)
else:
  for j in range(n):
    a += (x[j] - avr_min)** 2
    b += (x[j] - avr_max)** 2
  print(min(a, b))

Measured memory_bytes: 38384
#include<stdio.h>

int main()
{
  int i,n,q,right,left,mid,k=0,S[100000],T[50000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&T[i]);
    }

  for(i=0;i<q;i++)
    {
      left=0;
      right=n;
      while(left < right)
	{
	  mid = (left + right)/2;
	  if(S[mid]==T[i]){k++;break;}
	  else if(T[i]<S[mid])right=mid;
	  else left = mid+1;
	}
    }
  printf("%d\n",k);
  return 0;
}
  



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

namespace CS.contests._160
{

    public class Program
    {
        public static void Main(string[] args)
        {
            new A().test();
        }
    }
}

	public class A
	{
		public void test()
		{
			// スペース区切りの整数の入力
			var input = CommonRead.ReadStr();

			// 六文字以下は異なる
			if(input.Length != 6)
			{
				Console.WriteLine("No");
				return;
			}

			// 3文字目と4文字目が異なる
			if (!(input.Substring(2,1).Equals(input.Substring(3, 1))))
			{
				Console.WriteLine("No");
					return;
				// 4文字目と5文字目が異なる
			}
			else if (!(input.Substring(4, 1).Equals(input.Substring(5, 1))))
			{
				Console.WriteLine("No");
					return;
				}
				else
			{
				Console.WriteLine("Yes");
					return;
				}

		}
	}

static class CommonRead
{
    public static string ReadStr()
    {
        return Console.ReadLine();
    }
    public static string[] ReadStrA()
    {
        return ReadStr().Split(' ');
    }
    public static List<string> ReadStrL()
    {
        return ReadStrA().ToList();
    }
    public static int ReadInt()
    {
        return Convert.ToInt32(ReadStr());
    }
    public static int[] ReadIntA()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntL()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
    }
    public static long ReadLong()
    {
        return Convert.ToInt64(ReadStr());
    }
    public static long[] ReadLongA()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
    }
    public static List<long> ReadLongL()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
    }

    public static decimal ReadDecimal()
    {
        return Convert.ToDecimal(ReadStr());
    }
    public static decimal[] ReadDecimalA()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
    }
    public static List<decimal> ReadDecimalL()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
    }

    public static double ReadDouble()
    {
        return Convert.ToDouble(ReadStr());
    }
    public static double[] ReadDoubleA()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
    }
    public static List<double> ReadDoubleL()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
    }

}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;

ll n;
Vi a;
graph g;
Vi as;

void dfs(ll idn,ll prev,Vi& dp){
    ll tmp = lower_bound(all(dp),a[idn]) - dp.begin();
    ll mem = dp[tmp];
    dp[tmp] = a[idn];
    as[idn] = lower_bound(all(dp),INF)-dp.begin();
    rep(i,g[idn].size()){
        edge e = g[idn][i];
        if(e.to != prev){
            dfs(e.to,idn,dp);
        }
    }
  dp[tmp] = mem;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    g.resize(n);
    a.resize(n);
    as.resize(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-1){
        ll in,inp;
        cin>>in>>inp;
        in--;
        inp--;
        g[in].pb(edge(inp));
        g[inp].pb(edge(in));
    }
    Vi tp;
    tp.resize(n,INF);
    dfs(0,-1,tp);
    rep(i,as.size()){
        print(as[i]);
    }
    return 0;
}


Measured memory_bytes: 33216
i = list(map(int, input().split()))
A = i[0]
B = i[1]

count = 0
flag = True
if B <= 1:
    flag = False
elif A >= B:
    flag = False
    count +=1
else:
    count +=1
while flag:
    if (A-1) * count + A >= B:
        count +=1
        break
    count +=1

print(count)

Measured memory_bytes: 3064
use proconio::input;
use std::vec::Vec;

fn main() {
	input! {
		n: i32,
		a: [u64; n],
	}
	if a.contains(&0) {
		println!("{}", 0);
		return;
	}
	let mut ans: u64 = 1;
	let th: u64 = 1000000000000000000;
	for v in a.iter() {
		if ans > th / v {
			println!("-1");
			return;
		}
		ans = ans * v;
	}
	println!("{}", ans);
}


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

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < N; ++i) {
    ans = (ans + v[i]) / 2.0;
  }
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map(&:to_i).sort

def devide(x, y)
  if x.even? or y.even?
    s = x * y / 2
    return [s, s]
  else
    a = [x, y].min
    b = devide(x - 1, y)
    return [b[0], b[1] + a]
  end
end

def trisect(x, y)
  w1 = x / 3
  all = [w1 * y] + devide(y, x - w1)
  ans1 = all.max - all.min
  w2 = w1 + 1
  all = [w2 * H] + devide(y, x - w2)
  ans2 = all.max - all.min
  [ans1, ans2].min
end
     
if H % 3 == 0 || W % 3 == 0
  puts 0
else
  puts [trisect(H, W), trisect(W, H)].min
end

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

using P = pair<int, int>;

struct edge {
    int to, weight;
};

using edges = vector<edge>;
using graph = vector<edges>;

constexpr int INF = 1e9;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> T(N);
    for(int i=0; i<N; ++i) {
        cin >> T[i];
    }
    graph g(N);
    for(int i=0; i<M; ++i) {
        int a, b, d;
        cin >> a >> b >> d;
        a--; b--;
        g[a].push_back((edge){b, d});
        g[b].push_back((edge){a, d});
    }
    
    using state = tuple<int, int, int, int>;
    vector<vector<vector<int>>> d(N, vector<vector<int>>(3, vector<int>(X+1, INF)));
    d[0][0][X] = 0;
    priority_queue<state, vector<state>, greater<state>> que;
    que.push(make_tuple(0, 0, 0, X));
    while(!que.empty()) {
        int cd, v, t, x;
        tie(cd, v, t, x) = que.top();
        que.pop();
        if(d[v][t][x] < cd) {
            continue;
        }
        for(auto& e : g[v]) {
            int nx = (T[e.to] == 1 ? max(0, x - e.weight) : X);
            if(T[e.to] == 1 && d[e.to][t][nx] > d[v][t][x] + e.weight) {
                d[e.to][t][nx] = d[v][t][x] + e.weight;
                que.push(make_tuple(d[e.to][t][nx], e.to, t, nx));
            } else if(T[e.to] != 1 && (T[e.to] != t && x <= e.weight || T[e.to] == t)) {
                if(d[e.to][T[e.to]][nx] > d[v][t][x] + e.weight) {
                    d[e.to][T[e.to]][nx] = d[v][t][x] + e.weight;
                    que.push(make_tuple(d[e.to][T[e.to]][nx], e.to, T[e.to], nx));
                }
            }
        }
    }
    int res = INF;
    for(int i=0; i<3; ++i) {
        for(int j=0; j<X+1; ++j) {
            res = min(res, d[N-1][i][j]);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 28640
#import<atcoder/all>
#define F int X){return X<b
int n,a,b;int o(int b,F?b:X;};int e(){return-1;}main(){auto&c=std::cin>>n>>a;atcoder::segtree<int,o,e>P(n);for(;b<n;P.set(b++,a))c>>a;for(;c>>n>>a>>b;printf(n<2?P.set(a,b),"":"%d ",n-2?P.max_right(a,[](F;})+1:P.prod(a,b)))a--;}

Measured memory_bytes: 6152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int ans = 0;
		int a = 0;
		int b = 0;
		int c = 0;

		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			ans += count(s);

			String str[] = s.split("");

			if (str[0].equals("B") && str[str.length - 1].equals("A")) {
				c++;
			} else if (str[0].equals("B")) {
				b++;
			} else if (str[str.length - 1].equals("A")) {
				a++;
			}
		}

		int min = 0;
		if (a == 0 && b == 0) {
			min = Math.max(0, c - 1);
		} else {
			min = c + Math.min(a, b);
		}

		System.out.println(ans + min);
	}

	static int count(String str) {
		int i = 0;
		Pattern p = Pattern.compile("AB");
		Matcher m = p.matcher(str);
		while (m.find()) {
			i++;
		}
		return i;
	}
}


Measured memory_bytes: 56748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
cout << fixed;
cout << setprecision(n) << ans;
*/

int main() {
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC";
    }
    else if(r<2800){
        cout << "ARC";
    }
    else cout << "AGC";



    
}

/*
*/


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

int a, b, c;
void f(char a) {
	cout << a << endl;
}

int main(){
	while (cin >> a >> b >> c && !(a == -1 && b == -1 && c == -1)) {
		if (a == -1 || b == -1)
			f('F');
		else if (a + b >= 80)
			f('A');
		else if (a + b >= 65)
			f('B');
		else if (a + b >= 50)
			f('C');
		else if (a + b >= 30)
			if (c >= 50)
				f('C');
			else
				f('D');
		else
			f('F');
	}

	return 0;
}

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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(n);
    vll a(n);
    vll b(n);
    vll d(0);
    ll y=0;
    ll x=0;
    ll z=0;
    FOR(i,0,n-1){
        cin >>a[i];
    }
    FOR(i,0,n-1){
        cin >>b[i];
    }
    FOR(i,0,n-1){
        if(a[i]<b[i]){
            y+=b[i]-a[i];
            x++;
        }else{
            d.pb(a[i]-b[i]);
            z++;
        }
    }
    rSORT(d);
    ll j=0;
    while(y>0){
        y-=d[j];
        j++;
        x++;
        if(j==z) break;
    }
    sal(((j==z&&y>0)?-1:x));
}


Measured memory_bytes: 2936