akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void SelectSort(int x[], int N);
void BubbleSort(int x[], int N);
void InsertSort(int x[], int N, int num);
void ShellSort(int x[], int N);
void Trace(int x[], int N);
void Trace2(int x[], int N);

int gCount = 0;

int main() {
    int N;

    cin >> N;

    int x[N];

    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    //SelectSort(x, N);
    //BubbleSort(x, N);
    InsertSort(x, N, 1);
    //ShellSort(x, N);
    Trace(x, N);
    //Trace2(x, N);
    //cout << gCount << endl;

    return 0;
}


void SelectSort(int x[], int N) {
    int min;

    for (int i = 0; i < N - 1; i++) {
        min = i;
        for (int j = i; j < N; j++) {
            if (x[min] > x[j]) {
                min = j;
            }
        }
        if (i != min) {
            gCount++;
            swap(x[min], x[i]);
        }
    }
}

void BubbleSort(int x[], int N) {
    for (int i = 0; i < N - 1; i++) {
        for (int j = N - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {
                swap(x[j - 1], x[j]);
                gCount++;
            }
        }
        //Trace(x, N);
    }
}

void ShellSort(int x[], int N) {
    cout << "dummy" << endl;
}

void InsertSort(int x[], int N, int num) {
    for(int i = num; i < N; i++) {
        int v = x[i];
        int j = i - num;
        Trace(x, N);
        while (j >= 0 && x[j] > v) {
            x[j + 1] = x[j];
            j -= num;
        }
        x[j + num] = v;
    }
}

void Trace (int x[], int N) {
    int i;
    for (i = 0; i < N - 1; i++) {
        cout << x[i] << " ";
    }
    cout << x[i] << endl;
}

void Trace2 (int x[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        cout << x[i] << endl;
    }
}

Measured memory_bytes: 3084
a,b,c,d,e,f=map(int,input().split())
a,b=a*100,b*100

DP=[-1 for _ in range(f+3000)]
DP[a],DP[b]=0,0
for i in range(f+1):
    if DP[i]==-1:continue
    for j in a,b:
        if i+j<=f:DP[i+j]=DP[i]
    for j in c,d:
        if i+j<=f and 100*(DP[i]+j)/(i+j)<=100*e/(100+e):
            DP[i+j]=DP[i]+j

ans,water=0,[a,0]
for i,j in enumerate(DP):
    if i==0:continue
    if ans<100*j/i:
        ans=100*j/i
        water=[i,j]
print(*water)

Measured memory_bytes: 73784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[] as;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        int min = Integer.MAX_VALUE;
        for (int i = -100; i <= 100; i++) {
            int score = 0;
            for (int j = 0; j < n; j++) {
                score += (i - as[j]) * (i - as[j]);
            }
            if (score < min) {
                min = score;
            }
        }
        System.out.println(min);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
#include <stdio.h>

int main(void){
    int n,i,j,count=0,k;
    int a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++){
        for(j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                k=a[j];
                a[j]=a[j+1];
                a[j+1]=k;
                count++;
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        if(i!=n-1){
            printf(" ");
        }
    }
    printf("\n%d\n",count);
    return 0;
}


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

typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  // vector<int> la(n);
  // for (int &a: la) cin >> a;
  unordered_map<int, int> rem0;
  unordered_map<int, vector<int>> rem;
  rem[0].push_back(-1);
  int s = 0;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    --a;
    s += a;
    s %= k;
    // cout << a << " " << s << endl;
    // for (auto it: rem) {
    //   cerr << "[r]" << it.first << " " << it.second << endl;
    // }
    if (rem.find(s) != rem.end()) {
      for (int j = rem0[s]; j < rem[s].size(); ++j) {
        int from = rem[s][j];
        if (i-from >= k) ++rem0[s];
        else { 
          ans += rem[s].size()-j;
          break;
        }
      }
    }
    if (rem0.find(s) == rem0.end()) rem0[s] = 0;
    rem[s].push_back(i);
  }
  cout << ans << endl;
}



Measured memory_bytes: 26256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;

