akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        for (int i = 1; i <= 9; i++)
        {
            for(int j = 1; j <= 9; j++)
            {
                Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            }
        }
    }
}

Measured memory_bytes: 9020
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll powa[60];
   powa[0] = 1;
   for(ll i=1;i<60;i++)
        powa[i] = powa[i-1]*2;
   
   ll n,k;
   cin>>n>>k;
   
   ll arr[n];
   rep(n)
        cin>>arr[i], arr[i]--;
        
   ll nxt[n][60];
   memset(nxt,-1,sizeof(nxt));
   rep(n)
        nxt[i][0] = arr[i];
   
   for(ll i=1;i<60;i++)
        repi(j,n)
            nxt[j][i] = nxt[nxt[j][i-1]][i-1];
   
   /*rep(n)
        repi(j,3)
            cout<<"for "<<i+1<<" , "<<powa[j]<<" = "<<nxt[i][j]+1<<"\n";*/
   
   ll curr = 0;
   for(ll j=59;j>-1;j--)
   {
       if(powa[j]<=k)
       {
           k-=powa[j];
           curr = nxt[curr][j];
       }
   }
   cout<<curr+1;
   
   return 0;        
}  
  
   

Measured memory_bytes: 98980
import java.util.*;

/**
 * Deadlock
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N;
		N = sc.nextInt();

		Set<String> vs = new HashSet<>();
		Map<String, Set<String>> indeg = new HashMap<>();
		Map<String, Set<String>> outdeg = new HashMap<>();

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

			String u, d, rel;

			u = 'u' + sc.next();
			rel = sc.next();
			d = 'd' + sc.next();

			vs.add(u);
			vs.add(d);
			indeg.putIfAbsent(u, new HashSet<>());
			indeg.putIfAbsent(d, new HashSet<>());
			outdeg.putIfAbsent(u, new HashSet<>());
			outdeg.putIfAbsent(d, new HashSet<>());

			if (rel.equals("lock")) {
				indeg.get(u).add(d);
				outdeg.get(d).add(u);
			} else {
				indeg.get(d).add(u);
				outdeg.get(u).add(d);
			}
		}

		Queue<String> que = new ArrayDeque<>();

		for (String v : indeg.keySet()) {
			if (indeg.get(v).size() == 0) {
				que.offer(v);
			}
		}

		while (!que.isEmpty()) {
			String u = que.poll();
			for (String v : outdeg.get(u)) {
				indeg.get(v).remove(u);
				if (indeg.get(v).size() == 0) {
					que.offer(v);
				}
			}
			vs.remove(u);
		}

		System.out.println(vs.size() == 0 ? 0 : 1);
	}
}


Measured memory_bytes: 33768
A,P=[1],[1]
for i in range(50):
    A.append(A[i]*2+3)
    P.append(P[i]*2+1)

def n(N, X):
    if X<=0: return 0
    if N==0: return 1
    return n(N-1, X-1) if X <= A[N-1]+1 else P[N-1] + 1 + n(N-1, X-(A[N-1]+2))

print(n(*list(map(int, input().split()))))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
 char c;
    cin>>c;
    c=c+1;
    cout<<c<<endl;

    return 0;
}




Measured memory_bytes: 3616
#include <stdio.h>
const int INF=2147483647;
struct segment_tree{
    int map[2000010];
    void build(int now,int l,int r){
        if(l==r){
            map[now]=INF;
            return;
        }
        map[now]=-1;
        int mid=(l+r)/2;
        build(now*2+1,l,mid);
        build(now*2+2,mid+1,r);
        return ;
    }
    void change(int n,int now,int L,int R,int l,int r){
        if(R<l||L>r)return;
        if(L>=l&&R<=r){
            map[now]=n;
            return;
        }
        if(map[now]!=-1){
            map[now*2+1]=map[now*2+2]=map[now];
            map[now]=-1;
        }
        int mid=(L+R)/2;
        change(n,now*2+1,L,mid,l,r);
        change(n,now*2+2,mid+1,R,l,r);
        return ;
    }
    int find(int now,int L,int R,int n){
        if(L==R)return map[now];
        if(map[now]!=-1){map[now*2+1]=map[now*2+2]=map[now];
            int temp=map[now];
            map[now]=-1;
            return temp;
        }
        int mid=(L+R)/2;
        if(mid>=n)return find(now*2+1,L,mid,n);
        else return find(now*2+2,mid+1,R,n);
    }
};
int main(){
    int n,m,k,l,r;
    segment_tree arr;
    scanf("%d%d",&n,&m);
    arr.build(0,0,n-1);
    while(m--){
        scanf("%d",&k);
        if(k==0){
            scanf("%d%d%d",&l,&r,&k);
            arr.change(k,0,0,n-1,l,r);
        }
        else {
            scanf("%d",&k);
            printf("%d\n",arr.find(0,0,n-1,k));
        }
    }
    
}

Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<vector>
using ll = unsigned long long;
using namespace std;

// https://www.hamayanhamayan.com/entry/2017/10/15/002216

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

    string* s = new string[h];
    int* a = new int[h*w];

    for(int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    for(int hi = 0; hi < h; ++hi) {
        for(int wi=0; wi < s[hi].size(); ++wi) {
            if(s[hi][wi] == '#') {
                
                if(wi-1>=0)a[hi+((wi-1)*h)]++;
                if(wi+1<w)a[hi+(wi+1)*h]++;

                if(hi+1<h) {
                    a[hi+1+(wi*h)]++;
                    if(wi+1<w) a[hi+1+((wi+1)*h)]++;
                    if(wi-1>=0) a[hi+1+(wi-1)*h]++;
                }
                
                if(hi-1>=0){
                a[hi-1+(wi*h)]++;
                
                if(wi+1<w)a[hi-1+((wi+1)*h)]++;
                if(wi-1>=0)a[hi-1+(wi-1)*h]++;
                }
                
            }
        }
    }

    for(int hi = 0; hi < h; ++hi) {
        for(int wi=0; wi < s[hi].size(); ++wi) {
            if(s[hi][wi]=='.'){
                cout << a[hi+wi*h];
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 2e5+5;
int const inf = 2e16;

void solve(){  
    int i,j,l;
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> a(n);
    for(auto &x:a){
        cin>>x;
    }
    for(i=1;i<n;i++){
        a[i] += a[i-1];
    }
    a.pb(inf);

    int ans = 0;

    ans = lower_bound(all(a) , k+1) - a.begin();

    // cout<<ans<<endl;

    int sm = 0;
    for(i=0;i<m;i++){
        int x;
        cin>>x;
        sm += x;
        int l = lower_bound(all(a) , k-sm+1) - a.begin();
        if(k-sm >= 0)
        ans = max(ans , i+1 + l);
    }

    cout<<ans<<endl;
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

1 3 4 7 8 8 


*/

