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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

string a, b;
void in(){
    cin >> a >> b;

}

void solve(){

    set<int> s;
    rep(i,1,999){
        s.insert(i * i);
    }

    if(exist(s, stoi(a + b))){
        print("Yes");
    }else{
        print("No");
    }
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
/*
 * Aizu Online Judge
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 * @author yoshkur
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			InputData inputData = new InputData(br);
			Processing processing = new Processing(inputData);
			System.out.println(processing.getResult());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class InputData {

	private Integer a;
	private Integer b;
	private Integer c;

	public InputData(BufferedReader br) throws IOException {
		String line = br.readLine().trim();
		String[] values = line.split(" ");
		this.a = Integer.valueOf(values[0]);
		this.b = Integer.valueOf(values[1]);
		this.c = Integer.valueOf(values[2]);
	}

	public Integer getA() {
		return a;
	}

	public void setA(Integer a) {
		this.a = a;
	}

	public Integer getB() {
		return b;
	}

	public void setB(Integer b) {
		this.b = b;
	}

	public Integer getC() {
		return c;
	}

	public void setC(Integer c) {
		this.c = c;
	}
}

class Processing {

	private InputData inputData;

	public Processing(InputData inputData) {
		this.inputData = inputData;
	}

	public String getResult() {
		String result = null;
		List<Integer> list = new ArrayList<>();
		list.add(this.inputData.getA());
		list.add(this.inputData.getB());
		list.add(this.inputData.getC());
		Collections.sort(list);
		StringBuilder sb = new StringBuilder();
		for (Integer i : list) {
			sb.append(i);
			sb.append(" ");
		}
		result = sb.toString().trim();
		return result;
	}
}

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

int main(){
	int h1, h2, k1, k2, a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	
	if(h1*a+h2*b+(h1/10*c)+(h2/20*d) < k1*a+k2*b+(k1/10*c)+(k2/20*d)) cout << "kenjiro" << endl;
	else if(h1*a+h2*b+(h1/10*c)+(h2/20*d) == k1*a+k2*b+(k1/10*c)+(k2/20*d)) cout << "even" << endl;
	else cout << "hiroshi" << endl;
	
	return 0;
}


Measured memory_bytes: 3104
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
--import           Control.Monad.Loops
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

----------
-- main --
----------
main :: IO ()
main = postalCode

postalCode :: IO ()
postalCode = do
  [a, b] :: [Int] <- getLineSpc
  s <- T.getLine
  let splitS = filter (/= T.pack "") $ T.split (== '-') s
  if length splitS /= 2
    then
    putStrLn "No"
    else if (a == T.length (head splitS)) && (b == T.length (last splitS))
    then
    putStrLn "Yes"
    else
    putStrLn "No"

Measured memory_bytes: 508
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<pair<ll, ll>> ab(N);
  ll a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    ab[i] = {a, b};
  }
  sort(ab.begin(), ab.end());
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    a = ab[i].first;
    b = ab[i].second;
    cnt += b;
    if (K <= cnt) {
      cout << a << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long mod = 1e9 + 7;
long long fact[N];
int main(){
    fact[0] = 1;
    for(int i = 1 ; i < N ; i++){
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
    int n, m;
    cin >> n >> m;
    if (n == m)
        cout << fact[n] * fact[m] % mod * 2 % mod;
    else if (abs(n - m) == 1){
        cout << fact[n] * fact[m] % mod;
    }
    else
        cout << 0;
    return 0;
}


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

int main () {
  int a, b, k;
  cin >> a >> b >> k;
  set<int> se;
  for (int i=a; (i<=b && i<a+k); i++) se.insert(i);
  for (int i=b; (i>=a &&i>b-k); i--) se.insert(i);
  for (auto x: se) cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

int main(){
    int a,b;
    cin >> a >> b;
    int ans = a-(b*2);
    ans = ans>0 ? ans : 0;
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*; 
 
public class Main
{
	public static void main(String args[]) throws Exception{
		new Main().run();
	}

	int w,h;
	
	public void run()
	{
		int i,j,k,l;
		Scanner cin=new Scanner(System.in);
		while(true){
			int N = cin.nextInt();
			if(N==0) break;
			double sx,sy,ex,ey;
			sx = cin.nextDouble();
			sy = cin.nextDouble();
			ex = cin.nextDouble();
			ey = cin.nextDouble();
			double h[] = new double[N];
			double mindist[] = new double[N];
			double res = 999999999;
			for(i=0;i<N;i++){
				double minx, maxx, miny, maxy;
				minx = cin.nextDouble();
				miny = cin.nextDouble();
				maxx = cin.nextDouble();
				maxy = cin.nextDouble();
				h[i] = cin.nextDouble();
				mindist[i] = res;
				double hi = 1;
				double low = 0;
				double nowdist = 0;
				for(l=0;l<200;l++){
					double left = (low+low+hi) /3;
					double right = (low + hi + hi) / 3;
					double lx = sx * left + ex * (1-left);
					double ly = sy * left + ey * (1-left);
					double rx = sx * right + ex * (1-right);
					double ry = sy * right + ey * (1-right);
					
					double ldist = dist(minx,miny, maxx, maxy,lx,ly);
					double rdist = dist(minx,miny, maxx, maxy,rx,ry);
					if(ldist<rdist){
						hi = right;
					}
					else{
						low = left;
					}
					nowdist = ldist;
					
				}
				mindist[i] = Math.min(mindist[i], nowdist);
			}

			double hh = 100000;
			double ll = 0;
			for(l=0;l<200;l++){
				double mid = (hh + ll) / 2;
				boolean flag = false;
				for(i=0;i<N;i++){
					double need = mindist[i];
					if(mid<h[i]){
						need -= mid;
					}
					else{
						need -= Math.sqrt(mid * mid - (mid-h[i]) * (mid-h[i]));
					}
					//System.out.println(need);
					if(need<0) flag= true;
				}
				if(flag){
					hh = mid;
				}
				else{
					ll = mid;
				}
			}
			res = ll;
			System.out.println(res);
		}
	}
	double dist(double minx, double miny,double maxx, double maxy, double bx, double by){
		boolean flagx = false;
		boolean flagy = false;
		if(bx>=minx && bx<=maxx) flagx = true;
		if(by>=miny && by<=maxy) flagy = true;
		if(flagx && flagy) return 0;
		else if(flagx) return Math.min(dist(bx,miny,bx,by), dist(bx,maxy,bx,by));
		else if(flagy) return Math.min(dist(minx,by,bx,by), dist(maxx,by,bx,by));
		return Math.min(
				Math.min(dist(minx,miny,bx,by), dist(minx,maxy,bx,by)),
				Math.min(dist(maxx,miny,bx,by), dist(maxx,maxy,bx,by))
				);
	}
	
	
	double dist(double ax, double ay,double bx, double by){
		
		return Math.sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by));
	}
	
	boolean ok(int y, int x){
		return x>=0 && y>=0 && x<w && y<h;
	}
	
}

Measured memory_bytes: 13000
#include <stdio.h>

int main(){

	int vecA[100][100] = { 0 };
	int vecB[100] = { 0 };
	int vecC[100] = { 0 };
	int x, y;
	int i, j;
	scanf("%d %d", &x, &y);

	for (i = 0; i < x; i++){
		for (j = 0; j < y; j++){
			scanf("%d", &vecA[i][j]);
		}
	}
	for (j = 0; j < y; j++){
		scanf("%d", &vecB[j]);
	}

	for (i = 0; i < x; i++){
		for(j = 0; j < y; j++ ){
			vecC[i] = vecC[i] +( vecA[i][j] * vecB[j]);
		}
		printf("%d\n", vecC[i]);
	}
	
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;

  vector<int> Nums;
  int now = 1;//いま見ている数
  int cnt = 0;//nowがいくつ並ぶか
  rep(i,n){
    if(s[i] == (char)('0'+now))cnt++;
    else{
      Nums.push_back(cnt);
      now = 1-now; //1と0切り替え
      cnt = 1;
    }
  }
  if(cnt != 0)Nums.push_back(cnt);
  //連続する1の数-連続する0の数-…ってかんじの配列
  //1-0-1-0-…-0-1のように1でおわりにする
  if(Nums.size()%2 == 0)Nums.push_back(0);

  int ans = 0;
  for(int i=0; i<Nums.size(); i+=2){
    int tmp = 0;

    int left = i;
    int right = min(i+2*k+1,(int)Nums.size());
    reps(j,left,right){
      tmp += Nums[j];
    }
    ans = max(tmp,ans);
  }

  cout << ans << endl;

}

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


int main(){
    int N,M;
    cin >> N >> M;
    
    vector<pair<ll,ll>> shop;
    
    //店を取得して安い順
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        shop.push_back(make_pair(a,b));
    }
    sort(shop.begin(), shop.end());
    
    
    int i=0;
    ll now_M = M;
    ll totalcost=0;
    while(now_M>0){
        if(shop[i].second <= now_M){
            now_M -= shop[i].second;
            totalcost += shop[i].first * shop[i].second;
        }else if(shop[i].second > now_M){
            totalcost += shop[i].first * now_M;
            now_M = 0;
        }
        
        i++;
    }
    
    cout << totalcost << endl;
    
    /*
    for(pair<ll,ll> t:shop){
        ll x,y;
        x = t.first;
        y = t.second;
        cout << x << " " << y <<endl;
    }
    */
}


