akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> H = new ArrayList<Integer>();
        ArrayList<Integer> W = new ArrayList<Integer>();
        int tempH, tempW;

        while (true) {
            tempH = sc.nextInt();
            tempW = sc.nextInt();

            if (tempH == 0 && tempW == 0)
                break;

            H.add(tempH);
            W.add(tempW);
        }

        for (int k = 0; k < H.size(); k++) {
            for(int i = 0; i < W.get(k); i++){
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < H.get(k) - 1; i++) {
                System.out.print("#");
                for (int j = 1; j < W.get(k) - 1; j++) {
                    System.out.print(".");
                }
                System.out.print("#");
                System.out.println();
            }
            for(int i = 0; i < W.get(k); i++){
                System.out.print("#");
            }
            System.out.println();
            System.out.println();
        }

        sc.close();
    }
}


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


int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	for(int i = 0; i < N; i++){
		cin >> p.at(i);
	}
	int counter = 0;
	for(int i = 0; i < N; i++){
		if(p.at(i) != i + 1){
			counter++;
		}
	}
	if(counter <= 2){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離

N = iin()
a = iln()
mi = a[0]
ans = 1
for i in range(1, N):
    if mi >= a[i]:
        ans += 1
    mi = min(mi, a[i])
print(ans)




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

using namespace std;

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

   vector<long long int> C(N);
   for(int i=0;i<N;i++){
       cin >> C[i];
   }

   for(int i=0;i<N;i++){
       vector<long long int> mx(N);

       mx[0] = C[i];
       long long int tmp = C[i];
       int now = P[i],count = 1;

       while(now != i && count < K){
           tmp += C[now];
           mx[count] = max(mx[count-1], tmp);
           now = P[now];
           count++;
       }

       if(tmp <= 0 || count == K){
           ans = max(ans,mx[count-1]);
       }else{
           if(mx[K%count] < 0){
               if(K%count==0){
                    ans = max({ans, (K/count)*tmp, (K/count - 1)*tmp + mx[count-1]});
               }else{
                    ans = max({ans, (K/count)*tmp, (K/count - 1)*tmp + mx[count-1]});
               }
           }else{
               if(K%count==0){
                    ans = max({ans, (K/count)*tmp, (K/count - 1)*tmp + mx[count-1]});
               }else{
                    ans = max({ans, (K/count)*tmp+ mx[K%count - 1], (K/count -1)*tmp + mx[count-1]});
               }
           }
       }
   }

   cout << ans << endl;
}

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;

    char ans = 'A';
    char res = 'a';
    while (true) {
        if (ans == 'A' && A.size() == 0) {
			break;
        }
        else if (ans == 'B' && B.size() == 0) {
			break;
        }
        else if (ans == 'C' && C.size() == 0) {
			break;
        }
      
        if (ans == 'A' && A.size() > 0) {
            res = A[0];
            A.erase(A.begin());
        }
        else if (ans == 'B' && B.size() > 0) {
            res = B[0];
            B.erase(B.begin());
        }
        else if (ans == 'C' && C.size() > 0) {
            res = C[0];
            C.erase(C.begin());
        }

        if (res == 'a') {
            ans = 'A';
        }
        else if (res == 'b') {
            ans = 'B';
        }
        else if (res == 'c') {
            ans = 'C';
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
nums = [int(x) for x in input().split()]

dp = [float('inf')] * N
rest = [0] * N
if nums[0] == 1:
    dp[0] = 0
    rest[0] = 1
else:
    dp[0] = 1
    rest[0] = 0

for i, num in enumerate(nums[1:], start=1):
    if rest[i - 1] + 1 == num:
        dp[i] = dp[i - 1]
        rest[i] = rest[i - 1] + 1
    else:
        dp[i] = dp[i - 1] + 1
        rest[i] = rest[i - 1]

if dp[-1] == N:
    print(-1)
else:
    print(dp[-1])

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

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

using namespace std;

int main(void){
    int N, K, count=0, height;
    cin>>N>>K;
    rep(i, N){
        cin >>height;
        if(height>=K) count++;
    }
    cout <<count <<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> Ds(N);
  int count = 0;
  
  for (int i = 0; i < N; i++)
    cin >> Ds.at(i);
  
  sort(Ds.begin(), Ds.end());
  
  if (Ds.at(N/2 - 1) != Ds.at(N/2))
    count = Ds.at(N/2) - Ds.at(N/2 - 1);
    
  cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,M; cin>>N>>M;
  vector<pair<int,int>>A(N);
  for(int i=0;i<N;i++){
    int a,b; cin>>a>>b;
    A[i].first=a;
    A[i].second=b;
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++){
    if(A[i].second>=M){cout<<A[i].first<<endl; return 0;}
    M-=A[i].second;
  }
}

Measured memory_bytes: 3992
n=int(input())
a=[int(input()) for i in range(n)]
num=1
res=False
time=1
for j in range(n-1):
    if a[num-1]==2:
        res=True
        time+=j
        break
    else:
        num=a[num-1]

if res:
    print(time)
else:
    print(-1)


Measured memory_bytes: 12932
#include <bits/stdc++.h>
using ll = long long;
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    int n; std::cin >> n;
    std::vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i] >> b[i];
    }
    ll answ = 0;
    for (int i = n-1; i >= 0; i--) {
        a[i] += answ;
        ll na = (a[i] + b[i] - 1) / b[i] * b[i];
        answ += na - a[i];
    }
    std::cout << answ << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
