akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 110000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};

vector<int> gr[MAX];
LL dp[MAX][2];

void dfs(int node, int par = -1) {


	LL p0, p1, t;
	p0 = 1;
	p1 = 1; 
	for (auto x : gr[node]) {
		if (x == par) continue;
		dfs(x, node);
		p1 *= (dp[x][0] + dp[x][1]); 
		p1 %= base;

		p0 *= dp[x][0];
		p0 %= base;
	}
	dp[node][1] = p0;
	dp[node][0] = p1;
	dp[node][0] %= base;
}

void solve() {

	LL result = 0;
	int n;

	cin >> n;
	for (int i = 1; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	dfs(1);
	result = dp[1][0] + dp[1][1];
	result %= base;
	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

Measured memory_bytes: 14464
S = input()
S = S[::-1]
N = len(S)
mod = 10 ** 9 + 7

dp = [[0] * 13 for _ in range(N + 10)]
dp[0][0] = 1

for i, s in enumerate(S):
    if s == "?":
        val = tuple(range(10))
    else:
        val = (int(s),)

    digit = pow(10, i, 13)
    for j in range(13):
        for k in val:
            ni = i + 1
            nj = (j + digit * k) % 13
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod

ans = dp[N][5] % mod
print(ans)


Measured memory_bytes: 61916
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;


int main() {
  int A,B;
  while(1) {
    cin >> A >> B;
    if(A==0 && B ==0) {
      break;
    }
    if(A<B) {
      cout << A << " " << B << endl;
    } else {
      cout << B << " " << A << endl;
    }
  }
  return 0;
}



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

public class Main {
    private static long solve(int n, int m, char[][] grid, long[][] dp) {
        dp[0][0] = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (grid[i][j] == '#')
                    continue;
                if (i - 1 >= 0)
                    dp[i][j] = (dp[i][j] + dp[i - 1][j]) % 1000000007;

                if (j - 1 >= 0) {
                    dp[i][j] = (dp[i][j] + dp[i][j - 1]) % 1000000007;
                }
            }
        }
        // System.out.println(Arrays.deepToString(dp));
        return dp[n - 1][m - 1];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        long[][] dp = new long[n][m];
        char[][] grid = new char[n][m];

        for (int i = 0; i < n; i++) {
            String temp = sc.next();
            for (int j = 0; j < m; j++) {
                grid[i][j] = temp.charAt(j);
            }
        }
        // System.out.println(Arrays.deepToString(grid));
        System.out.println(solve(n, m, grid, dp));

    }
}

Measured memory_bytes: 40504
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define trav(a, x) for (auto& a : x)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define endl "\n"
#define F first
#define S second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define viii vector< vector<vector<int> > >
#define cd complex<double>
#define PI acos(-1)
#define pie 3.14159265358979323846
#define all(c) (c).begin(),(c).end()
#define prec(n) fixed << setprecision(n)
#define print_time {cout << flush; cerr << endl << "Time taken: " << fixed << setprecision(3) << 1.0 * clock() / CLOCKS_PER_SEC << " secs\n";}
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b)) / gcd((a),(b))
#define bc(n) __builtin_popcountll(n)
#define leadzero(a) __builtin_clz(a)        // count leading zeroes
#define trailzero(a) __builtin_ctz(a)       // count trailing zeroes
#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lps(v,x) (lower_bound(all(v),x)-v.begin())
#define ups(v,x) (upper_bound(all(v),x)-v.begin())
typedef long double ld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
    X ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inft = (1LL<<61) ;
const int inf = 5e18;
const int mod = 1e9+7;
int modpow(int x, int n, int mod){
    x %= mod ;
    int res = 1;
    while(n>0){
        if(n & 1)res = res * x % mod;
        x = x*x%mod;
        n>>=1 ;}
    return res;}
const int N = 1e6+1e4+1e2+1 ;
const int M = 3*(1e5+1e3+1e1) ;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

signed main()
{
    boost ;
    cin.exceptions(cin.failbit);

    #ifndef ONLINE_JUDGE
       //freopen("input.txt", "r", stdin);
       //freopen("output.txt","w", stdout) ;
    #endif // ONLINE_JUDGE

    int n ;
    cin >> n ;
    int mx ;
    cin >> mx ;

    n-- ;
    int ans=1 ;
    while(n--)
    {
        int a ;
        cin >> a ;
        if(a>=mx)
        {
            ans++ ;
            mx=max(mx,a) ;
        }
    }

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





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;
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; }

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

Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
    // Your code here!
    int n,i,j,count=0,ans=0;
    scanf("%d",&n);
    
    for(i=1; i<=n; ++i){
        if(i%2 == 1){
            for(j=1; j<=n; ++j){
                if(i%j == 0)count++;
            }
        }
        if(count == 8)ans++;
        count = 0;
    }
    
    printf("%d",ans);
    
    return 0;
}


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

