akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
typedef int SegT;
const int defvalue=0;
class SegTree{
	private:
		vector<SegT>val;
		SegT combine(SegT a,SegT b){return a+b;}
	public:
		int n;
		SegTree(int size){
			n=1;
			while(n<size)n<<=1;
			val=vector<SegT>(2*n,defvalue);
		}
		SegTree(const vector<SegT> &in){
			n=1;
			while(n<in.size())n<<=1;
			val=vector<SegT>(2*n,defvalue);
			for(int i=n-1+in.size()-1;i>=0;i--){
				if(n-1<=i)val[i]=in[i-(n-1)];
				else val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		void update(int i,SegT a){
			i+=n-1;
			val[i]=a;
			while(i>0){
				i=(i-1)/2;
				val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		SegT query(int a,int b,int k=0,int l=0,int r=-1){//[a,b)
			if(r==-1)r=n;
			if(r<=a||b<=l)return defvalue;
			if(a<=l&&r<=b)return val[k];
			else return combine(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
		}
		void tmp(){
			rep(i,val.size())cout<<" "<<val[i];cout<<endl;
		}
};
int main(){
	int n;
	cin>>n;
	SegTree st(vi(n,1));
	vi in(n);
	ll t;
	cout<<"? 1 "<<n<<endl;
	cin>>t;
	vi cnt(n);
	for(int i=n-1;i>0;i--){
		cout<<"? 1 "<<i<<endl;
		ll s;
		cin>>s;
		int co=t-s+1;
		int l=0,r=n+1;
		while(r-l>1){
			int h=(l+r)/2;
//			cout<<l<<" "<<h<<" "<<r<<" "<<st.query(h,n)<<endl;
			if(st.query(h,n)>=co)l=h;
			else r=h;
		}
		in[i]=l+1;
		cnt[l]=true;
		st.update(l,0);
		t=s;
	}
	rep(i,n)if(!cnt[i])in[0]=i+1;
	cout<<"!";
	rep(i,n)cout<<" "<<in[i];cout<<endl;
}

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

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int len = s.length();
		for(int i = 0;i < len; ++i){
			if (s.charAt(i) != '?'){
				System.out.print(s.charAt(i));
			}else{
				System.out.print('D');
			}
		}


	}
}

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

ll N;
int ans = 0;

bool judge(ll x)
{
  string s = to_string(x);
  bool f[3];
  memset(f, 0, 3);
  rep(i, 0, s.size())
  {
    rep(j, 0, 3)
    {
      if (s[i] == '3' + 2 * j)
        f[j] = true;
    }
    if (f[0] && f[1] && f[2])
      return true;
  }
  return false;
}

void dfs(ll x)
{
  if (x > N)
    return;
  if (judge(x))
    ans++;
  for (int i = 3; i <= 7; i += 2)
    dfs(10 * x + i);
}

int main()
{
  cin >> N;
  dfs(0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// C.

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL n;
	cin >> n;
	vector<LL> a(n), b(n), c(n), d(n), e(n);
	for (LL i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (LL i = 0; i < n; ++i) {
		cin >> b[i];
	}
	for (LL i = 0; i < n; ++i) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	LL right = n - 1;
	for (LL i = n - 1; i >= 0; --i) {
		while (right > 0 && b[i] < c[right - 1]) {
			--right;
		}
		if (b[i] < c[right]) {
			d[i] = n - right;
		}
	}
	right = n;
	LL ans = 0, sum = 0;
	for (LL i = n - 1; i >= 0; --i) {
		while (right > 0 && a[i] < b[right - 1]) {
			--right;
			sum += d[right];
		}
		if (right < n && a[i] < b[right]) {
			ans += sum;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n, num, digit, rev, count = 0;

    int A, B = 0;

    cin >> A >> B;

    for (int i = A; i <= B; i++)
    {
        num = i;
        n = num;
        rev = 0;
        do
        {
            digit = num % 10;
            rev = (rev * 10) + digit;
            num = num / 10;
        } while (num != 0);
        
        if (n == rev)
        {
            count += 1;
        }
        
    }
    

    cout << count << endl;
}

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

int main(){
    int x,a;
    cin>>x;
    a=0;
    for (int i = 0; x>=500; i++) {
		x=x-500;
        a=a+1000;
	}
	for (int j = 0; x>=5; j++) {
        x=x-5;
        a=a+5;
    }
    cout << a << endl;
}

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

pair< int , int > setBox(pair< int , int > pos,int d){
	pair< int , int > res;
	switch(d){
	case 0:
		res.first=pos.first-1;
		res.second=pos.second;
		break;
	case 1:
		res.first=pos.first;
		res.second=pos.second-1;
		break;
	case 2:
		res.first=pos.first+1;
		res.second=pos.second;
		break;
	case 3:
		res.first=pos.first;
		res.second=pos.second+1;
		break;
	}
	
	return res;
}


int main(){
	int n;
	vector< pair < int ,int > > box;
	while(cin>>n,n!=0){
		//cout<<"n"<<n<<endl;
		box.clear();
		pair< int ,int > tmp;
		tmp.first=0;
		tmp.second=0;
		box.push_back(tmp);
		for(int i=1;i<n;i++){
			int ni,d;
			cin >> ni >> d;
			tmp=setBox(box[ni],d);
			box.push_back(tmp);
		}
		int minpos[2],maxpos[2];
		minpos[0]=minpos[1]=0;
		maxpos[0]=maxpos[1]=0;
		for(int i=0;i<n;i++){
			//cout<<box[i].first<<" "<<box[i].second<<endl;
			minpos[0]=min(box[i].first,minpos[0]);
			minpos[1]=min(box[i].second,minpos[1]);
			maxpos[0]=max(box[i].first,maxpos[0]);
			maxpos[1]=max(box[i].second,maxpos[1]);
		}
		int ansx,ansy;
		//cout<<minpos[0]<<" "<<maxpos[0]<<" "<<minpos[1]<<" "<<maxpos[1]<<endl;
		ansx=(maxpos[0]-minpos[0])+1;
		ansy=(maxpos[1]-minpos[1])+1;
		cout<<ansx<<" "<<(ansy)<<endl;
	}
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
int inf=100000000;
const double PI = 3.14159265358979323846;
/*Graph t;
void dfs(int v, int pv=-1){
    for(int vn: t[v]){
        if (vn == pv) continue;
        dfs(vn, v);
    }
}*/
const ll MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const    ll o=1;
const    ll q=0;
pair<ll,ll>bfs(vector<vector<ll>> &k,vector<vector<pair<ll,ll>>> &z,vector<ll> &parent,ll point){
  if(k[point].size()==1&&point!=0){
    parent[point]=k[point][0];
    pair<ll,ll> u;
    u=make_pair((long long)1,(long long)0);
    return make_pair(o,o);
  }
  else{
    ll ans1=1;
    ll ans2=1;
    for(ll b: k[point]){
      if(b==parent[point])continue;
      parent[b]=point;
      pair<ll,ll> p=bfs(k,z,parent,b);
      z[point].push_back(p);
      ans1+=p.first;
      ans2=ans2*p.second%MOD;
      ans2=ans2*COM(ans1-1,p.first)%MOD;
    }
    return make_pair(ans1,ans2);
  }  
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
void bfs2(ll point,pair<ll,ll> p,pair<ll,ll> pp,vector<vector<ll>> &k,vector<vector<pair<ll,ll>>> &z,vector<ll> &parent){
  ll cnt=0;
  for(ll e: k[point]){
    if(e==parent[point])continue;
    pair<ll,ll> m=z[point][cnt];
    pair<ll,ll> tmp=make_pair(pp.first-m.first+p.first,pp.second*modinv(COM(pp.first-1,m.first),MOD)%MOD*modinv(m.second,MOD)%MOD*p.second%MOD*COM(pp.first-m.first+p.first-1,p.first)%MOD);
    //if(e==3)cout << pp.first << " " << pp.second << " " << m.first << " " << m.second << endl;
    bfs2(e,tmp,m,k,z,parent);
    z[e].push_back(tmp);  
    cnt++;
  }
}
int main(){
  COMinit();
  ll n;
  cin >> n;
  Graph k(n);
  vector<ll> parent(n,-2);
  parent[0]=-1;
  vector<vector<pair<ll,ll>>> z(n);
  rep(i,n-1){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    k[a].push_back(b);
    k[b].push_back(a);
    
  }
  bfs2(0,make_pair(0,1),bfs(k,z,parent,0),k,z,parent);
  rep(i,n){
    ll ans1=1;
    ll ans2=1;
    for(pair<ll,ll> p: z[i]){
      ans1+=p.first;
      ans2=ans2*p.second%MOD;
      ans2=ans2*COM(ans1-1,p.first)%MOD;
      //if(i==3)cout << p.first << " " << p.second << " " << ans2 << endl;
    }
    cout << ans2 << endl;
  }
}  


Measured memory_bytes: 42752
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int N,K,C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    
    vector<int> A(K);
    vector<int> B(K);
    
    
    int day_before = -3e+6;
    int count = 0;
    for ( int i = 0; i < N; ++i){
        if ( S[i] == 'o' and ( i - day_before ) > C ) {
            A.at(count) = i+1;
            day_before = i;
            ++count;
            if ( count >= K ){
                break;
            }
        }
    }
    
    day_before = 3e+6;
    count = K - 1;
    for ( int i = N - 1; i >= 0; --i){
        if ( S[i] == 'o' and ( day_before - i ) > C ) {
            B.at(count) = i+1;
            day_before = i;
            --count;
            if ( count < 0 ){
                break;
            }
        }
    }
    
    
    /*for ( int i = 0; i < K; ++i){
        cout << A.at(i) << B.at(i) << endl;
    }*/
    
    
    
    int none = 0;
    for ( int i = 0; i < K; ++i){
        if ( A.at(i) == B.at(i) ){
            cout << A.at(i) << endl;
            none = 1;
        }
    }
    if ( none == 0 ){
        cout << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3332
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int r = sc.nextInt();
		int s = r * r;
		System.out.println(s);
	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 23380
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
int n,m,r;
int R[10];
int f[205][205];

void floyd()
{
	for (int k=1;k<=n;++k)
	{
		for (int i=1;i<=n;++i)
		{
			for (int j=1;j<=n;++j)
			{
				f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
				f[j][i]=f[i][j];
			}
		}
	}
}

int main()
{
	for (int i=0;i<205;++i) for (int j=0;j<205;++j) f[i][j]=1e9;
	
	scanf("%d%d%d",&n,&m,&r);
	for (int i=0;i<r;++i)
	{
		scanf("%d",R+i);
	}
	for (int i=0;i<m;++i)
	{
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		f[x][y]=f[y][x]=c;
	}
	
	floyd();
	
	int ans=1e9;
	sort(R,R+r);
	do
	{
		int p=0;
		for (int i=0;i<r-1;++i)
		{
			p+=f[R[i]][R[i+1]];
		}
		ans=min(ans,p);
	}while (next_permutation(R,R+r));
	
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main(void) {
	int a, b;
	cin >> a >> b;
	if (a % b > 0) {
		cout << a / b + 1 << endl;
	}
	else {
		cout << a / b << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
import itertools

input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N = int(input())
L = list(map(int, input().split()))

ans = 0
for a in list(itertools.combinations(L, 3)):
    a1, a2, a3 = a
    if a1 == a2 or a2==a3 or a3 == a1:
        continue
    a = list(a)
    a.sort()
    if a[2] < a[0] + a[1]:
        ans += 1
print(ans)

Measured memory_bytes: 89304
// AtCoder Grand Contest 037
// A - Dividing String
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  
  int s_size = s.size() - 1;
  int k = 1;
  int cur = 1;
  string si;
  string si1;
  si = s.at(0);
  si1 = s.at(1);
  while (cur <= s_size) {
    while (cur <= s_size) {
      if (si != si1) {
          cur++;
          k++;
          si = si1;
          if (cur <= s_size) {
              si1 = s.at(cur);
          }
          break;
      } else {
          cur++;
          if (cur > s_size){
              break;
          }
          si1 += s.at(cur);
      }
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==1 && b==1)puts("Draw");
  else if(a==1)puts("Alice");
  else if(b==1)puts("Bob");
  else
  {
    if(a>b)puts("Alice");
    else if(a==b)puts("Draw");
    else puts("Bob");
  }
}

Measured memory_bytes: 256
i = gets.to_i
a = gets.chomp.split.map(&:to_i)
l = 0
loop do 
    a.sort!.reverse!
    (a.size - 1).times do |hoge|
        a[hoge] %= a[hoge + 1]
    end
    a.delete(0)
    break if a.size == 1
    l = 0
end
puts a


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
typedef long long ll;
//#define int long long
const int mod = 1000000007;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    int k, x;
    cin >> k >> x;
    
    int mini = -1000000;
    int maxi = 1000000;
    int strt = max(x - k + 1, mini);
    int ed = min(x + k - 1, maxi);
    
    for(int i = strt; i <= ed; ++ i)
    {
        cout << i << " ";
    }
    cout << endl;
    
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 5;
ll id[MAX];
ll siz[MAX];
 
long long int root(ll x)
{
    while (id[x] != x)
    {
        x = id[x];
    }
    return id[x];
}
 
void unio(ll x, ll y)
{
    ll p = root(x);
    ll q = root(y);
    id[p] = id[q];
}
 
long long int kruskal(ll x, ll y, ll z)
{
    long long int min = 0;
    if (root(x) != root(y))
    {
        min += z;
        unio(x, y);
    }
    return min;
}
 
bool join(int a,int b){
    a=root(a);
    b=root(b);
    if(a!=b){
        if(siz[a]>siz[b]) swap(a,b);
        id[a]=b;
        siz[b]+=siz[a];
        return 1;
    }
    return 0;
}
 
const ll man=1e6;
vector<ll> edges[man];
map<pair<ll,ll>,ll> len;
const ll inf=1e18; 
vector<ll> dist(man,inf);
vector<ll> visited(man,-1);
// void dfs(ll a){
//     visited[a]=1;
//     for(auto v:edges[a]){
//         if(visited[v]==-1){
//             dist[v]=min(dist[v],dist[a]+len[{a,v}]);
//             dfs(v);
//         }
//     }
// }
const ll mod=1e9+7;
ll mul(ll a,ll b){
    return a*b%mod;
}
pair<ll,ll> dfs(ll a,ll p){
    ll all_white=1;
    ll smt_blcak=0;
    for(auto v:edges[a]){
        if(v!=p){
            pair<ll,ll> p=dfs(v,a);
            smt_blcak=mul(all_white,p.first)+mul(smt_blcak,p.first+p.second)%mod;
            all_white=mul(all_white,p.second);
        }
    }
    return {all_white,(all_white+smt_blcak)%mod};
}
int main()
{
    int n, m, i, j,k;
    int t;
    cin >> n;
    for(i=0;i<n-1;i++){
        ll u,v;
        cin>>u>>v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    pair<ll,ll> p=dfs(1,-1);
    cout<<(p.first+p.second)%mod<<endl;
}

Measured memory_bytes: 50560
A, B = map(int, input().split()) 
aaa = []
for i in range(1, 1251):
  if int(i*0.08) == A and int(i*0.1) == B:
    aaa.append(i)
    break
if A < 0 or B < 0:
  print(-1)
elif len(aaa) >= 1:
  print(min(aaa))
else:
  print(-1)

Measured memory_bytes: 3064
def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    ans = 0
    fact = 1
    for i in range(2, n):
        fact = fact*i % mod

    fact_2 = [fact]
    for i in range(2, n):
        fact_2.append((fact_2[-1] + fact * pow(i, mod-2, mod) % mod))

    for i in range(n-1):
        ans = (ans + (a[i+1]-a[i])*fact_2[i]) % mod
    print(ans % mod)


main()


Measured memory_bytes: 65176
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

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

long long INF = 1LL<<60;
int main(){
    string s;
    cin>>s;
    rep(i,s.size())cout<<"x";
    return 0;
}




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

int main(){
    int n, m;
    cin >> n >> m;
    ll sum = 0;
    for(int i = 0, a; i < m; i++){
        scanf("%d", &a);
        sum += a;
    }
    cout << (sum <= n ? n - sum : -1) << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    vector<ll> c(n-1),s(n-1),f(n-1);
    rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
    rep(i,n-1){
        ll t=0;
        for(ll j=i;j<n-1;j++){
            if(t<=s[j]) t=s[j];
            else t=(t+f[j]-1)/f[j]*f[j];
            t+=c[j];
        }
        cout<<t<<endl;
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;++i) cin>>a[i];
  int cnt=0;
  for(int i=0;i<n;++i){
    while(!(a[i]%2)){
      a[i]/=2;
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 896
p = 100
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n):
		x1,y1 = xy[i]
		xy = xy[:i] + sorted(xy[i:], key = lambda XY:(XY[0]-x1)**2 + (XY[1]-y1)**2)
		cur = 0
		for j in range(n-1,i,-1):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				cur = (x1-x2)**2 + (y1-y2)**2
				break
		ans = max(ans,cur)
	print ans

Measured memory_bytes: 5828
n = int(input())
s = input()
x = [int(i) for i in s]
pc = s.count('1')

def popcnt(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

def f(x):
    if x == 0:
        return 0
    return f(x % popcnt(x)) + 1

ans = [0]*n
for a in range(2):
    npc = pc
    if a == 0:
        npc += 1
    else:
        npc -= 1
    
    if npc <= 0:
        continue
    
    r0 = 0
    for i in range(n):
        r0 = (r0*2) % npc
        r0 += x[i]

    k = 1
    for i in range(n-1, -1, -1):
        if x[i] == a:
            r = r0
            if a == 0:
                r = (r+k) % npc
            else:
                r = (r-k+npc) % npc
            ans[i] = f(r) + 1
        k = (k*2) % npc

for i in ans:
    print(i)

Measured memory_bytes: 12912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner (System.in);
		int n = in.nextInt();
		int x = in.nextInt();
		int[] y = new int[n];
		for (int i = 0; i < n; i++)
			y[i] = in.nextInt();
		
		int[] diff = new int[n];
		diff[0] = Math.abs(x - y[0]);
		for (int i = 1; i < n; i++)
			diff[i] = Math.abs(y[i] - y[i - 1]);
		int d = diff[0];
		int temp;
		for (int i = 1; i < n; i++){
			temp = gcd(d, diff[i]);
			if (temp < d)
				d = temp;
		}
		
		System.out.println(d);

	}
	
	public static int gcd(int n1, int n2){
		
		int t;
		
		while (n2 > 0){
			t = n1 % n2;
			n1 = n2;
			n2 = t;
		}
		
		return n1;
			
	}

}

Measured memory_bytes: 49792
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

string toUpper( string s ){
  string t=s;
  for(int j=0;j<t.size();j++){
    t[j]=toupper(t[j]);
  }
  return t;
}

int main( ){
  string w,a;
  int i=0;
  cin>>w;
  w=toUpper(w);
  while(1){
    cin>>a;
    if(a=="END_OF_TEXT")break;
    a=toUpper(a);
    if(a==w)i++;
  }
  cout<<i<<endl;
  return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

typedef tree<
        pair<int, int>,
        null_type,
        less<pair<int, int>>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{*
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}
*/

bool first(vector<int> a)
{
    ll sum = 0;
    int n = a.size();
    for (auto it: a) sum+=it;
    if (sum%2 != n%2) return true;
    int cntodd = 0;
    for (int i = 0; i<n; i++)
    {
        if (a[i]==1) return false;
        if (a[i]%2)
        {
            cntodd++; a[i]--;
        }
    }
    if (cntodd!=1) return false;
    int gcd = a[0];
    for (auto it: a) gcd = __gcd(gcd, it);

    for (auto &it: a) it/=gcd;
    return !first(a);
}

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

    ll n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    if (first(a)) cout<<"First"; else cout<<"Second";




}



Measured memory_bytes: 12872
def vec_sub(v1, v2)
  return nil if v1.size != v2.size
  
  u = [0] * v1.size
  v1.size.times do |i|
    u[i] = v1[i] - v2[i]
  end
  return u
end

def vec_dist_pow2(v)
  s = 0
  v.size.times do |i|
    s += v[i] ** 2
  end
  return s
end

def is_square_number(n)
  (Math.sqrt(n.abs).floor ** 2) == n
end

def main(argv)
  (n, d) = gets.chomp.split(' ').map(&:to_i)
  
  x = [nil] * n
  n.times do |i|
    x[i] = gets.chomp.split(' ').map(&:to_i)
  end
  
  count = 0
  n.times do |i|
    ((i+1)...n).each do |j|
      count += 1 if is_square_number(vec_dist_pow2(vec_sub(x[i], x[j])))
    end
  end
  puts count.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
 

 
int main(){
    
   int n;
   cin>>n;
   bool ans=false;
   vector<int> a(n);
   rep(i,n)cin>>a.at(i);
   
   sort(a.begin(),a.end());
   
   rep(i,n-1){
       if(a.at(i)==a.at(i+1))ans=true;
   }
   
   if(ans)cout<<"NO"<<endl;
   else cout<<"YES"<<endl;
    
}

Measured memory_bytes: 1152
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        a: [chars;h],
    }
    let mut passed = vec![vec![false; w]; h];
    passed[0][0] = true;
    'outer: for i in 0..h {
        for j in 0..w {
            if i == h - 1 && j == w - 1 {
                break 'outer;
            }
            if a[i][j] == '.' {
                continue;
            }
            if !passed[i][j] {
                println!("Impossible");
                return;
            }
            if i < h - 1 && j < w - 1 {
                if a[i + 1][j] == '#' && a[i][j + 1] != '#' {
                    passed[i + 1][j] = true;
                    continue;
                } else if a[i + 1][j] != '#' && a[i][j + 1] == '#' {
                    passed[i][j + 1] = true;
                    continue;
                } else {
                    println!("Impossible");
                    return;
                }
            } else if i < h - 1 {
                if a[i + 1][j] == '#' {
                    passed[i + 1][j] = true;
                    continue;
                } else {
                    println!("Impossible");
                    return;
                }
            } else if j < w - 1 {
                if a[i][j + 1] == '#' {
                    passed[i][j + 1] = true;
                    continue;
                } else {
                    println!("Impossible");
                    return;
                }
            }
        }
    }
    println!("Possible");
}

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

typedef long long int ll;
#define T int t,q; scanf("%d",&t); for(q=1;q<=t;q++)

int main(){
	ll n,i;
	cin >> n;
	ll ar[n+5];
	
	for(i=0;i<n;i++){
		cin >> ar[i];
	}
	sort(ar,ar+n);
	ll ans=ar[n-1];
	ll c=1;
	for(int i=n-2;i>0;i--){
		if(c==n-1)break;
		if(c+2>=n){
            c++;
            ans+=ar[i];
		}
		else{
			c+=2;
			ans+=ar[i]+ar[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5196
#include<iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 1;

ll A[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) {
        ans += A[i] / 2;
        if (A[i] % 2 && A[i + 1] > 0) {
            ans++;
            A[i + 1]--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

table = defaultdict(int)
ans = 0
for a in A:
    table[a] += 1
    ans += a

for _ in range(Q):
    B, C = map(int, input().split())
    diff = table[B] * (C - B)
    table[C] += table[B]
    table[B] = 0
    ans += diff
    print(ans)


Measured memory_bytes: 94524
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        char al = a.charAt(a.length() - 1);
        char bf = b.charAt(0);
        char bl = b.charAt(b.length() - 1);
        char cf = c.charAt(0);

        println((al == bf) && (bl == cf) ? "YES" : "NO");
    }

    public void print(Object o) {
        System.out.print(o);
    }

    public void println(Object o) {
        System.out.println(o);
    }

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


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;

  queue<char> a;
  each (i, sa) {
    a.push(i);
  }
  queue<char> b;
  each (i, sb) {
    b.push(i);
  }
  queue<char> c;
  each (i, sc) {
    c.push(i);
  }

  char pos = a.front();
  a.pop();

  while (true) {
    if (pos == 'a') {
      if (a.empty()) {
        cout << "A" << endl;
        return 0;
      }
      pos = a.front(); a.pop();
    }

    if (pos == 'b') {
      if (b.empty()) {
        cout << "B" << endl;
        return 0;
      }
      pos = b.front(); b.pop();
    }

    if (pos == 'c') {
      if (c.empty()) {
        cout << "C" << endl;
        return 0;
      }
      pos = c.front(); c.pop();
    }
  }

  return 0;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>



using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  string s;
  cin >> s;
  deque<char> deq;
  rep(i,s.size())deq.push_back(s.at(i));
  int q;
  scanf("%d", &q);
  int cnt = 0;
  rep(i,q){
    int a;
    scanf("%d", &a);
    if(a%2){
      cnt++;
      continue;
    }else{
      int f;
      scanf("%d", &f);
      char m;
      cin >> m;
      if((f+cnt)%2){
        deq.push_front(m);
      }else{
        deq.push_back(m);
      }
    }
  }
  if(cnt%2){
    while(!deq.empty()){
      cout << deq.back();
      deq.pop_back();
    }
  }else{
    while(!deq.empty()){
      cout << deq.front();
      deq.pop_front();
    }
  }
  cout << endl;
}


Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long 

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

signed main()
{
    int N; cin>>N;
    map<int, int> m;
    vi arr;
    rep(i,N){
        int a; cin >> a;
        m[a] += 1;
        if (m[a] == 2 or m[a] == 4) {
            arr.PB(a);
        } 
    }
    if (arr.size() < 2){
        cout << 0 << endl;
        return 0;
    }

    sort(all(arr),greater<int>());

    cout << arr[0] * arr[1] << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    while(a[i]%2==0){
      ans++;
      a[i]/=2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll a; cin >> a;
    ll ans = a + a*a + a*a*a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
N, M = map(int, input().split())

E = [[] for i in range(N)]

ab = []
for i in range(M):
    a, b = map(int, input().split())
    ab.append([a-1, b-1])

visited = []


def search(pos):
    for n_pos in E[pos]:
        if n_pos not in visited:
            visited.append(n_pos)
            search(n_pos)

count = 0
for i in range(M):
    visited = []
    E = [[] for i in range(N)]
    for j in range(M):
        if j == i:
            continue
        E[ab[j][0]].append(ab[j][1])
        E[ab[j][1]].append(ab[j][0])
    search(0)
    if len(visited) < N:
        count += 1

print(count)

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	public class Obj
	{
		public string Str{get;set;}
		public int Keta{get;set;}
	}
	
	public static void Main(string[] args)
	{
		var k = Console.ReadLine().ToInt();

		
		var q = new Queue<Obj>();
		for(int i = 1; i< 10; i++)
		{
			q.Enqueue(new Obj(){Str=i.ToString(), Keta = 1});
		}
		
		long cnt = 0;
		while(q.Count > 0)
		{
			var o = q.Dequeue();
			int last = (int)(o.Str[o.Str.Length - 1] - '0');
			
			if(last == 0)
			{
				q.Enqueue(new Obj(){Str=o.Str+"0", Keta = o.Keta + 1});
				q.Enqueue(new Obj(){Str=o.Str+"1", Keta = o.Keta + 1});
			}
			else if(last==9)
			{
				q.Enqueue(new Obj(){Str=o.Str+"8", Keta = o.Keta + 1});
				q.Enqueue(new Obj(){Str=o.Str+"9", Keta = o.Keta + 1});
			}
			else
			{
			
			for(int i = last-1; i <= last+1; i++)
			{
				q.Enqueue(new Obj(){Str=o.Str+i, Keta = o.Keta + 1});
				
			}
			}
			cnt++;
			if(cnt == k)
			{
				Console.WriteLine(o.Str);
				return;
			}
		}
		
	}
	
	
	static bool IsRunRun(long k)
	{
		if(k<10)
			return true;
			
		var p = k.ToString();
		for(int i = 1; i < p.Length; i++)
		{
			if(Math.Abs(p[i-1] - p[i])>1)
				return false;
		}
		return true;
	}
	
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 38052
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b,n;
  cin >> a >> b;
  n = a*b;
  if (n % 2 == 1){
    cout << "Odd" << endl;
  }
  if (n % 2 == 0){
    cout << "Even" << endl;
  }
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long LL;
int n;

int main(){
    cin>>n;
    int t,last;
    LL sum=0;
    cin>>last;
    for(int i=1;i<n;++i){
        cin>>t;
        if(t<last){
            sum+=(last-t);
        }
        else last=t;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;
use std::str::Chars;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let mut s:String = read();
    let mut cnt = s.chars().filter(|&c| c == '7').count();
    if cnt > 0
    {
        println!("Yes");
    }
    else{
        println!("No");
    }
}

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

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

const int lim = 1000000007;
const int INF = 100000000;

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

    //1個の時はコーナーケースとして処理
    if (N == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    int white = 0, black = 0;
    rep(i, N)
    {
        if (S[i] == '.')
            white++;
    }
    int ans = white;
    rep(i, N)
    {
        if (S[i] == '#')
            black++;
        if (S[i] == '.')
            white--;
        ans = min(ans, black + white);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  cin >> N;
  int count = 0;
  for(int i=0; i<N; i++){
    cin >> x;
    int div = 0;
    bool isDivided = true;
    while(isDivided){
      int y=2;
      for(int j=0; j<div; j++){
        y *= 2;
      }
      if(x%y == 0){
        div++;
      }else{
        isDivided = false;
      }
    }
    if(i == 0){
      count = div;
    }else if(div < count){
      count = div;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

long long n;
int main()
{
	cin>>n;
	if(n&1) cout<<n*2<<endl;
	else cout<<n;
	return 0;
	
	
} 



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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  while(true){
    int x, y, z;
    cin >> x >> y >> z;
    if(x == -1 && y == -1 && z == -1) break;
    if(x == -1 || y == -1) cout << "F" << endl;
    else if(x+y >= 80) cout << "A" << endl;
    else if(x+y >= 65) cout << "B" << endl;
    else if(x+y >= 50 || (x+y >= 30 && z >= 50)) cout << "C" << endl;
    else if(x+y >= 30) cout << "D" << endl;
    else cout << "F" << endl;
  }
  return 0;
}



Measured memory_bytes: 3052
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, a, count=0;
    cin >> N;
    for (int i=1;i<=N;i++){
        cin >> a;
        if(i%2==1 && a%2==1){
            count++;
        }
    }
    cout << count;
            
}

Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if b == 1 {
		fmt.Println(0)
		return
	}
	ans := 1
	t := a
	for t < b {
		t--
		t += a
		ans++
	}
	fmt.Println(ans)
}


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

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

  int reserved = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;

    reserved += (r - l) + 1;
  }

  cout << reserved << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
#define pii pair<int,int>
typedef long long ll;
using namespace std;
int n,m;
vector<vector<int> > g;
vector<int> memo;
int dfs(int v)
{
	if(memo[v]!=-1)
	{
		return memo[v];
	}
	memo[v]=0;
	for(int i=0;i<g[v].size();i++)
	{
		int u=g[v][i];
		memo[v]=max(memo[v],dfs(u)+1);
	}
	return memo[v];
}
int main()
{
	cin>>n>>m;
	g.resize(n);
	memo=vector<int>(n,-1);
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--,y--;
		g[x].pb(y);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
n = int(input())
w = list(map(int,input().split()))
all = sum(w) / 2
sa = all - w[0] 
for N in range(n - 1):
        w[N + 1] += w[N]
        sa = min(sa,abs(all - w[N + 1]))
print(int(sa * 2))

Measured memory_bytes: 3060
function Main(input) {
	var str = input;
	var ans = "No";

	var str = str.split("\n")[0];//一行の場合
	var num = str.split(" ");//一行の場合
	var x = Number(num[0]);
	var y = Number(num[1]);
	if((x * 4 - y)/2 <= x && (x * 4 - y)/2 >=0 && (x * 4 - y)%2==0){
		ans = "Yes";
	}
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29632
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}


int main() {
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int a=A*X+B*Y;
  int b=C*2*max(X,Y);
  int c;
  if(X>=Y){c=C*2*Y+A*(X-Y);}
  else{c=C*2*X+B*(Y-X);}
  cout<<min({a,b,c})<<endl;
  return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 62;

std::vector<std::vector<ll>> Warshall_Floyd(const std::vector<std::vector<std::pair<int, ll>>> & from) {
  const int N = from.size();
  std::vector<std::vector<ll>> d(N, std::vector<ll>(N, INF));
  for(int i = 0; i < N; ++i) {
    for(auto p : from[i]) {
      d[i][p.first] = std::min(d[i][p.first], p.second);
    }
  }

  rep(i, N) d[i][i] = 0;
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if(d[i][k] < INF && d[k][j] < INF) {
          d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }

  return d;
}

int main() {
  int N, M;
  ll L;
  std::cin >> N >> M >> L;
  std::vector<std::vector<std::pair<int, ll>>> from(N);

  rep(i, M) {
    int A, B, C;
    std::cin >> A >> B >> C;
    --A; --B;
    from[A].push_back(std::make_pair(B, C));
    from[B].push_back(std::make_pair(A, C));
  }

  int Q;
  std::cin >> Q;
  std::vector<int> s(Q), t(Q);
  rep(i, Q) {
    std::cin >> s[i] >> t[i];
    --s[i];
    --t[i];
  }

  auto d = Warshall_Floyd(from);
  std::vector<std::vector<std::pair<int, ll>>> from2(N);
  rep(i, N) {
    rep(j, N) {
      if(i == j) continue;
      if(d[i][j] <= L) {
        from2[i].push_back(std::make_pair(j, 1));
      }
    }
  }

  auto ans = Warshall_Floyd(from2);
  rep(i, Q) {
    if(ans[s[i]][t[i]] < INF) {
      std::cout << ans[s[i]][t[i]] - 1 << '\n';
    } else {
      std::cout << -1 << '\n';
    }
  }

}


Measured memory_bytes: 7424
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      t = i * 500 + j * 100 + k * 50
      if x == t:
        count = count + 1

print(count)


Measured memory_bytes: 9048