akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 1110
using namespace std;
bool prm[N];
ll n,sz[N];
vector<ll> prime,big;
set<ll> nbg;
int main(){
	ll i,j,a;
	memset(prm,true,sizeof(prm));
	prm[0]=prm[1]=false; 
	for(i=2;i<N;i++)
	{
		if(!prm[i])
		{
			continue;
		}
		prime.push_back(i);
		for(j=i+i;j<N;j+=i)
		{
			prm[j]=false;
		}
	}
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a);
		for(j=0;j<prime.size();j++)
		{
			if(a%prime[j]==0)
			{
				sz[j]++;
			}
			while(a%prime[j]==0)
			{
				a/=prime[j];
			}
		}
		if(a!=1)
		{
			nbg.insert(a);
			big.push_back(a);
		}
	}
	if(nbg.size()==1&&big.size()==n)
	{
		puts("not coprime");
		return 0;
	}
	for(i=0;i<prime.size();i++)
	{
		if(sz[i]==n)
		{
			puts("not coprime");
			return 0;
		}
	}
	for(i=0;i<prime.size();i++)
	{
		if(sz[i]>1)
		{
			puts("setwise coprime");
			return 0;
		}
	}
	if(big.size()!=nbg.size())
	{
		puts("setwise coprime");
		return 0;
	}
	puts("pairwise coprime");
	return 0;
}

Measured memory_bytes: 14716
#include <iostream>

using namespace std;

int main()
{
    int c[4][4] = {0};
    bool ansFlag = false;

    int a1, a2, a3, b1, b2, b3;

    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i <= 100; i++) {
        // a1 = iで固定した場合のb1〜b3の関係は以下の通り
        a1 = i;
        b1 = c[1][1] - i;
        a2 = c[2][1] - c[1][1] + i;
        b2 = c[1][2] - i;
        a3 = c[3][1] - c[1][1] + i;
        b3 = c[1][3] - i;

        if ((a1 + b1 == c[1][1]) && (a1 + b2 == c[1][2]) && (a1 + b3 == c[1][3]) && (a2 + b1 == c[2][1]) && (a2 + b2 == c[2][2]) && (a2 + b3 == c[2][3]) && (a3 + b1 == c[3][1]) && (a3 + b2 == c[3][2]) && (a3 + b3 == c[3][3])) {
            ansFlag = true;
            break;
        }
    }

    if (ansFlag) cout << "Yes" << endl;
    else         cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  string s; cin >> s;
  int q; cin >> q;
  for(int i = 0; i < q; i++){
    string qq; cin >> qq;
    if(qq == "print"){
      int a,b; cin >> a >> b;
      cout << s.substr(a,b-a+1) << endl;
    }else if(qq == "reverse"){
      int a,b; cin >> a >> b;
      string ss = s.substr(a, b-a+1);
      reverse(ss.begin(), ss.end());
      s = s.substr(0,a) + ss + s.substr(b+1,s.size()-b+1);
    }else if(qq == "replace"){
      int a,b; cin >> a >> b;
      string ss; cin >> ss;
      s = s.substr(0,a) + ss + s.substr(b+1,s.size()-b+1);
    }
  }
  return 0;
}



Measured memory_bytes: 3172
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int t;
    cin >> t;
    set<string> ss;
    while (t--) {
        string s;
        cin >> s;
        ss.insert(s);
    }
    cout << ss.size();
    return 0;
}

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

int main() {
    deque<char> DQ;
    char str[11];
    scanf("%s", str);
    for (int i=0;i<strlen(str);i++) {
        if (str[i]=='B') {
            if (DQ.size()!=0) {
                DQ.pop_back();
            }
        } else {
            DQ.push_back(str[i]);
        }
    }
    for (int i=0;i<DQ.size();i++) cout << DQ[i];
}


Measured memory_bytes: 256
def main ():
  N = int(input())
  A = list(map(int,input().split()))
  if 0 in A:
    print (0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
  
main ()

Measured memory_bytes: 21640
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun solve() {
    val n = inf.readLine()!!.toInt()
    val map = TreeMap<Int, Int>()
    inf.readLine()!!.split(' ').map(String::toInt).forEach {
        map.getOrPut(it - 1, {0})
        map.put(it, map.getOrElse(it, {0}) + 1)
        map.getOrPut(it + 1, {0})
    }
    var ans = 0
    for (i in map.keys) {
        ans = Math.max(ans, map.getOrElse(i - 1, {0}) + map.getOrElse(i, {0}) + map.getOrElse(i + 1, {0}))
    }
    println(ans)
}

fun main(args: Array<String>) {
    solve()
    ouf.close()
}

val inf = BufferedReader(InputStreamReader(System.`in`))
val ouf = PrintWriter(System.out)

Measured memory_bytes: 60004
#pragma GCC diagnostic ignored "-Wunused-result"
#define NDEBUG

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdio>
#include <tuple>
#include <vector>

#ifdef NDEBUG
#  define debug(...)
#else
#  define debug(...)                                \
  do {                                              \
    fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
    fprintf(stderr, __VA_ARGS__);                   \
    fputc('\n', stderr);                            \
  } while (false)
#endif

using namespace std;
using tii = tuple<int, int>;

int N, x, a[100];

int main() {
  scanf("%d %d", &N, &x);
  for (int i = 0; i < N; i++) scanf("%d", a+i);
  sort(a, a+N);
  int i;
  int64_t total = 0;
  for (i = 0; i < N && total <= (int64_t)x; i++) total += a[i];
  printf("%d\n", total == x ? i : i-1);
  return 0;
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

ll powm(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b%2)
            res = (res * a) % M;
        a = (a * a) % M;
        b /= 2;
    }
    return res;
}