/*勇者多すぎる　これもう勇者一般人だろ*/

int main(){
  int N;
  cin >> N;
  ll count = 0;                                        //勇者数と勇者化物討伐可能数を考慮して64bit
  int monster[N+1];
  int braver[N];

  for(int i = 0; i < N + 1; i++)         //計算量O(N)
    cin >> monster[i];

  for(int i = 0; i < N; i++)                 //計算量O(N)
    cin >> braver[i];

  for(int i = 0; i < N; i ++){              //計算量O(N)
    if(monster[i] >= braver[i])
      count += braver[i];               
    else{
      if(braver[i] >= monster[i] + monster[i+1]){
        count += monster[i] + monster[i+1];
        monster[i+1] = 0;                   //monster[i]への0代入は省略
      }else{
        count += braver[i];
        braver[i] -= monster[i];
        monster[i+1] -= braver[i];
      }
    }
  }

  cout << count <<endl;

}
  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

const int INF = 1e9 + 1;

using namespace std;


int main(){
	_

	int n, k;

	cin>>n>>k;

	int ans = 0;

	vi v(n + 1), dp(n + 1);

	rep(i, 0, n){
		dp[i + 1] = INF;
		cin>>v[i + 1];
	}

	dp[1] = 0;

	rep(i, 1, n + 1)
		rep(j, 1, k + 1)
			if(i - j >= 1)
				dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));


	cout<<dp[n]<<"\n";

	return 0;
}

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

typedef long long ll;
const ll MAX_E = 2100;		
const ll MAX_V = 1100;

#define INF (1LL << 62)

// 頂点と頂点を結ぶ辺についての構造体
struct edge { ll from, to, cost; };

edge es[MAX_E]; // 辺

ll d[MAX_V];
ll V, E;

//	ベルマンフォード（単一始点最短経路（Negative Edges))
// 負の閉路が存在したら true を返す
void bellman_ford(ll s) {
	ll cnt = 0;
	// 最短距離の初期化
	for (ll i = 0; i < V; i++) d[i] = INF;
	// 頂点 s への最短距離は0
	d[s] = 0;
	for(int i=0; i<V-1; i++) {
		cnt++;
		bool update = false;
		// すべての辺に対して
		for (ll i = 0; i < E; i++) {
			edge e = es[i];
			// この時点での e.to へ行くコストより e.from を経由して行く方がコストが小さいとき d[e.to] を更新する
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		// 更新がなければ終了
		if (!update) break;
	}
}

bool find_negative_loop() {
	bool negative[MAX_V];
	for(int i=0; i<MAX_V; i++) negative[i]=false;

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < E; j++) {
			edge e = es[j];
			if(d[e.from]==INF) continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				negative[e.to]=true;
			}
			if(negative[e.from]) negative[e.to]=true;
		}
	}

	if(negative[V-1]) return true;
	else return false;
}

int main() {
	ll r=0;
	cin >> V >> E;
	ll from, to, cost;

	for (ll i = 0; i < E; i++) {
		cin >> from >> to >> cost;
		from--; to--;
		es[i] = edge{ from, to, cost*(-1) };
	}

	bellman_ford(r);

	ll ans = d[V-1]*(-1);

	if (find_negative_loop()) {
		cout << "inf" << endl;
	}
	else {
		cout << ans << endl;
	}

}


Measured memory_bytes: 256
size = gets.chomp.to_i
input_values = gets.chomp.split.map(&:to_i)

count = 0
min_index = 0
  (0..size-1).each do |i|
    min_index = i
    (i..size-1).each do |j|
      if input_values[j] < input_values[min_index]
        min_index = j
      end
    end

    if input_values[min_index] < input_values[i]
      tmp = input_values[i]
      input_values[i] = input_values[min_index]
      input_values[min_index] = tmp
      count += 1
    end
  end
  puts input_values.join(' ')
  puts count

