akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define zeroend __builtin_ctz
#define ones __builtin_popcount
#define ends "\n"
#define space ' '
typedef long long ll;
typedef pair<int, int> pii;

/*
void solve(int i, int j, string s){
	if(i==0)
		ans.insert(s2.substr(0, j)+s);
	else if(j==0)
		ans.insert(s1.substr(0, i)+s);
	else if(s1[i-1]==s2[j-1])
		solve(i-1, j-1, s1[i-1]+s);
	else{
		if(dp[i-1][j]<=dp[i][j-1])
			solve(i-1, j, s1[i-1]+s);
		if(dp[i-1][j]>=dp[i][j-1])
			solve(i, j-1, s2[j-1]+s);
	}
}*/


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

	for(int i=1; i<n; ++i){
		for(int j=0; j<i; ++j){
			if(a[j]>a[i]&&low[i]<high[j]+1)
				low[i]=high[j]+1;
			else if(a[j]<a[i]&&high[i]<low[j]+1)
				high[i]=low[j]+1;
		}
		ans=max({ans, low[i], high[i]});
	}

	cout << ans << ends;


*/

const int N = 100, N2=1e5, M = 1e9+7;

int dp[N2+1];
//array<ll, 3> dp;
//set<string> ans;
//vector<int> low(N, 1), high(N, 1);
ll a[N];

ll n, x;

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

	dp[0]=1;
	for(int i=1; i<=n; ++i){
		vector<int> pref_sum(x+1, 0);
		pref_sum[0]=1;
		for(int f=1; f<=x; ++f)
			pref_sum[f]=(pref_sum[f-1]+dp[f])%M;
		for(int j=1; j<=x; ++j){
			if(a[i-1]>=j)
				dp[j]=pref_sum[j];
			else
				dp[j]=(pref_sum[j]-pref_sum[j-a[i-1]-1]+M)%M;
		}
		// for(int g=1; g<=x; ++g)
		// 	cout << dp[g] << space;
		// cout << ends;
	}


	cout << dp[x] << ends;
}

Measured memory_bytes: 4412
#include<cstdio>
#include<algorithm>
using namespace std;typedef long long ll;ll mod=1e9+7;const int N=1e5+10;
ll dpa[N];ll dpb[N];ll cnt[N];char mde[N];int n;ll res=0;
inline ll po(ll a,ll p){ll r=1;for(;p;p>>=1,a=a*a%mod)if(p&1)r=r*a%mod;return r;}
int main()
{
	scanf("%s",mde+1);for(n=1;mde[n+1]!='\0';n++);
	for(int i=1;i<=n;i++)cnt[i]=cnt[i-1]+(mde[i]=='?');
	for(int i=1;i<=n;i++)
		if(mde[i]=='A'){dpa[i]=(dpa[i-1]+po(3,cnt[i-1]))%mod;}
		else if(mde[i]=='?'){dpa[i]=(dpa[i-1]*3+po(3,cnt[i-1]))%mod;}
		else dpa[i]=dpa[i-1];
	//for(int i=1;i<=n;i++)printf("%lld ",dpa[i]);printf("\n");
	for(int i=n;i>=1;i--)
		if(mde[i]=='C'){dpb[i]=(dpb[i+1]+po(3,cnt[n]-cnt[i]))%mod;}
		else if(mde[i]=='?'){dpb[i]=(dpb[i+1]*3+po(3,cnt[n]-cnt[i]))%mod;}
		else dpb[i]=dpb[i+1];
	//for(int i=1;i<=n;i++)printf("%lld ",dpb[i]);printf("\n");
	for(int i=2;i<=n-1;i++)(res+=(mde[i]=='B'||mde[i]=='?')*dpa[i-1]*dpb[i+1])%=mod;
	printf("%lld",res);return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    int dx = x2 - x1;
    int dy = y2 - y1;

    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x3 - dx;
    y4 = y3 - dy;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#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 it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
#define max 2000000
bool sosu[max]={1,1,0};
int main(){
  for(int i=4;i<max;i+=2)sosu[i]=1;
  for(int i=3;i<max;i+=2)
    if(!sosu[i])
      for(int j=i*3;j<max;j+=i*2)
	sosu[j]=1;

  int a,b,c;
  while(cin>>a>>b>>c,a+b+c){
    int co=0;
    while(1){
      if(!sosu[a])co++;
      if(co==c)break;
      a+=b;
    }
    cout<<a<<endl;
  }
}

Measured memory_bytes: 3112
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = Integer.parseInt(sc.next());
		sc.close();
		Arrays.sort(a);
		ou.println(a[n - 1] - a[0]);
		ou.flush();
	}
}

