akhauriyash/Code-Regression huggingface dataset:
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

vi adj[200005];
int dp[200005];
int ans[200005];
bool vis[200005] = {false};

void dfs(int v){
    for(int x:adj[v]){
        if(!vis[x]){
            vis[x] = true;
            ans[x] = ans[v] + dp[x];
            dfs(x);
        }
    }
}
 
signed main()
{
    tezz
    
    int n,q;
    cin>>n>>q;

    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;

        adj[a].pb(b);
        adj[b].pb(a);
    }

    for(int i=0;i<q;i++){
        int p, x;
        cin>>p>>x;

        dp[p] += x;
    }
    // for(int i=1;i<=n;i++) cout<<dp[i]<<' ';
    //     cout<<endl;

    vis[1] = true;
    ans[1] = dp[1];
    dfs(1);

    for(int i=1;i<=n;i++) cout<<ans[i]<<' ';
} 

Measured memory_bytes: 22656
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int a = ni();
		int b = ni();
		int c = ni();
		int d = ni();

		for (;;) {
			c -= b;
			if (c <= 0) {
				out(Y);
				break;
			}
			a -= d;
			if (a <= 0) {
				out(N);
				break;
			}
		}

	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


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

capa_list = [int(input()) for i in range(5)]

min_num = min(capa_list)
min_index = capa_list.index(min(capa_list))


hoge = 0 if n%min_num == 0 else 1