int a[100010];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = mod;
	loop(i, a[0], a[n - 1]+1) {
		int sum = 0;
		rep(j, n) {
			sum += (i- a[j]) * (i - a[j]);
		}
		if (sum < ans) {
			ans = sum;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, s, n, m) for(ll i = s; i < (ll)(n); i+=m)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        print(s);
    } else {
        print("red");
    }
    return 0;
}

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

int kaibun(vector<char> strr){
  int a=1;
  int n=strr.size();
  //cout<<n<<endl;

  for(int i=0;i<n;i++){
    if(strr.at(i)!=strr.at(n-1-i))
    {
      a=0; 
      //cout<<i<<endl;
      //cout<<strr.at(i)<<strr.at(n-1-i)<<endl;
      break;
    }
  }
  return a;
}
int main() {
  
  string s;
  
  int a=0,b=1,c=1;
  
  cin>>s;
  int n=s.size();
  vector<char> str(n);
  vector<char> str1((n-1)/2),str2((n-1)/2);
  
  for(int i=0;i<n;i++)
    str.at(i)=s.at(i);
  
  //for(int i=0;i<n;i++)
    //cout<<str.at(i);
  //cout<<endl;
  
  for(int i=0;i<(n-1)/2;i++){
    str1.at(i)=str.at(i);
  }
  for(int i=0;i<(n-1)/2;i++)
    str2.at(i)=str.at((n+3)/2-1+i);
  
  //for(int i=0;i<str1.size();i++)
    //cout<<str1.at(i);
  //cout<<endl;
  //for(int i=0;i<str2.size();i++)
    //cout<<str2.at(i);
  //cout<<endl;
  
  a=kaibun(str);
  b=kaibun(str1);
  c=kaibun(str2);
  
  if((a==1&&b==1)&&c==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  //cout<<a<<endl<<b<<endl<<c<<endl;
  
}

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

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

    for(int i=1; i<=50000; i++){
        int price = i * 1.08;
        if(price == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main() {
    int r,c;
    cin >> r >> c;

    int sheet[r+1][c+1];

    for (int i = 0; i <= r ; i++) {
        for (int j = 0; j <= c; j++) {
            sheet[i][j] = 0;
        }
    }

    for (int i = 0; i < r ; i++) {
        for (int j = 0; j < c ; j++) {
            int in;
            cin >> in;

            sheet[i][j] = in;
            sheet[i][c] += in;
            sheet[r][j] += in;
            sheet[r][c] += in;
        }
    }
    for (int i = 0; i <= r ; i++) {
        for (int j = 0; j <= c; j++) {
            cout << sheet[i][j];
            if (j != c)
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String[] SArray = S.split("");
		if(SArray[0].equals(SArray[1])) {
			System.out.println("Bad");
			}else if(SArray[1].equals(SArray[2])) {
					System.out.println("Bad");
				}else if(SArray[2].equals(SArray[3])) {
					System.out.println("Bad");
				}else {
					System.out.println("Good");
				}
		}

}

Measured memory_bytes: 23764
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   // int n,ans=inf;
   // cin>>n;
   // vector<int>a(n);
   // for(int i=0;i<n;i++)
   // {
   // 	cin>>a[i];
   // }
   int t;
   cin>>t;
   cout<<3*t*t<<endl;
}	

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 2, 0, -1):
    if h[i] - h[i + 1] >= 1:
        h[i] -= 1
for i in range(n - 1):
    if h[i + 1] < h[i]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 14396
#include <stdio.h>

int main(void){
    int K,X,min,max;
    scanf("%d %d",&K,&X);
    if(X-K+1>=-1000000) min=X-K+1;
    else min=-1000000;
    if(X+K-1<=1000000) max=X+K-1;
    else max=1000000;
    for(int i=min;i<=max;i++){
        printf("%d ",i);
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5, mo = 1e9 + 7 ;
using namespace std ;

bool vis[N] ;
int opt[N], d[N], sz[N], f[N], q[N] ;
int n, e, ter[N << 1], nxt[N << 1], lnk[N], fac[N], inv[N], sum_ave, sum_sz ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e, ++ d[x] ;
}

int mul(int a, int b) {
	int ans = 1, w = a % mo ;
	for ( ; b; b /= 2) {
		if (b & 1) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;
	}
	return ans ;
}

int C(int x, int y) {
	return (ll) fac[x] * inv[y] % mo * inv[x - y] % mo ;
}

void upd(int &x, int y) {
	x = (x + y) % mo ;
}

void dfs(int p, int las, int rt) {
	bool flg = true ;
	for (int i = lnk[p] ; i; i = nxt[i]) if (ter[i] != las && ter[i] != rt) dfs(ter[i], p, rt), flg = false ;
	if (flg) {
		sz[p] = f[p] = 1 ;
		return ;
	}
	f[p] = 1, sz[p] = 0 ;
	for (int i = lnk[p] ; i; i = nxt[i]) if (ter[i] != las && ter[i] != rt) {
		int v = ter[i] ;
		if (v < las) {
			f[p] = (ll) f[p] * C(sz[p] + sz[v], sz[v]) % mo * f[v] % mo ;
			sz[p] += sz[v] ;
		} else {
			sum_ave = (ll) sum_ave * C(sum_sz + sz[v], sz[v]) % mo * f[v] % mo ;
			sum_sz += sz[v] ;
		}
	}
	++ sz[p] ;
}

void solve(int x, int &_sz, int &ret) {
	int he = 0, ta = 1, tot = 0 ; ret = 0 ;
	q[1] = x, vis[x] = false ;
	for ( ; he != ta ; ) {
		int u = q[++ he] ;
		for (int i = lnk[u] ; i; i = nxt[i]) if (vis[ter[i]]) {
			vis[ter[i]] = false ;
			q[++ ta] = ter[i] ;
		}
	}
	q[0] = ta ;
	rep(i, 1, q[0]) {
		int u = q[i] ;
		for (int j = lnk[u] ; j; j = nxt[j]) ++ tot ;
	}
	if (tot != q[0] * 2) { ret = 0 ; return ; }
	he = 0, ta = 0 ;
	rep(i, 1, q[0]) if (d[q[i]] == 1) opt[++ ta] = q[i] ;
	for ( ; he != ta ; ) {
		int u = opt[++ he] ;
		for (int i = lnk[u] ; i; i = nxt[i]) {
			int v = ter[i] ;
			-- d[v] ;
			if (!d[v]) continue ;
			if (d[v] == 1) opt[++ ta] = v ;
		}
	}
	int k = 0, tmp[5] = {0} ;
	rep(i, 1, q[0]) if (q[i] > k && d[q[i]] > 1) k = q[i] ;
	for (int i = lnk[k] ; i; i = nxt[i]) if (d[ter[i]] > 1) tmp[++ tmp[0]] = ter[i] ;
	rep(i, 1, tmp[0]) {
		sum_ave = 1, sum_sz = 0 ;
		dfs(k, tmp[i], k) ;
		sum_ave = (ll) sum_ave * C(sum_sz + sz[k], sz[k]) % mo * f[k] % mo ;
		upd(ret, sum_ave) ;
	} 
	_sz = q[0] ;
}

int main() {
	scanf("%d", &n) ;
	int x, y ;
	rep(i, 1, n * 2) {
		scanf("%d%d", &x, &y) ;
		add(x, n + y), add(n + y, x) ;
	}
	n <<= 1 ;
	fac[0] = inv[0] = 1 ;
	rep(i, 1, n) fac[i] = (ll) fac[i - 1] * i % mo ;
	inv[n] = mul(fac[n], mo - 2) ;
	for (int i = n - 1 ; i ; -- i) inv[i] = (ll) inv[i + 1] * (i + 1) % mo ;
	int ans = 1, las = 0, _sz, ret ;
	rep(i, 1, n) vis[i] = true ;
	rep(i, 1, n) if (vis[i]) {
		solve(i, _sz, ret) ;
		ans = (ll) ans * ret % mo *  C(_sz + las, _sz) % mo ;
		las += _sz ;
	}
	printf("%d\n", ans) ;
	return 0 ;
}

Measured memory_bytes: 13056
#include <stdio.h>

int main(void)
{
  int a, b, c, tmp;

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

  for (int i=0; i<2; i++) {
    if (a > b) {
      tmp = a;
      a = b;
      b = tmp;
    } else if (b > c) {
      tmp = b;
      b = c;
      c = tmp;
    }
  }

  printf("%d\n", a+b);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int a,b,c;
    cin >> a >> b >> c;
    cout << max(0,c - (a-b)) << endl;

    return 0;
}

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

using lint = long long;

#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto &&i : n)

inline bool inside(int y, int x, int h, int w) { return 0 <= y && y < h && 0 <= x && x < w; }
const int dy[] = {0, 1, 0, -1}, dx[] = {1, 0, -1, 0};
struct PRE { PRE() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);} } _PRE;
// }}}

int n;
vector<lint> a;

signed main() {
  cin >> n;
  a = vector<lint>(n);
  rep(i, n) cin >> a[i];
  lint res = 0;
  lint sum = 0;
  rep(i, n) {
    if (a[i] == 0) {
      res += sum / 2;
      sum = 0;
      continue;
    }
    sum += a[i];
  }
  cout << res + sum / 2 << endl;
}


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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int N,K;
	cin >> N >> K;
    if(N%K == 0)cout << 0 << endl;
    else cout << 1 << endl;
}


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