int main() {
    fast;
    ll n, k;
    cin >> n >> k;
    vi dp(k+1, 0);
    REP(i, 1, k+1)
        dp[i] = powm(k/i, n);
    ll sum = 0;
    RREP(i, k, 0) {
        for (ll j = i*2; j < k+1; j += i)
            dp[i] = (dp[i] - dp[j] + M) % M;
        sum = (sum + (i*dp[i]) % M) % M;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string K;
  bool F = false;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> K;
    if(K == "Y"){
      F = true;
      break;
    }
  }
  if(F == true){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300010


int main(){
  int n,Q;
  ll c[SIZE],q[SIZE];
  
  scanf("%d%d",&n,&Q);

  for(int i=1;i<=n;i++) scanf("%lld",c+i);
  c[0] = 0;
  c[n+1] = INF;
  sort(c,c+n+2);
  
  for(int i=0;i<Q;i++) scanf("%lld",q+i);


  for(int i=0;i<Q;i++){
    ll ans = 0;
    
    for(int j=1;;j++){
      
      int l = 0, r = n+1, mid;
      
      while(l<r){
        mid = (l+r)/2 + 1;
        if(c[mid] >= j*q[i])
          r = mid-1;
        else
          l = mid;
      }

      ans = max(ans,c[l]%q[i]);
     
      if(j*q[i] > c[n-1]) break;
    }

    printf("%lld\n",ans);
  }
  
  return 0;
}

Measured memory_bytes: 4616
s = input().split()
if (s[0] == s[1]) and (s[0] != s[2]):
    output = "Yes"
elif (s[0] == s[2]) and (s[0] != s[1]):
    output = "Yes"
elif (s[1] == s[2]) and (s[1] != s[0]):
    output = "Yes"
else:
    output = "No"

print(output)

Measured memory_bytes: 3064
<?php 
  fscanf(STDIN,"%d %d",$a,$b);
  if($a < $b){
    $tmp = $a;
    $a = $b;
    $b = $tmp;
  }
  $m = $a;
  $n = $b;
  $amari = 1;
  while($amari>0){
    $amari = $m%$n;
    $m = $n;
    $n = $amari;
  }
  echo (($a*$b)/$m)."\n";


Measured memory_bytes: 4604
loop do
  ss = [gets.chomp]
  break if ss[0] == ?0
  ss += 2.times.map { gets.chomp }
  ss.each_with_index do |s|
    a, b = 0, 0
    s.each_char.drop(1).each do |c|
      if c == ?A
        a += 1
      else
        b += 1
      end
    end
    if a > b
      a += 1
    else
      b += 1
    end
    puts "#{a} #{b}"
  end
end

Measured memory_bytes: 8696
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    if(n % 1000 == 0){
        cout << 0 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }

}


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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    ll arr[200001] = {0};
    vector<ll> v;
    for(ll i = 0; i < n; ++i){
        ll tmp; cin >> tmp;
        v.push_back(tmp);
        arr[tmp]++;
    }
    ll ans = 0;
    for(ll i = 0; i < 200001; ++i){
        if(arr[i] > 1){
            ans += (arr[i] - 1) * (arr[i]) / 2;
        }
    }
    for(ll i = 0; i < n; ++i){
        cout << ans - (arr[v[i]] - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 5872
import java.util.Scanner;

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

			while(true) {
			int sum = 0;
			String num = sc.next();
			if(num.equals("0"))	break;

			for(int i = 0; i < num.length(); i++) {
				int n = 0;
				n = Integer.parseInt(num.substring(i, i+1));
				sum += n;
			}
			System.out.println(sum);
		}
		sc.close();
	}
}




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


def solve(N: int, X: int, Y: int):
    ans = [0] * N
    for i in range(1, N):
        for j in range(i+1, N+1):
            a = min(j-i, abs(j-Y)+abs(X-i)+1)
            ans[a] += 1
    print(*ans[1:], sep='\n')


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K,H,W;
ll ans = 1;
P A[200005];
ll M = 1000000007;
ll ac;
P minminus= P(M,0);
P maxminus = P(M,0);
P minplus = P(M,0);
P maxplus = P(M,0);
bool found = true;

int main() {
    cin >> N >> K>> H;
    cout << K/H-(N-1)/H << endl;
}


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

int main(){
    string s; cin>>s;
    int size=s.size();
    set<int> st;
    for(int i=0;i<size;i++){
        st.insert(s[i]);
    }
    auto itr=st.begin();
    for(int i=0;i<=25;i++){
            if(*itr!=i+97) {
               char ans=i+97;
               cout<<ans;
                return 0;
            }
            itr++;
    }
    cout<<"None";
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

	string s;
	cin >> s;
	auto dp = make_v<int64>(s.size()+1, 2);
	fill_v<int64>(dp, 0);
	dp[0][1] = -INF_LL;
	REP(i, s.size()) {
	    chmax(dp[i+1][0], dp[i][1] + 1);
	    if (i == 0 || s[i] != s[i-1]) {
	        chmax(dp[i+1][0], dp[i][0] + 1);
	    }
	    if (i + 2 <= s.size())
            chmax(dp[i + 2][1], dp[i][0] + 1);
	}
	cout << max(dp[s.size()][0], dp[s.size()][1]) << endl;
}


Measured memory_bytes: 11412
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using db = double;
using vi = vector<int>;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout << #x <<'	' << x <<endl
const int inf = 0x3f3f3f3f;
const db eps = 1e-8;
const int mod = 1e9+7;
ll qpow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b&1)ret = ret*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ret;
}

