akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;


// sqrt(n) までの素数を求める。 まで対応
void create_primes(int64_t n, bitset<2000001> & primes) {
	primes.flip();

	int64_t u_b = n;

	{
		for (int64_t j = 4; j <= u_b; j += 2) {
			primes.reset(j);
		}
	}
	for (int64_t i = 3; i <= u_b; i += 2) {
		if (!primes.test(i)) continue;

		for (int64_t j = i * 2; j <= u_b; j += i) {
			primes.reset(j);
		}
	}
}

bitset<2000001> primes;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int x; cin >> x;

	create_primes(200000, primes);

	FOR_LT(i, x, 200000) {
		if (primes.test(i)) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

    long long ab = a * b;
    if (a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

    while (b != 0) {
        int tmp = b;
        b = a % b;
        a = tmp;
    }

    cout << ab/a << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
void StrCat(char *p,int num) {

	for (int i = 0; i < num; i++) {
	*(p+num) = *p;
	++p;
	}
	
}
int main()
{
	char s[200] = {};
	char p[100];
	int count[100] = { 0 };
	cin >> s >> p;
	StrCat(s,strlen(s));
	if(strstr(s, p)!=NULL) cout<<"Yes"<<endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int, int> P;
int main(){
    int N,C;
    cin >> N >> C;
    vector<int> s(N), t(N), c(N);
    for(int i = 0; i < N; i++)
    {
        cin >> s[i] >> t[i] >> c[i];
    }
    vector<vector<int>> ch(C,vector<int>(100100));
    vector<int> vec(100100, 0);
    for(int i = 1; i <= C; i++)
    {
        for(int j = 0; j < N; j++)
        {
            if (c[j] == i) {
                ch[i-1][s[j]]++;
                ch[i-1][t[j]]--;
            }
        }
    }
    for(int i = 0; i < C; i++)
    {
        for(int j = 0; j < 100100; j++)
        {
            if (ch[i][j] == 1) {
                vec[j-1]++;
            }
            else if (ch[i][j] == -1) {
                vec[j]--;
            }
        }
    }
    
    for(int i = 1; i < 100100; i++)
    {
        vec[i] += vec[i-1];
    }
    int ans = 0;
    for(int i = 0; i < 100100; i++)
    {
        ans = max(ans, vec[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13568
S = input()
k = int(input())

if S[0] == '1':
    cnt = 0
    for s in S:
        if s == '1':
            cnt += 1
        else:
            not1 = s
            break
    if k <= cnt:
        print(1)
    else:
        print(not1)
else:
    print(S[0])


Measured memory_bytes: 2940
import java.util.*;
     
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	
    	int game = N * (N - 1) / 2;
    	int[] point = new int[N];
    	int[] rank = new int[N];
    	int s = 0,num = 0,eq = -1,count = 1;
    	
    	//試合結果入力、勝ち点判定
    	for(int i = 0;i < game;i++){
    		int A = sc.nextInt();
    		int B = sc.nextInt();
    		int C = sc.nextInt();
    		int D = sc.nextInt();
    		
    		if(C > D){
    			point[A - 1] += 3;
    		}else if(C < D){
    			point[B - 1] += 3;
    		}else{
    			point[A - 1] += 1;
    			point[B - 1] += 1;
    		}
    	}
    	
    	for(int j = 0;j < N;j++){
    		int max = 0;
    		for(int i = 0; i < N;i++){
    			if(point[i] > point[max])
    				max = i;
    		}
    		
    		if(eq == point[max]){
    			count++;
    		}else{
    			num += count;
    			count = 1;
    		}
    		
        	eq = point[max];
    		point[max] = 0;
    		rank[max] = num;
    	}
    	
    	for(int i = 0;i < N;i++){
    		System.out.println(rank[i]);
    	}
    }
}

Measured memory_bytes: 42048
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,j,a[800005],b[800005][2],sum,sum2,top2,ans[800005];
int max1[800005],max2[800005],max3[800005],max4[800005],p1,p2,p3;
int top,nex[800005],to[800005],fir[800005];
set<pair<int,int> > s;
set<pair<int,int> > :: iterator it;
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
void buildtree(int u,int v,int w){
	int mid=(u+v>>1);
	if(u==v){
		if(v&1){
			max1[w]=a[v];
			max2[w]=n+1;
			max3[w]=v;
		}
		else{
			max1[w]=n+1;
			max2[w]=a[v];
			max4[w]=v;
		}
		return;
	}
	buildtree(u,mid,w<<1);
	buildtree(mid+1,v,(w<<1)|1);
	if(max1[w<<1]<max1[(w<<1)|1]){
		max1[w]=max1[w<<1];
		max3[w]=max3[w<<1];
	}
	else{
		max1[w]=max1[(w<<1)|1];
		max3[w]=max3[(w<<1)|1];
	}
	if(max2[w<<1]<max2[(w<<1)|1]){
		max2[w]=max2[w<<1];
		max4[w]=max4[w<<1];
	}
	else{
		max2[w]=max2[(w<<1)|1];
		max4[w]=max4[(w<<1)|1];
	}
}
void xtree(int u,int v,int w){
	int mid=(u+v>>1);
	if(p1<=u&&v<=p2){
		if(p3==1){
			if(max1[w]<sum2){
				sum2=max1[w];
				sum=max3[w];
			}
		}
		else{
			if(max2[w]<sum2){
				sum2=max2[w];
				sum=max4[w];
			}
		}
		return;
	}
	if(p1<=mid) xtree(u,mid,w<<1);
	if(p2>=mid+1) xtree(mid+1,v,(w<<1)|1);
}
void gb(int u,int v,int w,int ww){
	if(u>v)
		return;
		
	int fir=0,sec=0;
	
	p1=u;p2=v;
	if(u&1)
		p3=1;
	else
		p3=2;
	sum=0;sum2=n+1;
	xtree(1,n,1);
	fir=sum;
	
	p1=fir+1;p2=v;
	if(fir&1)
		p3=2;
	else
		p3=1;
	sum=0;sum2=n+1;
	xtree(1,n,1);
	sec=sum;
	
	b[ww][0]=a[fir];
	b[ww][1]=a[sec];
	if(w!=0)
		lj(w,ww);
	
	top2++;
	gb(u,fir-1,ww,top2);
	top2++;
	gb(fir+1,sec-1,ww,top2);
	top2++;
	gb(sec+1,v,ww,top2);
}
int main(){
    int v;
    n=read();
    for(i=1;i<=n;i++)
    	a[i]=read();
    buildtree(1,n,1);
    top2=1;
    gb(1,n,0,1);
    s.insert(make_pair(b[1][0],1));
    top=0;
    while(s.size()!=0){
    	it=s.begin();
    	v=it->second;
    	top++;
    	ans[top]=b[v][0];
    	top++;
    	ans[top]=b[v][1];
		for(int top1=fir[v];top1;top1=nex[top1])
			s.insert(make_pair(b[to[top1]][0],to[top1]));
		s.erase(make_pair(b[v][0],v));
	}
	for(i=1;i<=top;i++)
		pus(ans[i],1);
    cout<<endl;
	return 0;
}

Measured memory_bytes: 33152
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	B := ReadInts(N)
	C := ReadInts(N - 1)
	prev := -2
	ans := 0
	for i := 0; i < N; i++ {
		a := A[i] - 1
		ans += B[a]
		if prev == a-1 {
			ans += C[prev]
		}
		prev = a
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int a[52][52];
int ans[52][52];
int main() 
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char c;
			cin>>c;
			if(c=='#')
			{
				a[i][j]=1;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(!a[i][j])
		    {
			    if(a[i+1][j])
			    {
				    ans[i][j]++;
			    }
			    if(a[i][j+1])
			    {
				    ans[i][j]++;
			    }
			    if(a[i-1][j])
			    {
				    ans[i][j]++;
			    }
			    if(a[i][j-1])
			    {
				    ans[i][j]++;
			    }
			    if(a[i+1][j+1])
			    {
				    ans[i][j]++;
			    }
			    if(a[i+1][j-1])
			    {
				    ans[i][j]++;
			    }
			    if(a[i-1][j+1])
			    {
				    ans[i][j]++;
			    }
			    if(a[i-1][j-1])
			    {
				    ans[i][j]++;
			    }
			    cout<<ans[i][j];
		    }
		    else
		    {
		    	cout<<"#";
		    }
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*ITS FUCKING O(N) now
GET ACCEPTED FOR FUCK'S SAKE*/


#include <iostream>
# include <bits/stdc++.h>
using namespace std;

long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;

#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int main()
{
  
    sci(n);
    int flag=1;
    int sum=0;
    int flag1=1;
    vi v;
    map<int,int>m;
    string s;
    int d=n%10;
    if(d==2||d==4||d==5||d==7||d==9)
    {
      cout<<"hon";
    }
    else if(d==0||d==1||d==6||d==8)
    {
      cout<<"pon";
    }
    else if(d==3)
    {
      cout<<"bon";
    }
    

  
    return 0;
}

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

import sys


def eratosthenes_sieve(n):
    table = [0]*(n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
    return prime_list


def prime(n):
    return eratosthenes_sieve(n)

def main():
    inp = [int(n) for n in sys.stdin]
    for n in inp:
        n_pn = len(prime(n))
        print(n_pn)

if __name__ == '__main__':
    main()

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

const long MOD = 1e9+7;

template <typename T>
T modPow(T base, T e, T mod) {
  if(e==0) return 1;
  if(e==1) return base%mod;
  if(e%(T)2==1) return (base * modPow(base, e-(T)1, mod)) %mod;
  
  T tmp = modPow(base, e/(T)2, mod);
  return (tmp * tmp) % mod;
}
template <typename T>
T primeModDiv(T num, T den, T primeMod){
  return ( num*modPow(den, primeMod-(T)2, primeMod) )%primeMod;
}
template <typename T>
T modComb(T n, T k, T mod) {
  T num = (T)1; //numerator
  T den = (T)1; //denominator
  if (k > n-k) k = n-k;
  for (T i = 1; i <= k; i++) {
    num *= (n-i+(T)1);
    num %= mod;
    den *= i;
    den %= mod;
  }
  return primeModDiv(num, den, mod);
}

int main(){
  long X, Y;
  cin >> X >> Y;
  
  long xMove1 = -1;
  long xMove2 = -1;
  for (int move2 = 0; move2 <= X/2; move2++) {
    int move1 = X - 2*move2;
    if (Y==2*move1+move2) {
      xMove1 = move1;
      xMove2 = move2;
      break;
    }
  }
    
  if (xMove1==-1) {
    cout << 0 << endl;
    return 0;
  }
  cout << modComb(xMove1+xMove2, xMove1, MOD) << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int cnt = 0;
	char a[n][n], b[m][m];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			cnt = 0;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (a[i + k][j + l] == b[k][l]) {
						cnt++;
					}
				}
			}
			if (cnt == m * m) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int x,y,z,k,s;
  int as = 0;
  cin >> k >> s;
 
  for(x = 0; x<=k; x++){
    	for(y = 0; y<=k; y++){
    		int z = s - x - y;
    			if(z>=0 && z<=k){
                  as++;
        }
    }
  }
  cout << as << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int MOD = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

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

            if(i==0){
                if(j==0){
                    continue;
                }
                dp[i][j] +=dp[i][j-1];
            }
            else if(j==0){
                dp[i][j] += dp[i-1][j];
            }
            else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            dp[i][j] %=MOD;
        }
    }
    cout << dp[h-1][w-1] << '\n';
}

Measured memory_bytes: 5248
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//228
	int a,b,c;
	cin>>a>>b>>c;
	int cnt = 0;
	int mx = max(a,max(b,c));
	int av = (mx-a)/2;
	cnt+=av;
	a+=2*av;
	av=(mx-b)/2;
	cnt+=av;
	b+=2*av;
	av=(mx-c)/2;
	cnt+=av;
	c+=2*av;
	if(a!=b||b!=c) {
		cnt++;
		int mn = max(a,max(b,c));
		int cd =0;
		if(a==mn)cd++;if(b==mn)cd++;if(c==mn)cd++;
		if(cd==2)cnt++;
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    a=abs(a-x);
    b=abs(b-x);
    if (a>b){
        cout << "B" << " ";
    }
    else if (b>a){
        cout << "A" << " ";
    }
    else {
        cout << "A" ;
    }
    return 0;
}




/*#include <iostream>

using namespace std;

int main() {
        int a,b;
        cin >> a >> b;
        b*=2;
        b-=a;
        cout << b ;
    return 0;
}*/


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b)

if __name__=='__main__':
    main()

Measured memory_bytes: 65596
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  
  int n;
  char c;
  int kind[4] = {};

  cin >> n; 
  for(int i=0;i<n;i++){
    cin >> c;
    if(c == 'P')kind[0] = 1;
    if(c == 'W')kind[1] = 1;
    if(c == 'G')kind[2] = 1;
    if(c == 'Y')kind[3] = 1;
  }

  int f = 0;
  for(int i=0;i<4;i++){
    if(kind[i] == 0){
      f = 1;
      break;
    }
  }

  if(f){
    cout << "Three" << endl; 
  } else {
    cout << "Four" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
int a,b;
cin >> a >> b;
if ((a+b)<24)
{
  cout << a+b << endl;
}else
{
  cout << a+b-24 << endl;
}


  

  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
	int n = 0;
	cin >> n;
	map<string, int> res = { {"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0} };
	for (int i = 0; i < n; ++i)
	{
		string str;
		cin >> str;
		res[str] += 1;
	}

	cout << "AC x " << res["AC"] << endl;
	cout << "WA x " << res["WA"] << endl;
	cout << "TLE x " << res["TLE"] << endl;
	cout << "RE x " << res["RE"] <<endl;
}



Measured memory_bytes: 3232
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

a = I()

ans = int(a + a ** 2 + a ** 3)

print(ans)

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

string s;
int k;
vector<int> v[30];
set<string> st;

int main(){
	cin >> s >> k;
	int n = s.size();
	for(int i=0; i<n; ++i)
		v[s[i]-'a'].push_back(i);
	for(int i=0; i<26; ++i){
		if(st.size() > k) break;
		for(int j=0; j<v[i].size(); ++j){
			for(int l=1; v[i][j]+l<=n&&l<k+1; ++l){
				st.insert(s.substr(v[i][j], l));
			}
		}
	}
	auto it = st.begin();
	for(int i=0; i<k-1; ++i) ++it;
	cout << *it << endl;
}

Measured memory_bytes: 384
n = int(input())
d = []
for i in range(n):
    d1, d2 = map(int, input().split(' '))
    d.append([d1, d2])

cnt = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
    else:
        cnt = 0

    if cnt == 3:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9144
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	MOD = 10**9 + 7
	rows, cols = rli()
	dp = [[0 for __ in range(cols)] for _ in range(rows)]
	A = []
	for _ in range(rows):
		row = []
		for c in rll()[0]:
			if c == "#":
				row.append(1)
			else:
				row.append(0)
		A.append(row)

	dp[0][0] = 1
	for c in range(1, cols):
		if A[0][c] == 1:continue
		dp[0][c] = dp[0][c-1]

	for r in range(1, rows):
		if A[r][0] == 1: continue
		dp[r][0] = dp[r-1][0]

	for r in range(1, rows):
		for c in range(1, cols):
			if A[r][c] == 1: continue
			dp[r][c] = dp[r-1][c] + dp[r][c-1]

	print(dp[-1][-1] % MOD)

	stdout.close()

if __name__ == "__main__":
	main()

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

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M + 1);
  for (int i = 1; i <= M; i++) {
    cin >> t.at(i);
  }
  
  int ans = 0;
  
  for (int i = 1; i <= N - 1; i++) {
    int gain = 1;
    for (int j = i + 1; j <= N ; j++) {
      if (s.at(i) == s.at(j)) gain++;
    }
    for (int j = 1; j <= M; j++) {
      if (s.at(i) == t.at(j)) gain--;
    }
  if (ans < gain) ans = gain;
  }
  
  cout << ans;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

string s;
int x,y;
int dpx[2][16001];
int dpy[2][16001];

int main() {
    cin>>s;
    cin>>x>>y;
    int num=0;
    int now=0;
    while(1){
        if (s[now]=='F'){
            num+=1;
            now+=1;
        }
        else break;
    }
    x-=num;
    //cout<<num<<endl;
    vi yoko,tate;
    //縦移動からスタート
    now=0;
    int z=0;
    s+='A';
    for (int i=num+1;i<s.size();i++){
        if (s[i]=='F')now+=1;
        else if (now!=0){
            if (z==0){
                z=1;
                tate.push_back(now);
                now=0;
            }
            else{
                z=0;
                yoko.push_back(now);
                now=0;
            }
        }
        else z=1-z;
    }
    /*rep(i,tate.size())cout<<tate[i]<<" ";
    cout<<endl;
    rep(i,yoko.size())cout<<yoko[i]<<" ";*/
    memset(dpx,0,sizeof(dpx));
    memset(dpy,0,sizeof(dpy));
    dpx[0][8000]=1;
    dpy[0][8000]=1;
    for (int i=0;i<tate.size();i++){
        for (int j=0;j<16001;j++){
            if (dpy[i%2][j]==1){
                dpy[(i+1)%2][j+tate[i]]=1;
                dpy[(i+1)%2][j-tate[i]]=1;
                dpy[i%2][j]=0;
            }
        }
    }
    for (int i=0;i<yoko.size();i++){
        for (int j=0;j<16001;j++){
            if (dpx[i%2][j]==1){
                dpx[(i+1)%2][j+yoko[i]]=1;
                dpx[(i+1)%2][j-yoko[i]]=1;
                dpx[i%2][j]=0;
            }
        }
    }
    int num1=x+8000,num2=y+8000;
    int i1=(yoko.size())%2,i2=(tate.size())%2;
    if (dpx[i1][num1]==1 && dpy[i2][num2]==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    






    

    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Aoj.ALDS.Chapter5A
{
    class Program
    {
        public static List<int> ns;
        public static List<int> ms;
        public static int n;
        public static int q;

        public static bool Solve(int current, int answer, int i)
        {
            if (current == answer)
                return true;

            if (i == n)
                return false;

            return Solve(current, answer, i + 1) || Solve(current + ns[i], answer, i + 1);
        }

        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("Aoj/AlgorithmsAndDataStructures/Input/05_Recursion_A_01.txt"));
            // var sw = new Stopwatch();
            // sw.Start();

            n = int.Parse(Console.ReadLine());
            ns = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();

            q = int.Parse(Console.ReadLine());
            ms = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();

            for (int i = 0; i < q; i++)
            {
                bool result = Solve(0, ms[i], 0);
                Console.WriteLine(result ? "yes" : "no");
            }

            // Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
        }
    }
}

Measured memory_bytes: 9368
import collections

a,b = list(map(int,input().split()))
c,d = list(map(int,input().split()))
e,f = list(map(int,input().split()))

N = []
N.extend([a,b,c,d,e,f])

k = collections.Counter(N)

if(k.most_common()[0][1] == 2):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3444
#include <cstdio>
using namespace std;
int n,i,a[200050];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=2;i<=n;i++) if (a[i]>a[i-1]+1) return puts("-1"),0;
	if (a[1]) return puts("-1"),0;
	long long ans=0;
	for (i=2;i<=n;i++) if (a[i]==a[i-1]+1) ans++;else ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    string s;
    cin>>s;
    char odd,even;
    bool is=true;
    REP(i,s.length()){
        if(i%2==0&&s[i]=='L'){
            is=false;
            break;
        }
        if(i%2!=0&&s[i]=='R'){
            is=false;
            break;
        }
    }
    if(is){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int main(){
	boost;
	int n;
	cin>>n;
	v vec(n);
	for(auto&it :vec)cin>>it;
	int comp=1;
	int ans=0;
	for (int i = n-2; i >= 0; i--)
	{
		if(vec[i]>=vec[i+1])comp++;
		else ans=max(ans,comp-1),comp=1;
	}
	cout<<max(ans,comp-1);
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a, b, n; cin >> a >> b >> n;
  
  int y=0;
  if(n>=b) n = b-1;
  
  y = (a*n)/b;
    
  cout << y << endl;
}

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

using namespace std;

int main(){
    int A,B,C,buf;
    bool flag;
    scanf("%d%d%d",&A,&B,&C);
    buf = 0;
    flag = false;
    for(int i=0;i<B;i++){
        buf = (buf+A)%B;
        if(buf==C){
            flag = true;
            break;
        }            
    }

    if(flag)
        printf("YES\n");
    else    
        printf("NO\n");
    
    
    return 0;
}

Measured memory_bytes: 256
from math import degrees, atan
a, b, x = map(int, input().split())
vol = a * a * b
if x == vol:
    print(0)
elif x <= vol / 2:
    print(degrees(atan((a * b * b) / (2 * x))))
else:
    print(degrees(atan(2 * (vol - x) / (a ** 3))))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int a = sc.nextInt();

			int r = 0;
			if (h % a > 0) {
				r++;
			}
			System.out.println(h / a + r);
		}
	}
}


Measured memory_bytes: 21972
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

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

    int N = scanner.nextInt();
    TreeMap<Integer, Integer> map = new TreeMap<>();
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt();
      map.put(a, map.getOrDefault(a, 0) + 1);
    }

    int cnt = 0;
    while (!map.isEmpty()) {
      Map.Entry<Integer, Integer> entry = map.lastEntry();
      int a = entry.getKey();
      int va = entry.getValue() - 1;
      if (va == 0) map.remove(a);
      else map.put(a, va);
      int b = (Integer.highestOneBit(a) << 1) - a;
      if (map.containsKey(b) && map.get(b) > 0) {
        int vb = map.get(b) - 1;
        if (vb == 0) map.remove(b);
        else map.put(b, vb);
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 102976
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	int ans = 0, cnt = 0, prev = 1 << 30;
	for (int i = n - 1; i >= 0; --i) {
		if (h[i] < prev) {
			cnt = 0;
		} else {
			++cnt;
		}
		ans = max(ans, cnt);
		prev = h[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	ll a,b,c;
	cin>>a>>b>>c;
	umap<ll,ll> m;
	m[a]++;
	m[b]++;
	m[c]++;
	if(m.size()==2)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  bool y = false;
  cin >> n;
  
  for (int i=0;i <= n;i++) {
    cin >> s;
    if (s == "Y") {y = true;}
  }
  if (y == false) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
ll gcd(ll a,ll b){
if(a==0||b==0)return max(a,b);
if(b>a)swap(a,b);
 while(1){
        if(a%b!=0){
            ll tmp=b;b=a%b;
            a=tmp;
        }else{
            return b;
        }
    }
}
int main() {


    ll n;
    cin>>n;
    vector<ll> v(n);
    ll ans=0;
    rep(i,n){
        cin>>v[i];
        ans+=(v[i]-1);
    }
//    ll m=v[0];
//    for(int i=1;i<n;i++){
//        ll k=gcd(m,v[i]);
//        m=m*v[i]/k;
//    }
//    m--;
//    ll ans=0;
//
//    rep(i,n){
//        ans+=m%v[i];
//    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"
#include "math.h"

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;

/** Problem1189 : Prime Caves **/
int caves[1010][1010];
int dp[1010][1010];
const int MAX = 1030000;
bool prime[MAX];

int main()
{
	int m, n;
	const int dx0[4] = {1, 0, -1, 0}, dy0[4] = {0, -1, 0, 1}, dx1[3]={-1, 0, 1};
	int sx=0, sy=0;
	
	for (int i=0; i<MAX; i++)
		prime[i] = true;
	
	prime[0] = false; prime[1] = false;
	
	for (int i=2; i<MAX; i++) {
		if (prime[i]) {
			for (int j=2; i*j<MAX; j++) {
				prime[i*j] = false;
			}
		}
	}
	
	while (cin>>m>>n, m||n) {
		fill(caves[0], caves[0]+1010*1010, 0);
		fill(dp[0], dp[0]+1010*1010, -1);
		int x=1010/2, y=1010/2 , t=1, direct=1;
		caves[x][y]=1;
		caves[++x][y]=2;
		int i=2; bool change = true;
		if (n==1) {
			sx=x; sy=y;
		}
		while (1) {
			rep(j, t) {
				x+=dx0[direct]; y+=dy0[direct];
				caves[x][y]=i+1;
				i++;
				if (i==n) {
					sx = x; sy = y;
				}
				if (i>=m) goto end;
			}
			if (change) {
				t++;
				change = false;
			} else {
				change=true;
			}
			direct++; direct%=4;
		}
		
	end: ;
		int ans=0, alast=0, test=0;

		dp[sx][sy] = prime[caves[sx][sy]];
		REP(j, 0, 1010) {
			REP(i, 0, 1010) {
				ans = max(ans, dp[i][j]);
				
				if (dp[i][j] == -1) continue;
				if (caves[i][j] == 0) continue;
				
				rep(k, 3) {
					int nx=i+dx1[k], ny=j+1;
					if (!(0<=nx && nx<1010) || ny>=1010) continue;
					if (caves[nx][ny]==0) continue;

					dp[nx][ny] = max(dp[nx][ny], dp[i][j]+prime[caves[nx][ny]]);
					if (dp[nx][ny]<dp[i][j]+prime[caves[nx][ny]]) {
						dp[nx][ny] = dp[i][j]+prime[caves[nx][ny]];
					}
					
					
					test = max(test, caves[nx][ny]);
					ans = max(ans, dp[nx][ny]);
				}
			}
		}
		
		if (ans!=0) {
			REP(j, 0, 1010) {
				REP(i, 0, 1010) {
					if (dp[i][j]==ans && prime[caves[i][j]]) {
						alast = max(alast, caves[i][j]);
					}
				}
			}
		}
		
		cout << ans << " " << alast << endl;
	}
	return 0;
}

Measured memory_bytes: 10140
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0) continue;
        if(i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  int a[n + 1];

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

  int c = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[a[i]] == i) c++;
  }
  //ダブルカウントしているので半分にする
  p(c / 2);
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    int k,t;
    cin >> k >> t;
    vector<int> a(k);
    REP(i,k){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());

    int maxi = a[0]-1;
    for(int i = 1;i < k;i++){
        maxi -= a[i];
    }
    int ans;
    if(maxi <= 0){
        ans = 0;
    }else{
        ans = maxi;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	// cout << fixed << setprecision(20);

	int N; cin >> N;
	string s; cin >> s;
	V<int> a(N); rep(i,N) a[i] = s[i]-'1';
	bool odd = false;
	rep(i,N) if(a[i] == 1) odd = true;
	if(!odd){
		rep(i,N) a[i] /= 2;
	}
	int ans = 0;
	rep(i,N){
		if(((N-1)&i) == i && a[i] == 1) ans ^= 1;
	}
	if(!odd) ans *= 2;
	cout << ans << endl;
}


Measured memory_bytes: 5252
#include<stdio.h>
#include<stdlib.h>

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

int main(){

  int n;
  scanf("%d",&n);

  int str[100];
  int i = 0;

  int tmp = 0;
  int r = 0;
  while(abs(n) > 0){
    if( n % 2 == 0)str[i] = 0;
    else str[i] = 1;

    n = (n - str[i])/(-2);
    i++;
  }

  if(i == 0){
    printf("0");
    return 0;
  }

  for(int j = i-1; j >= 0; --j){
     printf("%d",str[j]);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <algorithm>
typedef long long ll;
using namespace std;
 
int main() {
	int k;
	cin >> k;
	queue<ll> v;
	for (int i = 1; i <= 9; i++)
		v.push(i);
	ll num;
	for (int i = 1; i <= k; i++) {
		num = v.front();
		v.pop();
		if (num % 10 != 0)
			v.push(10 * num + num % 10 - 1);
		v.push(10 * num + num % 10);
		if (num % 10 != 9)
			v.push(10 * num + num % 10 + 1);
	}
	cout << num << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 N, A, B;
  cin >> N >> A >> B;
  if ((A & 1) == (B & 1)) {
    cout << (B - A) / 2 << endl;
  } else {
    i64 ans = 2e18;
    {
      i64 c = A - 1;
      i64 a = 1;
      i64 b = B - c - 1;
      amin(ans, c + 1 + (b - a) / 2);
    }
    {
      i64 c = N - B;
      i64 a = A + c + 1;
      i64 b = N;
      amin(ans, c + 1 + (b - a) / 2);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

#define NUM_BUILDING 4
#define NUM_FLOOR 3
#define NUM_ROOM 10

int main()
{
  int n, b, f, r, v;
  int tenant[NUM_BUILDING][NUM_FLOOR][NUM_ROOM] = {};

  scanf("%d", &n);
  while (n--) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    tenant[b-1][f-1][r-1] += v;
  }
  for (b = 0; b < NUM_BUILDING; b++) {
    for (f = 0; f < NUM_FLOOR; f++) {
      for (r = 0; r < NUM_ROOM; r++) {
        printf(" %d", tenant[b][f][r]);
      }
      putchar('\n');
    }
    if (b < NUM_BUILDING - 1) printf("####################\n");
  }

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  int K;
  cin >> K;
  
  int l[60];
  for (int i=0; i<N; i++) cin >> l[i];
  
  sort (l, l+N, greater<int>());
  
  int saidai = 0;
  
  for(int i=0; i<K; i++) {
    saidai += l[i];
  }
  cout << saidai << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int nodes,edges;
	cin >> nodes >> edges;
	vector<int> adj[nodes+1];
	vector<bool> visited(nodes+1);
	vector<int> ans(nodes+1);
	for(int i=1;i<=edges;i++)
	{
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	queue<int> q;
	q.push(1);
	ans[1] = 1;
	visited[1] = true;
	while(!q.empty())
	{
		int cur = q.front();
		q.pop();
		for(int next : adj[cur])
		{
			if(!visited[next])
			{
				q.push(next);
				visited[next] = true;
				ans[next] = cur;
			}
		}
	}
	cout << "Yes\n";
	for(int i=2;i<=nodes;i++)
		cout << ans[i] << "\n";
}	


Measured memory_bytes: 10096
import * as fs from 'fs';

namespace AtCoder.abc096 {
    export class Program {
        constructor(private readonly args: string[][]) {
        }

        main(this: Program) {
            const abc: number[] = this.args[0].map(Number);
            const [k]: number[] = this.args[1].map(Number);
            const max: number = Math.max(...abc);
            const shifted: number = (max << k) - max;
            const ans: number = abc.reduce((acc: number, cur: number) => acc + cur) + shifted;

            console.log(ans);
        }
    }
}

const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
const prg: AtCoder.abc096.Program = new AtCoder.abc096.Program(args);
prg.main();

Measured memory_bytes: 7500
fun main(args: Array<String>) {
    val inLine = readLine()?.split(" ").orEmpty()

    val n = inLine[0].toLong()
    val a = inLine[1].toLong()
    val b = inLine[2].toLong()

    val tmp1 = n / (a + b)
    val tmp2 = n % (a + b)

    if(tmp2 <= a) {
        println((tmp1 * a) + tmp2)
    }else{
        println((tmp1 * a) + a)
    }
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  ll N;
  cin >> N;
  for(int i = sqrt(N);; --i) {
    if(N % i == 0) {
      int res = max(to_string(i).length(), to_string(N / i).length());
      cout << res << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 256