int main(){
  int N;
  cin >> N;
  for(int i = 3; i > 0; i--){
    N = N % (10 * i);
  }
  if(N == 3){
    cout << "bon" << endl;
  }
  if(N == 0 || N == 1 || N == 6 || N == 8){
    cout << "pon" << endl;
  }
  if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9){
    cout << "hon" << endl;
  }
  return 0;
}


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

string S;
int main() {
	cin >> S;
	for(int i = 0; i < (int) S.length(); i++) {
		if(i%2 && S[i] == 'R') {
			printf("No\n");
			return 0;
		}
		if(i%2==0 && S[i] == 'L') {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,tong[300001],x,f[300001],s[300001];
inline bool cmp(const int &x,const int &y) {return x>y;}
int main()
{
	read(n);
	for(res i=1;i<=n;++i) read(x),++tong[x];
	sort(tong+1,tong+1+n,cmp);int p=1,now=1;
	s[n]=tong[n];for(res i=n-1;i;--i) s[i]=s[i+1]+tong[i];
	for(res i=n;i;--i) {
		for(;p<=n&&tong[p]>=i;++p);
		int sum=(p-1)*i+s[p];sum/=i;
		while(now<=sum) f[now++]=i;
	}
	for(res i=1;i<=n;++i) print(f[i],'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 4224
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;
const int MAX_HW = 1000;
int n, h, w, rat, s[2], g[2], flag[MAX_HW+1][MAX_HW][2];
int town[MAX_HW][MAX_HW];
char town2[MAX_HW][MAX_HW];
queue <P> que;
P p;
void bfs(int sy, int sx){
	que.push(P(sy, sx));
	flag[sy][sx][0]=rat;
	while (que.size()){
	RE:
		p = que.front();
		que.pop();
		for (int i = -1; i <= 1; i++){
			for (int j = -1; j <= 1; j++){
				if (i == 0 || j == 0){
					if (town2[p.first + i][p.second + j] != 'X'&&flag[p.first + i][p.second + j][0] != rat&&p.first + i < h&&p.first + i >= 0 && p.second + j < w&&p.second + j >= 0) {
							flag[p.first+i][p.second+j][0] = rat;
							flag[p.first + i][p.second + j][1] = flag[p.first][p.second][1] + 1;
							if (town[p.first + i][p.second + j] == rat){
							if (rat == n) return;
							rat++;
							flag[p.first+i][p.second+j][0] = rat;
							while (que.size()){
								que.pop();
							}
							que.push(P(p.first + i, p.second + j));
							goto RE;
						}
						else{
						que.push(P(p.first + i, p.second + j));
						}
					}
				}
			}
		}
	}
}
int main(){
	cin >> h >> w >> n;
	rat = 1;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> town2[i][j];
			town[i][j] = town2[i][j] - 48;
			if (town2[i][j] == 'S'){
				s[0] = i;
				s[1] = j;
			}
			if (town[i][j] == n){
				g[0] = i;
				g[1] = j;
			}
		}
	}
	bfs(s[0], s[1]);
	cout << flag[g[0]][g[1]][1] << endl;
	return 0;
}

Measured memory_bytes: 13916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble();
		System.out.printf("%.9f\n", Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
	}
}



Measured memory_bytes: 28272
using System;
using System.Linq;

namespace diverta2019ProgrammingContest
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            long sum = 0;
            for (long m = 1; m * m < N; ++m)
            {
                if (N % m == 0)
                {
                    var div = N / m;
                    if (1 < div && N / (div - 1) == N % (div - 1)) { sum += div - 1; }
                }
            }
            Console.WriteLine($"{sum}");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;

int ans[2005];

void bfs(const vector<vector<int>>& to, int s) {
  int n = to.size();
  vector<int> d(n, -1);
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (auto& u : to[v]) {
      if (d[u] != -1) continue;
      d[u] = d[v] + 1;
      q.push(u);
    }
  }
  rep(i, n) {
    ans[d[i]]++;
  }
}

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

  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;

  vector<vector<int>> to(n);
  rep(i, n-1) {
    to[i].push_back(i+1);
    to[i+1].push_back(i);
  }
  to[x].push_back(y);
  to[y].push_back(x);

  rep(i, n) bfs(to, i);

  for (int i = 1; i <= n-1; i++){
    cout << ans[i] / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 384
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


m=inp()
print(24 + 24-m)

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

int main(){
	string a;cin >> a;
	if((a.at(0)==a.at(1) && a.at(1)==a.at(2)) || (a.at(1)==a.at(2) && a.at(2)==a.at(3))) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  string s[n+1];
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;i++){
    cout<<s[i];
  }
  cout<<endl;
  return(0);
}

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

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

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'U') continue;
		else if (S[i] == 'D') continue;
		else {
			if (i % 2 != 0) {
				if (S[i] == 'L') continue;
			}
			else {
				if (S[i] == 'R') continue;
			}
		}

		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, d;
	cin >> n >> d;
	int x[n][d];
	REP(i, n){
		REP(j, d){
			cin >> x[i][j];
		}
	}
	double ans = 0;
	int cnt = 0;
	REP(i, n){
		REP(j, i){
			ans = 0;
			REP(k, d){
				ans += pow((x[i][k]-x[j][k]), 2);
			}
			ans = sqrt(ans);
			if (ans == (int)ans) cnt++;
		}
	}

	cout << cnt << endl;



}


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