Measured memory_bytes: 8656
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val (n, m) = intList()
    val array1 = Array<MutableList<Long>>(n + 1) { mutableListOf() }
    val array2 = Array<HashMap<Long, Int>>(n + 1) { hashMapOf() }
    val ps = mutableListOf<Pair<Long, Long>>()
    repeat(m) {
        val (p, y) = longList()
        array1[p.toInt()].add(y)
        ps.add(Pair(p, y))
    }
    repeat(n + 1) { i ->
        array1[i].sort()
        array1[i].forEachIndexed { j, y ->
            array2[i][y] = j
        }
    }
    buildString {
        ps.forEach {
            appendln("%06d%06d".format(it.first, array2[it.first.toInt()][it.second]!! + 1))
        }
    }.let {
        println(it.trimIndent())
    }
}


Measured memory_bytes: 110984
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    //cin >> h >> w;
    while (cin >> h >> w,h != 0 && w != 0){
        for (int i = 0; i < h; i++) {
            cout << '#';
            for ( int j = 1; j < w; j++) {
                if (i == 0 || i == h - 1){
                    cout << '#';
                } else {
                    if ( j != w - 1){
                        cout << '.';
                    } else {
                        cout << '#';
                    }
                }
            }
            cout << "\n";
        }
        cout << endl;
    }

    return 0;
}


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

int main() {
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  char t[200005],d[200005];
  for (int i=0; i<q; i++) {
    cin>>t[i]>>d[i];
  }

  int mid,lo=-1,hi=n,left,right;
  while (hi-lo>1) {
    mid=(lo+hi)/2;
    int pos=mid;
    for (int i=0; i<q; i++) {
      if (s[pos]==t[i]) {
	if (d[i]=='L') pos--;
	else pos++;
	if (pos<0||pos>=n) break;
      }
    }
    if (pos<0) lo=mid;
    else hi=mid;
  }
  left=hi;
  
  lo=-1;
  hi=n;
  while (hi-lo>1) {
    mid=(lo+hi)/2;
    int pos=mid;
    for (int i=0; i<q; i++) {
      if (s[pos]==t[i]) {
	if (d[i]=='L') pos--;
	else pos++;
	if (pos<0||pos>=n) break;
      }
    }
    if (pos>=n) hi=mid;
    else lo=mid;
  }
  right=lo;
  
  cout<<max(0,right-left+1)<<endl;
  return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int p; cin >> p;
	vector<int> a(p);
	for (int i = 0; i < p; i++) cin >> a[i];
	vector<int> b(p), u = a;
	b[0] = a[0];
	int x = p - 1;
	int q = 1;
	for (int i = 0; i < p - 2; i++) q *= x, q %= p;
	for (int t = p - 2; t >= 1; t--) {
		int y = 0;
		for (int i = 0; i < p; i++) {
			u[i] *= i;
			u[i] %= p;
			y += u[i];
			y %= p;
		}
		b[t] = y*q % p;
	}
	int y = 0;
	for (int i = 0; i < p; i++) {
		y += a[i];
		y %= p;
	}
	b[p - 1] = y*q % p;
	for (int i = 0; i < p; i++) cout << b[i] << " \n"[i == p - 1];
	return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub 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")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let mut a = read::<i64>();
  let mut b = read::<i64>();
  let mut ans = "";

  if a == b {
    ans = "Draw"
  } else if a == 1 && b != 1 {
    ans = "Alice"
  } else if a != 1 && b == 1 {
    ans = "Bob"
  } else if a < b {
    ans = "Bob"
  } else {
    ans = "Alice"
  }

  println!("{}", ans);
}



Measured memory_bytes: 4352
import numpy as np
import logging
logging.basicConfig(level=logging.DEBUG)
logging.disable(logging.CRITICAL)

N=int(input())

x=np.array(list(map(int,input().split())))
logging.debug('x={}'.format(x))

i=np.amin(x)
ans=[]
while i<=np.amax(x):

    logging.debug('i={}'.format(i))
    y=np.array([i]*N)
    ans.append(sum((x-y)**2))

    logging.debug('ans={}'.format(ans))
    i+=1
print(min(ans))


Measured memory_bytes: 27924
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  if(n > k)
    ans += (double)(n - k + 1) / (double)n;
  else if(n == 1 && k == 1)
    ans = 1;
  rep2(i, 1, min(n + 1, k)) {
    int num = 0;
    int j = i;
    while(j < k) {
      num++;
      j *= 2;
    }
    ans += 1 / (double)pow(2, num) / (double)n;
  }
  printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;


using namespace std;


const int max_comb = 300000;
vector<ll> fac(max_comb + 1); //n! (mod M)
vector<ll> ifac(max_comb + 1); //k!^(-1) (mod M)