int main()
{
	lld n,m;
	lld a[MAXN] ={0},b[MAXN] = {0};

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

	lld cnt[MAXN] = {0};

	for(int i = 0; i < m; i++)
	{
		cnt[a[i]-1]++;
		cnt[b[i]-1]++;
	}

	for(int i = 0; i < n; i++)
	{
		if (cnt[i] % 2 != 0)
		{
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		Long N = sc.nextLong();
		Long conX = new Long(1000000000);
        Long x = (conX - N % conX) % conX;
		Long y = (N + x) / conX;
		
		System.out.println("0 0 1000000000 1 " + x + " " + y);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>    //vectorを使う
using namespace std;


int main(void){
    vector<int> l(5);
    int k;

    for(int i = 0; i <5 ; ++i){
        cin >> l.at(i) ;
    }
    
    cin >> k;

    bool y=0;
    if(l.at(4)-l.at(0) > k){
            y=1;
    }
    else{
    }
    

    if(y==0){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

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

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N;
    while(cin >> N) {
        LL A, B;
        REP(i, N) {
            LL x, y;
            cin >> x >> y;
            if(i == 0) {
                A = x;
                B = y;
            } else {
                LL k = max((A + x - 1) / x, (B + y - 1) / y);
                A = k * x;
                B = k * y;
            }
        }
        cout << (A + B) << endl;
    }
    return 0;
}


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

typedef long long int ll;

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	ll sum = 0;
	
	string s;
	cin >> s;
	
	for (ll i=0 ; i<s.size() ; i++) {
		sum += (s[i]-'0');
	}
	
	if (sum%9==0) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			int n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int m = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
			if (n == 0 && m == 0)
				break;

			//
			m++;
			int[] wish = new int[m];
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				for (int j = 0; j < line.length(); j += 2) {
					wish[j / 2 + 1] += (line.charAt(j) - '0');
				}
			}

			//
			StringBuilder sb = new StringBuilder();
			for (int i = n; i >= 0; i--) {
				for (int j = 1; j < m; j++) {
					if (wish[j] == i)
						sb.append(j + " ");
				}
			}
			System.out.println(sb.toString().substring(0, sb.length() - 1));
		}
	}
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
const num inf = 0x3f3f3f3f3f3f3f3f;
int n, a[nsz + 5];
num dp[nsz + 5][5], ans;
string dat[nsz + 5];

int inline to(string s) {
    int res = 0;
    loop (i, s.size()) {
        res *= 10;
        res += s[i] ^ 48;
    }
    return res;
}

void inline upd(num &a, num b) {
    if (a < b) {
        a = b;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    dat[0] = '+';
    cont (i, 2 * n - 1) {
        cin >> dat[i];
        if (i & 1) {
            int cur = to(dat[i]);
            a[i >> 1] = dat[i - 1] == "-" ? -cur : cur;
        }
    }
    memset(dp, -inf, sizeof(dp));
    dp[0][0] = 0;
    loop (i, n) {
        loop (k, 3) {
            num val = dp[i][k], cur = k & 1 ? -a[i] : a[i];
            for (int l = k - 1; l >= 0; --l) {
                upd(dp[i + 1][l], val + cur);
            }
            if (k < 2 && a[i] < 0) {
                upd(dp[i + 1][k + 1], val + cur);
            }
            upd(dp[i + 1][k], val + cur);
        }
    }
    loop (k, 3) {
        upd(ans, dp[n][k]);
    }
    cout << ans << ln;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(1e5+1)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
int main()
{
	fastio;
	int n;
	cin>>n;
	vector <ld> p(n+1);
	for(int i=1;i<=n;i++)cin>>p[i];
	vector <ld> dp(n+1,0),newdp(n+1,0);
	dp[0]=1;
	for(int coins=1;coins<=n;coins++)
	{
		for(int i=0;i<=coins;i++)
		{
			
			newdp[i]=dp[i]*(1-p[coins]);
			if(i>=1){
				newdp[i]+=dp[i-1]*p[coins];
			}			
		}
		dp=newdp;
	}
	long double ans=0;
	for(int heads=0;heads<=n;heads++)
	{
		if(2*heads >n)
			ans+=newdp[heads];
	}
	cout<<setprecision(15)<<ans<<endl;

}


Measured memory_bytes: 3964
#include<cstdio>

using namespace std;

typedef long long ll;

int main(){
	ll k; scanf("%lld", &k);
	ll res[50];
	for(int i = 0; i < 50; i++) res[i] = k / 50 + i;
	k %= 50;
	for(int i = 0; i < k; i++){
		for(int j = 0; j < 50; j++) res[j]--;
		res[i] += 51;
	}
	puts("50");
	for(int i = 0; i < 50; i++) printf("%lld%c", res[i], i == 49 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 128
A = list(map(int , input().split()))
if A[0] < A[-1]:
    a = A[0]
    b = A[-1] - A[0]
    if A[1] < b:
        a -= (b - A[1])
elif A[-1] < A[0]:
    a = A[-1]
else:
    a = A[0]
print(a)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	
	long ans = 1;
	
	int unsame = 0;
	vector<int> alphabet(26,1);
	int tmp = 0;
	
	for (int i = 0; i < N; i++) {
		tmp = S.at(i) - 'a';
//cout << "dbg " << S.at(i) << ", tmp " << tmp << endl;

		alphabet.at(tmp)++;

	}
	for (int i = 0; i < 26; i++) {
		ans = ans * alphabet.at(i) % 1000000007;
	}
	


	ans = ans % 1000000007;
	
	cout << ans-1 << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> t(n);
    rep(i, n) cin >> t[i];
    ll ans = t[0];
    rep(i, n) ans = ans / __gcd(ans, t[i]) * t[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int X,Y,Z;

	scanf("%d %d %d",&X,&Y,&Z);

	int ans = 0;

	for(int k = 1; k <= 100000; k++){

		if(k*Y+(k+1)*Z <= X){

			ans = k;
		}else{
			break;
		}
	}

	printf("%d\n",ans);

	return 0;
}


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

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    for (int i = 1, x; i <= 5; i++) {
        cin >> x;
        if (x==0){
            cout << i << '\n';
            return 0;
        }
    }

    return 0;
}

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


int main(){
    ll N,ans = 0;
    cin >> N;
    string tmp = to_string(N);
    if(tmp.size() == 1){
        ans = (tmp[0] - '0');
        cout << ans << endl;
        return 0;
    }
    ans += (tmp[0] - '0') + (tmp.size() - 1) * 9;
    if(N % 10 == 9){
        cout << ans << endl;
    }else{
        cout << ans - 1 << endl;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int N = 0;
	cin >> N;

	int genka1 = round(N / 1.08);
	int genka2 = round(N / 1.08)+1;

	int N2 = floor(genka1 * 1.08);
	int N3 = floor(genka2 * 1.08);
	

	if (N2 == N ) {
		cout << genka1 << endl;
	}
	else if (N3 == N) {
		cout << genka2 << endl;
	}
	else if (N <= 0 || 50000<N) {
		cout << ":(" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int A, B, C;
  scanf("%d %d %d",&A,&B,&C);
  if(A == B)
  printf("%d\n",C);
  if(B == C)
  printf("%d\n",A);
  if(A == C)
  printf("%d\n",B);


  
  return 0;
}

Measured memory_bytes: 128
word = sorted(input().split())
length = len(word)
cnt = 0
cc = ""
w = ""
wc = 0
for i in word:
    if cnt < len(i):
        cnt = len(i)
        cc = i
for i in range(length):
    if word.count(word[i]) > wc:
        wc = word.count(word[i])
        w = word[i]
print(w, cc)
    


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

using namespace std;
struct P
{
    //string r;
    int x,y;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    double a;
    int n;
};
vector<P> v[5110],v1[2222];

int a,b,c,i,k,d,n,m,e,dy[15]={0,0,-1,1,-1,1,-1,1},dx[15]={-1,1,0,0,1,1,-1,-1};
int o[5010];
int l[1500][1111];
//int dy[10]={1,0,-1,-1,-1,0},dx[10]={0,1,1,0,-1,-1};
//int dy1[10]={1,1,0,-1,0,1},dx1[10]={0,1,1,0,-1,-1};
long long x,y[200111],z[200111];
//P u[2500600];
int j[5400];
//queue<P> q,q1;
//stack<int> s;
queue<int> q;

//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//map<long long, int > p;
string r,r1;
//char r[1010];

bool as(int a,int b)
{
    return a>b;
    //return a.x>b.x;
}



long long g(int a)
{
    long long x=1;
    for(int h=1,u=1;h<=a;u++,h<<=1)
    if((h&a))
    {
        x*=y[u],x%=i;
       //printf("%lld\n",x);
    }
    return x;
}


//char h[22][22]={ abbbabbaaabbbaaa, abbabbabbbabbba ,ababbbabbbabbba ,aabbbbabbbabbba ,ababbbabbbabbba ,abbabbabbbabbba ,abbbabbaaabbbaaa};
//char h[22][22];
int main()
{
    cin>>r;
    scanf("%d",&b);
    for(int t=1;t<=b;o[c]=1,t++)
        scanf("%d",&c);
    for(int t=r[0]-'0';t<=9;t++)
    if(!o[t]) goto asd;
    for(int t=0;t<=r.size();t++)
    {
        for(int w=0;w<=9;w++)
            if(!o[w])
            if(t>0||w>0)
            {printf("%d",w);
            break;
            }
    }
    return 0;
    asd:;
    for(int t=0;t<r.size();t++)
    {
        for(int w=0;w<10;w++)
        if(!o[w])
        if(w>=r[t]-'0'||i)
        {
            if(w>r[t]-'0') i=1;
            q.push(w);
            //printf("%d",w);
            goto qwe;
        }
        for(int t=0;t<=r.size();t++)
    {
        for(int w=0;w<=9;w++)
            if(!o[w])
            if(t>0||w>0)
            {
                printf("%d",w);
            break;
            }

    }
    return 0;
        qwe:;
    }
    for(;q.size();q.pop())
        printf("%d",q.front());
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int m, f, r, x;
	while(1)
	{
		scanf("%d %d %d", &m, &f, &r);
		if(m == -1 && f == -1 && r == -1) break;
		x = m + f;
		
		if(m == -1 || f == -1)
		{
			printf("F");
		}
		
		else if(x > 79)
		{
			printf("A");
		}
		
		else if(x > 64)
		{
			printf("B");
		}
		
		else if(x > 49)
		{
			printf("C");
		}
		
		else if(x > 29 && r > 49)
		{
			printf("C");
		}
		
		else if(x > 29)
		{
			printf("D");
		}
		
		else if(x < 30)
		{
			printf("F");
		}
		
		printf("\n");
	}
	
	return 0;
}




Measured memory_bytes: 2040
//#include"pch.h"
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<algorithm>

int main() {

	int T, X;

	scanf("%d %d", &T, &X);

	printf("%.9f", (double)T / X);


	return(0);
}

Measured memory_bytes: 128
N, M = map(int, input().strip().split(" "))

to_one = [False] * N
to_N = [False] * N
for m in range(M):
    a, b = map(int, input().strip().split(" "))
    if a == 1:
        to_one[b] = True
    if b == N:
        to_N[a] = True

res = False
for n in range(2, N):
    if to_N[n] and to_one[n]:
        print("POSSIBLE")
        res = True
        break

if not res:
    print("IMPOSSIBLE")


Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define pb push_back
#define mem(a, b) memset(a, b, sizeof(a))

int main() {
	int q;
	LL a, b, ans;
	scanf("%d", &q);
	while (q--) {
		scanf("%lld%lld", &a, &b);
		if (a > b) swap(a, b);
		if (a == b) {
			ans = 2 * (a - 1);
		}
		else if (a == b - 1) {
			ans = 2 * (a - 1);
		}
		else {
			LL c = sqrt(a * b);
			if (c * c == a * b) c--;
			if(c * (c + 1) >= a * b) {
				ans = 2 * c - 2;
			}
			else {
				ans = 2 * c - 1;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
} 

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;

    for (int i = 1; i <= 9; i++) {
        if (N%i ==0 && N/i <= 9) {
            cout << "Yes" << endl;
            return 0;
        }
    }    

    cout << "No" << endl;
}


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

int main() {
int N;
cin >> N ;
int cnt1=0;
for (int i = 1; i <=N; i+=2)
{
  double mid=sqrt(i);
  int cnt2=0;
  for (int j = 2; j <mid ; j++)
  {
    if(i%j==0) cnt2++;
  }
  if(cnt2==3) cnt1++;
}
cout << cnt1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#include <random>
#include <ctime>
#include <chrono>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long

using namespace std;
const int N = 1e6 + 1e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

//long long arr[N];


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

    ll n = 0,k=0;cin >> n >> k;
    ll arr[n];
    for(ll i = 0;i < n;i++) cin >> arr[i];
    
    ll ans = 0;
    sort(arr,arr+n);
    for(ll i =0;i < k; i++)
      ans += arr[i];
      
     cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//mod
const int mod = 1e9 + 7;
int pow(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}
const int nm = 1e5;
int n, c[nm];
int main() {
	cin >> n;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		c[a]++;
	}
	bool b = ~n & 1 | c[0] == 1;
	for (int i = n - 1; i > 0; i -= 2)
		if (c[i] != 2) {
			b = 0;
			break;
		}

	cout << (b ? pow(2, n / 2) : 0) << endl;

}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N);
  vector<int> w(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i] >> w[i];
  }
  debug(v);
  debug(w);
  vector<int> dp(W + 1);
  for (int i = 0; i < N; i++) {
    for (int j = w[i]; j < W + 1; j++) {
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    }
  }
  debug(dp);
  cout << dp[W] << endl;
  return 0;
}


Measured memory_bytes: 3160
from collections import deque
t=input()
s=deque(t)
q=int(input())
flag=True
for i in range(q):
  ques=list(input().split())
  if ques[0]=="1":
    flag=not flag
    continue
  if ques[1]=="1":
    if flag:
      s.appendleft(ques[2])
    else:
      s.append(ques[2])
  else:
    if flag:
      s.append(ques[2])
    else:
      s.appendleft(ques[2])
if flag==False:
    print(''.join(reversed(list(s))))
else:
    print(''.join(list(s)))

Measured memory_bytes: 10356
K, N = map(int, input().split(' '))
A_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(N):
    l = A_ls[(i + 1) % N] - A_ls[i]
    if l < 0:
        l = K - A_ls[i] + A_ls[(i + 1) % N]
    if rst == -1:
        rst = l
    else:
        rst = max(rst, l)
print(K - rst)

Measured memory_bytes: 32188
function main(input) {
  input = input.trim().split('\n');
  const n = Number(input[0]);
  const as = input[1].split(' ').map(n => Number(n));
  const bs = input[2].split(' ').map(n => Number(n));
  const sumA = as.reduce((a, b) => a+b);
  const sumB = bs.reduce((a, b) => a+b);
  const limit = sumB - sumA;
  let cntA = 0;
  let cntB = 0;
  for (let i = 0; i < n; i++) {
    const a = as[i];
    const b = bs[i];
    if (a === b) continue;
    if (a < b) {
      cntA += Math.ceil((b-a)/2);
    } else {
      cntB += a - b;
    }
  }
  const result = Math.max(limit, cntA, cntB) === limit ? 'Yes' : 'No';
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9336
n, m, q = gets.split.map(&:to_i)
abcd = []

q.times { abcd << gets.split.map(&:to_i) }

answer = []

[*1..m].repeated_combination(n).each { |h|
  answer << abcd.sum(0) { |a, b, c, d| h[b - 1] - h[a - 1] == c ? d : 0 }
}

puts answer.max


Measured memory_bytes: 15720
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class PQ
  attr_accessor:queue,:n
  def initialize(n)
    @n=0
    @queue=array(n,1,10**9)
  end

  def push_q(x)
    i=@n
    @n+=1
    while i>0
      p=(i-1)/2
      break if @queue[p]>x
      @queue[i]=@queue[p]
      i=p
    end
    @queue[i]=x
  end

  def pop_q()
    min=@queue[0]
    @n-=1 unless @n.zero?
    x=@queue[@n]
    i=0
    while i*2+1<@n
      l=i*2+1
      r=i*2+2
      l=r if r<@n and @queue[l]<@queue[r]
      break if @queue[l]<=x
      @queue[i]=@queue[l]
      i=l
    end
    @queue[i]=x
    return min
  end
end

n,q=get_i
pq=array(n,1)
n.times do|i|
  pq[i]=PQ.new((2*10**5)/n)
end
q.times do
  query=get_i
  case query[0]
  when 0 then
    pq[query[1]].push_q(query[2])
  when 1 then
    puts pq[query[1]].queue[0]  unless pq[query[1]].n.zero?
  when 2 then
    pq[query[1]].pop_q()  
  end
end



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

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int res = 1;
    int sum = K;
    while (sum < N) {
        sum += (K - 1);
        res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env pytHon3
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB.sort()

    for a, b in AB:
        K -= b
        if K <= 0:
            break

    print(a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27872
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int MOD;

int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans=INF;
    int leftneed=0;
    int rightneed=0;
    rep(i,N) if(S[i]=='R') rightneed++;
    rep(i,N+1){
        int L=N-i,R=N-L;
        int cmp=max(leftneed,rightneed);
        ans=min(ans,cmp);
        if(i<N){
            if(S[i]=='W') leftneed++;
            else rightneed--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;
vector<pair<int, int>> v;

int main() {
	cin >> n;
	inc(i, n) {
		int a; cin >> a;
		v.EB(a, i + 1);
	}
	sort(ALL(v));
	
	inc(i, n) {
		cout << v[i].SE << (i == n - 1 ? "\n" : " ");
	}
	
	return 0;
}

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

using namespace std;

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

    if(n < 10){
        m = n;
    }

    if(9 < n && n < 100){
        m = 9;
    }

    if(99 < n && n < 1000){
        m = n - 99 + 9;
    }

    if(999 < n && n < 10000){
        m = 909;
    }

    if(9999 < n && n < 100000){
        m = n - 9999 + 909;
    }

    if(n == 100000){
        m = 90909;
    }

    cout << m << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vli vector<lli>
#define vi vector<int>
#define vs vector<string>
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

typedef long long int lli;
typedef long int li;

const lli mod=1000000007;
const lli limit=1000000;

using namespace std;

void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k,m;
    cin>>n>>m;
    lli arr[n];
    FOR(i,n)cin>>arr[i];
    sort(arr,arr+n,greater<lli>());
    temp=0;
    FOR(i,n)temp+=arr[i];
    temp1=ceil(temp/(4.0*(double)m));
    if(arr[m-1]<temp1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
 
}


Measured memory_bytes: 256
#SUN,MON,TUE,WED,THU,FRI,SAT
S = input()
if S == "SUN":
  print("7")
elif S == "MON":
  print("6")
elif S == "TUE":
  print("5")
elif S == "WED":
  print("4")
elif S == "THU":
  print("3")
elif S == "FRI":
  print("2")
elif S == "SAT":
  print("1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int n,l,r;
  while(cin>>n>>l>>r,n){
	int sum=0;
	int a[55];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=l;i<=r;i++){
	  a[n]=i;
	  for(int j=0;j<=n;j++){
		if(i%a[j]==0){
		  if(j%2==0)sum++;
		  break;
		}
	  }
	}
	cout<<sum<<endl;
  }
  return 0;
}



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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";



int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a - k >= 0) {
        return cout << k << "\n", 0;
    }
    k -= a;

    if (b - k >= 0) {
        return cout << a << "\n", 0;
    }
    k -= b;

    cout << a - k << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,ans=0; cin>>N;
  vector<ll> A(N,0);
  for(int i=0; i<N; i++)cin>>A[i];
  map<ll,ll> M;
  for(int i=0; i<N; i++){
    ans+=(M[i-A[i]]);
//    cout<<"i:"<<i<<"ans:"<<ans<<endl;
    M[A[i]+i]++;
  }
  cout<<ans<<endl; 
}

Measured memory_bytes: 27328
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int a,b;
    cin >> a >> b;

    int ans = 0;
    if(a > b){
        for(int i = 1; i <= pow(10,a-1); i*=10){
            ans += b*i;
        }
    } else {
        for(int i = 1; i <= pow(10,b-1); i*=10){
            ans += a*i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int32_t main()
{   fastio;

    int a , b;
    cin>>a>>b;
    cout<<max(0ll , a-2*b);
}


Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>
#include <unordered_map>

using namespace std;

long long f(long long a) {
    if (a <= 0) return 0;
    long long ans = 0;
    for (int i=40; i>0; i--) {
        if (a & (1LL<<i) && !(a & 1)) ans |= (1LL<<i);
    }
    ans |= (a&1)^(a>>1&1);
    return ans;
}
int main() {
    long long a, b;
    cin>>a>>b;
    cout<<(f(a-1)^f(b))<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int a,b,r,tmp;
scanf("%d ",&a);
scanf("%d",&b);
if(a<b){
tmp = a;
a = b;
b = tmp;
}
r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
printf("%d\n", b);
return 0;
}



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
	string s; cin >> s;
	string po;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] != 'A') po += s[i];
	}
	if(po != "KIHBR"){
		cout << "NO\n";
		return 0;
	}
	string ak = "AKIHABARA";
	for(int i = 0; i < ak.size(); ++i){
		if(s[i] != ak[i]){
			s.insert(s.begin() + i, 'A');
		}
	}
	if(s == ak){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
typedef unsigned long long ull;
int N, M; char s[1000009]; ull w[500009], p2[500009];
int main() {
	w[0] = 73; p2[0] = 257;
	for (int i = 0; i < 500000; i++) {
		w[i + 1] = w[i] * 66049 + 20376;
		p2[i + 1] = p2[i] * 66049;
	}
	while (scanf("%d", &N), N) {
		scanf("%d%s", &M, s);
		ull h = 0, b = 0, l = N * 2 + 1;
		for (int i = 0; i < l; i++) h = h * 257 + s[i];
		int ret = 0;
		for (int i = l; i <= M; i++) {
			if (h == w[N]) ret++;
			h = h * 257 + s[i] - p2[N] * s[i - l];
		}
		printf("%d\n", ret);
	}
	return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    cout << max(A - 2*B, 0);
}

Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=1e5+10;
char s[N];
void main() {
    R(s);
    int n=strlen(s);
    int c[3]={};
    REP(i,n) c[s[i]-'a']++;
    sort(c,c+3);
    if ( c[2]-c[0]<=1 ) W("YES");
    else W("NO");
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


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

#define ll long long int
const ll mod=1e9+7;
const ll sz=1e5+100;
vector<ll> ad[sz];
ll root;

ll tk[sz],k;

ll DFS(ll p,ll par,ll tot)
{
    tk[p]=tot%mod;
    int siz=ad[p].size();

    ll start=(p==root) ? k-1 : k-2;
    for(ll i=0;i<siz;i++)
    {
        ll x=ad[p][i];
        if( x != par){
            ll le=DFS(x,p,start);
            tk[p]=(tk[p] * le)%mod;
            start=max(0ll,start-1);
        }
    }

    return tk[p];
}

int main()
{
    ll x,y,n,m,p,q;
    cin>>n>>k;
    for(ll i=1;i<n;i++){
        cin>>p>>q;
        ad[p].push_back(q);
        ad[q].push_back(p);
    }

    root=1;
    ll ans=DFS(1,-1,k);
    cout<<ans<<'\n';
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long double L;
    cin >> L;
    cout << setprecision(10) << (L/3.0)*(L/3.0)*(L/3.0) << endl;
    return 0;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
dp = [[0 for j in range(W+1)] for i in range(N)]
w,v = map(int,input().split())
for j in range(W+1):
    if w <= j:
        dp[0][j] = v
for i in range(1,N):
    w,v = map(int,input().split())
    for j in range(W+1):
        if j >= w:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v)
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N-1][W])


Measured memory_bytes: 171528
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    int x,t,ans;
    cin >> x >>t;
    ans = max(x-t,0);
    cout << ans << endl;
}

int main(){
/*/Debug by file input
    ifstream inp("input");
    cin.rdbuf(inp.rdbuf());// */
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
counter = 0
Ans = 0
temp = 0
for i in range(N-1):
  if H[counter]>=H[counter+1]:
    temp += 1
    if temp > Ans:
      Ans = temp
    counter += 1
  else:
    temp = 0
    counter += 1
    
print(Ans)

Measured memory_bytes: 14252
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }


void merge(vvl &dp, vvl &b) {
	int n = dp[0].size(), m = b[0].size();
	vvl ret(2, vl(n + m, INF * INF));
	REP(i, n) {
		REP(j, m) {
			chmin(ret[0][i + j], dp[0][i] + b[0][j]);
			chmin(ret[1][i + j], dp[1][i] + b[1][j]);
			chmin(ret[0][i + j], dp[0][i] + b[1][j]);
			chmin(ret[0][i + j], dp[1][i] + b[0][j]);
			if (b[0][j] < 0) {
				chmin(ret[0][i + j + 1], dp[0][i]);
				chmin(ret[1][i + j + 1], dp[1][i]);
			}
			if (b[1][j] != INF * INF) {
				chmin(ret[0][i + j + 1], dp[0][i]);
				chmin(ret[1][i + j + 1], dp[1][i]);
			}
		}
	}
	swap(ret, dp);

}

void dfs(vector<vvl> &dp, vvi &g, vi &a, int v, int p) {
	vvl ret(2, vl(1));
	if (a[v] < 0) {
		ret[0][0] = a[v];
		ret[1][0] = INF * INF;
	}
	else {
		ret[0][0] = INF * INF;
		ret[1][0] = a[v];
	}
	REP(i, g[v].size()) {
		if (g[v][i] == p)continue;
		dfs(dp, g, a, g[v][i], v);
		merge(ret, dp[g[v][i]]);
	}
	dp[v] = ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n); REP(i, n)cin >> v[i];
	vvi g(n);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<vvl> dp(n, vvl(2));
	dfs(dp, g, v, 0, -1);
	ll ans = INF;
	REP(i, n) {
		if (dp[0][0][i] < 0) {
			chmin(ans, i);
		}
		if (dp[0][1][i] != INF * INF) {
			chmin(ans, i);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 245120
from collections import deque

def bfs():
  q = deque()
  q.append([[1,1],0])
  used = set((1,1))
  
  while len(q)>0:
    prv_pos,prv_cost = q.popleft()
    i,j = prv_pos
    for ii,jj in [[i+1,j],[i,j+1],[i-1,j],[i,j-1]]:
      if (ii,jj) in used: continue
      if S[jj][ii]=='.':
        if [ii,jj] == [W,H]:
          return prv_cost+1
        else:
          q.append([[ii,jj],prv_cost+1])
          used.add((ii,jj))
  return -1

H,W = map(int,input().split())
S = [['#' for _ in range(W+2)]] + [['#']+[s for s in input()]+['#'] for _ in range(H)] + [['#' for _ in range(W+2)]]

res = bfs()
if res == -1:
  print(-1)
else:
  cntb = sum([row.count('#') for row in S])-2*(H+2)-2*(W+2)+4
  print(H*W-res-cntb-1)


Measured memory_bytes: 3692
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int n; cin>>n;
  long ans[n+1]; ans[0]=2; ans[1]=1;
  if(n>1){
  	for(int i=2;i<n+1;i++){
    	ans[i]=ans[i-1]+ans[i-2];
    }
  }
  cout<<ans[n]<<endl;
  return 0;
}

Measured memory_bytes: 256