const int N=2e5+1e3+7;

int n,vis[N],a[N],cnt,k;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(vis[a[i]]==0)
			cnt++;
		vis[a[i]]++;
	}
	if(cnt<=k)
	{
		puts("0");
		return 0;
	}
	sort(vis+1,vis+n+1);
	int ans=0;
	for(int i=n;i>=n-k+1;i--)
		ans+=vis[i];
	printf("%d",n-ans);
}

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

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

int main()
{
  int n, k, a[100000];
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int g = a[0], m = a[0];
  for(int i = 1; i < n; i++){
    g = gcd(g, a[i]);
    m = max(m, a[i]);
  }

  if(k%g == 0 and k <= m){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }


  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0;i < s.size()-1;++i) {
		if (s[i] == s[i + 1]) {
			if (s[i] == '1') {
				s[i + 1] = '0';
				++cnt;
			}
			else {
				s[i + 1] = '1';
				++cnt;
			}
		}
	}
	cout << cnt << "\n";

	return 0;
}

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

using namespace std;

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

	int sum = 0;
	int j = 0;
	while(j < N) {
		int k = 0;
		while(A[k + j] == A[j] && k + j < N) k++;
		sum += k % 2;
		j += k;
	}

	cout << sum << endl;

	return 0;
}




Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
string l;
mint dp[100010][3][2];
int main()
{
  cin >> l;

  dp[0][0][0].x = 1;

  int ls = l.size();

  rep(i,ls) rep(j,3) rep(k,2){
    int li = l[i] - '0';
    rep(jj,((li||k)?3:1)){
      dp[i+1][jj][k||jj<li] += dp[i][j][k];
    }
  }

  mint res;

  rep(j,3) rep(k,2) res += dp[ls][j][k];

  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 5120
n = int(input())
h = [int(x) for x in input().split()]
h.reverse()
flag = True


def Back(x):
    x = x - 1
    return x


for i in range(1,n):
    if h[i] > h[i-1]:
        h[i] = Back(h[i])
        if h[i] > h[i-1]:
            flag = False
            break
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14396
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

bool is_prime(int a) {
	int now = 2;
	while (now*now <= a) {
		if (a%now == 0)return 0;
		else now++;
	}
	return 1;
}


int main() {
	while (cin >> n) {
		ll ans = 0;
		bool a[1000001];
		for (int i = 0; i < 1000001; i++)a[i] = 0;
		for (int i = 2; i <= n; i++) {
			if (a[i] != 1)ans++;
			for (int j = i; j <= n; j += i) {
					a[j] = 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
const int INF=1000010000;
typedef long long ll;
int main() {
  int n,W;cin >> n >> W;
  vector<ll> w(n),v(n);
  for(int i=0; i<n; i++) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
  for(int i=1; i<=n; i++){
    for(int j=0; j<=W; j++){
      if(j-w[i-1]>=0) dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  cout << dp[n][W] << endl;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef pair<int, int> P;

int main(){
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if(x == 1) ans += 300000;
  if(x == 2) ans += 200000;
  if(x == 3) ans += 100000;
  if(y == 1) ans += 300000;
  if(y == 2) ans += 200000;
  if(y == 3) ans += 100000;
  
  if(x == 1 && x == y) ans += 400000;
  
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
string = gets.chomp.split("")
answer = "AC"

if string.first == "A" && string.slice(1) == string.slice(1).downcase
  string = string.slice(2...string.length)
  cnt = 0
  idx = []

  string.each_with_index do |s, index|
    if s == "C" && index != string.length-1
      cnt += 1
      idx.push(index)
    end
  end
  
  if cnt == 1 && !idx.empty?
    string.delete_at(idx.first)
    new_string = []

    string.each_with_index do |s, index|
      new_string.push(s.downcase)
    end
    answer = "WA" unless string == new_string
  else
    answer = "WA"
  end
else
  answer = "WA"
end

puts answer

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int ans = -1;
    if (B < C || D < A) {cout << 0 << endl; return 0;}
    FOR(i, min(A, C), max(B, D) + 1) {
        if (A <= i && i <= B && C <= i && i <= D) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
public class Main {
  private static void solve() {
    char[] s = ns();
    char[] t = ns();
    int n = s.length;
    int m = t.length;
    
    int found = -1;
    for (int i = 0; i < n - m + 1; i ++) {
      boolean ng = false;
      for (int j = 0; j < m; j ++) {
        if (s[i + j] != '?' && s[i + j] != t[j]) {
          ng = true;
          break;
        }
      }
      if (!ng) {
        found = i;
      }
    }
    
    if (found >= 0) {
      for (int i = 0; i < m; i ++) {
        s[i + found] = t[i];
      }
      for (int i = 0; i < n; i ++) {
        if (s[i] == '?') s[i] = 'a';
      }
      System.out.println(s);
    } else {
      System.out.println("UNRESTORABLE");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n, w;
int main(){
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for(int i = 0; i < n; i++)cin  >> value[i] >> weight[i];
	ll dp[n+1][w+1];
	for(int i = 0; i < n+1; i++){
		for(int j = 0; j < w+1; j++){
			dp[i][j] = 0;
		}
	}
	for(int i = 0; i < n; i++){ // 品物の数
		for(int j = 0; j < w+1; j++){ // 重さの数
			for(int k = 0; k < i+1; k++){
				if(j - weight[k] >= 0){
					ll tmp = dp[i+1][j - weight[k]] + value[k];
					// printf("dp[%d+1][%d] = max(%d, %d) \n", i,j,tmp, dp[i][j]);
					dp[i+1][j] = max(tmp, dp[i][j]);
				} else {
					dp[i+1][j] = dp[i][j];
				}
			}
		}
	}
	// for(int i = 0; i < n+1; i++){
	// 	// cout << i << ":\t";
	// 	for(int j = 0; j < w+1; j++){
	// 		// cout << dp[i][j] << "\t";
	// 	}
	// 	// cout << endl;
	// }

	cout << dp[n][w] << endl;

}


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int n, k;
    read(n, k);
    
    vt<ar<int, 2>> v(n);
    FOR(n) {
        read(v[i][0], v[i][1]);
    }
    sort(all(v));
    
    
    int cnt = 0;
    FOR(n) {
        cnt += v[i][1];
        if (cnt >= k) {
            print(v[i][0]);
            return;
        }
    }
    
    
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        
        solve();
        
    }
    
}



Measured memory_bytes: 4772
#include <iostream>

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int ans=0;
  if(A==B&&B==C){
    if(A%2==0&&B%2==0&&C%2==0){
      cout<<-1<<endl;
      return 0;
    }
    else{
      cout<<0<<endl;
      return 0;
    }
  }
  int i=0;
  for(;A%2==0&&B%2==0&&C%2==0;i++){
    int a=A;
    int b=B;
    int c=C;
    A=0;
    B=0;
    C=0;
    A=b/2+c/2;
    B=a/2+c/2;
    C=a/2+b/2;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string s,s1,s2;
    cin >> s;
    ll ans,i;
    for(i=1;i<s.size()/2;i++){
      s1=s.substr(0,i);
      s2=s.substr(i,i);
      if(s1==s2)ans=i*2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
    int n, cnt=0; cin >> n;
    vector<int>a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    for(int i=0; i<n; i++){
        if(i%2==0 && a[i]%2==1) cnt++;
    }

    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 3640
# Area of Polygon

from math import sin
from math import radians

while True:
    m = int(raw_input())
    if m == 0:
        break

    a1, v, vv = (0.0, 0, 0)
    for i in range(m):
        if i < m - 1:
            v = int(raw_input())
            vv += v
        else:
            v = 360 - vv
        a1 += sin(radians(v)) * 10

    n = int(raw_input())

    a2, v, vv = (0.0, 0, 0)
    for i in range(n):
        if i < n - 1:
            v = int(raw_input())
            vv += v
        else:
            v = 360 - vv
        a2 += sin(radians(v)) * 10

    if a1 > a2:
        print 1
    elif a1 < a2:
        print 2
    else:
        print 0

Measured memory_bytes: 4440
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
dp = [0]*(n+1)
mod = 10**9+7
dp[0] = 1
dp[1] = int(1 not in a)
for i in range(2,n+1):
  if i in a:
    continue
  dp[i] = (dp[i-1] + dp[i-2])%mod
print(dp[n])


Measured memory_bytes: 13216
#!/usr/bin/python3
# -*- coding: utf-8 -*-
x, y = map(int, input().split())
total = 0
if x == 1 and y == 1:
    total += 400000
if x == 1:
    total += 300000
elif x == 2:
    total += 200000
elif x == 3:
    total += 100000
if y == 1:
    total += 300000
elif y == 2:
    total += 200000
elif y == 3:
    total += 100000

print(total)

Measured memory_bytes: 3064