Measured memory_bytes: 6368
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

ans = 0
for i in range(2 ** H):
  for j in range(2 ** W):
    count = 0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii&1) == 0 and (j>>jj&1) == 0 and c[ii][jj] == '#':
          count += 1
    if count == K:
      ans += 1
print(ans)

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

int main() {
  int N;
  cin>>N;
  vector<int>A(N+1,0);
  
  for(int i=2;i<=N;i++){
    int tmp;
    cin>>tmp;
    A[tmp]++;
  }
  
  for(int i=1;i<=N;i++){
    cout<<A[i]<<endl;
  }
  
  
}


Measured memory_bytes: 3952
#include <iostream>

using namespace std;

int main()
{
	int n;

	cin >> n;

	for(int i=1; i<=n; i++)
	{
		int x = i;

		if(x/10 >= 3 && x/10 < 4)
		{
			cout << " " << x;
		}
		else if(x%100 >= 30 && x%100 < 40)
		{
			cout << " " << x;
		}
		else if(x%1000 >= 300 && x%1000 < 400)
		{
			cout << " " << x;
		}
		else if(x%10000 >= 3000 && x%10000 < 4000)
		{
			cout << " " << x;
		}

		else if(x%3 == 0 || x%10 == 3)
		{
			cout << " " << i;
		}

	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    string s;cin>>s;
    int ans = 0;
    for(int i=0; i<n-2; i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
MOD = 10**9 + 7
Lnum=[0]*n
LRnum=[0]*n
ans = 0
for i in range(n):
    Lnum[i] = sum(x>a[i] for x in a[:i])
    LRnum[i] = Lnum[i] + sum(x>a[i] for x in a[i+1:])
    ans += Lnum[i]*k + LRnum[i] * (k*(k-1)//2)
    ans = ans % MOD
print(ans)

Measured memory_bytes: 3188
package main

import "fmt"

func check(b byte) string {
	switch b {
	case 'a', 'e', 'i', 'o', 'u':
		return "vowel"
	}
	return "consonant"
}

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(check(s[0]))
}


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

long long gcd(long long x, long long y){
    if(!(x%y)) return y;
    return gcd(y, x%y);
}

int main(){
    long long a, b, c, d; cin >> a >> b >> c >> d;
    long long l =c * d / gcd(c, d);
    a--;
    long long ans = b - a  - (b/c + b/d - b/l) + (a/c + a/d - a/l);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int fib(int n);

int memo[45];

int main() {
  int n;

  //入力
  cin >> n;

  //出力
  cout << fib(n) << endl;

  return 0;
}

int fib(int n){

  if(n == 0) {
    return 1;
  }else if(n == 1){
    return 1;
  }else if(memo[n] != 0){
    return memo[n];
  }else{
    return memo[n] = fib(n-1) + fib(n-2);
  }
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){

  int n, a[100], max = -1, min = 1001;

  cin >> n;

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

  cout << max-min << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
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; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll modpow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) res = 1LL * res * x % inf;
        y >>= 1;
        x = 1LL * x * x % inf;
    }
    return res;
}

int main(){cout<<fixed<<setprecision(20);
		   ll n;
           cin>>n;
           vll a(n);
           rep(i,0,n)cin>>a[i];
           ll sum=0;
           rep(i,0,n)
           {
            sum+=a[i];
             sum%=inf;
           }
           ll ans=0;
           rep(i,0,n){
            ll k= sum-a[i];
             if(k<0)k+=inf;
            ans+=k*a[i];
             ans%=inf;
           }
           ans=ans*modpow(2,inf-2)%inf;
           cout<<ans<<endl;
}

Measured memory_bytes: 4816
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,k;
    cin>>n>>k;
    if(n<=k){
        ll t=abs(k-n);
        cout<<min(t,n)<<endl;
    }else{
        ll t = n/k;
        ll t1 = abs(n-k*t);
        ll t2 = abs(n-k*(t+1));
        cout<<min(t1,t2)<<endl;
    }

    
return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		saori.close();
		int i = 1;
		while(true){
			if(i*n % 360 == 0){
				System.out.println(i);
				return;
			}
			i++;
		}
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

typedef long long ll;
const int N=100010;
ll s[N];
int n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",s+i);
	std::sort(s+1,s+n+1);
	ans=1;
	for(int i=1;i<n;i++)
	{
		ans=ans*(s[i]*2>=s[i+1])+1;
		s[i+1]+=s[i];
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {

  string S;
  cin >> S;

  long K;
  cin >> K;

  vector<int> v;
  v.push_back(1);

  int count = 0;
  
  for (int i = 1; i < S.size(); i++) {
    if (S[i - 1] == S[i]) {
      v[count]++;
    } else {
      count++;
      v.push_back(1);
    }
  }

  if (v.size() == 1) {

    cout << S.size() * K / 2 << endl;

  } else {

    long result = 0;
    int size = v.size();
    
    if (S[0] != S[S.size() - 1]) {
      
      for (int i = 0; i < size; i++) {
        int v_ = v[i];
        result += v_ / 2;
      }

      cout << result * K << endl;

    } else {

      for (int i = 0; i < size; i++) {
        int v_ = v[i];
        result += v_ / 2;
      }
      
      int a1 = v[0] / 2 + v[size - 1] / 2;
      int a2 = (v[0] + v[size - 1]) / 2;

      cout << result * K + (a2 - a1) * (K - 1) << endl;

    }

  }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

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

int main() {

	int K;
	int i;
	int a, b, c;
	int total = 0;

	cin >> K;
	a = 0; b = 0; c = 0;
	for (a = 1; a <= K; a++) {
		for (b = 1; b <= K; b++) {
			for (c = 1; c <= K; c++) {
				total = total +gcd(gcd(a, b), c);
			}
			c = 1;
		}
		b = 1;
	}
	
	cout << total;

	return 0;
}

Measured memory_bytes: 3636
r, c, R, C = [int(_) for _ in input().split()]
mod = 10**9 + 7

f = [1] * (2 * 10**6 + 10)
for i in range(1, 2 * 10**6 + 10):
    f[i] = i * f[i - 1] % mod
fi = {}


def inv(x):
    return pow(x, mod - 2, mod)


a1 = (C + 2) * f[c + 1] * f[C + R + 2] - (c + 1) * f[C + 2] * f[c + R + 1]
a1 *= inv(f[c + 1]) * inv(f[C + 2]) * inv(f[R + 1])
a2 = (C + 2) * f[c + 1] * f[C + r + 1] - (c + 1) * f[C + 2] * f[c + r]
a2 *= inv(f[c + 1]) * inv(f[C + 2]) * inv(f[r])
ans = a1 - a2
ans %= mod
print(ans)


Measured memory_bytes: 82164
#include <iostream>
#include <queue>

int main(void)
{
    int a, b, c, x;
    std::cin >> a >> b >> c >> x;
    int way = 0;
    for (int ia = 0; ia <= a; ++ia)
    {
        for (int ib = 0; ib <= b; ++ib)
        {
            for (int ic = 0; ic <= c; ++ic)
            {
                int total = ia * 500 + ib * 100 + ic * 50;
                if (total == x)
                {
                    ++way;
                }
            }
        }
    }
    std::cout << way << std::endl;
}


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

using namespace std;

int main()
{
	int n;
	long long int tmp,ans;
	cin >> n;
	vector<long long int> v;
	for(int i=0;i<n;i++)
	{
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.rbegin(),v.rend());
	
	ans=v[0];n-=2;
	
	for(int i=1;n;i++)
	{
		if(n) ans+=v[i],n--;
		if(n) ans+=v[i],n--;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 5284
#include<stdio.h>

int main(){
  int n, k, x, y, total=0;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  scanf("%d", &y);

  for(int i=1; i<=n; i++){
    if(i<=k)
      total += x;
    else
      total += y;
  }

  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 1708
def dfs(v, d, c):
    if vis[v][d] or d < 0:
        return
    vis[v][d] = 1
    if not color[v]:
        color[v] = c
    for u in E[v]:
            dfs(u, d - 1, c)
n, m = map(int, raw_input().split())
E = [[] for i in xrange(n + 1)]
for i in xrange(m):
    a, b = map(int, raw_input().split())
    E[a].append(b)
    E[b].append(a)
q = input()
operations = [map(int, raw_input().split()) for i in xrange(q)]
operations.reverse()
color = [0] * (n + 1)
vis = [[0] * 11 for i in xrange(n + 1)]
for op in operations:
    dfs(op[0], op[1], op[2])
for i in xrange(1, n + 1):
    print color[i]


Measured memory_bytes: 53992
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int N, K; cin >> N >> K;
    vector<bool> D(10);
    rep(i,K) {
        int d; cin >> d;
        D[d] = true;
    }

    int t;
    while(true){
        t = N;
        bool isOK = true;
        while (t > 0){
            if (D[t%10]){
                isOK = false;
                break;
            }
            t /= 10;
        }
        if (isOK) break;
        N++;
    }

    cout << N << endl;

    
}

Measured memory_bytes: 3492
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <cmath>
#include<bits/stdc++.h>
#include<queue>
using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> a(100000+2);
    vector<long long> d(100000+2);
    for(int i=0; i<n; i++){
        cin >> a[i];
        d[a[i]] = i;
    }
    d[100001] = 100001;
    vector<long long> r(100000+2,100001);
    vector<long long> r2(100000+2,100001);
    vector<long long> l(100000+2,100001);
    vector<long long> l2(100000+2,100001);
    priority_queue<int,vector<int>,greater<int>> qr;
    priority_queue<int,vector<int>,greater<int>> qr2;
    priority_queue<int,vector<int>,greater<int>> ql;
    priority_queue<int,vector<int>,greater<int>> ql2;

    qr.push(a[0]);
    ql.push(a[n-1]);
    long long t;
    for(int i=1; i<n; i++){
        while(qr2.size()>0 and qr2.top()<a[i]){
            t = qr2.top();
            qr2.pop();
            r2[t] = a[i];
        }
        while(qr.size()>0 and qr.top()<a[i]){
            t = qr.top();
            qr.pop();
            r[t] = a[i];
            qr2.push(t);
        }
        qr.push(a[i]);

        while(ql2.size()>0 and ql2.top()<a[n-1-i]){
            t = ql2.top();
            ql2.pop();
            l2[t] = a[n-1-i];
        }
        while(ql.size()>0 and ql.top()<a[n-1-i]){
            t = ql.top();
            ql.pop();
            l[t] = a[n-1-i];
            ql2.push(t);
        }
        ql.push(a[n-1-i]);
    }

    long long dl1, dl2, dr1, dr2;
    long long ans = 0;
    for(int i=0; i<n; i++){
        dl1 = d[l[a[i]]];
        dl2 = d[l2[a[i]]];
        if(dl1==100001){
            dl1 = -1;
        }
        if(dl2==100001){
            dl2 = -1;
        }
        dr1 = min(d[r[a[i]]], n);
        dr2 = min(d[r2[a[i]]], n);
        ans += ((dl1-dl2) * (dr1-i))*a[i];
        ans += ((dr2-dr1) * (i-dl1))*a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5628
n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
def judge(i):
	border=a[i]+m
	ok=min((n-i)+(p-1),n)
	if ok>=v:
		return border>=a[p-1]
	if border<a[p-1]:
		return False
	lis=[x for x in a[p-1:i]]
	cnt=0
	for i in range(len(lis)):
		cnt+=min(border-lis[i],m)
	return cnt>=(v-ok)*m

l=0
r=n
while r-l>1:
	mid=(l+r)//2
	if judge(mid):
		l=mid
	else:
		r=mid
print(l+1)


Measured memory_bytes: 20600
while 1:
	try:
		pos=[]
		for i in xrange(8):
			s=raw_input()
			for j in xrange(8):
				if int(s[j])==1:
					pos.append([i,j])
		if pos[0][0]+1==pos[3][0] and pos[0][1]+1==pos[3][1]:
			print('A')
		elif pos[0][0]+3==pos[3][0]:
			print('B')
		elif pos[0][1]+3==pos[3][1]:
			print('C')
		elif pos[0][1]==pos[3][1]+1:
			print('D')
		elif pos[0][0]+1==pos[3][0] and pos[0][1]+2==pos[3][1]:
			print('E')
		elif pos[0][0]+2==pos[3][0]:
			print('F')
		else:
			print('G')
		raw_input()
	except:
		break

Measured memory_bytes: 6440
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

a = ni()
b = ni()
c = ni()
x = ni()
ans = 0
for ai in range(a+1):
        for bi in range(b+1):
                if (x - 500 * ai - 100 * bi) % 50 == 0 \
                        and (x - 500 * ai - 100 * bi) // 50 <= c \
                                and (x - 500 * ai - 100 * bi) // 50 >= 0:
                        ans += 1
print(ans)

Measured memory_bytes: 3064
s = list(input())
t = list(input())
n = len(s)

s_par = [i for i in range(n + 1)]
t_par = [i for i in range(n + 1)]

def operation(x, par):
    for i in range(n):
        for j in range(i):
            if x[i] == x[j]:
                par[i] = par[j]
                break
    return par

if operation(s, s_par) == operation(t, t_par):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 28052
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    if n % k:
        print(1)
    else:
        print(0)
    return

#B
def B():
    n = II()
    dp = [0] * (100 + 1)
    dp[4] = 1
    dp[7] = 1
    for i in range(8,n + 1):
        if dp[i - 4] or dp[i - 7]:
            dp[i] = 1
    print(["No", "Yes"][dp[n]])
    return

#C
def C():
    n = II()
    ans = []
    if n == 0:
        print(0)
    while n:
        ans.append("{}".format(n % 2))
        n = (n-1) // -2
    print("".join(ans[::-1]))
    return

#D
def D():
    n, m = LI()
    a = LI()
    a = list(map(lambda x: x % m, a))
    a = [0] + a
    d = defaultdict(int)
    ans = 0
    for i in range(1, n + 1):
        a[i] += a[i - 1]
        a[i] %= m
        d[a[i]] += 1
    d[0] += 1
    for value in d.values():
        ans += value * (value - 1) // 2
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 60568
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    A = []
    for _ in range(2):
        A.append(list(map(int, input().split())))

    ans = 0
    for i in range(N):
        score = 0
        for j in range(N):
            if j <= i:
                score += A[0][j]
            if j >= i:
                score += A[1][j]
        ans = max(ans, score)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include <stdio.h>
 
int main(void) {
    int N, K, X, Y, sum;
    scanf("%d %d %d %d", &N, &K, &X, &Y);
  
    if (N >= K){
      sum = K * X + (N - K) * Y;
    }
    else{
      sum = N * X;
    }
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;
int x[maxn],ww[maxn],w[maxn];
int l,r,s,t,n,m;
long long c=0;
int main()
{
	cin>>n>>l>>t;
	for(int i=1;i<=n;i++)
	cin>>w[i]>>x[i]; 
	for(int i=1;i<=n;i++)
	{
		if(x[i]==2)x[i]=-1;
		r=w[i]+x[i]*t;
        if (r>0) (c+=r/l)%=n;
        else if (r<0) (c+=(r+1)/l-1)%=n;
        ww[i]=(r%l+l)%l;
	}
	sort(ww+1,ww+n+1);
	c=(c+n)%n;
	for(int i=c+1;i<=n;i++)
	cout<<ww[i]<<endl;
	for(int i=1;i<=c;i++)
	cout<<ww[i]<<endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    REP(i, n)   cin >> a[i];
    map<ll, ll> key;
    ll res=0;
    REP(i, n){
        res += key[i-a[i]];
        key[i+a[i]] += 1;
    }
   
    cout << res << endl;
}


Measured memory_bytes: 27288
M1, D1 = map(int, input().split(" "))
M2, D2 = map(int, input().split(" "))

if M1 ==2 :
    if D1==28:
        print(1)
    else:
        print(0)
elif (M1==1) or (M1==3) or (M1==5) or (M1==7) or (M1==8) or (M1==10) or (M1==12) :
    if(D1==31):
        print(1)
    else:
        print(0)    
elif  (M1==4) or (M1==6) or (M1==9) or (M1==11) :
    if(D1==30):
        print(1)
    else:
        print(0)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
 
 
int main()
{
	cin >> s;
	REP(i, s.size() / 2)
	{
		if (s[i] != s[s.size() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
div_4 = 0
div_2 = 0
div_0 = 0
for a in A:
    tmp = a
    count = 0
    while True:
        if tmp % 2 == 0:
            tmp = tmp // 2
            count += 1
        else:
            break
    if count == 0:
        div_0 += 1
    elif count == 1:
        div_2 += 1
    else:
        div_4 += 1
if div_2 == 0:
    if div_0 <= (div_4 + 1):
        print("Yes")
    else:
        print("No")
else:
    if div_0 <= div_4:
        print("Yes")
    else:
        print("No")


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(a*b, c) <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, m, a[MAXN], b[MAXN], tag[MAXN << 2];
pii val[MAXN << 2];
LL ans;

inline void Build(int x, int l, int r)
{
	val[x] = mp(b[l], l);
	if (l == r)
		return ;
	int mid = l + r >> 1;
	Build(x << 1, l, mid), Build(x << 1 | 1, mid + 1, r);
}

inline void Modify(int x, int l, int r, int ql, int qr)
{
	if (l == ql && r == qr)
		return (void)(val[x].xx ++, tag[x] ++);
	if (tag[x])
		val[x << 1].xx += tag[x], tag[x << 1] += tag[x], val[x << 1 | 1].xx += tag[x], tag[x << 1 | 1] += tag[x], tag[x] = 0;
	int mid = l + r >> 1;
	if (qr <= mid)
		Modify(x << 1, l, mid, ql, qr);
	else if (ql > mid)
		Modify(x << 1 | 1, mid + 1, r, ql, qr);
	else
		Modify(x << 1, l, mid, ql, mid), Modify(x << 1 | 1, mid + 1, r, mid + 1, qr);
	val[x] = min(val[x << 1], val[x << 1 | 1]);
}

inline pii Query(int x, int l, int r, int ql, int qr)
{
	if (l == ql && r == qr)
		return val[x];
	if (tag[x])
		val[x << 1].xx += tag[x], tag[x << 1] += tag[x], val[x << 1 | 1].xx += tag[x], tag[x << 1 | 1] += tag[x], tag[x] = 0;
	int mid = l + r >> 1;
	if (qr <= mid)
		return Query(x << 1, l, mid, ql, qr);
	if (ql > mid)
		return Query(x << 1 | 1, mid + 1, r, ql, qr);
	return min(Query(x << 1, l, mid, ql, mid), Query(x << 1 | 1, mid + 1, r, mid + 1, qr));
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = b[i] = Read(), ans -= a[i];
	sort(b + 1, b + n + 1), m = unique(b + 1, b + n + 1) - b - 1, Build(1, 1, m);
	for (int i = 1; i <= n; i ++)
	{
		pii val = Query(1, 1, m, lower_bound(b + 1, b + m + 1, a[i]) - b, m);
		ans += val.xx;
		if (val.yy > 1)
			Modify(1, 1, m, 1, val.yy - 1);
	}
	return printf("%lld\n", ans), 0;
}


Measured memory_bytes: 11136
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A + B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	
}

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

int main(){
  int n;
  cin>>n;
  int ans = n;
  vector<int> dp(n+1);
  REP(i,n+1)dp[i] = i;
  int v = 6;
  while(v <= n){
    REP(i,n+1-v)dp[i+v] = min(dp[i+v], dp[i]+1);
    v *= 6;
  }
  v = 9;
  while(v <= n){
    REP(i,n+1-v)dp[i+v] = min(dp[i+v], dp[i]+1);
    v *= 9;
  }
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 640
use std::io;

fn main() {
    let mut line = String::new();
    let mut r = io::stdin().read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
 
    let tate: i32 = vec[0].parse().unwrap();
    let yoko: i32 = vec[1].parse().unwrap();

    println!("{} {}", tate * yoko, tate * 2 + yoko * 2);
}



Measured memory_bytes: 5028
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int main(){
        int a,b,c,d;
        cin>>a>>b;
        //c=min(a,b);
        d=max(a,b);

        if(d>8) cout<<":("<<endl;
        else cout<<"Yay!"<<endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll k,n,sum=0;
int main()
{
    fast;
   ll t;
    t=1;
   while(t--)
   {
       ll i,j=7,d=0,e=0;
       std::cin >> n;
       fr(i,1,1000001)
       {
           d=(d+j)%n;
           j=(j*10)%n;
           if(d==0)
           {
               e=i;
               break;
           }
       }
       if(e==0)
       cout<<"-1\n";
       else
       cout<<e<<"\n";
   }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

/*------------------------------------------------------------------*/
int main(){
    int n, l; cin >> n >> l;
    vector<string> vec;
    rep(i, n){
        string t; cin >> t;
        vec.push_back(t); 
    }
    sort(vec.begin(), vec.end()); 
    string ans = "";
    for(auto it : vec){
        ans += it;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N, finalRows, k = 0, sum, count;
		List<Integer> b = new ArrayList<Integer>();
		L0: while ((N = scan.nextInt()) != 0) {
			b.clear();
			sum = 0;
			for (int i = 0; i < N; i++)
				b.add(scan.nextInt());
			for (int val : b)
				sum += val;
			L1: if (true) {
				for (int i = 1; i <= 100; i++) {
					k = i * (i + 1) / 2;
					if (sum == k) {
						finalRows = i;
						break L1;
					}
				}
				System.out.println("-1");
				continue L0;
			}
			List<Integer> tri = new ArrayList<Integer>();
			for (int i = 0; i < finalRows; i++)
				tri.add(i + 1);
			count = 0;
			while (!tri.equals(b)) {
				if (count > 10000) {
					System.out.println("-1");
					continue L0;
				}
				for (int i = 0; i < b.size(); i++)
					b.set(i, b.get(i) - 1);
				b.add(b.size());
				count++;
				while (b.remove(new Integer(0)));
			}
			System.out.println(count);
			continue L0;
		}
	}
}

Measured memory_bytes: 36664
//file_name:ABC82_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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


    int ans = (n+x+(n+x)%2)/2;

    cout << ans << endl;
    return 0;
}



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

const int INF = 1001001001;
int main(){
  int n,x,y;
  cin >>n>>x>>y;
  //頂点番号は0空にしたいのでデクリメント
  --x;--y;
  vector<int> ans(n);
  rep(sv,n){
    vector<int> dist(n,INF);
    queue<int> q;
    auto push = [&](int v,int d){
      if(dist[v]!=INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(sv,0);
    while(!q.empty()){
      int v = q.front();q.pop();
      int d = dist[v];
      if(v-1>=0)push(v-1,d+1);
      if(v+1< n)push(v+1,d+1);
      if(v==x)push(y,d+1);
      if(v==y)push(x,d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }
  rep(i,n) ans[i] /=2;
  for(int i=1;i<=n-1;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())

t0 = int(input())
t1 = int(input())
minT = min(t0, t1)
answer = t1 - t0

for i in range(2, n):
    target = int(input())
    answer = max(answer, target - minT)
    minT = min(target, minT)

print(answer)


Measured memory_bytes: 5612
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it before "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int in;
    ll sum = 0;
    for (int i = 0;i < m;i ++) {
        scanf("%d",&in);
        sum += in;
    }
    if (n >= sum) printf("%lld\n",n - sum);
    else printf("-1\n");
    
    return 0;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		for(int i =0; i<n; i++)
		{
			int a=scan.nextInt();
			int b=scan.nextInt();
			int c=scan.nextInt();

			if(a*a==b*b+c*c)
				System.out.println("YES");
			else if(b*b==a*a+c*c)
				System.out.println("YES");
			else if(c*c==a*a+b*b)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}

}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	int ans=1e9;
	for(int i=0;i<n;i++){
		cin>>a[i];		
		int cnt=0;
		while(a[i]%2==0)cnt++,a[i]/=2;
		ans=min(ans,cnt);
	}
	cout<<ans;
}





Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

int main() {
    string s, t, u;
    map<string, int> mp;
    cin >> s >> t;
    cin >> mp[s] >> mp[t] >> u;
    mp[u]--;
    cout << mp[s] << ' ' << mp[t] << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
typedef struct Node{
    int key;
    Node *parent, *left, *right;
} Node;
 
Node *root,*NIL;
 
void insert(int k){
    Node *z = new Node;
     
    z->key = k;
    z->left = NIL;
    z->right = NIL;
 
    Node *y = NIL;
    Node *x = root;
    while( x != NIL){
        y=x;
        if(z->key < x->key) x=x->left;
        else x=x->right;
    }
    z->parent = y;
     
    //親yの処理
    if(y==NIL)root=z;
    else {
        if(z->key < y->key)y->left=z;
        else y->right=z;
    }
}
 
void isfound(Node*u,int k){
    while(u!=NIL && k!=u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    if(u!=NIL)cout << "yes" << endl;
    else cout << "no" << endl;
}
 
void Preorder(Node *u){
    if( u==NIL ) return;
    cout << " " << u->key;
    Preorder(u->left);
    Preorder(u->right);
}
 
void Inorder(Node *u){
    if( u== NIL ) return;
    Inorder(u->left);
    cout << " " << u->key;
    Inorder(u->right);
}
 
void deleteBST(Node *u){
    if(u == NIL)return;
    deleteBST(u->left);
    deleteBST(u->right);
    if(u->left==NIL && u->right==NIL){
        u->parent=NIL;
        delete u;
    }
}
 
int main(){
    int n;
    string com;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> com;
        if(com[0]=='i'){
            int k;
            cin >> k;
            insert(k);
        }else if(com[0]=='p'){
            Inorder(root);cout << endl;
            Preorder(root);cout << endl;
        }else {
            int k;
            cin >> k;
            isfound(root,k);
        }
    }
     
    deleteBST(root);
 
    return 0;
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>

int main(void){
    int N;
    scanf("%d", &N);
    int V[N];
    int C[N];
    int i,j,k;
    for(i = 0; i < N; i++){scanf("%d", &V[i]);}
    for(i = 0; i < N; i++){scanf("%d", &C[i]);}
    
    int box[N];
    int tmp = 1;
    int cnt;
    int max = -1;
    int vsum = 0;
    int csum = 0;
    
    int time = (int)pow((double)2, (double)N);
    for(i = 1; i <= time; i++){
        tmp = i;
        cnt = 0;
        while(cnt < N){
            box[cnt] = tmp % 2;
            tmp /= 2;
            cnt++;
        }
        //printf("i:%d    ", i);
        //for(k = 0; k < N; k++){printf("box[%d]:%d  ", k, box[k]);}
        //printf("\n");
        for(j = 0; j < N; j++){
            if(box[j] == 1){
                vsum += V[j];
                csum += C[j];
            }
        }
        if(max < vsum - csum){max = vsum - csum;}
        vsum = 0;
        csum = 0;
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 256
import math
def f(i,j):
    global N,D,X
    res = 0
    for x in range(D):
        res += (X[i][x]-X[j][x])**2
    return math.sqrt(res)
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        if i<=j:
            break
        if f(i,j)%1==0:
            ans+=1
print(ans)

Measured memory_bytes: 3064