ll mpow(ll x, ll n) { //x^n(mod M)
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		n = n >> 1;
	}
	return ans;
}

ll minv(ll x) {
	return mpow(x, MOD - 2);
}

ll comb(int a, int b) {     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % MOD;
	return tmp * fac[a] % MOD;
}

ll perm(int a, int b) {     // P(a,b) = a! * (a-b)!^(-1)
	if (b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] % MOD;
	return tmp * fac[a] % MOD;
}

void pre_comb()
{
	fac[0] = 1;
	ifac[0] = 1;
	for (int i = 0; i < max_comb; i++) {
		fac[i + 1] = fac[i] * (i + 1) % MOD; // n!(mod M)
		ifac[i + 1] = ifac[i] * minv(i + 1) % MOD; // k!^(-1) (mod M)
	}
	return;
}

void solve()
{
	int n, K;
	scanf("%d%d", &n, &K);
	pre_comb();

	ll ans = 0;
	int i;
	for (i = 0; i <= min(n, K); i++) {
		ll ans0 = comb(n, i);
		int num=i;
		int m = n - i;
		ll tmp = comb(num + m - 1, num);
		ans0 = ans0 * tmp%MOD;
		ans = (ans + ans0) % MOD;
	}
	printf("%lld\n", ans);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 4896
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int h,n,t=1e9;cin>>h>>n;
    vector<ii> v(n);
    for(auto &i:v) cin>>i.fi>>i.se;
    vector<int> dp(20001,M);
    dp[0]=0;
    rep(i,n) {
        repp(j,v[i].fi,20000) {
            dp[j]=min(dp[j],dp[j-v[i].fi]+v[i].se);
        }
    }
    Repp(i,20000,h) t=min(t,dp[i]);
    cout<<t;
}

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

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    int ans;
    ans = min(p+q,min(q+r,r+p));
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

  ll a, b, c, k, ans=0;
  cin >> a >> b >> c >> k;

  for(int i=0; i<=k; i++){
    for(int j=0; j<=k-i; j++){
      for(int u=0; u<=k-i-j; u++){
        ll tmp=a*pow(2, i)+b*pow(2, j)+c*pow(2, u);
        ans=max(tmp, ans);
      }
    }
  }
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()

ans = True
while s != "":
    words = ["eraser", "dream", "erase", "dreamer"]

    found = False
    for word in words:
        if s[-len(word):] == word:
            s = s[:-len(word)]
            found = True
            break

    if not found:
        ans = False
        break

print("YES" if ans else "NO")

Measured memory_bytes: 9176
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;
vi a;

int main(){
	cin>>n>>k;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vvb dp(n,vb(k,0)),DP(n,vb(k,0));
	dp[0][0]=DP[0][0]=1;
	for(int i=1;i<n;i++) for(int j=0;j<k;j++){
		dp[i][j]=dp[i-1][j]|(j-a[i-1]<0?false:dp[i-1][j-a[i-1]]);
		DP[i][j]=DP[i-1][j]|(j-a[n-i]<0?false:DP[i-1][j-a[n-i]]);
	}
	int res=n;
	for(int i=0;i<n;i++){
		bool flag=0;
		int num=0,s=0,t=0;
		for(int j=k-1;j>=0;j--){
			while(t<k-j){
				num+=DP[n-i-1][t];
				t++;
			}
			while(s<k-a[i]-j){
				num-=DP[n-i-1][s];
				s++;
			}
			if(dp[i][j]&&num) flag=1;
		}
//		cout<<flag<<endl;
		res-=flag;
	}
	cout<<res<<endl;
//	k-a[i]<=x<k;
}

Measured memory_bytes: 6912
S = input().rstrip()
T = input().rstrip()
count = 0
lens = len(S)
lent = len(T)
for i in range(lens-lent+1):
    tempcount=0
    for j in range(lent):
        if S[i+j]==T[j]:
            tempcount += 1
    #print(tempcount)
    count = max(count,tempcount)

print(lent-count)

Measured memory_bytes: 8940
orig_a = input().strip()
total = 0
l = len(orig_a)

for i in range(2 ** (l - 1)):
    a = orig_a[:]
    for j in range(l - 1):
        if (i >> j) % 2:
            a = a[:l-j-1] + "+" + a[l-j-1:]
    total += eval(a)
print(total)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


/*
int N;
Graph G;

int main() {
  cin >>N;
  rep(i, N-1){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b); G[b].push_back(a);
  }
}
*/