Measured memory_bytes: 2420
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);
            long m = long.Parse(input[2]);

            long[] ai = new long[a];
            long[] bi = new long[b];
            string[] input2 = Console.ReadLine().Split(' ');
            string[] input3 = Console.ReadLine().Split(' ');
            for(int i = 0;i < a;i++)
                ai[i] = long.Parse(input2[i]);
            for(int i = 0;i < b;i++)
                bi[i] = long.Parse(input3[i]);
           

            long ans = ai.Min() + bi.Min();

            for(int i = 0;i <m ;i++)
            {
                string[] input4 = Console.ReadLine().Split(' ');
                long temp = ai[long.Parse(input4[0])-1] + bi[long.Parse(input4[1])-1] - long.Parse(input4[2]);
                ans = Math.Min(temp, ans);

            }

            Console.WriteLine(ans);
            
    
        }
    }

Measured memory_bytes: 36188
# -*- coding: utf-8 -*-
N = int(input())
plan_list = [list(map(int, input().split())) for i in range(N)]

point = [0,0,0]
output = 'Yes'
for plan in plan_list:
    dist = abs(plan[1] - point[1]) + abs(plan[2] - point[2])
    time = plan[0] - point[0]
    if time >= dist and (dist - time)%2 == 0:
        point = plan
        continue
    else:
        output = 'No'
        break