t = (min_index) + (n//min_num + hoge) + (len(capa_list[min_index+1:]))

print(t)


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

using namespace std;
typedef map<int, int> mii;

bool check(mii mp) {
    mii::iterator it;
    for (it = mp.begin(); it != mp.end(); it++)
        if ((*it).first != (*it).second) return false;
    return true;
}

int main(void) {
    int n, s[110];
    while (cin >> n, n) {
        int ans = 0;
        mii mp, pre;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            mp[s[i]]++;
        }
        
        while (!check(mp)) {
            ans++;
            pre = mp;
            mp.clear();
            for (int i = 0; i < n; i++) {
                s[i] = pre[s[i]];
                mp[s[i]]++;
            }
        }

        cout << ans << endl;
        for (int i = 0; i < n; i++) {
            if (i) cout << " ";
            cout << s[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 2980
#include <iostream>
#include <deque>
#include <utility>
#include <stdio.h>
#define llint long long
#define eps 1e-9

using namespace std;
typedef pair<double, llint> P;

llint n, L;
deque<P> deq;
double T, V;

int main(void)
{
	cin >> n >> L;
	
	llint t, v;
	cin >> t >> v;
	T = t, V = v;
	deq.push_back(make_pair(t, v));
	printf("%.11f\n", T);
	
	for(int i = 2; i <= n; i++){
		cin >> t >> v;
		
		double dt, dv;
		while(V+v > L + eps){
			dt = deq.front().first;
			if(deq.front().second < V+v-L){
				dv = deq.front().second;
				deq.pop_front();
			}
			else{
				dv = V+v-L;
				P p = deq.front();
				deq.pop_front();
				p.second -= dv;
				deq.push_front(p);
			}
			T = (T*V-dt*dv) / (V-dv);
			V = V-dv;
			//cout << "* " << T << " " << V << " " << dt << " " << dv << endl;
		}
		
		double tt = t, vv = v;
		while(deq.size()){
			P p = deq.back();
			if(p.first > tt){
				deq.pop_back();
				tt = (p.first*p.second+tt*vv) / (p.second+vv);
				vv = p.second + vv;
			}
			else break;
		}
		deq.push_back(make_pair(tt, vv));
		T = (T*V+t*v) / (V+v);
		V = V+v;
		
		printf("%.11f\n", T);
	}
	
	return 0;
}

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int64> B(N - 1);
    rep(i, N - 1) B[i] = A[i] + A[i + 1];
    int id = max_element(B.begin(), B.end()) - B.begin();
    if(B[id] < L) {
        cout << "Impossible" << '\n';
    } else {
        cout << "Possible" << '\n';
        rep(i, id) cout << i + 1 << '\n';
        for(int i = N - 1; i >= id + 1; --i) cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,tmp=0;
    cin >> n;
    vll h(n);
    rep(i,n) cin >> h[i];
    rep(i,n){
        tmp=max(tmp,h[i]);
        if(tmp-h[i+1]>1 && i!=n-1){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long s[110000];
int pr[110000];
long long p[3][110000];
int main(){
	int a;scanf("%d",&a);
	pr[0]=pr[1]=-1;
	int sz=0;
	for(int i=2;i<110000;i++){
		if(pr[i]==0){
			pr[i]=1;
			for(int j=i+i;j<110000;j+=i){
				pr[j]=-1;
			}
			p[0][sz]=i;
			p[1][sz]=(long long)i*i;
			p[2][sz]=(long long)i*i*i;
			sz++;
		}
	}
	int ret=0;
	for(int i=0;i<a;i++){
		scanf("%lld",s+i);
		for(int j=0;j<sz;j++){
			if(s[i]<p[2][j])break;
			while(s[i]%p[2][j]==0)s[i]/=p[2][j];
		}
		if(s[i]==1)ret=2;
	}
	std::sort(s,s+a);
	for(int i=0;i<a;i++){
		if(s[i]==1||(i&&s[i]==s[i-1]))continue;
		long long tg=1;
		long long tmp=s[i];
		for(int j=0;p[2][j]<=10000000000LL;j++){
			if(tmp%p[1][j]==0){
				tg*=p[0][j];
				tmp/=p[1][j];
			}else if(tmp%p[0][j]==0){
				tg*=p[1][j];
				tmp/=p[0][j];
			}
			if(tg>10000000000LL){
				tg=0;break;
			}
		}
		if(tmp>1){
			int at=lower_bound(p[1],p[1]+sz,tmp)-p[1];
			int at2=lower_bound(p[0],p[0]+sz,tmp)-p[0];
			if(p[1][at]==tmp){
				tg*=p[0][at];
			}else if(p[0][at2]==tmp){
				if(tg<20000000000LL/p[1][at2])tg*=p[1][at2];
				else tg=0;
			}else{
				tg=0;
			}
		}
		int L=upper_bound(s,s+a,s[i])-lower_bound(s,s+a,s[i]);
	//	printf("%lld %lld %d\n",s[i],tg,L);
		
		if(tg==0){
			ret+=L*2;continue;
		}
		int R=upper_bound(s,s+a,tg)-lower_bound(s,s+a,tg);
		if(R==0){
			ret+=L*2;continue;
		}
		ret+=max(L,R);
	}
	ret/=2;
	printf("%d\n",ret);
}

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

int main() {
	
	int a;
	int b;
	cin >> a;
	cin >> b;
	if((a == 1) && (b == 2) || (a == 2) && (b == 1))
	{
	    cout << 3;
	}
	else if((a == 1) && (b == 3) || (a == 3) && (b == 1))
	{
	    cout << 2;
	}
	else if((a == 2) && (b == 3) || (a == 3) && (b == 2))
	{
	    cout << 1;
	} 
	return 0;
}


Measured memory_bytes: 256
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"NO";
	else
	cout<<"YES";
}

ll n, a[mx][3], dp[mx][3];

ll dya(ll x, ll y){

	ll i, j;

	if(x == n)
	return 0;

	if(dp[x][y] != -1)
	return dp[x][y];

	ll ans = -1;
	rep(j, 0, 3){

		if(j!= y){

			ans= max(ans,a[x][j]+ dya(x+1, j));
		}
	}

	return (dp[x][y] = ans);

}
void bta_de_yarr(){

	ll i, j, fl=0, ans, m;
	// ll a[mx];
	cin>>n;

	rep(i, 0, n){

		rep(j, 0, 3)
		{
			cin>>a[i][j];
			dp[i][j]= -1;
		}
	}

	ans= max(dya(0, 0), max(dya(0, 1), dya(0, 2)));
	// cin>>m;

	
	cout<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 16256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 10000000
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
typedef vector<int> v;
typedef vector<int, int> v2;
typedef vector< pair<int, int> > vp;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };


int main(){
	ios::sync_with_stdio(false);
	int n = 0;

	cin >> n;
	while (n != 0){
		int maxp = INT_MIN, minp = INT_MAX;
		
		for (int i = 0; i < n; i++){
			int sum = 0;
			for (int j = 0; j < 5; j++){
				int tmp;
				cin >> tmp;
				sum += tmp;
			}
			maxp = max(maxp, sum);
			minp = min(minp, sum);
		}

		cout << maxp << " " << minp << endl;

		cin >> n;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int MAX=1000;

int LCS(string X, string Y) {
    int i, j, maxl=0;
    int C[MAX+1][MAX+1];

    int X_len = X.size();
    int Y_len = Y.size();
    X = ' ' + X;
    Y = ' ' + Y;
    for (i=0; i<=X_len; i++) C[i][0]=0;
    for (j=1; j<=Y_len; j++) C[0][j]=0;

    for (i=1; i<=X_len; i++) {
        for (j=1; j<=Y_len; j++) {
            if (X[i]==Y[j]) {
                C[i][j]=C[i-1][j-1]+1;
                maxl = max(C[i][j], maxl);
            } else C[i][j]=max(C[i-1][j], C[i][j-1]);
        }
    }

    return maxl;
}

int main() {
    int n, i;
    string X, Y;
    
    cin >> n;
    for (i=0; i<n; i++) {
        cin >> X >> Y;
        cout << LCS(X, Y) << endl;
    }

    return 0;
}


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

using namespace std;

#define int long long

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

signed main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> acd(n, 0);
  vector<int> p(n, 0);
  for (int i = 0; i < m; ++i) {
    int j;
    cin >> j;
    string res;
    cin >> res;
    if (res == "AC") {
      acd[j - 1] = 1;
    } else {
      if (!acd[j - 1]) { p[j - 1]++; }
    }
  }

  int pn = 0;
  for (int i = 0; i < n; ++i) {
    if (acd[i]) { pn += p[i]; }
  }

  // cout << accumulate(acd.begin(), acd.end(), 0) << " " << accumulate(p.begin(), p.end(), 0) << endl;
  cout << accumulate(acd.begin(), acd.end(), 0) << " " << pn << endl;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       int x=s.nextInt(),y=s.nextInt();
       int res=0;
       if(x==1){res+=300000;}
       else if(x==2){res+=200000;}
        else if(x==3){res+=100000;}
        if(y==1){res+=300000;}
       else if(y==2){res+=200000;}
        else if(y==3){res+=100000;}
        if(x==1&&y==1){res+=400000;}
        System.out.println(res);
        }
    }


Measured memory_bytes: 21844
import copy
H, W = map(int, input().split())
s = []
for _ in range(H):
    s.append(list(input()))
ans = copy.deepcopy(s)
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            continue
        c = 0
        for dx in [-1, 0, 1]:
            for dy in [-1, 0, 1]:
                if 0 <= dy + i < H and 0 <= dx + j < W:
                    if s[i+dy][j+dx] == '#':
                        c += 1
                else:
                    continue
        ans[i][j] = str(c)
for a in ans:
    print("".join(a))

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

int i;

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

long long stringToInt(string s) {
    int ret = 0;
    int p = 1, i = 0;
    rep(i, s.length()) {
        ret += p*charToInt(s[i]);
        p *= 5;
    }

    return ret;
}

#define HASH_VALUE 1046527
string dic[HASH_VALUE];

int hash1(int key) {
    return key % HASH_VALUE;
}

int hash2(int key) {
    return 1 + (key % (HASH_VALUE-1));
}

void insert(string s) {
    long long key = stringToInt(s);
    long long i, h;
    for (i=0; ; i++) {
        h = (hash1(key) + i * hash2(key)) % HASH_VALUE;

        if (dic[h] == s) {
            return; // 既に辞書に入れている
        } else if (dic[h].length() == 0) {
            dic[h] = s;
            return;
        }
    }
}

bool find(string s) {
    long long key = stringToInt(s);
    long long i, h;
    for (i=0; ; i++) {
        h = (hash1(key) + i * hash2(key)) % HASH_VALUE;

        if (dic[h] == s) return true;
        else if (dic[h].length() == 0) return false;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    rep(i, HASH_VALUE) dic[i] = "";
    char how[6], str[14];
    rep(i, n) {
        scanf("%s %s", how, str);
        if (how[0] == 'i') {
            insert(str);
        } else { // find
            if (find(str))
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 24336
# include <iostream>
# include <algorithm>
# include <vector>
# include <functional>

int t;
int n, k;
std::vector<int> input;
std::vector<int> x;
int a;
unsigned long long sum = 0;
unsigned long long s = 0;

int main() {
	std::cin >> t;
	for (int j = 0; j < t; ++j) {
		input.clear();
		x.clear();
		sum = 0;
		s = 0;
		std::cin >> n >> k;
		for (int i = 0; i < n; ++i) {
			std::cin >> a;
			input.push_back(a);
		}
		if (n == 1)
			std::cout << 0 << std::endl;
		else if (n <= k)
			std::cout << 0 << std::endl;
		else {
			std::sort(input.begin(), input.end());
			for (int i = 1; i < input.size(); ++i) {
				x.push_back(input[i] - input[i - 1]);
			}
			s = input[input.size() - 1] - input[0];
			std::sort(x.begin(), x.end(), std::greater<int>());
			for (int i = 0; i < k - 1; ++i) {
				sum += x[i];
			}
			s -= sum;
			std::cout << s << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2120
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    dict = {}
    for i in range(1, 5):
        dict[i] = 0
    for i in range(3):
        input_raw = read_func().strip().split()
        [a, b] = [long(input_raw[0]), long(input_raw[1])]
        dict[a] += 1
        dict[b] += 1

    max_n = 0
    for n  in dict:
        max_n = max(dict[n], max_n)

    if max_n >= 3:
        print "NO"
    else:
        print "YES"


if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
k, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
max = 0
a.each_with_index do |ai, idx|
  if idx == n - 1
    td = k + a[0] - ai
  else
    td = a[idx+1] - ai
  end
  max = [max, td].max
end
puts k - max

Measured memory_bytes: 19332
# -*- coding: utf-8 -*-

# input
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

# solve
right = 0
left = 0

for i in range(len(A)):
    if (A[i] > X):
        right += 1
    if (A[i] < X):
        left += 1

if (right < left):
    print(right)
else:
    print(left)


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

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;ll k;
  cin>>n>>k;
  ll a,b;
  pair<ll,ll> p[n];
  rep(i,n){
    cin>>a>>b;
    p[i]=make_pair(a,b);
  }
  sort(p,p+n);
  ll cnt=0;
  rep(i,n){
    cnt+=p[i].second;
    //cout<<cnt<<endl;
    if(cnt>=k){
      cout<<p[i].first<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        
        for(int i=0; i<n; i++){
            h -= sc.nextInt();
        }
        
        System.out.println(h<=0?"Yes":"No");
    }
}

Measured memory_bytes: 46968
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int n,ans=-1,c=0;
    cin>>n;
    vector<int>a(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[c]==2){
            ans=i+1;
            break;
        }
        else{
            c=a[c]-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7188
#include<cstdio>
#define rnt re int
#define re register
#define V inline void
#define FOR(i,a,b) for(rnt i=a;i<=b;i++)
#define ROF(i,a,b) for(rnt i=a;i>=b;i--)
const int N=2e5+1,mod=998244353;
int n,m,ans,f[N];char a[N];
V check(int&x){x-=mod,x+=x>>31&mod;}
int main(){
	scanf("%d %s",&n,a);
	FOR(i,1,n)if((i&1)&&(n%i==0)){
		m=n/i;rnt flag=1;
		FOR(j,0,m-1)check(f[i]=f[i]<<1|a[j]-'0');
		FOR(j,m,n-1)if(a[j]!=(a[j%m]^(j/m&1))){
			flag=a[j]>(a[j%m]^(j/m&1));break;
		}check(f[i]+=flag);
	}
	ROF(i,n,1)FOR(j,2,n/i)check(f[i]+=mod-f[i*j]);
	FOR(i,1,n)check(ans+=2ll*n/i*f[i]%mod);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 768
import Queue
dic = {
        'rg':'b', 'gr':'b',
        'gb':'r', 'bg':'r',
        'br':'g', 'rb':'g',
        }
while True:
    s = raw_input()
    if s=='0':
        break
    que = Queue.PriorityQueue()
    l = len(s)
    cost = {}
    cost[s] = 0
    que.put((0, s))
    ans = -1
    while not que.empty():
        nn, ss = que.get()
        if all(e == ss[0] for e in ss):
            ans = nn
            break
        if cost[ss] < nn:
            continue
        for i in xrange(l-1):
            cc = ss[i:i+2]
            if cc[0]!=cc[1]:
                code = dic[cc]
                sa = ss[:i] + code*2 + ss[i+2:]
                if sa not in cost or nn+1 < cost[sa]:
                    cost[sa] = nn+1
                    que.put((nn+1, sa))
    print "NA" if ans<0 else ans

Measured memory_bytes: 6752
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <iterator>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	const int m = n * 2;
	vector<int> pos(m), inv(m), a(n), b(n);
	for(int i = 0, j = 0, k = 0; i < m; ++i){
		if(s[i] == 'a'){
			a[j] = i;
			pos[i] = j++;
		}else{
			b[k] = i;
			pos[i] = k++;
		}
	}
	for(int i = 0; i < m; ++i){
		if(s[i] == 'a'){
			inv[i] = b[pos[i]];
		}else{
			inv[i] = a[pos[i]];
		}
	}
	set<int> current_marks;
	vector<char> current_string;
	for(int current_state = 0; current_state < m; ){
		bool accept = false;
		for(int c = 'b'; c >= 'a'; --c){
			auto marks = current_marks;
			auto target = current_string;
			int state = current_state, done = target.size();
			target.push_back(c);
			while(state < m && done < target.size()){
				if(inv[state] > state){
					if(s[state] == target[done]){
						marks.insert(state);
						++done;
					}
					++state;
				}else if(marks.find(inv[state]) != marks.end()){
					if(s[state] == target[done]){
						marks.insert(state);
						++state;
						++done;
					}else{
						int rollback = inv[state];
						auto it = marks.end();
						while(it != marks.begin() && *prev(it) >= rollback){
							const int p = *(--it);
							if(inv[p] < p){ rollback = min(rollback, inv[p]); }
							if(inv[p] <= state){ marks.erase(it++); }
						}
						++state;
						done = marks.size();
					}
				}else{
					++state;
				}
			}
			if(done == target.size()){
				current_state = state;
				current_marks = move(marks);
				current_string = move(target);
				accept = true;
				break;
			}
		}
		if(!accept){ break; }
	}
	current_string.push_back('\0');
	cout << current_string.data() << endl;
	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 100003, M = N << 1;

int n, k;
int a[N], b[N];
int tot, head[N], ver[M], nxt[M];
char s[N];

inline void add(int u, int v)
{
    ver[++tot] = v, nxt[tot] = head[u], head[u] = tot;
}

int main()
{
    n = gi(), k = gi();
    for (int i = 1; i <= n; i+=1) a[i] = gi();
    for (int i = 1; i <= k; i+=1)
    {
        int u = gi(), v = gi();
        add(u, v), add(v, u);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i+=1)
    {
        bool fl = true;
        for (int j = head[i]; j; j = nxt[j])
        {
            int v = ver[j];
            if (a[v] >= a[i]) {fl = false; break;}
        }
        if (fl) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

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

	int cnt[200001] = {0};
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		cnt[a]++;
	}

	vector<int> v;
	for (int i = 1; i <= 200000; i++){
		if(cnt[i] > 0)
			v.push_back(cnt[i]);
	}
	sort(v.begin(), v.end());
	int len = v.size();
	int ans = 0;
	for(int i = 0; i < len-k; i++){
		ans += v[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    int a[n][3];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        cin>>a[i][j];
    }
    int s=0,b=1,h=2;
    int dp1[n],dp2[n],dp3[n];
    dp1[0]=a[0][s];
    dp2[0]=a[0][b];
    dp3[0]=a[0][h];
    for(i=1;i<n;i++)
    {
        dp1[i]=a[i][s]+max(dp2[i-1],dp3[i-1]);
        dp2[i]=a[i][b]+max(dp1[i-1],dp3[i-1]);
        dp3[i]=a[i][h]+max(dp2[i-1],dp1[i-1]);
    }
    cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
    return 0;
}


Measured memory_bytes: 2560
import copy
n,k,*A = map(int,open(0).read().split())
for _ in range(min(50,k)):
    B = [0] * (n+1)
    for i,d in enumerate(A):
        start = max(0,i-d)
        B[start] += 1
        end = min(n,i+d+1)
        B[end] -= 1
    light = 0 
    for i,b in enumerate(B[:n]):
        light += b
        A[i] = light

print(*A)


Measured memory_bytes: 172336
#include <iostream>
using namespace std;
void arraycout(int *arrayy,int n){
    for(int u=0;u<n;u++){//出力
        if(u==n-1){
            cout<<arrayy[u]<<endl;
        }else{
            cout<<arrayy[u]<<' ';
        }
    }
    
}


void insertionSort(int* sou,int n){//挿入ソート
    for(int i=0;i<n;i++){
        int v=sou[i];
        int j=i-1;
        while(j>=0&&v<sou[j]){
            sou[j+1]=sou[j];
            j--;
        }
        sou[j+1]=v;
        arraycout(sou,n);
    }
}
int Bubble1(int* sou,int n){
    int flag=1;
    int ans=0;
    while(flag){
        flag=0;
        for(int i=n-1;i>0;i--){
            if(sou[i]<sou[i-1]){
                flag=1;
                swap(sou[i],sou[i-1]);
                ans++;
            }
        }
    }
    return ans;
    
}
int Bubble(int* sou,int n){
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=i+1;j--){
            if(sou[j]<sou[j-1]){
                ans++;
                swap(sou[j],sou[j-1]);
            }
        }
    }
    return ans;
}
int main(){
    
    int n;
    cin>>n;
    int sou[n];
    for(int i=0;i<n;i++){
        cin>>sou[i];
    }
  //  int ans=Bubble(sou,n);
   // arraycout(sou,n);
    //cout<<ans<<endl;
    insertionSort(sou,n);
    // arraycout(sou,n);
    
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n,s,m[10];

int f(int n,int s,int m){
	if(n==1){
		if(s<m)return 1;
		else return 0;
	}
	int t=0;
	for(int i=0;i<=s&&i<m;i++)t+=f(n-1,s-i,i);
	return t;
}

int main() {
	while(cin>>n>>s){
		if(n+s==0)return 0;
		cout<<f(n,s,10)<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

const int mod = 1000000007; // 998244353;
struct mint {
  long long x;
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { return mint(-x); }
  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 {
    return mint(*this) += a;
  }
  mint operator-(const mint& a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint& a) const {
    return mint(*this) *= a;
  }
  mint pow(long long 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 {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

mint dp[1009][1009];

int main(){
  int h,w;
  cin>>h>>w;
  vector<string>a(h);
  rep(i,h)cin>>a[i];
  dp[0][1]=1;
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#')continue;
      dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1];
    }
  }
  cout<<dp[h][w]<<endl;
  return(0);
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

// int right[100005];

int gcd(int a,int b){
  if(a<b)swap(a,b);
  int c=a%b;
  // cout<<c<<endl;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}

int main(){
  int n; cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> left(n);
  vector<int> right(n);

  left[0]=a[0];
  for(int i=0;i<n-1;i++){
    left[i+1]=gcd(a[i+1],left[i]);
  }
  right[n-1]=a[n-1];
  for(int i=n-1;0<i;i--){
    right[i-1]=gcd(a[i-1],right[i]);
  }
  int ans=-1;
  rep(i,n){
    if(i==0)
    ans=max(ans,right[i+1]);
    else if(i==n-1)
    ans=max(ans,left[i-1]);
    else
    ans=max(ans,gcd(right[i+1],left[i-1]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

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

	cin >> a >> b >> c;

if(a > b && a > c){
	cout << b+c << endl;
}

else if(b > a && b > c){
	cout << a+c << endl;
}

else if(c > a && c > b ){
	cout << a + b << endl;
}

else{
	cout << a+b << endl;
}

return 0;


}

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

using ll = long long;
const int INF = 1e9 + 1;

int main() {

	int x;
	cin >> x;

	for (int i = x;; i++) {
		bool flag = true;
		for (int j = 2; j <= sqrt(i); j++) {
			if (i % j == 0) {
				flag = false;
				break;
			}
		}

		if (flag) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
 
typedef long long ll;
const int N = 102;

int n;
int a[N];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	int mx = 0;
	int mn = n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a[x]++;
		mx = max(mx,x);
		mn = min(mn,x);
	}
	
	if(mx &1){
		if(a[(mx+1)/2] != 2){
			cout<<"Impossible";
			return 0;
		}
	}else{
		if(a[mx/2] != 1){
			cout<<"Impossible";
			return 0;
		}
	}
	if(mn < (mx+1)/2){
		cout<<"Impossible";
		return 0;
	}
	
	for(int i=mn+1;i<=mx;i++){
		if(a[i] < 2){
			cout<<"Impossible";
			return 0;
		}
	}
	
	cout<<"Possible";
	
	return 0;
}


Measured memory_bytes: 3652
n,k=map(int,input().split())
flag=False
key=0

if n<k: l=n
else: l=k-1

for i in range(l):
    cnt=1
    tmp=(i+1)*2
    while flag==False:
        if k<=tmp:
            break
        tmp*=2
        cnt+=1
    key+=1/n*1/2**cnt


if k<=n:
    key+=1/n*(n-k+1)

print(key)

Measured memory_bytes: 3064
n = input()
n += "-"
_max = 0
count = 1
for i in range(1, len(n)):
    # print(n[i])
    if n[i] == n[i-1]:
        count += 1
    else:
        _max = max(_max, count)
        count = 1
if _max >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  vec a(3);
  for(ll i=0;i<3;i++) cin >> a[i];
  sort(a.rbegin(),a.rend());
  cout << a[0]*10+a[1]+a[2] << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    X = int(input())

    if X <= 599:
        print(8)
    elif X <= 799:
        print(7)
    elif X <= 999:
        print(6)
    elif X <= 1199:
        print(5)
    elif X <= 1399:
        print(4)
    elif X <= 1599:
        print(3)
    elif X <= 1799:
        print(2)
    else:
        print(1)


if __name__ == "__main__":
    main()


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

int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;

    while (1)
    {
        if (n / k != 0)
        {
            ans++;
        }
        else
        {
            break;
        }
        n /= k;
    }

    cout << ans << endl;
}

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

int main(){
	double r;
	int n;
	while(cin>>r>>n, r!=0){
		vector<double> x(50,0);
		for(int i=0;i<n;i++){
			int L,R;
			double h;	cin>>L>>R>>h;
			L+=20;	R+=20;
			for(int j=L; j<R;j++)x[j]=max(x[j],h);
		}

		/*
		   (memo)
		   x^2 + (y-r+t)^2<=r^2
		 */


		double t=0;
		while(1){
			for(int L=0;L<40;L++){
				double X=(double)L-20.0, Y=(double)x[L];
				if(X<0){
					// 右の高さを採用
					X+=1.0;
				}
				//cout<<X<<endl;
				double d=(X*X) + ((Y-(t-r))*(Y-(t-r)));
				//cout<<d<<endl;
				if(d<(r*r)){
					printf("%.4lf\n",t);
					goto END;
				}
			}


			t+=0.0001;
		}
		END:
			continue;
	}

	return 0;
}



Measured memory_bytes: 3156
import java.util.Scanner;
 
public class Main {  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = Long.parseLong(sc.next());
    long M = Long.parseLong(sc.next());
    long ans =0;
    if (N * 2 >= M) {
      ans = M / 2;
    } else {
      ans = N + (M - 2 * N) / 4;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる






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

  deque<ll> que;
  rep(i,n){
    ll x;
    cin>>x;
    que.pb(x);
  }

  ll ans=0;

  rep(i,k+1){
    rep(j,k+1){
      if(i+j>k) continue;
      int z=k-i-j;
      ll sum=0;
      auto copy=que;
      vector<ll> p;
      rep(s,i){
        if(copy.empty()) {
          z+=i-s;
          break;
        }
        ll x=copy.front();
        copy.pop_front();
        p.pb(x);
        sum+=x;
      }
      rep(s,j){
        if(copy.empty()) {
          z+=j-s;
          break;
        }
        ll x=copy.back();
        copy.pop_back();
        p.pb(x);
        sum+=x;
      }
      sort(all(p));
      rep(s,z){
        if(s<p.size() && p[s]<0) sum-=p[s];
      }
      chmax(ans,sum);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n = list(map(lambda c: ord(c) - ord('0'), input()))



def solve(pos, leading_zero, is_small, i3, i5, i7):

    # print(pos, is_small, i3, i5, i7)

    if pos == len(n):
        if i3 and i5 and i7:
            return 1
        return 0

    res = 0

    for d in [0,3,5,7]:
        if leading_zero == False and d == 0:
            continue
        if not is_small and d > n[pos]:
            continue
        new_is_small = True
        if d == n[pos] and not is_small: new_is_small = False
        new_leading_zero = False
        if leading_zero and d == 0:
            new_leading_zero = True
        res += solve(pos + 1, new_leading_zero, new_is_small,
                     i3 or (d == 3), i5 or (d == 5), i7 or (d == 7))

    return res


print(solve(0, True, False, False, False, False))


Measured memory_bytes: 46556
#include <iostream> 
#include <stdio.h>
#include <string>
using namespace std;
#define MAX_N 21
int main() {
	int n;
	cin >> n;
	int h[MAX_N];
	for (int i(0);i < n;i++){
		cin >> h[i];
	}
	int cnt(0),a(0);
	for (int i(0);i < n; i++){
		a = 0;
		for (int k(0);k < i;k++){
			if (h[k] > h[i]) {
				a = 1;
			}
		}
		if (a == 0){
			cnt += 1;
		}
	}
	cout << cnt;
    return 0;
 }

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

int a,b;
char c;

int main(){
	cin>>a>>c>>b;
	if(c=='+') cout<<a+b<<endl;
	else cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
 
int main()
{
  string w;
  cin >> w;
  sort( w.begin(), w.end() );
  int s = 0;
  for( int i = 0; i < w.size(); i += 2 ) {
    s += w[ i + 1 ] - w[ i ];
  }
 
  cout << ( s ? "No" : "Yes" ) << endl;
  return 0;
}

Measured memory_bytes: 256
// AOJ 2386

#include <iostream>
using namespace std;

int c[100][100];
int main(){
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            cin >> c[i][j];
    long long ans = 0;
    for(int i = 0 ; i < n ; i++)
        for(int j = i+1 ; j < n ; j++)
            ans += min(c[j][i],c[i][j]);
    cout << ans << endl;
    
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i = j; i <= k; i ++)
#define FORD(i,j,k) for(int i = j; i >= k; i --)
#define mp make_pair
#define maxn 100005
//#define f first
//#define s second
//#define int long long
#define AMAZINGCODE""
using namespace std;
int n, dp[maxn], a[maxn];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen(AMAZINGCODE".inp","r",stdin);
    //freopen(AMAZINGCODE".out","w",stdout);
    cin >> n;
    FOR(i,1,n)
    {
        cin >> a[i];
    }
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    FOR(i,3,n)
    {
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 1 << 17;

// セグメント木を持つグローバル配列
int n;
ll dat[2 * MAX_N - 1];
const ll inf = 1234567812345678;
// 初期化
void init(int n_){
    // 簡単のため要素数を2のべき乗に
    n = 1;
    while(n < n_)n *= 2;

    // 全ての値をINT_MAXに
    for(int i = 0; i < 2 * n - 1; i++)dat[i] = inf;
}

// k番目の値(0-indexed)をaに変更
void update(int k, ll a){
    // 葉の接点
    k += n - 1;
    dat[k] = a;
    // 登りながら更新
    while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

// [a,b)の最小値を求める
// 後ろのほうの引数は、計算の簡単のための引数。
// kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
// したがって、外からはquery(a, b, 0, 0, n)として呼ぶ。
ll query(int a, int b, int k, int l, int r){
    // [a, b)と[l, r)が交差しなければ、INT_MAX
    if (r <= a || b <= l)return inf;

    // [a, b)が[l, r)を完全に含んでいれば、この節点の値
    if (a <= l && r <= b)return dat[k];
    else {
        // そうでなければ、2つの子の最小値
        ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}


int main(){
    int m;
    cin >> n >> m;
    int n_ = n;

    init(n);
    int now = 0;
    vector<pair<P,ll>> v;
    rep(i,m){
        int l,r;
        ll c;
        cin >> l >> r >> c;
        pair<P,ll> p;
        p.first.first = l;
        p.first.second = r;
        p.second = c;
        v.push_back(p);
    }
    sort(v.begin(), v.end());

    rep(i,m){
        int l = v[i].first.first;
        int r = v[i].first.second;
        ll c = v[i].second;
        l--; r--;
        if(l == 0){
            ll now = query(r,n,0,0,n);
            if(c < now){
                update(r,c);
            }
        }else{
            c = c + query(l,n,0,0,n);
            ll now = query(r,n,0,0,n);
            if(c < now){
                update(r,c);
            }
        }
    }
    ll ans = query(n_-1,n,0,0,n);
    if(ans>=inf)ans = -1;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int sum = 0;
  int min = 100;
  for(int i=0; i<4; i++) {
    int tmp;
    cin >> tmp;
    sum += tmp;
    if(tmp < min) min = tmp;
  }
  sum -= min;
  
  int max = 0;
  for(int i=0; i<2; i++) {
    int tmp;
    cin >> tmp;
    if(tmp > max) max = tmp;
  }
  sum += max;
  cout << sum << endl;
}



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

class Mainclass 
{
    static void Main()
    {
        int[] A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        if (A[0] + A[1] < 10)
        {
            Console.WriteLine(A[0]+A[1]);
        }
        else
        {
            Console.WriteLine("error");
        }
    }
}

Measured memory_bytes: 27480
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int sum = 0;
  int fore = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'a'){
      if(sum < a + b){
        cout << "Yes" << endl;
        sum++;
      }else{
        cout << "No" << endl;
      }
    }else if(s[i] == 'b'){
      if(sum < a + b && fore < b){
        cout << "Yes" << endl;
        sum++;
        fore++;
      }
      else cout << "No" << endl;
    }else{
      cout << "No" << endl;
    }
  }
	return 0;
}


Measured memory_bytes: 896
<?php

$input = trim(fgets(STDIN));
$input = explode(" ", $input);
$n = (int) $input[0];
$m = (int) $input[1];

$limit = floor($m / $n);
for ($i=$limit; $i > 0; $i--) { 
	if ($m % $i === 0) {
		echo $i;
		exit(0);
	}
}


Measured memory_bytes: 4728
from collections import Counter

N = int(input())

lists = list(map(int, input().split()))

dicts = Counter(lists)

ans = 0

for key in dicts.keys():
    if dicts[key] - int(key) >= 0:
        ans += dicts[key] - int(key)
    else:
        ans += dicts[key]
    
print(ans)

Measured memory_bytes: 18676
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    int mx = 0;
    int cnt = 0;
    ll bH;
    cin >> bH;
    REP(i, N-1){
        ll H;
        cin >> H;
        if(bH>=H){
            cnt++;
            chmax(mx, cnt);
        }else{
            cnt=0;
        }
        bH = H;
    }
    cout << mx << el;
}



Measured memory_bytes: 256