const int maxn = 200010;
int n, m;
ll a[maxn], b[maxn], sum[maxn], f[maxn], p[maxn], dp[maxn], vis[maxn];
int Find(int x){
	return f[x] == x?x:f[x]=Find(f[x]);
} 
vector<int>G[maxn];
bool cmp(int x, int y){
	return a[x] < a[y];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i=1; i<=n; ++i){
		cin >> a[i] >> b[i];
		a[i] = max(a[i]-b[i], 0ll);
		p[i] = f[i] = i;
		sum[i] = b[i];
		dp[i] = a[i];
	}
	for(int i=0, u, v; i<m; ++i){
		cin >> u >> v;
		G[v].pb(u);
		G[u].pb(v);
	}
	sort(p+1, p+1+n, cmp);
	for(int i=1; i<=n; ++i){
		int u = p[i];
		vis[u] = 1;
		for(auto v:G[u]){
			if(vis[v]){
				int x = Find(u), y = Find(v);
				if(x!=y){
					f[y] = x;
					sum[x] += sum[y];
					dp[x] = min(dp[x], max(dp[y], a[x]-sum[y]));
				}
			}
		}
	} 
	cout << dp[Find(1)] + sum[Find(1)] <<"\n";
}


Measured memory_bytes: 16988
x1,  y1,  x2, y2 = map(int, input().split())
z3 = ((x1 - x2) + (y1 - y2)*1j) * -1j + (x2 + y2*1j)
x3, y3 = int(z3.real), int(z3.imag)
z4 = ((x2 - x3) + (y2 - y3)*1j) * -1j + (x3 + y3*1j)
x4 , y4 = int(z4.real), int(z4.imag)
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int H, W, N, K;
int query(int xa, int ya, int xb, int yb) {
	cout << "? " << xa << ' ' << ya << ' ' << xb - 1 << ' ' << yb - 1 << endl;
	int ret; cin >> ret;
	return ret;
}
int modpow(int a, int b, int m) {
	int ret = 1;
	while(b) {
		if(b & 1) ret = 1LL * ret * a % m;
		a = 1LL * a * a % m;
		b >>= 1;
	}
	return ret;
}
int a[55][55];
int main() {
	cin >> H >> W >> N >> K;
	int r = 4, b = H / r;
	for(int i = 0; i < b; i++) {
		for(int j = 0; j < b; j++) {
			int xl = i * H / b, xr = (i + 1) * H / b, yl = j * W / b, yr = (j + 1) * W / b;
			int cnt = query(xl, yl, xr, yr);
			for(int k = xl; k < xr && cnt > 0; k++) {
				for(int l = yl; l < yr && cnt > 0; l++) {
					a[k][l] = query(k, l, k + 1, l + 1);
					cnt -= a[k][l];
				}
			}
		}
	}
	int ret = 0;
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			ret += a[i][j] * modpow(2, i * W + j, K);
			ret %= K;
		}
	}
	cout << "! " << ret << endl;
	return 0;
}

Measured memory_bytes: 724
#include <iostream>

using namespace std;

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

    long long int ans=1000;
    long long int counter=1000;
    long long int a[n];

    for(int i=0;i<n;i++)
    {
        cin>>a[i];

    }

    for(int i=0;i<n-1;i++)
    {
        if(a[i]<a[i+1])
        {
            counter=ans/a[i];
            ans-=(counter)*a[i];
            ans+=counter*a[i+1];
        }

    }

    cout<<ans;

}