print (output)

Measured memory_bytes: 27380
L,R = list(map(int,input().split()))
from itertools import combinations

numbers = [i for i in range(L,min(R+1,L+2019))]
ans = 2019
for conb in combinations(numbers,2):
  if ans > (conb[0]*conb[1])%2019:
     ans = (conb[0]*conb[1])%2019
    
print(ans)

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

#define mod 998244353
#define  ll long long
using namespace std;




int main() {
ll x;
cin>>x;
ll ans=0;
ll n=x/500;
ans+=n*1000;

x-=n*500;
n=x/5;
ans+=n*5;
cout<<ans;

}

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

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

  int n;
  cin >> n;
  vector<string> s(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  int a = 0;
  int b = 0;
  int ab = 0;
  for (auto str : s) {
    int cnt = 0;

    if (str.front() == 'B') {
      b++;
    }
    if (str.back() == 'A') {
      a++;
    }
    if (str.front() == 'B' && str.back() == 'A') {
      a--;
      b--;
      ab++;
    }
    for (int i = 1; i < str.size(); i++) {
      if (str[i - 1] == 'A' && str[i] == 'B') {
        cnt++;
      }
    }
    ans += cnt;
  }

  if(ab == 0) {
    ans += min(a, b);
  } else if(a + b > 0) {
    ans += min(a, b) + ab;
  } else {
    ans += ab - 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 768
a_price,b_price,ab_price,num_a,num_b = map(int, input().split())
total = 0

if a_price + b_price < 2 * ab_price:
	total = a_price * num_a + b_price * num_b

elif a_price + b_price >= 2 * ab_price:
	if num_a >= num_b:
		if a_price > ab_price * 2:
			total = ab_price * 2 * num_a
		else:
			total = ab_price * 2 * num_b + a_price * (num_a - num_b)
	else:
		if b_price > ab_price * 2:
			total = ab_price * 2 * num_b
		else:
			total = ab_price * 2 * num_a + b_price * (num_b - num_a)

print(total)



Measured memory_bytes: 61568
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,Q,c[300010],ans[300010];
int p[601];

int main(){
	cin>>N>>Q;
	rep(i,N)cin>>c[i];
	sort(c,c+N);
	
	fill(p+1,p+601,N-1);
	for(int i=300000;i>=601;i--){
		rep2(j,1,601){
			while(p[j]>=0 && c[p[j]] >= i*j) p[j]--;
			if(p[j]>=0) ans[i]=max(ans[i],c[p[j]]%i);
		}
	}
	
	rep2(i,1,601){
		rep(j,N)ans[i]=max(ans[i],c[j]%i);
	}
	
	rep(i,Q){
		int q;
		cin>>q;
		cout<<ans[q]<<endl;
	}
}

Measured memory_bytes: 3520
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int max(int , int);//大きい方を返す
int min(int, int);//小さい方を返す

int main(void){
    int i, N, M, X, Y;
    scanf("%d %d %d %d", &N, &M, &X, &Y);
    int MAX=X, MIN=Y;
    for(i=0; i<N; i++){
        scanf("%d", &X);
        MAX = max(MAX, X);
    }
    for(i=0; i<M; i++){
        scanf("%d", &Y);
        MIN = min(MIN, Y);
    }
    if(MAX < MIN)printf("No War\n");
    else printf("War\n");
    return 0;
}

int min(int A, int B){ return (A<=B) ? A : B; }
int max(int A, int B){ return (A>=B) ? A : B; }


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

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


int a[200010];
int cnt[200010];

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

    a[1] = 0;
    repp(i, 2, n){
        cin >> a[i];
    }

    repp(i, 2, n) cnt[a[i]]++;

    repp(i, 1, n) cout << cnt[i] << endl;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int N, M, Q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A)
{
  if (A.size() == N + 1)
  { // 最初に入れた1を除くから
    // calc score
    int now = 0;
    for (int i = 0; i < Q; i++)
    {
      if (A[b[i]] - A[a[i]] == c[i])
        now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= M)
  {
    dfs(A);
    A.back()++;
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M >> Q;
  a = b = c = d = vector<int>(Q);
  for (int i = 0; i < Q; i++)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1, 1)); // とりあえず1を入れておく（これは答えの配列に含まれない）
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  
  cin >> N;
  
  vector<int> t(N);
  vector<int> r(N);
  
  for (int i = 0; i < N; i++){
    cin >> t.at(i);
    cin >> r.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++){
    sum += r.at(i) - t.at(i) + 1;
  }
  
  cout << sum << endl;
}

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

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    if(b > a) return gcd(b, a);
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    int N;
    ll K;
    cin >> N >> K;

    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];

    ll G = A[0];
    for(int i=1;i<N;i++) G = gcd(G, A[i]);

    sort(A.begin(), A.end());

    if(K%G == 0 && K <= A[N-1]){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <stack>
#include <map>

const int MaxN = 1e5;
typedef long long LL;
using namespace std;

int a,b, c, d;

int main()
{
	cin >> a >> b >> c >> d;
	int x = min(a,b);
	int y = min(c,d);
	cout << x + y << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll N, M;
    cin >> N >> M;
    ll i, a[100001], s[100001]={0};
    Map mp;
    for(i=1; i<=N; i++) {
        cin >> a[i];
        s[i]=s[i-1]+a[i];
        mp[s[i]%M]++;
    }
    mp[0]++;
    ll ans=0;
    for(auto it=mp.begin(); it!=mp.end(); it++) {
        ll t=it->second;
        ans+=t*(t-1)/2;
    }
    
    prin(ans)
}


Measured memory_bytes: 5760
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace Contest
{


    class Program
    {


        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderBy(x => x).ToArray();

            long res = 0;

            for(int i = 0; i < n; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    for(int k = j + 1; k < n; k++)
                    {
                        if (l[i] != l[j] && l[j] != l[k] && l[i] + l[j] > l[k]) res++;
                    }
                }
            }

            Console.WriteLine(res);

        }
    }
}