Measured memory_bytes: 35500
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int m;
  cin >> m;
  i64 ans = 0;
  vt<int> v(m);
  rep(i, 0, m) {
    int d;
    i64 c;
    cin >> d >> c;

    int mo = -1;
    i64 res = 0;
    if(c != 1 && c % 2 == 1) mo = d, c--;
    while(c > 1) {
      if(c % 2 == 1) {
        if(mo == -1) mo = d;
        else {
          mo += d;
          res++;
          if(mo >= 10) {
            res++;
            mo = (mo / 10) + (mo % 10);
          }
        }
        c--;
      }

      d *= 2;
      res += c / 2;
      if(d >= 10) {
        res += c / 2;
        d = (d / 10) + (d % 10);
      }
      c /= 2;
    }

    if(mo != -1) {
      d += mo;
      res++;
      if(d >= 10) {
        res++;
        d = (d / 10) + (d % 10);
      }
    }
    v[i] = d;
    ans += res;
  }

  rep(i, 1, m) {
    if(v[i - 1] == 0) continue;

    int num = v[i - 1] + v[i];
    ans++;
    if(num >= 10) {
      ans++;
      num = (num / 10) + (num % 10);
    }
    v[i] = num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		long K = GetLong();
		long A = GetLong();
		long B = GetLong();

		long ans = 1;
		long rest = Math.Max(0, K - A + 1);
		ans += K - rest;
		if(B - A > 2)
		{
			ans += (B - A) * (rest / 2);
			ans += (rest % 2);
		}
		else
		{
			ans += rest;
		}

		Console.WriteLine(ans);		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T>
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vi h(n);
    cin >> h;
    vi adj[n + 1];
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int mx = 0;
        for (int j = 0; j < adj[i].size(); ++j) {
            mx = max(mx, h[adj[i][j] - 1]);
        }
        if (mx < h[i - 1]) cnt++;
    }
    cout << cnt;
}

int main() {
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}


Measured memory_bytes: 8800
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char i){
  if(i=='a'){
    return 1;
  }
  if(i=='b'){
    return 2;
  }
  if(i=='c'){
    return 3;
  }
  if(i=='d'){
    return 4;
  }
  if(i=='e'){
    return 5;
  }
  if(i=='f'){
    return 6;
  }
  if(i=='g'){
    return 7;
  }
  if(i=='h'){
    return 8;
  }
  if(i=='i'){
    return 9;
  }
  if(i=='j'){
    return 10;
  }
  if(i=='k'){
    return 11;
  }
  if(i=='l'){
    return 12;
  }
  if(i=='m'){
    return 13;
  }
  if(i=='n'){
    return 14;
  }
  if(i=='o'){
    return 15;
  }
  if(i=='p'){
    return 16;
  }
  if(i=='q'){
    return 17;
  }
  if(i=='r'){
    return 18;
  }
  if(i=='s'){
    return 19;
  }
  if(i=='t'){
    return 20;
  }
  if(i=='u'){
    return 21;
  }
  if(i=='v'){
    return 22;
  }
  if(i=='w'){
    return 23;
  }
  if(i=='x'){
    return 24;
  }
  if(i=='y'){
    return 25;
  }
  if(i=='z'){
    return 26;
  }
  return 100;
  
}