Measured memory_bytes: 3600
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int T, A; cin >> T >> A;
    vi H(N); REP(i, N) cin >> H[i];

    vd t(N);
    REP(i, N) t[i] = T - H[i] * 0.006;
    
    int ans = 0;
    double diff = INF;
    REP(i,N) {
        if(abs(t[i] - A) < diff){
            diff = abs(t[i] - A);
            ans = i + 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//verma_ankit484

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

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n, m;
  cin >> n >> m;
  vector<int> vc(n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> vc[i];
    s += vc[i];
  }
  sort(vc.begin(), vc.end(), greater<int>());
  double t = (double)s / double(4 * m);
  if ((double)vc[m - 1] < t) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
	char s[100];
	scanf("%s",s);
	
	if(s[5]=='0' && (s[6]<='4') ){
		printf("Heisei");
	}else{
		printf("TBD");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

#define INF 1e+9 //初期化注意
#define MAX_V 100000 //頂点数の最大値

struct edge {
	int to;
	int cost;
	//edge e ={to, cost}
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;// 頂点の数
vector<edge> G[MAX_V];
int d[MAX_V];



void dijkstra(int s) {
	//sからiへの最短距離をd[i]に保存 i=e.to
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;//初期位置へのコストは0

	que.push(P(0, s));
	//queはmake_pair(cost,to)?

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;//v=e.to	from s to v
		//すでにこの経路よりいい経路が見つかっているなら無視
		if (d[v] < p.first) continue;
		

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			// i 番目の v と v'を結ぶ辺　G=<e.to, e.cost>
			//e.to=v'
	                //e.cost means v to v' costs e.cost
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				//from s to v'> from s to v + from v to v'
				//vを経由したほうがコストが低いなら経由する
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	cin >> V;
	int E=V-1;//辺の数
	for (int i = 0; i < E; ++i) {
		int a, b, c=1;
		cin >> a >> b ;
		a--; b--;
		//the route a to b costs c
		edge e = { b, c };
		G[a].push_back(e);
        edge e2={a,c};
        G[b].push_back(e2);
		//有効グラフの場合であり、無向グラフなら e{a,c}も必要
	}
	dijkstra(0);
    vector<int>d1(V),d2(V);
	//dijkstra(int s); nからの最短距離を計算
	//d[i]はsからiまでの最短距離が保存される the path from s to i costs d[i]
    rep(i,V){
        d1[i]=d[i];
    }
    dijkstra(V-1);
    rep(i,V){
        d2[i]=d[i];
    }
    vector<bool>isSnuke(V,true);

    rep(i,V){
        if(d1[i]<=d2[i]){
            isSnuke[i]=false;
        }
    }
   
    int snuke=0,fennec=0;
    rep(i,V){
        if(isSnuke[i]){
            snuke++;
        }else{
            fennec++;
        }
    }
    if(snuke>=fennec){
        cout<<"Snuke"<<endl;
    }else{
        cout<<"Fennec"<<endl;
    }
}


Measured memory_bytes: 7876
#include <stdio.h>

int main()
{
    int n;
    int i, j;
    int flg = 0;

    scanf("%d", &n);

    for (i = 0; i < 100; i++) {
        for (j = 0; j < 100; j++) {
            if (i * 4 + j * 7 == n) {
                flg = 1;
            }
        }
    }

    printf("%s", (flg == 1 ? "Yes" : "No"));

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
char a[100001];int b[100001];
int main(){
	cin>>a;
	int n=0;
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='0'){
			b[n]=0;
			n++;
		}
		else if(a[i]=='1'){
			b[n]=1;
			n++;
		}
		else{
			if(n==0)continue;
			else{
				n--;
			}
		}
	}
	for(int i=0;i<=n-1;i++)cout<<b[i];
	return 0;
}

Measured memory_bytes: 256
from collections import deque
while True:
  h, w = map(int, input().split())
  if h == 0:
    break
  mp = [list("X" + input() + "X") for _ in range(h)]
  mp.insert(0, ["X"] * (w + 2))
  mp.append(["X"] * (w + 2))
  
  for y in range(h + 2):
    for x in range(w + 2):
      if mp[y][x] == "A":
        ax, ay = x, y
        mp[y][x] = "."
      if mp[y][x] == "B":
        bx, by = x, y
        mp[y][x] = "."
  INF = 1000
  dist_mp = [[INF] * (w + 2) for _ in range(h + 2)]
  dist_mp[ay][ax] = 0
  que = deque()
  que.append((0, ax, ay))
  vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
  while que:
    d, x, y = que.popleft()
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      if mp[ny][nx] == "." and dist_mp[ny][nx] == INF:
        que.append((d + 1, nx, ny))
        dist_mp[ny][nx] = d + 1
  
  limit = d
  pattern = input()
  length = len(pattern)
  t = 0
  dic = {}
  while True:
    if t >= dist_mp[by][bx]:
      print(t, by - 1, bx - 1)
      break
    if t > limit:
      if (t % length, bx, by) in dic:
        print("impossible")
        break
      else:
        dic[(t % length, bx, by)] = True
    c = pattern[t % length]
    if c == "5": pass
    elif c == "8" and mp[by - 1][bx] != "X": by -= 1
    elif c == "6" and mp[by][bx + 1] != "X": bx += 1
    elif c == "4" and mp[by][bx - 1] != "X": bx -= 1
    elif c == "2" and mp[by + 1][bx] != "X": by += 1
    t += 1
  else:
    print("impossible")


Measured memory_bytes: 6016
N = int(input())
v = list(map(int, input().split()))

v_sorted = sorted(v)

ans = [0]*N

for i in range(N):
    if i==0:
        ans[i] = v_sorted[i]
        
    else:
        ans[i] = (ans[i-1] + v_sorted[i])/2
        
print(ans[-1])

Measured memory_bytes: 3060
/*input
10 6
1
2
3
6
7
9

5 4
1 2 3 4 5 6 7 8 9 10

10 3
2
7
9
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define __builtin_popcount __builtin_popcountll
#define int long long
#define bit(x,y) ((x>>y)&1LL)
#define loop(i,l,r) for(int i=(int)l; i<=(int)r; i++)
#define rloop(i,l,r) for(int i=(int)l; i>=(int)r; i--)
const int N = 2e5 + 5;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
	return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	for (unsigned int i = 0; i < a.size(); i++)
		os << a[i] << (i < a.size() - 1 ? ", " : "");
	os << ']';
	return os;
}
int read() {
	int x; cin >> x; return x;
}

int sumle[N], sumri[N];
int a[N], b[N];
int L, n;

int getle(int l, int r, int core) {
	assert(l <= r);
	return (sumle[r] - sumle[l - 1]) - core * (r - l + 1);
}

int getri(int l, int r, int core) {
	assert(l <= r);
	return (sumri[l] - sumri[r + 1]) + core * (r - l + 1);
}

void init() {
	memset(sumle, 0, sizeof(sumle)); memset(sumri, 0, sizeof(sumri));
	loop(i, 1, n) sumle[i] = sumle[i - 1] + a[i];
	rloop(i, n, 1) sumri[i] = sumri[i + 1] + (L - a[i]);
}

int cal(int l, int r) {
	if (l == r) return a[l];
	int ret = a[l];
	int midPoint = (r - l + 2) / 2 + l - 1;
	int key = 0; if ((r - l + 1) % 2 == 1) key = 1;
	ret += (getle(l, midPoint, a[l])) * 2 + getri(midPoint + 1, r, a[l]) * 2;
	if (key == 0) ret -= (getle(midPoint, midPoint, a[l])) + getri(midPoint + 1, midPoint + 1, a[l]) * 2;
	else ret -= getri(midPoint + 1, midPoint + 1, a[l]) + (getle(midPoint, midPoint, a[l])) * 2;
	ret += max(a[midPoint + 1] - a[midPoint], a[midPoint] + L - a[midPoint + 1]);
	return ret;
}

signed main() {
#ifndef UncleGrandpa
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#endif
	cin >> L >> n;
	loop(i, 1, n) cin >> a[i];
	init();
	int ans = 0;
	loop(i, 1, n) ans = max(ans, cal(i, n));
	loop(i, 1, n) b[n - i + 1] = L - a[i];
	loop(i, 1, n) a[i] = b[i];
	init();
	loop(i, 1, n) ans = max(ans, cal(i, n));
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define int long long

#define INF 1e+9
#define MAX_V 100008


signed main() {
  string num; cin >> num;
  if(num[num.size() - 1] == '2' || num[num.size() - 1] == '4' || num[num.size() - 1] == '5' || num[num.size() - 1] == '7' ||  num[num.size() - 1] == '9'){
    cout << "hon" << endl;
  }else if(num[num.size() - 1] == '0' || num[num.size() - 1] == '1' || num[num.size() - 1] == '6' || num[num.size() - 1] == '8'){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
} 




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

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

using namespace std;

int main(){
  int n;cin>>n;
  vector<int>a(n);
  rep(i, n)cin>>a[i];
  ll dp[3001][3001];
  memset(dp, 0, sizeof(dp));

  rep(i, n)dp[i][i]=0;

  for(int len = 1; len<=n; len++){
    for(int l=0; l+len <= n; l++){
      int r = l+len;

      if((n-len)%2==0) dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1]);
      else dp[l][r] = min(dp[l+1][r]-a[l], dp[l][r-1] - a[r-1]);
    }
  }

  cout<<dp[0][n]<<endl;

//rep(i,n)cout<<dp[0][i+1]<<' ';

  return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,cap,rev;
	edge(){}
	edge(int tt,int cc,int rr){
		to=tt;
		cap=cc;
		rev=rr;
	}
};

int n,m;
vector<edge> G[105];
int cnt[101];


void add_edge(int from,int to,int cap){
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
}

vector<int> vec;
bool used[101];

int dfs(int v,int t,int f){
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

void dfs2(int v,int ccc){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge e=G[v][i];
		if(!used[e.to] && e.cap==ccc){
			dfs2(e.to,ccc);
		}
	}
}

void solve(){
	for(int i=0;i<n;i++){
		G[i].clear();
	}
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;
		v--;
		add_edge(u,v,1);
		cnt[u]++;
	}
	bool update=true;
	while(update){
		update=false;
		int p_min=0,p_max=0;
		for(int i=1;i<n;i++){
			if(cnt[p_min]>cnt[i]){
				p_min=i;
			}
			if(cnt[p_max]<cnt[i]){
				p_max=i;
			}
		}
		memset(used,false,sizeof(used));
		dfs2(p_min,0);
		for(int i=0;i<n;i++){
			if(!update && cnt[p_min]+1<cnt[i] && used[i]){
				memset(used,false,sizeof(used));
				int val=dfs(i,p_min,1);
				if(val==1){
					update=true;
					cnt[i]--;
					cnt[p_min]++;
					break;
				}else{
					assert(false);
				}
			}
		}
		memset(used,false,sizeof(used));
		dfs2(p_max,1);
		for(int i=0;i<n;i++){
			if(!update && cnt[i]+1<cnt[p_max] && used[i]){
				memset(used,false,sizeof(used));
				int val=dfs(p_max,i,1);
				if(val==1){
					update=true;
					cnt[p_max]--;
					cnt[i]++;
					break;
				}else{
					assert(false);
				}
			}
		}
		if(!update){
			printf("%d %d\n",cnt[p_min],cnt[p_max]);
			return;
		}
	}
}

int main(void){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		solve();
	}
	return 0;
} 


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

int main()
{
	long long n;
	cin>>n;
	long long ar[n+1];
	memset(ar,0,sizeof(ar));
	long long x;
	for(long long i=1;i<n;++i)
	{
		cin>>x;
		ar[x]++;
	}
	for(long long i=1;i<=n;++i)
	{
		cout<<ar[i]<<endl;
	}
}

Measured memory_bytes: 5200
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! chmax {
    ($x:expr, $y:expr) => {
        if $x < $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}


#[allow(unused_macros)]
macro_rules! chmin {
    ($x:expr, $y:expr) => {
        if $x > $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let _ = scan.read::<i64>();
    let a = scan.readn::<i64>(n);
    let mut heap = BinaryHeap::new();
    heap.push(Rev(a[0]));
    let mut cnt = 0;
    let mut max_delta = 0i64;
    for i in 1..n {
        let min_value = heap.peek().unwrap().0;
        chmax!(max_delta, a[i] - min_value);
        heap.push(Rev(a[i]));
    }
    heap.clear();
    heap.push(Rev(a[0]));
    for i in 1..n {
        let min_value = heap.peek().unwrap().0;
        if max_delta == a[i] - min_value {
            cnt += 1;
        }
        heap.push(Rev(a[i]));
    }
    println!("{}", cnt);
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while((str = br.readLine()) != null){
			String[] num = str.split(" ",0);
			int x = Integer.parseInt(num[0]);
			int y = Integer.parseInt(num[1]);
			int z = x + y;
			System.out.println(String.valueOf(z).length());
		}
	}
}

Measured memory_bytes: 24524
import java.util.*;

class Main{
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		
		int[] num=new int[5];
		int a=0;
		for(int i=0;i<5;i++){
			num[i]=sc.nextInt();
			if(num[i]==0)a=i;
		}
		System.out.println(a+1);
	
	}
}

Measured memory_bytes: 35724
#include<stdio.h>

int main(){
  int a,b;
  char *x[101], *y[101] ,*z[101];
  
  scanf("%s %s", &x,&y);
  scanf("%d %d", &a,&b);
  scanf("%s", &z);
  
  if(strcmp(x,z)==0){
    a--;
  }else{
    b--;
  }
  printf("%d %d",a,b);
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

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

    int a, b, c, d;
    int res = 0;
    cin >> a >> b >> c >> d;

    if (a <= c && d <= b)
        cout << d - c << endl;
    else if (c <= a && b <= d)
        cout << b - a << endl;
    else if (a <= c && c <= b && b <= d)
        cout << b - c << endl;
    else if (c <= a && a <= d && d <= b)
        cout << d - a << endl;
    else
        cout << 0 << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

P1 en = mp1(-1,-1,-1);

bool ret;
vector<int> G[100010];
int X[100010],Y[100010],T[100010];
P1 dfs0(int v,int p,int x,int y,int t){
	if(Y[v] < x || y < X[v]){
		ret = false;
		return en;
	}
	if(X[v] == Y[v] && (X[v]%2) != t){
		ret = false;
		return en;
	}
	X[v] = max ( X[v] , x );
	Y[v] = min ( Y[v] , y );
	T[v] = t;
	rep(i,G[v].size()){
		if(G[v][i] == p)continue;
		P1 q = dfs0(G[v][i],v,x-1,y+1,t^1);
		if(q == en)return en;
		if(Y[v] < q.fr || q.sc.fr < X[v]){
			ret = false;
			return en;
		}
		if(T[v] != q.sc.sc){
			ret = false;
			return en;
		}
		X[v] = max ( X[v] , q.fr );
		Y[v] = min ( Y[v] , q.sc.fr );
	}
	return mp1(X[v]-1,Y[v]+1,T[v]^1);
}

int ans[100010];
void dfs1(int v,int p,int x){
	if(p == -1)ans[v] = x;
	else if(X[v] <= x-1)ans[v] = x-1;
	else ans[v] = x+1;
	rep(i,G[v].size()){
		if(G[v][i] == p)continue;
		dfs1(G[v][i],v,ans[v]);
	}
}

int main(){
	static int n;
	static int a[100010],b[100010];
	static int k;
	static int v[100010],p[100010];
	scanf("%d",&n);
	rep(i,n-1)scanf("%d%d",&a[i],&b[i]);
	scanf("%d",&k);
	rep(i,k)scanf("%d%d",&v[i],&p[i]);
	
	ret = true;
	rep(i,n-1){
		G[a[i]].pb(b[i]);
		G[b[i]].pb(a[i]);
	}
	rep1(i,n){
		X[i] = -100000000;
		Y[i] = 100000000;
	}
	rep(i,k){
		X[v[i]] = p[i];
		Y[v[i]] = p[i];
		T[v[i]] = p[i]%2;
	}
	dfs0(v[0],-1,p[0],p[0],p[0]%2);
	
	if(!ret){
		puts("No");
		return 0;
	}
	else puts("Yes");
	
	dfs1(v[0],-1,p[0]);
	rep1(i,n){
		printf("%d\n",ans[i]);
	}
}



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

int main(){
    int N, M;
    int s,c;
    int flg_ne = 0, ans = 0;
    vector<int> the_num{10,10,10};

    std::cin >> N >> M;

    for(int i = 0; i < M; i++){
        std::cin >> s >> c;
        if(the_num[3-N+s-1] == 10){
            the_num[3-N+s-1] = c;
        }else{
            if(the_num[3-N+s-1] != c){
                flg_ne = 1;
                break;
            } 
        }
    }
    if(the_num[3-N]==0){
        if(N != 1){
            flg_ne = 1;
        }
    }
    if(the_num[0] == 10){
        the_num[0] = 1;
    }
    if(the_num[1] == 10){
        if(N == 2){
            the_num[1] = 1;
        }else{
            the_num[1] = 0;
        }
    }
    if(the_num[2] == 10){
        the_num[2] = 0;
    }

    if(flg_ne == 1){
        std::cout << -1;
    }else{
        if(N == 1){
            std::cout << the_num[2];
        }else if(N == 2){
            std::cout << the_num[1] << the_num[2];
        }else if(N == 3){
            std::cout << the_num[0] << the_num[1] << the_num[2];
        }
    }

}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void) {
	int A;
	cin >> A;
	for (int i = 0; i < A; i++) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 3 != 0 && x % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    if (A == 1 && B == 1) {
        cout << "Draw" << endl;
        return 0;
    } else if (A == 1) {
        cout << "Alice" << endl;
        return 0;
    } else if (B == 1) {
        cout << "Bob" << endl;
        return 0;
    }

    if (A > B) {
        cout << "Alice" << endl;
    } else if (A < B) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,m;
vector <ll> arr[100005];
ll dp[100005];

ll solve(ll i){
	
	if(dp[i]==-1){
		ll z = 0;
		for(ll j=0;j<arr[i].size();++j){
			
			z = max(z,solve(arr[i][j]));
			
		}
		dp[i] = 1+z;
		
	}
	return dp[i];
	
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		
		ll x,y;
		cin>>x>>y;
		arr[x-1].push_back(y-1);
	}
	m = 0;
	for(ll i=0;i<n;i++){
		
		m = max(m,solve(i));
		
	}
	cout<<m-1<<endl;
	
}

Measured memory_bytes: 8576
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;


Node treeSearch(Node x, int k){
  if(x == NIL || k == x->key) return x;
  if(k < x->key) return treeSearch(x->left,k);
  else return treeSearch(x->right,k);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
   
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;



}

void inorder(Node u){
 if(u!=NIL){
    if(u->left!=NIL) inorder(u->left);
    
    printf(" %d",u->key);
       
    if(u->right!=NIL) inorder(u->right);
   }
}
void preorder(Node u){
   printf(" %d",u->key);
  if(u!=NIL){
    if(u->left!=NIL) preorder(u->left);
    
    if(u->right!=NIL) preorder(u->right); 
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  bool ans = false;
  
  for(int i=0; i<=25; i++){
    for(int j=0; j<=14; j++){
      int sum = 4*i + 7*j;
      if (sum == n)
        ans = true;
    }
  }
  
  if (ans == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
function Main(input) {
  const n = Number(input);
  let result = '';
  for (let i = 1; i <= n; i++) {
    if (i % 3 === 0){
      result += ' ' + i;
    }
    else if (String(i).indexOf('3') != -1) {
      result += ' ' + i;
    } else {
      
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main(){
    int X, Y;

    
	cin >> X >> Y;

	if(Y%2 == 1){
		cout << "No";
	}else if(Y<=X*4 && Y>=X*2){
		cout << "Yes";
	}else{
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e16;
int main()
{
	int l; cin>>l;
	ll a[200001];
	for(int i=1; i<=l; i++) cin>>a[i];
	ll dp[5][200001];
	for(int j=0; j<5; j++){
		fill(dp[j], dp[j]+l+1, INF);
	}
	dp[0][0]=0;
	for(int i=1; i<=l; i++){
		for(int j=0; j<5; j++){
			ll x;
			if(j==0 || j==4) x=a[i];
			else if(j==1 || j==3){
				if(a[i]%2==1) x=1;
				else if(a[i]==0) x=2;
				else x=0;
			}else{
				if(a[i]%2==0) x=1;
				else x=0;
			}
			for(int k=0; k<=j; k++){
				dp[j][i]=min(dp[j][i], dp[k][i-1]+x);
			}
		}
	}
	ll ans=INF;
	for(int j=0; j<5; j++) ans=min(ans, dp[j][l]);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int h,w;
	cin >> h >> w;

	map<int,int> s;
	multiset<int> vals;
	rep(i,w) s[i] = i;
	rep(i,w) vals.insert(0);

	rep(i,h) {
		int l, r;
		cin >> l >> r;
		--l;

		auto it = s.lower_bound(l);
		int mr = -1;
		while(it != s.end() && it->first <= r) {
			mr = max(mr, it->second);
			int x = it->first - it->second;
			vals.erase(vals.find(x));
			s.erase(it++);
		}
		if (mr != -1 && r < w) {
			vals.insert(r - mr);
			s[r] = mr;
		}
		int ans = -1;
		if (vals.size() > 0) {
			ans = *vals.begin() + (i+1);
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 22468
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0,b=0;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  if(v.size()%2==0){
    for(int i=1;i<=n/2;i++){
      a+=v[2*i-2];
      b+=v[2*i-1];
    }
  }else{
    for(int i=1;i<=n/2;i++){
      a+=v[2*i-1];
    }
    for(int i=1;i<=(n+1)/2;i++){
      b+=v[2*i-2];
    }
  }
  cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 256
def e_coins_respawn(N, M, P, Edges, INF=float('inf')):
    edges = [(a - 1, b - 1, P - c) for a, b, c in Edges]
    dist = [INF] * N
    dist[0] = 0

    for _ in range(N - 1):
        for u, v, w in edges:
            if dist[u] == INF:
                continue
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
    ans_tmp = dist[N - 1]  # 負閉路がなければ、これが解

    # 負閉路がなければここからのループで距離は変わらない
    is_negative = [False] * N
    for _ in range(N):
        for u, v, w in edges:
            if dist[u] == INF:
                continue
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                is_negative[v] = True

            # ある頂点が負閉路の一部なら、それに隣接する頂点も負閉路の一部
            if is_negative[u]:
                is_negative[v] = True
    # 頂点Nが負閉路に含まれるなら、元のグラフでのスコアは無限大
    return -1 if is_negative[N - 1] else max(-ans_tmp, 0)

N, M, P = [int(i) for i in input().split()]
Edges = [[int(i) for i in input().split()] for j in range(M)]
print(e_coins_respawn(N, M, P, Edges))

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

int main()
{
	ll N,M;
	cin >> N >> M;
	if (N == 1 && M == 1) cout << 1 << endl;
	else if(N == 1 || M == 1) cout << max(N,M)-2 << endl;
	else cout << (N-2) * (M-2) << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include<cmath>
using namespace std;

int main(void) {
	string a, b;
	cin >> a >> b;
	string c = a + b;
	int x = stod(c);
	double y = sqrt(x);
	(floor(y) == y) ? cout << "Yes" : cout << "No";
	return 0;
}


Measured memory_bytes: 3784