Measured memory_bytes: 28468
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };
int main() {
	int n, m, start, goal;
	while (cin >> n>> m>> start>> goal,n|m|start|goal) {
		vector<vector<string>> DP(n,vector<string>(500,"~"));
		vector<vector<pair<string,int>>> E(n);
		REP(i, m) {
			int x, y;
			string s;
			cin >> x >> y >> s;
			E[x].push_back({ s,y});
		}
		bool clear = false;
		string ans;
		priority_queue<pair<string, int>, vector<pair<string, int>>, greater<pair<string, int>>> Q;
		Q.push({ "",start });
		DP[start][0] = "";
		while (!Q.empty()) {
			pair<string, int> q = Q.top(); Q.pop();
			if (q.first.length() > 500) {
				continue;
			}
			if (q.second == goal){
				if((q.first.length()<400))
				clear = true;
				ans = q.first;
				break;
			}
			REP(i, E[q.second].size()) {
				if (q.first.length() + E[q.second][i].first.length() >= 500)
					continue;
				if (DP[E[q.second][i].second][q.first.length() + E[q.second][i].first.length()] > q.first + E[q.second][i].first) {
					DP[E[q.second][i].second][q.first.length() + E[q.second][i].first.length()] = q.first + E[q.second][i].first;
					Q.push({ q.first + E[q.second][i].first ,E[q.second][i].second });
				}
			}
		}

		if (!clear){
			cout << "NO" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 19636
// ------------------------------------
// Date:2018/ 3/10
// Problem:ABC 049 Connectivity d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;
static const int MAX_N = 201010;

// par[0]: road / par[1]: train
int par[2][MAX_N];



int root(int n, int type)
{
  if (par[type][n] < 0) {
    return n;
  } else {
    return par[type][n] = root(par[type][n], type);
  }
}

bool unite(int p, int q, int type)
{
  p = root(p, type);
  q = root(q, type);
  if (p == q) return false;
  if (par[type][p] > par[type][q]) swap(p, q);
  par[type][p] += par[type][q];
  par[type][q] = p;
  return true;
}

bool same(int p, int q, int type)
{
  return root(p, type) == root(q, type);
}


void init(int n)
{
  REP(i, n) {
    par[0][i] = -1;
    par[1][i] = -1;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  map< pair< int, int>, int> m;
  int N, K, L;
  cin >> N >> K >> L;
  init(N);
  // road
  REP(i, K) {
    int p, q;
    cin >> p >> q;
    --p;
    --q;
    unite(p, q, 0);
  }

  // train
  REP(i, L) {
    int r, s;
    cin >> r >> s;
    --r;
    --s;
    unite(r, s, 1);
  }

  REP(i, N) {
    m[make_pair(root(i, 0), root(i, 1))]++;
  }

  REP(i, N) {
    cout << m[make_pair(root(i, 0), root(i, 1))];
    if (i != N-1) cout << " ";
    else cout << endl;
  }
  /*
  int cnt;
  bool ok;
  REP(i, N) {
    cnt = 0;
    REP(j, N) {
      ok = true;
      REP(type, 2) {
	// printf("root(%d):%d / root(%d):%d\n", i, root(i, type), j, root(j, type));
	if (not( same( root(i, type), root(j, type), type ) )) ok = false;
      }
      if (ok) cnt++;
    }

    cout << cnt;
    if (i != N-1) cout << " ";
    else cout << endl;
  }
  */
  return 0;
}


//1 1 2 1 2 2 2


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

typedef long long ll;
typedef long double ld;

ll a[200005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    sort(a+1, a+1+n);
    sum += a[n];
    ll svi = n-2;
    for(int i=n-1; i>=1; i--){
        if(svi <= 2){
            sum += svi*a[i];
            break;
        }
        svi -= 2;
        sum += 2*a[i];
    }
    cout << sum;
    return 0;
}


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


using namespace std;



int main()

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    vector <vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));
    for (unsigned long i = 0; i < s.length(); ++i){
        for(unsigned long j = 0; j <  t.length(); ++j){
            if (s[i] == t[j]){
                dp[i+1][j+1] = 1 + dp[i][j];
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    unsigned long n = dp[s.length()][t.length()];
    unsigned long i = s.length();
    unsigned long j = t.length();
    string ret (n, ' ');
    while (i > 0 && j > 0){
        if (dp[i][j] == dp[i-1][j]) {
            --i;
        }
        else if (dp[i][j] == dp[i][j-1]){
            --j;
        }
        else{
            ret[n-1] = s[i-1];
            --i; --j; --n;
        }
    }
    cout << ret << "\n";
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int N,C,D[5010][2],i,j;
main(){
    cin>>N;
    fill_n(*D+3,1e4,1e9);D[0][0]=1e9;
    for(i=0;cin>>C,i<N-1;i++)for(j=N/2;~j;j--)D[j+1][0]=min(D[j][0],D[j][1]+C),D[j][1]=min(D[j][0]+C,D[j][1]);
    cout<<min(D[N/2][0],D[N/2][1])<<endl;
}

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

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

    string s[N];
    cin >> s[0];

    int frag = 0;
    string next;
    int len = s[0].length();
    int cou = 1;

    for(int i = 0; i < N - 1; i++){
        cin >> next;
        if (s[i].substr(len - 1, 1) == next.substr(0, 1)){
            for(int j = 0; j < cou; j++){
                if(s[j] == next){
                    frag = 1;
                    break;
                }
            }
            if(frag == 0){
                s[i + 1] = next;
                cou++;
            }else{
                break;
            }
        }else{
            frag = 1;
            break;
        }

        len = next.length();
    }

    if(frag == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

int main()
{
  int n;
  int i,j;
  int *p;
  int max = -1000000000;
  int min;

  cin >> n;
  p = new int [n];

  for(i=0;i<n;i++){
    cin >> p[i];
  }

  min =	p[0];
  for( j=1; j<n; j++ ){
    if(max < p[j]-min){
      max = p[j] - min;
    }
    if(min > p[j]){
      min = p[j];
    }
  }

  cout << max << endl;

  delete [] p;
  return 0;
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(std::string S) {
  if(S=="ARC") cout << "ABC" << endl;
  else cout <<"ARC" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,min,c=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  c=1;
  min=a[0];
  for(i=1;i<n;i++)
  {
    if(a[i]<min)
    {
      c++;
      min=a[i];
    }
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

ll N,K;
vector<ll> A,F;

bool solve(ll X){
    ll cnt = 0;
    rep(i,N){
        cnt += max((ll)0, A[i] - X/F[i]);
    }
    return cnt <= K;
}

int main() {
    //入力
    cin>>N>>K;
    A.resize(N);
    F.resize(N);
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>F[i];
    sort(all(A));
    sort(all(F), greater<ll>());

    //めぐる式二分探索
    ll ng = -1;
    ll ok = 1e12 + 1;
    while(ok-ng > 1){
        ll mid = (ok + ng)/2;
        if(solve(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll n,v[1000001],w[1000001],q;
vector<P> ans[520];
ll ANS[520][100001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    rep(i,n) cin>>v[i+1]>>w[i+1];
    rep(i,min(n,(ll)511)){
        if(i==0) ans[i+1].push_back(P(0,0)),ans[i+1].push_back(P(v[i+1],w[i+1]));
        else{
            for(auto j:ans[(i+1)/2]){
                ans[i+1].push_back(j);
                if(j.second+w[i+1]<=100000) ans[i+1].push_back(P(j.first+v[i+1],j.second+w[i+1]));
            }
        }
    }
    if(n>=512){
        rep(i,256){
            rep(j,ans[i+256].size()) ANS[i+256][ans[i+256][j].second]=max(ANS[i+256][ans[i+256][j].second],ans[i+256][j].first);
            rep(j,100000) ANS[i+256][j+1]=max(ANS[i+256][j+1],ANS[i+256][j]);
        }
    }
    cin>>q;
    rep(i,q){
        ll V,L;
        cin>>V>>L;
        if(V<=511){
            ll answer=0;
            rep(j,ans[V].size()) if(ans[V][j].second<=L) answer=max(answer,ans[V][j].first);
            cout<<answer<<"\n";
        }
        else{
            ll answer=0;
            vector<P> A;
            A.push_back(P(0,0));
            while(V>=512){
                vector<P> B;
                rep(j,A.size()) if(A[j].second+w[V]<=100000) B.push_back(P(A[j].first+v[V],A[j].second+w[V]));
                rep(j,B.size()) A.push_back(B[j]);
                V/=2;
            }
            rep(j,A.size()) if(A[j].second<=L) answer=max(answer,ANS[V][L-A[j].second]+A[j].first);
            cout<<answer<<"\n";
        }
    }
}

Measured memory_bytes: 210328
#include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

int main(){
    int n;
    double h;
    int count[7] = {};
    cin >> n;
    int i, j;

    for (i = 0; i < n; i++){
        cin >> h;
        if (h < 165){
            count[1]++;
        }
        if (h < 170 && h >= 165){
            count[2]++;
        }
        if (h<175 && h >= 170){
            count[3]++;
        }
        if (h<180 && h >= 175){
            count[4]++;
        }
        if (h<185 && h >= 180){
            count[5]++;
        }
        if (h>=185){
            count[6]++;
        }
    }

    for (int i = 1; i <= 6; i++){
        cout << i << ":";
        for (int j = 0; j < count[i]; j++)putchar('*');
        puts("");
    }
}

    //    {
   
    //        for (i = 0; i < n; i++){
    //            if (hight[0] < 165)
    //                count++;
    //    }
    //        for (i = 0; i < count; i++){
    //            printf("1:%d", *);
    //        }

    //        for (j = 1; j <= 6; j++){
    //            for (i = 0; i < n; i++){
    //                if (hight[i] >= 165+i && hight[i]<175+i)
    //                    count++;
    //            }
    //            for (i = 2; i <= count; i++){
    //                printf("%d:%d", j, *);
    //            }
    //            i += 5;
    //        }
    //}

Measured memory_bytes: 1232
N = input()
L = len(N)

dp = [[[[0] * 2 for _ in range(2)] for _ in range(2)] for _ in range(2)]
pp = [[[[0] * 2 for _ in range(2)] for _ in range(2)] for _ in range(2)]
dp[0][0][0][0] = 1

for i in range(L):
    pp, dp = dp, pp
    dp = [[[[0] * 2 for _ in range(2)] for _ in range(2)] for _ in range(2)]
    n = int(N[i])
    dp[0][0][0][1] += pp[0][0][0][1]
    dp[1][0][0][1] += pp[0][0][0][1] + pp[1][0][0][1]
    dp[0][1][0][1] += pp[0][0][0][1] + pp[0][1][0][1]
    dp[0][0][1][1] += pp[0][0][0][1] + pp[0][0][1][1]
    dp[1][1][0][1] += pp[1][0][0][1] + pp[0][1][0][1] + pp[1][1][0][1] * 2
    dp[1][0][1][1] += pp[1][0][0][1] + pp[0][0][1][1] + pp[1][0][1][1] * 2
    dp[0][1][1][1] += pp[0][1][0][1] + pp[0][0][1][1] + pp[0][1][1][1] * 2
    dp[1][1][1][1] += pp[1][1][0][1] + pp[1][0][1][1] + pp[0][1][1][1] + pp[1][1][1][1] * 3
    if n > 0:
        dp[0][0][0][1] += pp[0][0][0][0]
    if n > 3:
        dp[1][0][0][1] += pp[1][0][0][0] + pp[0][0][0][0]
        dp[1][1][0][1] += pp[1][1][0][0] + pp[0][1][0][0]
        dp[1][0][1][1] += pp[1][0][1][0] + pp[0][0][1][0]
        dp[1][1][1][1] += pp[1][1][1][0] + pp[0][1][1][0]
    if n > 5:
        dp[0][1][0][1] += pp[0][1][0][0] + pp[0][0][0][0]
        dp[1][1][0][1] += pp[1][1][0][0] + pp[1][0][0][0]
        dp[0][1][1][1] += pp[0][1][1][0] + pp[0][0][1][0]
        dp[1][1][1][1] += pp[1][1][1][0] + pp[1][0][1][0]
    if n > 7:
        dp[0][0][1][1] += pp[0][0][1][0] + pp[0][0][0][0]
        dp[1][0][1][1] += pp[1][0][1][0] + pp[1][0][0][0]
        dp[0][1][1][1] += pp[0][1][1][0] + pp[0][1][0][0]
        dp[1][1][1][1] += pp[1][1][1][0] + pp[1][1][0][0]
    if n == 0:
        dp[0][0][0][0] += pp[0][0][0][0]
    if n == 3:
        dp[1][0][0][0] += pp[1][0][0][0] + pp[0][0][0][0]
        dp[1][1][0][0] += pp[1][1][0][0] + pp[0][1][0][0]
        dp[1][0][1][0] += pp[1][0][1][0] + pp[0][0][1][0]
        dp[1][1][1][0] += pp[1][1][1][0] + pp[0][1][1][0]
    if n == 5:
        dp[0][1][0][0] += pp[0][1][0][0] + pp[0][0][0][0]
        dp[1][1][0][0] += pp[1][1][0][0] + pp[1][0][0][0]
        dp[0][1][1][0] += pp[0][1][1][0] + pp[0][0][1][0]
        dp[1][1][1][0] += pp[1][1][1][0] + pp[1][0][1][0]
    if n == 7:
        dp[0][0][1][0] += pp[0][0][1][0] + pp[0][0][0][0]
        dp[1][0][1][0] += pp[1][0][1][0] + pp[1][0][0][0]
        dp[0][1][1][0] += pp[0][1][1][0] + pp[0][1][0][0]
        dp[1][1][1][0] += pp[1][1][1][0] + pp[1][1][0][0]


print(sum(dp[1][1][1]))

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K,X;
    K=sc.nextInt();
    X=sc.nextInt();
    if(500*K>=X){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    sc.close();
  }
}

Measured memory_bytes: 21844
#include <stdio.h>

void p(int A[], int n){
    int i;
    for (i = 0; i < n; i++) {
        if (i != 0) putchar(' ');
        printf("%d", A[i]);
    }
    putchar('\n');
}

int main(){
    int i, j, n, A[100], key;
    scanf("%d", &n);
    for (i = 0;i < n;i++) scanf("%d", A + i);
    for (j = 1; j < n; j++) {
        p(A, n);
        key = A[j];
        i = j - 1;
        while ((i >= 0) && (A[i] > key)) {
            A[i + 1] = A[i];
            i--;
        }
        A[i + 1] = key;
    }
    p(A, n);
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long a, b, k;
  cin >> a >> b >> k;
  long long t = min(a, k);
  a -= t;
  k -= t;
  t = min(b, k);
  b -= t;
  k -= t;
  cout << a << ' ' << b << '\n';
}


Measured memory_bytes: 256
def solve(n, x, m):
    result = [x]
    checked = [0] * m
    checked[x] = 1
    while len(result) < n:
        x = x * x % m
        if checked[x] > 0:
            break
        result.append(x)
        checked[x] = len(result)
    else:
        return sum(result)

    l = len(result)
    i = checked[x]
    before_len = i - 1
    loop_len = l - i + 1
    loop_sum = sum(result[before_len:])
    d, e = divmod(n - before_len, loop_len)
    ans = sum(result[:before_len]) + loop_sum * d + sum(result[before_len:before_len + e])
    return ans


n, x, m = map(int, input().split())

print(solve(n, x, m))


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

int main() {
  int n;
  cin >> n;
  
  cout << (n-1)/2 << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b=MAP()
if a==1 or b==1:
    print(1)
    exit()
n=a*b
if n%2==0:
    print(n//2)
else:
    print(n//2+1)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	int T, N, S, A, B;

	while (true)
	{
		cin >> T;

		if (T == 0) { break; }

		cin >> N; S = 0;

		for (int i = 0; i < N; i++)
		{
			cin >> A >> B;

			S += B - A;
		}

		if (S >= T)
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << T - S << endl;
		}
	}

	return 0;
}

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

int main(int argc, char const *argv[])
{
    char n[1000];
    while(true){
        scanf("%s", n);
        if (n[0] == '0') return 0;
        int i = 0;
        int sum = 0;
        while (n[i]){
            sum += n[i] - '0';
            i += 1;
        }
        cout << sum << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    set<string> st;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 19268
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int A =sc.nextInt();
		int B =sc.nextInt();
		int C =sc.nextInt();

		if(C > (A-B)) {
			System.out.println(C-(A-B));
		}else {
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s[3];
  rep(i, 3) {
    cin >> s[i];
    cout << s[i][0];
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n, m;
const int maxx = 500005;
vector<int> g[maxx], t[maxx];
bool visited[maxx];
stack<int> topo;// stack
vector<int> v[maxx]; // save the strongly connected components
void dfs(int u) // dfs push all vertices as their finish time to a stack
{
    visited[u] = 1;
    for(int nei: g[u])
        if(!visited[nei])
            dfs(nei);
    topo.push(u);
}
 
void scc(int idx, int u)
{
    visited[u] = 1;
    v[idx].push_back(u);
    for(int nei: t[u])
        if(!visited[nei])
            scc(idx, nei);
}
int main()
{
    cin >> n; // the number of vertice
    cin >> m; // the number of edge
    for(int i = 0; i < m; i++){
		int x, y; cin>>x>>y;
        g[x].push_back(y);
        t[y].push_back(x); // transpose of g
    }
    
    memset(visited, 0, sizeof(visited)); //mark all vertices unvisited for the second DFS
    for(int i = 0; i < n; i++)
    {
        if(!visited[i])
            dfs(i);
    }
    memset(visited, 0, sizeof(visited));//mark all vertices unvisited for the second DFS
    int x = 0;
    while(!topo.empty())
    {
        int u = topo.top(); topo.pop();
        if(!visited[u])
            scc(x++, u);
    }
    cout<<x<<endl;
	for(int i = 0; i < x; i++){
		cout<<v[i].size()<<" ";
		for(int j : v[i]){
			cout<<j<<" ";
		}
		cout<<endl;
	}
}


Measured memory_bytes: 76704
import java.util.Scanner;

class Main {
    static void quickSort(int[] a, int left, int right) {
        int pl = left;
        int pr = right;
        int x = a[(pl + pr) / 2];

        do {
            while (a[pl] < x) pl++;
            while (a[pr] > x) pr--;
            if (pl <= pr) {
                int t = a[pl];
                a[pl] = a[pr];
                a[pr] = t;
                pl++;
                pr--;
            }
        } while (pl <= pr);

        if (left < pr)  quickSort(a, left, pr);
        if (pl < right) quickSort(a, pl, right);
    }

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = Integer.parseInt(stdIn.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(stdIn.next());
        }

        quickSort(a, 0, n - 1);

        int i;
        for (i = 0; i < n - 1; i++) {
            if (a[i] == a[i + 1]) {
                System.out.println("NO");
                break;
            }
        }

        if (i == n - 1) {
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 50804