int main() {
  int n; cin >>n;
  cout <<(n-2) * 180 <<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main{
  public static void main(String[] args){
    Scanner sr = new Scanner(System.in);
    long A = sr.nextLong();
    long V = sr.nextLong();
    long B = sr.nextLong();
    long W = sr.nextLong();
    long T = sr.nextLong();
    
    long D = Math.abs(B-A);
    long S = V-W;
    if(S*T<D){System.out.println("NO");}
    	else{System.out.println("YES");}
  }

}

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

int main()
{
    string s;
    while (getline(cin, s))
    {
        for(int n=0; n<26; n++)
        {
            for(int i=0; i<s.size(); i++)
            {
                if(s[i] >= 'a' && s[i] < 'z')
                {
                    s[i]=s[i]+1;
                }
                else if(s[i] == 'z')
                {
                    s[i] = 'a';
                }
                else
                {

                }
            }
            if(  s.find("the")  != std::string::npos
              || s.find("this") != std::string::npos
              || s.find("that") != std::string::npos)
            {
                cout << s << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3148
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func solve() {
	n := scanInt()
	m := scanInt()
	a := make([]int, n)
	total := 0
	for i := 0; i < n; i++ {
		a[i] = scanInt()
		total += a[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	// fmt.Println(a)
	// fmt.Println(a[m-1], float64(total)/(4.0*float64(m)))
	if float64(a[m-1]) >= float64(total)/(4.0*float64(m)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


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


int main(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0 ; i < s.size(); i++){
		if(s[i] != t[i])
			ans++;

	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef double dbl;

#define size(s) (int) (s).size()
#define all(s) (s).begin(), (s).end()
#define rall(s) (s).rbegin(), (s).rend()

const int INF = 1e9;

int n, m;

bool check(int v, int u) {
	return v >= 0 && v < n && u >= 0 && u < m;
}

int main() {
	ios::sync_with_stdio(0);

	cin.tie(nullptr);
	cout.tie(nullptr);

	// freopen("", "r", stdin);
	// freopen("", "w", stdout);
	
	cin >> n >> m;

	vector<vector<int> > a(n, vector<int> (m, 0)), was = a;
	queue<pair<int, int> > q;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char z;
			cin >> z;
			if (z == '#') {
				a[i][j] = 1;
			}
		}
	}

	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			if (a[i][j - 1] == 1 && a[i - 1][j] == 1) {
				cout << "Impossible\n";
				return 0;
			}
		}
	}

	int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

	q.push({0, 0});

	while (!q.empty()) {
		int v = q.front().first, u = q.front().second;
		was[v][u] = 1;
		a[v][u] = 0;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int nv = v + dx[i], nu = u + dy[i];
			if (check(nv, nu) && a[nv][nu]) {
				q.push({nv, nu});
				break;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] == 1) {
				cout << "Impossible\n";
				return 0;
			}
		}
	}

	if (was[n - 1][m - 1]) {
		cout << "Possible\n";
	} else {
		cout << "Impossible\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int a,b;

  scanf("%d%d",&a,&b);

  if(a>b)
    for(int i=0;i<a;i++){printf("%d",b);}
  else
    for(int i=0;i<b;i++){printf("%d",a);}

  return 0;
}

Measured memory_bytes: 128
N = int(input())
S = map(str, input().split())

c = 0
g = 0
w = 0
y = 0
p = 0
for s in S:
  if s == 'G':
    if g == 0:
      g = 1
      c += 1
  elif s == 'W':
    if w == 0:
      w = 1
      c += 1
  elif s == 'Y':
    if y == 0:
      y = 1
      c += 1
  else:
    if p == 0:
      p = 1
      c += 1

if c == 3:
  print('Three')
else:
  print('Four')

Measured memory_bytes: 3064
n,m = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

g = [ [] for _ in range(n)]

for _ in range(m):
    a,b = [int(x)-1 for x in input().split()]
    g[a].append(b)
    g[b].append(a)

vis = [False]*n

cnt = 0

for i in range(n):
    if not vis[i]:
        vis[i] = True
        
        gtr = [ H[i] > H[x] for x in g[i] ]
        if all(gtr):
            cnt+=1
            for x in g[i]:vis[x] = True


print(cnt)

Measured memory_bytes: 30232
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,ans=1;
	string str;
	cin>>n>>str;
	char ch=str[0];
	for(int i=1;i<n;i++)
	{
		if(str[i]!=ch)
		{
			ans++;
			ch=str[i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void PrintArray(int[][]A, int a, int b){
    for(int i=0;i<a;i++){
      for(int j=0;j<b;j++){
        System.out.print(" " + A[i][j]);
      }
      System.out.println();
    }
  }
  public static void PrintHash(int n){
    for(int i=0;i<n;i++){
      System.out.print("#");
    }
    System.out.println();
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int [][] A = new int[3][10];
    int [][] B = new int[3][10];
    int [][] C = new int[3][10];
    int [][] D = new int[3][10];
    int b, f, r, v;
    while(sc.hasNext()){
      int n = sc.nextInt();
      for(int i=0;i<n;i++){
        b = sc.nextInt();
        f = sc.nextInt();
        r = sc.nextInt();
        v = sc.nextInt();
        
        switch(b){
          case 1:
            A[f-1][r-1] += v;
            break;
          case 2:
            B[f-1][r-1] += v;
            break;
          case 3:
            C[f-1][r-1] += v;
            break;
          case 4:
            D[f-1][r-1] += v;
            break;
          default:
            break;
        }
      }
      PrintArray(A, 3, 10);
      PrintHash(20);
      PrintArray(B, 3, 10);
      PrintHash(20);
      PrintArray(C, 3, 10);
      PrintHash(20);
      PrintArray(D, 3, 10);
    }
    sc.close();
  }
}


Measured memory_bytes: 29168
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct Book
{
  int read,write;
  Book(int read=inf,int write=inf):read(read),write(write){}
  bool operator < (const Book& a)const
  {
    if(read != a.read)return read < a.read;
    return write < a.write;
  }
};

int main()
{
  int N;
  while(scanf("%d",&N),N)
    {
      Book array[N];
      int sum_r = 0;
      int sum_w = 0;
      rep(i,N)
	{
	  scanf("%d %d",&array[i].read,&array[i].write);
	  sum_r += array[i].read;
	  sum_w += array[i].write;
	}

      sort(array,array+N);

      if(sum_r-array[N-1].read < array[N-1].read)
	{
	  int limit = array[N-1].read - (sum_r-array[N-1].read);
	  bool dp[limit+1];
	  rep(i,limit+1)dp[i] = false;
	  dp[0] = true;
	  int mex = 0;
	  rep(i,N-1)for(int j=limit;j>=0;j--)
	    {
	      if(!dp[j] || j+array[i].write > limit)continue;
	      dp[j+array[i].write] = true;
	      mex = max(mex,j+array[i].write);
	    }
	  printf("%d\n",sum_r+sum_w+(limit-mex));
	}
      else
	{
	  printf("%d\n",sum_r+sum_w);
	}

    }
  return 0;
}

Measured memory_bytes: 1192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int x = N * 800;
            int y = (N / 15) * 200;

            Console.WriteLine(x - y);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>

using namespace std;

int main(){

        string s, t; cin>>s>>t;
        bool no=true;
        for(int i=0; i<s.length(); i++){
            if(s[i]!=t[i]) {cout<<"No"<<'\n'; no=false; break;}
        }
        if(no) cout<<"Yes"<<'\n';
        return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
int main()
{
int i,j,k,h,w,sig1=0,sig2=0,sig3=0;
scanf("%d%d",&h,&w);
char a[h][w];int dp[h][w]={};
for(i=0;i<h;i++)
{
	for(j=0;j<w;j++)
	{
	cin>>a[i][j];
	if(i==0 && a[i][j]=='#')
	sig1=1;
	if(j==0 && a[i][j]=='#')
	sig2=1;
		if(i==0  && a[i][j]!='#' && !sig1)
		dp[i][j]=1;
		if(j==0  && a[i][j]!='#' && !sig2)
		dp[i][j]=1;
		if(a[i][j]=='#')
		sig3=1;
	}
}


for(i=1;i<h;i++)
{
	for(j=1;j<w;j++)
	{if(a[i][j]!='#')
		if(a[i-1][j]=='.' && a[i][j-1]=='.' )
		{
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
		}
		else if (a[i-1][j]=='.')
		{
			dp[i][j]=dp[i-1][j]%M;
		}
		else if(a[i][j-1]=='.')
		{
			dp[i][j]=dp[i][j-1]%M;
		}
	}
}


printf("%d ",dp[h-1][w-1]%M);

return 0;
}
/*

3 4
...#
.#..
....

3 3
...
...
...

*/


Measured memory_bytes: 5120
let () =
    let heights = Array.make 10 0 in
    for i = 1 to 10 do
        let n = read_int () in
        Array.set heights (i-1) n
    done;

    Array.sort compare heights;

    for i = 1 to 3 do
        let height = heights.(10-i) in
        Printf.printf "%d\n" height
    done;

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

int main() {
  int n;
  cin >> n;
  
  if(n == 1)
    cout << "Hello World";
  
  else{
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll n, a, b;
  cin >> n >> a >> b;
  
  //vector<ll> h(n);  rep(i, 0, n) cin >> h[i];
  
  cout << max(0LL, (b-a)*(n-2) +1) << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

Measured memory_bytes: 256
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  char c;
  scanf("%c", &c);
  printf("%c", c+1);
  return 0;
}


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

using namespace std;
using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i=0; i<n; i++) cin >> l[i];
    sort(l.begin(), l.end());

    int ans = 0;
    for (int i=0; i<n-2; i++) {
        for (int j=i+1; j<n-1; j++) {
            for (int k=j+1; k<n; k++) {
                if (l[k] < l[i]+l[j]) ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> a(N);
int sum = 0;
 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 sum += a[i];
 }
 
 int mini = sum;
 int prefix_sum = 0;
 for (int i = 0; i < N; ++i) {
 prefix_sum += a[i];
 mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
 }
 
 cout << mini << endl;
 return 0;
 }

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};

int main() {
    ll n, m;
    cin >> n >> m;

    UnionFind uf(n);

    vector<P> bridges(m);
    rep(i, m) cin >> bridges[i].first >> bridges[i].second;
    rep(i, m) bridges[i].first--;
    rep(i, m) bridges[i].second--;

    reverse(bridges.begin(), bridges.end());

    vector<ll> ans;

    ll v = n * (n - 1) / 2;
    for (P p : bridges) {
        ans.push_back(v);
        if (uf.is_union(p.first, p.second)) {
            continue;
        }
        ll size_a = uf.size(p.first);
        ll size_b = uf.size(p.second);

        uf.connect(p.first, p.second);
        v -= (size_a * size_b);
    }
    reverse(ans.begin(), ans.end());
    for (ll a : ans) cout << a << endl;

}


Measured memory_bytes: 4212
class Combination:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        l = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            l.append(num)
        self.fac = l.copy()

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        l = [1 for i in range(n+1)]
        l[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            l[i] = num
        self.rec = l.copy()

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod

mod = 10**9 + 7
x, y = map(int, input().split())

if (x + y) % 3 != 0:
    print(0)
    exit()
if y < x/2 or 2*x < y:
    print(0)
    exit()

n = (x + y) // 3
r = x - n
c = Combination(n, mod)
print(c.comb(n, r))

Measured memory_bytes: 60984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;



int main(){
    int k; cin >> k;
    queue<ll> que;
    for(int i = 1; i < 10; i++) que.push(i);
    for(int i = 0; i < k-1; i++){
        ll s = que.front();
        que.pop();
        for(int j = -1; j <= 1; j++){
            ll add = (s%10) + j;
            if(add >= 0 && add <= 9) que.push(s*10+add);
        }
    }
    cout << que.front() << endl;
    return 0;
}

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

long long n;
long double p[DIM];
long double d[DIM][DIM];
int main()
{
    cin>>n;
    for(int i = 1; i <= n; ++i)
        cin>>p[i];

    d[1][0] = 1-p[1];
    d[1][1] = p[1];

    for(int i = 2; i <= n; ++i)
        for(int j = 0; j <= i; ++j)
    {
        if(j) d[i][j] = d[i-1][j-1]*p[i];
        if(i > j) d[i][j] += d[i-1][j]*(1-p[i]);
    }
    long double res = 0;
    for(int i = n/2+1; i <= n; ++i)
        res += d[n][i];
    cout<<fixed<<setprecision(9)<<res;
    return 0;
}


Measured memory_bytes: 139776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = s[0];
            int B = s[1];
            int C = s[2];
            int D = s[3];

            if ((Math.Abs(A - B) <= D && Math.Abs(C - B) <= D)
                ||
                Math.Abs(A - C) <= D) {

                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }

            
        }

    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

#define MAX 10000
#define NIL -1

struct Node{int p, l, r;};

int n;
struct Node T[MAX];

void preParse(int u){
  if(u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  cin >> n;

  rep(i, n) T[i].p = NIL;
  rep(i, n){
    int u, l, r;
    cin >> u >> l >> r;
    T[u].l = l;
    T[u].r = r;
    if(l != NIL) T[l].p = u;
    if(r != NIL) T[r].p = u;
  }

  int root;
  rep(i, n) if(T[i].p == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        Q[P[i] - 1] = i;
    }

    int left = 0, right = 0, maxLen = 0;
    while (right < N) {
        while (right < N - 1 && Q[right] < Q[right + 1]) {
            right++;
        }
        maxLen = max(maxLen, right - left + 1);
        left = ++right;
    }

    cout << N - maxLen << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 101
char s[MAXN];
int main()
{
    cin>>s;
    cout<<s;
    if(s[strlen(s)-1]=='s') cout<<"es";
    else cout<<"s";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int N, A[1001] = {}, ans = 1;
	cin >> N;
	for (int i = 2; i < N+1; i++)
	{
		int tmp = i;
		for (int j = 2; j < i; j++)
		{
			while (tmp%j==0)
			{
				A[j]++;
				tmp /= j;
			}
		}
		A[tmp]++;
	}
	for (int i = 2; i < 1001; i++)
	{
		ans = ans*(A[i]+1)%1000000007;
	}
	cout << ans;
}


Measured memory_bytes: 256
/*Snuke has an integer sequence 
A
A of length 
N
N.

He will freely choose an integer 
b
b. Here, he will get sad if 
A
i
Ai and 
b
+
i
b+i are far from each other. More specifically, the sadness of Snuke is calculated as follows:

a
b
s
(
A
1
?
(
b
+
1
)
)
+
a
b
s
(
A
2
?
(
b
+
2
)
)
+
.
.
.
+
a
b
s
(
A
N
?
(
b
+
N
)
)
abs(A1?(b+1))+abs(A2?(b+2))+...+abs(AN?(b+N))
Here, 
a
b
s
(
x
)
abs(x) is a function that returns the absolute value of 
x
x.

Find the minimum possible sadness of Snuke.*/
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int a;
	cin>>a;
	cout<<3*a*a;
	return 0;
}
/*uidsgohh
ggggggggggg
















ddddd

dgdgrfhgf










gfjgfjfjgk










fgjjffjj*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    bool a[n+5];
    memset (a,0,sizeof(a));
    for (int i=0;i<=n;i++) a[i]=s[i]-'0';
    vector<int> v;
    int x = n;
    v.pb(x);
    while (x != 0) {
        int y = x - m;
        if (y < 0) y = 0;
        bool ada = 0;
        for (int i=y;i<x;i++) {
            if (!a[i]) {
                ada = 1;
                v.pb(i);
                x=i;
                break;
            }
        }
        if (!ada) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i=v.size()-2;i>=0;i--) cout << v[i]-v[i+1] << " ";
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

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

typedef long long ll;
const int N = 1e5 + 100;

ll n, cnt, sum, a[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt += (a[i] < 0);
		a[i] = fabs(a[i]);
		sum += a[i];
	}
	cout << (cnt & 1? sum - 2 * (*min_element(a, a + n)): sum);
	return 0;
}

Measured memory_bytes: 1024
#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];

  sort(a, a+N);



  long long sum = 0;
  int count = 1;
  for(int i = N-1; i >= 0; i--) {
    sum += a[i] -count;
    count++;
  }

  cout<<sum<<endl;
  return 0;
}



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

int main(){
    string s,t;
    cin >> s >> t;
    int num=s.length();
    int i,j;
    string a[101];
    a[0] = s;

    for (i=1;i<num;i++){
        string a1,a2;
        for (j=num-i;j<num;j++){
            a1 += s[j];
        }
        for (j=0;j<num-i;j++){
            a2 += s[j];
        }
        a[i] = a1 + a2;
    }
    int f = 0;
    for (i=0;i<num;i++){
        if(a[i] == t){
            cout << "Yes";
            f++;
            break;
        }
    }
    if (f == 0){
        cout << "No";
    }
}

Measured memory_bytes: 256
n = input()
d = n[len(n) - 1]
if d == "2" or d == "4" or d == "5" or d == "7" or d == "9":
    print("hon")
elif d == "0" or d == "1" or d == "6" or d == "8":
    print("pon")
elif d == "3":
    print("bon")

Measured memory_bytes: 9112
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var c = Console.ReadLine().Split().Select(char.Parse).ToArray();
        Console.WriteLine(c[0] < c[1] ? new string(c[0], (int)(c[1]-'0')) : new string(c[1], (int)(c[0]-'0')));
    }
}


Measured memory_bytes: 13268