int main() {
  int x=input();
  int y=input();
  int a[13]={0,1,2,1,3,1,3,1,1,3,1,3,1};
  if(a[x]==a[y]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  
  


  


  

  




  
  
}

  

Measured memory_bytes: 256
n, m = map(int, input().split())
aa = list(map(int, input().split()))

from queue import PriorityQueue

q = PriorityQueue()
for a in aa:
    q.put(-a)
for i in range(m):
    g = q.get()
    q.put(-(-g // 2))
cost = 0
for a in aa:
    cost -=q.get()
print(cost)

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

int main()
{   
    long long N, M;
    std::cin >> N >> M;
    
    long long A;
    long long must_day = 0;
    for(int i=0; i<M; i++){
        cin >> A;
        must_day += A;
    }
    
    if(N<must_day){
        std::cout << -1 << std::endl;
    }else{
        std::cout << N-must_day << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


typedef long long ll;

using namespace std;

int main() 
{ 

	int a, b;
	cin >> a >> b;

	if (a >= 10){
		cout << b << endl;
	} else {
		cout << b + (100 * (10 - a)) << endl;
	}

	return 0; 
} 


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

N,u,v = map(int,input().split())
u -= 1
v -= 1
E = [set() for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

DU = [-1 for _ in range(N)]  
DV = [-1 for _ in range(N)]
def dfs(p,c,D):
  D[p] = c
  for q in E[p]:
    if D[q] == -1:
      dfs(q,c+1,D)
dfs(u,0,DU)
dfs(v,0,DV)
#print(DU)
#print(DV)
mx = 0
for du,dv in zip(DU,DV):
  if du < dv:
    mx = max(dv,mx)
print(mx-1)

Measured memory_bytes: 113944
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] w, k;
    int i, j, tmp;

    w = new int[10]; k = new int[10];
    for(i = 0;i < 10;i++)w[i] = sc.nextInt();
    for(i = 0;i < 10;i++)k[i] = sc.nextInt();
    for(i = 0;i < 9;i++)for(j = 0;j < 9 - i;j++){
      if(w[j] < w[j + 1]){
        tmp = w[j]; w[j] = w[j + 1]; w[j + 1] = tmp;
      }
      if(k[j] < k[j + 1]){
        tmp = k[j]; k[j] = k[j + 1]; k[j + 1] = tmp;
      }
    }
    out.printf("%d %d%n", w[0] + w[1] + w[2], k[0] + k[1] + k[2]);

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

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

int main() {
	int n; 
	while (cin >> n, n) {
		int c[3];
		int cnt = 1;
		c[0] = 1; c[1] = 2; c[2] = 3;
		rep(i, n) {
			string s; cin >> s;
			int d = c[0];
			if (s == "North") { c[0] = c[1]; c[1] = 7 - d; }
			if (s == "East") { c[0] = 7 - c[2]; c[2] = d; }
			if (s == "West") { c[0] = c[2]; c[2] = 7 - d; }
			if (s == "South") { c[0] = 7 - c[1]; c[1] = d; }
			d = c[1];
			if (s == "Right") { c[1] = c[2]; c[2] = 7 - d; }
			if (s == "Left") { c[1] = 7 - c[2]; c[2] = d; }
			cnt += c[0];
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            List<double> lstInp = new List<double>();
            lstInp.Add(double.Parse(sS[0]));
            lstInp.Add(double.Parse(sS[1]));

            // 解析
            int iOut = (int)Math.Ceiling(lstInp.Average());

            // 出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int i;
  int n;
  cin >> n;
  int a[n];
  int max, semi, max_index;
  cin >> a[0] >> a[1];
  if(a[0]>a[1]){
    max = a[0]; max_index = 0; semi = a[1];
  }
  else{
    max = a[1]; max_index = 1; semi = a[0];
  }
  for(i=2;i<n;i++){
    cin >> a[i];
    if(max<=a[i]){
      semi = max;
      max = a[i];
      max_index = i;
    }
    else if(semi<=a[i]){
      semi = a[i];
    }
  }
  for(i=0;i<n;i++){
    if(i==max_index){
      printf("%d\n",semi);
    }
    else{
      printf("%d\n",max);
    }
  }

  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl

void solve() {
  string s1, s2;
  cin >> s1 >> s2;
  ll n = s1.length();
  ll m = s2.length();
  ll ans = LLONG_MAX;
  for (int i = 0; i <= n - m; i++) {
    ll diff = 0;
    ll temp = i;
    for (int j = 0; j < m; j++) {
      diff += (s1[temp] != s2[j]);
      temp++;
    }
    ans = min(ans, diff);
  }
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll test = 1;
  // cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return (x % MOD + k % MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return (x % MOD - k % MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

	const int N = 2e5 + 5;
	const int M = 3e3 + 3;
	const ll base = 1e9 + 7;
	ll fact[N],inv_fact[N],dp[N];
	int r[M],c[M],ord[M];
	int h,w,n;

	ll fastExp(ll x,int h){
		ll res = 1;
		for(;h > 0;h >>= 1,x = mul(x,x,base)){
			if(h & 1){
				res = mul(res,x,base);
			}
		}
		return res;
	}

	ll coef(int num,int k){
		return mul(fact[num],mul(inv_fact[k],inv_fact[num - k],base),base);
	}

    void solve(){
    	cin>>h>>w>>n;
    	for(int i = 1;i <= n;++i){
    		cin>>r[i]>>c[i];
    		ord[i] = i;
    	}
    	sort(ord + 1,ord + 1 + n,[&](const int &i,const int &j){
    		return (r[i] < r[j]) or (r[i] == r[j] and c[i] < c[j]);
    	});
    	fact[0] = inv_fact[0] = 1;
    	for(int i = 1;i <= h + w;++i){
    		fact[i] = mul(fact[i - 1],i,base);
    		inv_fact[i] = fastExp(fact[i],base - 2);
    	}
    	r[n + 1] = h,c[n + 1] = w;
    	ord[n + 1] = n + 1;
    	for(int i = 1;i <= n + 1;++i){
    		dp[i] = coef(r[ord[i]] + c[ord[i]] - 2,c[ord[i]] - 1);
    	}
        for(int i = 1;i <= n;++i){
            for(int j = i + 1;j <= n + 1;++j){
                if(r[ord[j]] >= r[ord[i]] and c[ord[j]] >= c[ord[i]]){
                    ll x = coef(r[ord[j]] - r[ord[i]] + c[ord[j]] - c[ord[i]],c[ord[j]] - c[ord[i]]);
                    dp[j] = submod(dp[j],mul(dp[i],x,base),base);
                }
            }
        }
    	cout<<dp[n + 1];
    }
}

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    task::solve();
}


Measured memory_bytes: 3456
while True:
    try:
        a = map(float, raw_input().split(' '))
        x = (a[1]*a[5]-a[2]*a[4])/(a[1]*a[3]-a[0]*a[4])
        y = (a[2]*a[3]-a[0]*a[5])/(a[1]*a[3]-a[0]*a[4])
        if x == 0: 
            x = abs(x)
        if y == 0:
            y = abs(y)
        print '%.3f %.3f' % (x,y)
    except EOFError:
        break

Measured memory_bytes: 5016
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,d;
  cin>>n>>d;
  int count=0;
  for(int i=0; i<n;i++)
  {
    double x,y;
    cin>>x>>y;
    double distance=sqrt(x*x+y*y);
    if(distance<=d)
      count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3844
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    int a[3];
    rep(i,3)cin>>a[i];

    sort(a,a+3);
    int sum=a[0]+a[1];
    cout<<sum;
}  

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

int main(){
    int n,m;
    cin >> n >> m;
    int c[n+1];    
    for (int i=0;i<n+1;i++){
        c[i] = -1;
    }

    bool flag=false;
    for(int i=0;i<m;i++){
        int s,x;
        cin >> s >> x;
        if(c[s]==-1){
            c[s] = x;
        }
        else if(c[s]!=x){
            flag = true;
        }

    }

    
    if(flag){
        cout << "-1";
        return 0;
    }

    if(c[1] == 0 && n>1 ){
        cout << "-1";
        return 0;
    }
    else if (c[1] == -1&&n>1){
        c[1] =1;
    }
    else if (c[1] == -1&&n==1){
        c[1]=0;
    }
    for(int i=1;i<n+1;i++){
        if (c[i]==-1){
            c[i] =0;
        }
        cout << c[i];
    }

   
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
    public static void Main()
    {

        int n = GetInt();
        while(n >= 0)
        {
            if (n % 4 == 0)
            {
                Console.WriteLine("Yes");
                return;
            }
            n -= 7;
        }
        Console.WriteLine("No");
        return;
    }
}


public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() { return int.Parse(getArg()); }
    public static long GetLong() { return long.Parse(getArg()); }
    public static double GetDouble() { return double.Parse(getArg()); }
    public static string GetString() { return getArg(); }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
		t=(t<<3)+(t<<1)+v-48;
		v=getchar();
	}
	return t;
}
long long a;
char s[12];
inline void dfs(re int x,re char c){
	if(x==a+1){
		printf("%s\n",s+1);
		return;
	}
	for(re int i='a';i<=min(c,'z');++i){
		s[x]=i;
		if(i!=c)dfs(x+1,c);
		else dfs(x+1,c+1);
	}
}
int main(){
	a=read();
	dfs(1,'a');
}


Measured memory_bytes: 1536
#include <iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	int n, now, prev = (int)1e9 + 1, mx = 0, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> now;
		if (prev == (int)1e9 + 1) {
			prev = now;
			continue;
		}
		if (prev >= now)
			cnt++;
		else {
			mx = max(mx, cnt);
			cnt = 0;
		}
		prev = now;
	}
	mx = max(mx, cnt);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

	int x=0;
	int N,i;
	int max=0;;
	scanf("%d\n",&N);
	char S;
	for(i=0; i<N; i++){
		scanf("%c", &S);
		if(S == 'I'){
			x++;
			if(max<x){
				max = x;
			}
		}else{
			x--;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
	ll N;
	cin >> N;
	ll* X = (ll*)malloc(sizeof(ll)*N);
	ll* A = (ll*)malloc(sizeof(ll)*N);
	for (int i = 0;i < N;i++) {
		cin >> X[i];
		A[i] = X[i];
	}
	sort(A, A + N);
	for (int i = 0;i < N;i++) {
		if (X[i]<A[N/2])cout << A[N / 2 ] << endl;
		else cout << A[N / 2 - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int a[100001],f[100001];
int main()
{
	int n,m,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	f[1]=0;
	for(i=2;i<=n;i++)
	{
		if(i!=2)
		{
			f[i]=min((f[i-1]+abs(a[i]-a[i-1])),(f[i-2]+abs(a[i-2]-a[i])));
		}
		else
		{
			f[i]=f[i-1]+abs(a[i]-a[i-1]);
		}
	}
	printf("%d",f[n]);
}

Measured memory_bytes: 1024
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
ll a[210000];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	multiset<ll> ss;
	for (int i = 0; i < n; ++i)
		ss.insert(a[i]);
	int ans = 0;
	while (!ss.empty()) {
		ll x = *ss.rbegin();
		ss.erase(ss.find(x));
		ll now = 1;
		while (now <= x)
			now *= 2;
		auto it = ss.find(now - x);
		if (it == ss.end())
			continue;
		ss.erase(it);
		++ans;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
long long n, c, t, mx, x[N], v[N], a[N], b[N], ma[N], mb[N];
int main() {
	int i;
	scanf("%lld%lld", &n, &c);
	for(i=1; i<=n; i++) scanf("%lld%lld", &x[i], &v[i]);
	for(i=1, t=0; i<=n; i++) {
		t += v[i];
		a[i] = t - x[i];
		ma[i] = max(ma[i-1], a[i]);
	}
	for(i=n, t=0; i; i--) {
		t += v[i];
		b[i] = t - (c-x[i]);
		mb[i] = max(mb[i+1], b[i]);
	}
	mx = max(ma[n], mb[1]);
	for(i=1; i<n; i++) mx = max(mx, a[i] - x[i] + mb[i+1]);
	for(i=n; i>1; i--) mx = max(mx, b[i] - (c-x[i]) + ma[i-1]);
	cout<<mx;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t
#define db double
inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

vector<lli> adj[200005];
map<lli,lli> mp;

void dfs(lli s,lli parent)
{
	mp[s]+=mp[parent];
	for(auto it:adj[s])
	{
		dfs(it,s);
	}
}
	
int main()
{
	fast();
	
	lli e,t,n,u,q,v;
	cin>>n>>q;
	rep(i,0,n-1)
	{
		cin>>u>>v;
		adj[u].push_back(v);
	}
	while(q--)
	{
		cin>>e>>t;
		mp[e]+=t;
	}
	
	dfs(1,0);
	rep(i,1,n+1)
		cout<<mp[i]<<" ";
	return 0;
}



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

int main(void){
    int n;
    cin>>n;
    vector<int> v = {1};
    for(int r = 6; r <= n; r *= 6) v.push_back(r);
    for(int r = 9; r <= n; r *= 9) v.push_back(r);
    vector<int> dp(n+1,n);
    dp[0] = 0;
    rep(i,n)for(int d : v)if(i+d <= n){
        if( dp[i+d] > dp[i] + 1 ){
            dp[i+d] = dp[i] + 1;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            string s = ReadString();
            bool ans = s.Contains("7");
            Console.WriteLine(YesNo(ans));
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static string YesNo(bool condition) => condition ? "Yes" : "No";
        static string YESNO(bool condition) => condition ? "YES" : "NO";

        #endregion
    }
}

Measured memory_bytes: 25796
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  Node y;
  y=x;
  while(y->left!=NIL) y=y->left;
 
  return y;
 
}
 
Node treeMaximum(Node x){
 Node y;
  y=x;
  while(y->left!=NIL) y=y->right;
 
  return y;
 
}
 
Node treeSearch(Node u, int k){
  Node x;
  x=u;
 
  while(x!=NIL && k!=x->key){
    if(k < x->key)x=x->left;
    else x=x->right;
  }
 
  return x;
 
}
 
Node treeSuccessor(Node x){
  Node y;
 
  if(x->right!=NIL)return treeMinimum(x->right);
 
  y=x->p;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->p;
  }
  return y;
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);
 
  if(y->left!=NIL)x=y->left;
  else x=y->right;
 
  if(x!=NIL)x->p=y->p;
  if(y->p==root)root=x;
  else if(y == y->p->left)y->p->left=x;
  else y->p->right=x;
 
  if(y!=z) z->key=y->key;
  free(y);
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(k < x->key)x=x->left;
    else x=x->right;
  }
  z->p=y;
 
  if(y==NIL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right=z;
 
}
 
void inorder(Node u){
  if (u==NIL)return;
 
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
 
}
void preorder(Node u){
if (u==NIL)return;
 
 printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);
 
}
 
 
int main(){
  int n, i, x;
  char com[20];
  Node t;
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
       t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

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

#define ll long long  
#define endl "\n"

const ll int MOD=1e9+7;

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	return 0;
}

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

for i in range(n):
  order = input()[::-1]
  message = input()

  for s in order:
    if s == 'J':
      message = message[len(message) - 1] + message[:len(message) - 1]
    elif s == 'C':
      message = message[1:] + message[0]
    elif s == 'E':
      message = message[(len(message)+1)//2:] + message[len(message)//2:(len(message) + 1)//2] + message[:len(message)//2]
    elif s == 'A':
      message = message[::-1] 
    elif s == 'P':
      temp = ''
      for c in message:
        if c == '0':
          c = '9'
        elif c > '0' and c <= '9':
          c = chr(ord(c) - 1)
        temp += c
      message = temp
    elif s == 'M':
      temp = ''
      for c in message:
        if c == '9':
          c = '0'
        elif c >= '0' and c < '9':
          c = chr(ord(c) + 1)
        temp += c
      message = temp
  print(message)      

Measured memory_bytes: 7720
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
string S,T;
ll N,K,L;
ll A[100005];
ll M = 1000000007;
ll ans = 0;
int main() {
    cin >> N;
    cin >> S;
    for(int i=0;i<N;i++){
        if(S[i]=='R'){
            K++;
        }
    }
    for(int i=0;i<K;i++){
        if(S[i]=='R'){
            L++;
        }
    }
    cout << K - L << endl;
    
        
}


Measured memory_bytes: 3756
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define M 1000002/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1+(key%(M-1));
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0; 1 ;i++){
    h  = (h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

using ll = long long;
using ull = unsigned long long;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N,l,flag=0;
    ll cnt=0,A=0,B=0;
    vector<int> a;
    vector<int> b;

    cin>>N;

    for(int i=0;i<N;i++)
    {
        cin>>l;
        a.emplace_back(l);
    }

    for(int i=0;i<N;i++)
    {
        cin>>l;
        b.emplace_back(l);
    }

    if(a==b) cout<<"0"<<'\n';
    else
    {
        vector<int> x(a);
        sort(x.begin(), x.end());
        do {
            if(x==a) {A=cnt;flag++;}
            else if(x==b) {B=cnt;flag++;}
            if(flag>1) break;
            cnt++;
        } while(next_permutation(x.begin(), x.end()));

        cout<<abs(A-B)<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
while 0<n=gets.to_i
g=(1..n).map{gets.split.map &:to_i}
a=[0]*(n+1);(0...n).map{|i|b=0;(0...n).map{|j|a[j]+=x=g[i][j];b+=x;printf"%5d",x};a[-1]+=b;printf"%5d\n",b}
a.map{|y|printf"%5d",y};puts
end

Measured memory_bytes: 6120
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    H = list(map(int, input().split()))
    a = 0
    res = 0
    while a < N-1:
        c = 0
        for i in range(a, N-1):
            if H[i]-H[i+1] >= 0:
                c += 1
            else:
                break
        a += c + 1
        res = max(res, c)
    print(res)



if __name__ == '__main__':
    main()

Measured memory_bytes: 14636
import java.util.Scanner;

public class Main {

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

		int K = sc.nextInt();
		String S = sc.next();

		int A = S.length();

		if (A > K) {

			String B = S.substring(0, K);

			System.out.print(B + "...");
		} else {
			System.out.print(S);
		}
	}

}


Measured memory_bytes: 38592
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(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;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A,B,C,X,ans = 0;
    cin >> A >> B >> C >> X;
    rep(i,A + 1){
        rep(j,B + 1){
            rep(k,C + 1){
                if(i*500+j*100+k*50==X)ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    ll n, m;
    cin >> n >> m;

    ll ans;
    if (n * 2 >= m) ans = min(n, m / 2);
    else {
        ans = n;
        m -= 2 * n;
        ans += m / 4;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin>>a>>b;
	cout<<6-(a+b);
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    int N, H;
    cin >> H >> N;
    int sum = 0;
    REP(i, N){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum >= H)cout << "Yes" << endl;
    else cout << "No" << endl;
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int count = 0;
  string s;
  cin >> s;
  if(s[0] == '1'){
    count++;
  }
  if(s[1] == '1'){
   	count++;
  }
  if(s[2] == '1'){
    count++; 
  }
  cout << count << endl;
}

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

int main(){
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
    stable_sort(vec.begin(),vec.end());
    if(vec.at(0)+vec.at(1)==vec.at(2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
typedef long long int ll;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const ll LINF = 1001002003004005006ll;
const int MX = 200005;

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

  long dp[MX]; // base: v
  rep(i, MX) dp[i] = LINF;

  dp[0] = 0;
  int wi, vi;
  rep (i, n) {
    cin >> wi >> vi;

    drep(j, MX - vi) {
      int ni = j + vi;
      dp[ni] = min(dp[ni], dp[j] + wi);
    }
  }


  int maxV = 0;
  rep (i, MX) {
    if (dp[i] <= w) maxV = i;
  }

  cout << maxV << endl;
  return 0;
}



Measured memory_bytes: 1792
N = int(input())
print(N-1, flush=True)
x = input()
if x == 'Vacant':
    exit(0)
print(0, flush=True)
s = input()
if s == 'Vacant':
    exit(0)
left = 0
right = N-1
mid = (right+left)//2
while True:
    print(mid, flush=True)
    t = input()
    if t == 'Vacant':
        exit(0)
    if bool(s == t) ^ bool((mid-left) % 2 == 0):
        right = mid
    else:
        left = mid
        s = t
    mid = (left+right)//2


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// pow2[0][j] = 2^i mod (popcnt(x)+1)
// pow2[1][j] = 2^i mod (popcnt(x)-1) ただし popcnt(x)=0 のときは 0
constexpr int MAX_N = 200005;
ll pow2[2][MAX_N] = {};
ll f[MAX_N] = {};
int main()
{
    int n;
    string x;
    cin >> n >> x;
    // popcount(x) を計算する
    int popcount_x = 0;
    for (const auto &xi: x){
        if (xi=='1'){
            popcount_x += 1;
        }
    }
    // 2^i mod (popcount(x) \pm 1) を計算する
    for(int i=0; i<2; ++i){
        const ll mod = popcount_x + ((i==0)?1:(-1));
        pow2[i][0] = 1;
        if (mod <= 0)continue; // mod 負のときはスルー
        for(int j=1; j<n; ++j){
            pow2[i][j] = (2 * pow2[i][j-1]) % mod;
        }
    }
    // popcount(x) 以下について f(m) を計算する
    f[0] = 0;
    for(int i=1; i<=popcount_x+1; ++i){
        int popcount = 0;
        for(int d=0; d<30; ++d){
            if(i&(1<<d))popcount++;
        }
        f[i]=f[i%popcount]+1;
    }
    // x mod (popcount(x) \pm 1) を計算する
    ll x_mod_popcnt[2] = {};
    for(int i=0; i<n; ++i){
        const int d = n-i-1;
        if(x[i]=='1'){
            for(int j=0; j<2; ++j){
                x_mod_popcnt[j]+=pow2[j][d];
            }
        }
    }
    // f(x_i) を計算する
    for(int i=0; i<n; ++i){
        const int d = n-i-1;
        if (x[i]=='0'){
            // 反転して1が増える
            const ll mod = popcount_x + 1;
            const ll xi_mod_popcnt = (x_mod_popcnt[0] + pow2[0][d]) % mod;
            cout << f[xi_mod_popcnt] + 1 << endl;
        }else{
            // 反転して1が減る
            const ll mod = popcount_x - 1;
            if(mod == 0){
                cout << 0 << endl;
                continue;
            }
            const ll xi_mod_popcnt = (x_mod_popcnt[1] + mod - pow2[1][d]) % mod;
            cout << f[xi_mod_popcnt] + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N, Q;
    cin >> N >> Q;
    vector<vector<int> > tree(N);
    vector<ll> cnt(N, 0);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        tree.at(a - 1).push_back(b - 1);
        tree.at(b - 1).push_back(a - 1);
    }

    for (int i = 0; i < Q; ++i) {
        int p;
        ll x;
        cin >> p >> x;
        cnt.at(p - 1) += x;
    }
    queue<int> que;
    vector<int> used(N, 0);
    que.push(0);
    while (!que.empty()) {
        int p = que.front();
        que.pop();
        used.at(p) = 1;
        for (auto &np : tree.at(p)) {
            if (used.at(np)) continue;
            cnt.at(np) += cnt.at(p);
            que.push(np);
        }
    }

    for (int i = 0; i < N; ++i) {
        if (i) cout << ' ';
        cout << cnt.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 17140
#include <stdio.h>
int main(void){
int x,y,z,temp;
  scanf("%d %d %d",&x,&y,&z);
  temp=x;
  x=y;
  y=temp;
  temp=x;
  x=z;
  z=temp;
  printf("%d %d %d",x,y,z);
  return 0;  
}


Measured memory_bytes: 1680