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

#define ll long long
int main()
{
   ll n;
   cin>>n;
   vector<ll> a(n);
   for(ll i=0;i<n;i++)
   {
   	 cin>>a[i];
   }
   for(ll i=n-1;i>0;i--)
   {
   	 if(a[i]<a[i-1])
   	 {
   	 	a[i-1]=a[i-1]-1;
	 }
   }
   vector<ll> b;
   b=a;
   sort(b.begin(),b.end());
   if(b==a)
   {
    cout<<"Yes";
   }
   else
   {
   	cout<<"No";
   }
   return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int n;
vector<vector<long long>> memo1, memo2;
vector<int> a;
long long INF = 1000000000000000000LL;

long long jiro(int, int);
long long taro(int st, int ls) {
  if (memo1[st][ls] != -INF)
    return memo1[st][ls];
  if (st + ls >= n)
    return 0;
  return memo1[st][ls] =
             max(jiro(st + 1, ls) + a[st], jiro(st, ls + 1) + a[n - 1 - ls]);
}

long long jiro(int st, int ls) {
  if (memo2[st][ls] != -INF)
    return memo2[st][ls];
  if (st + ls >= n)
    return 0;
  return memo2[st][ls] =
             min(taro(st + 1, ls) - a[st], taro(st, ls + 1) - a[n - 1 - ls]);
}

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  memo1.resize(n + 1);
  memo2.resize(n + 1);
  for (int i = 0; i <= n; i++) {
    memo1[i].resize(n + 1);
    memo2[i].resize(n + 1);
    for (int j = 0; j <= n; j++)
      memo1[i][j] = memo2[i][j] = -INF;
  }
  cout << taro(0, 0) << endl;
  return 0;
}


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

#define is_uruu main
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
    
struct card { char suit,value; };
    
void selectionSort(struct card A[], int N){
	FOR(i,0,N-1){
		int minj=i;
		FOR(j,i+1,N){
			if(A[minj].value > A[j].value)minj = j;
		}
		if(minj != i){
			swap(A[i], A[minj]);
		}
	}
}

void bubbleSort(struct card A[], int N){
    int j;
    bool flag = 1;
    while(flag){
        flag = 0;
        ROF(j,N-1,0){
            if(A[j].value < A[j-1].value){
                swap(A[j], A[j-1]);
                flag = 1;
            }
        }
    }
}
    
int is_uruu(){
	int N;
	card A[36], B[36];
	cin >> N;
	FOR(i,0,N)cin >> A[i].suit >> A[i].value;
	FOR(i,0,N)B[i] = A[i];
	
	bubbleSort(A, N);
	FOR(i,0,N-1)cout << A[i].suit << A[i].value << " ";
	cout << A[N-1].suit << A[N-1].value << endl << "Stable" << endl;
	
	
	selectionSort(B, N);
	FOR(i,0,N-1)cout << B[i].suit << B[i].value << " ";
	cout << B[N-1].suit << B[N-1].value << endl;
	FOR(i,0,N){
		if(B[i].suit != A[i].suit){
			cout << "Not stable" << endl;
			return 0;
		}
	
	}
	cout << "Stable" << endl;
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int n, k ;
    cin >> n >> k ;
    int a[n] ;
    rep(i, 0, n) cin >> a[i] ;
    rep(i, k, n) {if(a[i] > a[i-k]) cout << "Yes\n" ; else cout << "No\n" ;}
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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


Measured memory_bytes: 5216
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll h;
    cin >> h;

    ll tmp = (ll)log2(h);
    
    ans = pow(2, tmp+1) - 1;

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int a,b,ans=0;cin>>a>>b;
    for(int i=1;i<=b-a;i++)ans+=i;
    cout<<ans-b<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
LL a,b,x,i,j,y;
LL f(LL a){
	return a*a*a*a*a;
}
int main(){
	scanf("%lld",&x);
	for(i=-1000;i<=1000;i++){
		y=f(i)+x;
		for(j=-1000;j<=1000;j++)
			if(f(j)==y){
				printf("%lld %lld\n",j,i);
				return 0;
			}
	}
	return 0;
}

Measured memory_bytes: 3180
/*input
3 998244353
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int>pii;
const int maxn = 5050;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, k, MOD, change[maxn];
void add(int &a, int b)
{
	a += b;
	if(a >= MOD)
		a -= MOD;
}
int dp[maxn][maxn];
int solve(int i, int opsbal)
{
	if(i == n - 2)
		return n - opsbal;
	int &ret = dp[i][opsbal];
	if(ret != -1)
		return ret;
	ret = 0;
	add(ret, solve(i + 1, opsbal));
	if(opsbal - change[i] + 1 <= n)
		add(ret, solve(i, opsbal - change[i] + 1));
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> MOD;
	
	k = (n - 1) / 2;
	change[0] = 0;
	for(int i = 1; i <= k; i++)
		change[i] = -i;
	if(n % 2 == 0)
		change[k + 1] = -k;
	int cur = -k;
	for(int i = k + (n % 2 == 0) + 1; i <= n; i++)
	{
		++cur;
		change[i] = cur;
	}

	sort(change, change + n + 1);

	memset(dp, -1, sizeof dp);
	int ans = 0;
	for(int i = 0; i <= n - 1; i++)
		add(ans, solve(0, i));
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll N, X; cin >> N >> X;
  vector<ll> x(N); 
  for(int i = 0; i < N; i++) cin >> x[i];
  x.push_back(X);
  sort(x.begin(),x.end());
  ll ans = x[1] - x[0];
  for(int i = 2; i < x.size(); i++){
    ans = __gcd(ans, x[i] - x[i-1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x[2];
	x[0]=read(),x[1]=read();
	int K=read();
	for(int i=1; i<=K; ++i)
		{
			int id=(i&1)^1;
			if(x[id]&1)
				{
					--x[id];
				}
			x[id^1]+=x[id]>>1;
			x[id]>>=1;

		}
	cout<<x[0]<<' '<<x[1];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define long long long
const int MAXN = 1e6 + 7;
const long MOD = 1e9 + 7;
const long INF = 1e15;


main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int i, j, k;

    int N; cin >> N;
    int c = 0;
    for (i = 1; i <= N; ++i) {
        c += to_string(i).size() & 1;
    }
    cout << c << "\n";
}

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


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


  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll tot = 0;
  rep(i,n) tot ^= a[i];
  rep(i,n){
    cout << (tot^a[i]) << " \n"[i==n-1];
  }
  
  return 0;
    

}


Measured memory_bytes: 4752
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

# 左の箱（パターンにあたる）と右の箱（対象）が連動して動く
# 文字が同じ限り右に広げて、lcpを記録しながら左に縮めていく感じ
# 縮められなくなったら、topを右の箱の左端にして、左の箱を0までずらす
# 箱ができていない（幅が0）のときは、右の箱を1つ右に

def ZAlgorithm(aa):
    target = aa
    # s = input()
    len_t = len(target)
    lcp = [-1] * len_t
    top = 1  # 右の箱において、左の箱の0に対応する点
    left = 0  # 左の箱の左端(本当はここでので宣言は不要だけど理解の為)
    right = 0  # 左の箱の右端
    lcp[0] = 0
    while top < len_t:
        # 箱を右に広げていく
        while top + right < len_t and target[right] == target[top + right]:
            right += 1
        # 右の箱左端のlcpを記録
        lcp[top] = right
        left = 1
        # 箱の幅が0だったらtopを動かして、このターン終了
        if right == 0:
            top += 1
            continue
        # lcpを記録しながら箱を左に縮めていく（最初の条件重要）
        while left + lcp[left] < right and left < right:
            lcp[top + left] = lcp[left]
            left += 1
        # topを右の箱の左端にして、左の箱を0まで戻す
        top += left
        right -= left
        left = 0  # これも本当は不要
    return lcp

def main():
    # 「aを左にシフト」＝「bを右にシフト」
    # 左にシフトは面倒なのでbを右に動かす
    # 動かした(下記は2つシフトしたとき)結果
    #  a0  a1  a2  a3  a4
    # xor xor xor xor xor
    #  x   x   x   x   x
    #  =   =   =   =   =
    #  b3  b4  b0  b1  b2
    # と、なっていればよい。ここで、xorをただの足し算に置き換えて考える
    #  a0  a1  a2  a3  a4
    #  +   +   +   +   +
    #  x   x   x   x   x
    #  =   =   =   =   =
    #  b3  b4  b0  b1  b2
    # 具体例で
    #  4   6   3   7   2
    #  +   +   +   +   +
    #  1   1   1   1   1
    #  =   =   =   =   =
    #  5   7   4   8   3
    # このとき、aの増減とbの増減は一致する
    # aの増減・・・末尾から(+2) 4 (+2) 6 (-3) 3 (+4) 7 (-5) 2
    # bの増減・・・末尾から(+2) 5 (+2) 7 (-3) 4 (+4) 8 (-5) 3
    # これはxorでも同様のことがいえる
    # よって、a,bそれぞれの隣接xorのリストを作る
    # aを2つ並べて(ループするから)、bを右にシフトしながら一致する位置を探す
    # 一致する位置を探すのはZ-Algorithmを使った
    # シフト量が分かれば、対応する1組のa,bからxも分かる
    # らしいが、こんなの思いつかんわ!!

    inf = pow(2, 31)
    n = II()
    aa = LI()
    bb = LI()
    ax = [aa[i - 1] ^ aa[i] for i in range(n)]
    bx = [bb[i - 1] ^ bb[i] for i in range(n)]
    # print(ax)
    # print(bx)
    ll = ZAlgorithm(bx + [inf] + ax + ax[:-1])
    # lcp・・・length common prefixみたいな?
    for shift, lcp in enumerate(ll[n + 1:]):
        if lcp == n: print(shift, aa[shift] ^ bb[0])

main()


Measured memory_bytes: 54292
/* -------------------------------- */
/* Name: MD. Khairul Basar          */
/* Institute: HSTU                  */
/* Dept: CSE                        */
/* Email: khairul.basar93@gmail.com */
/* -------------------------------- */

#include <bits/stdc++.h>
/* all header files */

#define fs            first
#define sc            second
#define sp            printf(" ")
#define nl            printf("\n")
#define pb(a)         push_back(a)

#define setzero(a)    memset(a,0,sizeof(a))
#define setneg(a)     memset(a,-1,sizeof(a))
#define setinf(a)     memset(a,126,sizeof(a))

#define tc1(x)        printf("Case %d: ",x)
#define tc2(x)        printf("Case #%d: ",x)
#define tc3(x)        printf("Case %d:\n",x)
#define tc4(x)        printf("Case #%d:\n",x)

#define iin(x)        scanf("%d",&x)
#define din(x)        scanf("%lf",&x)
#define lin(x)        scanf("%lld",&x)
#define clin(x)       scanf("%I64d",&x)

#define pr1(x)        cout<<x<<"\n"
#define pr2(x,y)      cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)    cout<<x<<" "<<y<<" "<<z<<"\n"
#define pr4(w,x,y,z)  cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define fast          ios::sync_with_stdio(0)
#define read          freopen("input.txt","r",stdin)
#define write         freopen("output.txt","w",stdout)
#define prflag1(flag) printf("%s\n",(flag)?"YES":"NO")
#define prflag2(flag) printf("%s\n",(flag)?"Yes":"No")
#define prflag3(flag) printf("%s\n",(flag)?"yes":"no")
/* macro definitions */

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int>pii;
typedef pair<LL, LL>pll;
typedef vector<int>vi;
typedef vector<LL>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
/* type definitions */

LL MOD_EXPO(LL b, LL p, LL m)
{
    if(p==0) return 1;
    LL ret=MOD_EXPO(b,p/2,m)%m;
    ret=(ret*ret)%m;
    return ((p&1) ? (ret*b)%m : ret%m);
}
LL POWER(LL N, LL K)
{
    LL i,ans=1;
    for(i=1;i<=K;i++) ans*=N;
    return ans;
}
int SET(int N, int pos)
{
    return (N | (1<<pos));
}
int RESET(int N, int pos)
{
    return (N & !(1<<pos));
}
bool CHECK(int N, int pos)
{
    return (N & (1<<pos));
}
/* necessary functions */

int dx4[]= {1,-1,0,0};
int dy4[]= {0,0,1,-1};
int dx6[]= {0,0,1,-1,0,0};
int dy6[]= {1,-1,0,0,0,0};
int dz6[]= {0,0,0,0,1,-1};
int dx8[]= {1,-1,0,0,-1,1,-1,1};
int dy8[]= {0,0,1,-1,1,1,-1,-1};
int dkx8[]= {-1,1,-1,1,-2,-2,2,2};
int dky8[]= {2,2,-2,-2,1,-1,1,-1};
/* direction arrays */

int tc=1;
const double eps=1e-9;
const double pi=acos(-1.0);
const long long int mx=1e5;
const long long int mod=1e9+7;
/* global declarations */

LL a[mx+5],b[mx+5];

int main()
{
    LL n,i,ans,k,x;
    while(cin>>n)
    {
        ans=0;
        for(i=1;i<=n;i++)
        {
            lin(a[i]);
            lin(b[i]);
        }
        for(i=n;i>=1;i--)
        {
            k=a[i]+ans;
            if(k%b[i])
            {
                x=k/b[i]+(k%b[i]!=0);
                x*=b[i];
                ans+=x-k;
            }
        }
        pr1(ans);
    }
    return 0;
}


Measured memory_bytes: 1792
n,m,k=map(int,input().split())
a=[0] + list(map(int,input().split()))
b=[0] + list(map(int,input().split()))

for i in range(1,n+1):
    a[i] += a[i-1]

for i in range(1,m+1):
    b[i] += b[i-1]

ans=0
j=m
for i in range(n+1):
    l = k - a[i]
    if(l<0):
        break
    while b[j]>l:
        j-=1
    
    ans = max(ans, i+j)
print(ans)

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

int64_t mod = 1000000007;

int64_t ruijo(int64_t a, int64_t b)		// aのb乗(mod)を計算する。
{
	if (b == 1) {
		return  a % mod;
	} else if (b % 2 == 0) {
		int64_t temp = ruijo(a, b / 2);
		return (temp * temp) % mod;
	} else {
		return (a * ruijo(a, b - 1)) % mod;
	}
}
int main()
{
	int64_t n, k;
	cin >> n >> k;

	vector<int64_t> v(k + 1);

	for (int64_t i = k; i >= 1; i--) {
		int64_t num = k / i;
		int64_t baisuu = ruijo(num, n);
		if (i * 2 <= k) {
			for (int64_t j = i * 2; j <= k; j += i) {
				baisuu -= v.at(j);
			}
		}
		v.at(i) = baisuu;
	}

	int64_t ans = 0;
	for (int i = 0; i < k + 1; i++) {
		ans += i * v.at(i);
		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

string s1, s2, tval;

char up[4] = {'.', '.', '#', '#'};
char dn[4] = {'.', '#', '.', '#'};

int main() {
    GI(n);

    bool fwd = true;

    while (s1.size() < n) {
        bool ok = false;

        FORN(i, 4) {
            string ns1 = (fwd ? s1 + up[i] : up[i] + s1);
            string ns2 = (fwd ? s2 + dn[i] : dn[i] + s2);

            cout << ns1 << "\n" << ns2 << "\n";
            cin >> tval;

            if (tval[0] == 'T') {
                s1 = ns1;
                s2 = ns2;
                ok = true;
                break;
            }
            else if (tval[0] == 'e') {
                return 0;
            }
        }

        if (!ok) {
            fwd = false;
        }
    }
    
    return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define mp make_pair
#define mt make_tuple
typedef long long ll;
using namespace std;

ll N,M;
typedef pair<ll,ll> P;
P task[100000];

priority_queue<P> que;

int main(void){
    cin >> N >> M;
    rep(i,N)cin >> task[i].first >> task[i].second;
    sort(task,task+N);
    //rep(i,N)cout << task[i].first <<" " << task[i].second << endl;
    //rep(i,N)que.push(mp(task[i].second,task[i].first));
    //cout << que.top().first << " " << que.top().second << endl;
    ll j = 0;
    ll ans = 0; 
    for(ll i = 1;i<=M;i++){
        while(j<N){
            if(task[j].first > i)break;
            que.push(mp(task[j].second,task[j].first));
            j++;
        }
        if(!que.empty()){ans += que.top().first;que.pop();}        
    }
    cout << ans << endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		long N=stdIn.nextLong();
		long A=1,B=1,min=N;
		while(A<=Math.sqrt(N)){
			if(N%A==0){
				B=N/A;
				String a=String.valueOf(A);
				String b=String.valueOf(B);
				if(a.length()<=b.length()){
					if(min>b.length())
						min=b.length();
				}
				else
					if(min>a.length())
						min=a.length();
			}
			A++;
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21844
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')



def solve():
    n = f()[0]
    a = f()

    add_sum = 0
    xor_sum = 0
    ans = 0

    l = 0
    r = 0
    while r<=n-1:
        add_sum += a[r]
        xor_sum ^= a[r]

        r+= 1

        if add_sum != xor_sum:
            while add_sum != xor_sum:
                add_sum -= a[l]
                xor_sum ^= a[l]
                ans += r - l-1
                l += 1

        if r == n:
            ans += (n-l+1)*(n-l)//2
    
    print(ans)


solve()


Measured memory_bytes: 24840
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll n;
vi v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  if(n == 0) cout << 0;
  while(n != 0){
    if(n % -2){
      v.pb(1);
      n -= 1;
    }else{
      v.pb(0);
    }
    n /= -2;
  }
  reverse(rng(v));
  for(int i: v) cout << i;
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    double l;
    cin >> l;
    printf("%.10f\n", l*l*l/27);
    return 0;
}

Measured memory_bytes: 256
class Node:
	def __init__(self, value):
		self.value = value
		self.next = None

class SimpleQeueue:
	def __init__(self):
		self.size = 0
		self.head = None
		self.tail = None
		return

	def enqueue(self, value):
		node = Node(value)
		if self.head == None:
			self.head = node
			self.tail = node
		else:
			self.tail.next = node
			self.tail = node
		self.size += 1

	def dequeue(self):
		if self.is_empty() == True:
			return None
		node = self.head
		self.head = self.head.next
		self.size -= 1
		if self.is_empty() == True:
			self.head = None
			self.tail = None
		return node.value

	def peek(self):
		if self.is_empty() == True:
			return None
		return self.head.value

	def get_size(self):
		return self.size

	def is_empty(self):
		return self.size == 0

	def __str__(self):
		str_ = '['
		current = self.head
		while current != None:
			str_ += str(current.value)
			current = current.next
			if current != None:
				str_ += ', '
		str_ += ']['
		if self.tail != None:
			str_ += str(self.tail.value)
		str_ += ']'
		return str_

class Process:
	def __init__(self, name, time):
		self.name = name
		self.time = int(time)

	def set_time(self, time):
		self.time = time

n, q = map(int, input().split())
myqueue = SimpleQeueue()
for i in range(n):
	name, time = map(str, input().split())
	myqueue.enqueue(Process(name, time))

time_elapsed = 0
while myqueue.is_empty() != True:
	process = myqueue.dequeue()
	time = process.time
	if time > q:
		process.set_time(time - q)
		time_elapsed += q
		myqueue.enqueue(process)
	else:
		time_elapsed += time
		print(process.name + ' ' + str(time_elapsed))



Measured memory_bytes: 25196
object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n=s.nextInt

		val a=Array.fill(n)(s.nextInt)
		val b=Array.fill(n)(s.nextInt)

		println((0 to n-1).map(i=>a(i)-b(i)).filter(i=>i>0).sum)
	}
}

Measured memory_bytes: 25640
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#k = int(input())
#n, k = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))


if s == "RRR":
    print(3)
elif s == "SSS":
    print(0)
elif s == "RRS":
    print(2)
elif s == "SRR":
    print(2)
else:
    print(1)


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

ll check(ll n){
	return n?check(n/10)+n%10:0;
}
int main(){
	ll n; scanf("%lld",&n);
	ll ans=check(n),i,rst=0;ll nn=n;
	for (i=10; i<=nn; i*=10){
		rst+=(i/10)*(n%10);
		ll tmp=(n/10);
		if (rst<i-1) tmp--;
		ans=max(ans,check(tmp*i+i-1));
		n=tmp;
	}
	printf("%lld\n",ans);
	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,pos;
vector< int > pre,in,post;
void rec(int l,int r){
    if(l>=r) return;
    int root=pre[pos++];
    int p=0; while(in[p]!=root) p++;
    rec(l,p);
    rec(p+1,r);
    post.push_back(root);
}
int main(){
    scanf("%d",&n);
    int temp;
    for(int i=0;i<n;++i){
        scanf("%d",&temp);
        pre.push_back(temp);
    }
    for(int i=0;i<n;++i){
        scanf("%d",&temp);
        in.push_back(temp);
    }
    pos=0;
    rec(0,n);
    printf("%d",post[0]);
    for(int i=1;i<n;++i){
        printf(" %d",post[i]);
    }
    putchar('\n');
    return 0;
}

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

using namespace std;
using llint = long long;

int n, m, ans=0;
vector<int> k;
vector<int> p;


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

    k.resize(m);
    p.resize(m);
    vector<vector<int> > s(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> k.at(i);
        s.at(i).resize(k.at(i));
        for (int j = 0; j < k.at(i); ++j)
        {
            cin >> s.at(i).at(j);
        }
    }

    for (int i = 0; i < m; ++i)
    {
        cin >> p.at(i);
    }

    for (int bit = 0; bit < (1<<n); ++bit) 
    {
        int light = 0;
        for (int i = 0; i < m; ++i)
        {
            int sum = 0;
            for (int j = 0; j < k.at(i); ++j)
            {
                if (bit & (1<<(s.at(i).at(j)-1)))
                {
                   sum ++;
                }
            }

            if (sum%2 == p.at(i))
            {
                light ++;
            } else {
                break;
            }
        }
        
        if (light == m)
        {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
class SwitchingRails
  def initialize
    @cars = []
  end

  def io_cars(num)
    if num == 0
      puts @cars.pop
    else
      @cars.push(num)
    end
  end
end

obj = SwitchingRails.new()

while line = gets
  num = line.to_i
  obj.io_cars(num)
end

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

vector<int> adj[100001];
vector<int> sign(100001,-1);

/*void bfs(int r,int p){
    for(int i=0;i<adj[r].size();i++){
        if(adj[r][i]!=p &&  sign[adj[r][i]]==-1){
            sign[adj[r][i]] = r;
            bfs(adj[r][i],r);
        }
    }
}*/

void bfs(int s){
    queue<int> q;
    q.push(s);
    int u;
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(int v=0;v<adj[u].size();v++){
            if(sign[adj[u][v]]==-1){
                sign[adj[u][v]] = u;
                q.push(adj[u][v]);
            }
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    sign[0] = -2;
    bfs(0);
    cout << "Yes" << endl;
    for(int i=1;i<n;i++){
        cout << sign[i]+1 << endl;
    }
}

Measured memory_bytes: 10340
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeScanner(1024)
	nab := eGetInts(scanner)
	n, a, b := nab[0], nab[1], nab[2]
	sum := 0
	for i := 1; i <= n; i++ {
		k1 := (i / 10000) % 10
		k2 := (i / 1000) % 10
		k3 := (i / 100) % 10
		k4 := (i / 10) % 10
		k5 := (i / 1) % 10
		ksum := k1 + k2 + k3 + k4 + k5
		if ksum >= a && ksum <= b {
			sum += i
		}
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


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

using namespace std;

using int64 = long long;

// ねね
int main() {
  int N, Q;
  cin >> N >> Q;
  int now = 0;
  for(int i = 0; i < Q; i++) {
    int T, K;
    cin >> T >> K;
    if(T == 1) {
      (now += K) %= N;
    } else {
      cout << (now + K - 1) % N + 1 << endl;
    }
  }
}




Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string> 
#include <string.h>
#include <set>
#include <stdlib.h>
using namespace std; 
int main()
{
    int x,t;
    cin>>x>>t;
    if (t>x) {
    	cout<<0;
    	return 0;
	}
	cout<<x-t;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 707;
int n, dp[N][N], use[N], w[N][N], nr[4], m, a, b, ans;
vector <int> v[N];

void dfs(int node, int col) {
	// dbg(node, col);
	use[node] = col;
	nr[col]++;

	for(auto i : v[node])
		if(use[i] == col) {
			cout << "-1\n";
			exit(0);
		} else if(!use[i])
			dfs(i, 3 - col);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	ans = m;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(i != j)
				w[i][j] = w[j][i] = 1;

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

	for(int i = 1; i <=n; i++)
		for(int j = 1; j <= n; j++)
			if(w[i][j])
				v[i].push_back(j);


	vector <pair<int, int> > c;


	for(int i = 1; i <= n; i++) {
		if(!use[i]) {
			nr[2] = nr[1] = 0;
			dfs(i, 1);
			c.push_back({nr[2], nr[1]});
		}
	}

	dp[0][0] = 1;
	// dbg(c);
	int k = 0;
	for(auto i : c) {
		k++;
		for(int j = 0; j <= n; j++) {
			if(j >= i.st) dp[k][j] |= dp[k - 1][j - i.st];
			if(j >= i.nd) dp[k][j] |= dp[k - 1][j - i.nd];
		}
		// dbg_v(dp[k], n + 1);
	}

	// dbg_v(dp, n + 1);
	for(int i = 0; i <= n; i++)
		if(dp[k][i] && dp[k][n - i]) {
			// dbg(i);
			ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
		}

	cout << ans << '\n';
}	

	

Measured memory_bytes: 4992
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    deque<int> dq;
    bool is_reversed = false;

    for (auto &&i : a) {
        if (!is_reversed) {
            dq.emplace_back(i);
        } else {
            dq.emplace_front(i);
        }
        is_reversed = !is_reversed;
    }

    vector<int> ans;
    for (auto &&i : dq) {
        ans.emplace_back(i);
    }

    if (is_reversed) reverse(ans.begin(), ans.end());

    for (auto i = ans.begin(); i != prev(ans.end()); i++) {
        cout << *i << " ";
    }
    cout << *prev(ans.end()) << endl;
}


Measured memory_bytes: 8496
#include <iostream>
using namespace std;
long long fib[50];

int main(void) {
    fib[0] = fib[1] = 1;
    for (int i = 2; i < 50; i++) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }
    int n;
    cin >> n;
    cout << fib[n] << endl;
    return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

ll gcd(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main() {
    int n;
    cin >> n;
    vector<ll> t(n);

    int ni = 0;
    int yon = 0;
    int sonota = 0;

    REP(i, n) {
        int k;
        cin >> k;
        if(k % 4 == 0) yon++;
        else if(k % 2 == 0) ni++;
        else sonota++;
    }
    
    int ans = 0;
    
    if(ni == 0) {
        if(yon + 1 < sonota) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        if(yon < sonota) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
}
 

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    ll n,d; cin>>n>>d;
    if(n%(2*d+1))
        OUT(n/(2*d+1)+1);
    else
        OUT(n/(2*d+1));
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)

sys.setrecursionlimit(100000)

N, X = map(int, input().split())

def f(x, n):
    if x == 0 or x == n:
        return 0
    debug(x,n)
    # if 2*x == n:
    #     return 3*x
    if x % (n-x) == 0:
        return 3*x
    if 2*x < n:
        # return f(x, n-x) + 3*x# n + x
        return f(n-x, n)
    a = x//(n-x) + 1
    t = a*(n-x) - x
    return f(n-x-t, n-x) + 3*x # + t

print(f(X, N))


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>

int main(int argc, char* argv[])
{
    int N = 0;
    std::cin >> N;

    std::string S = "";
    std::cin >> S;

    if (N % 2 != 0) {
        std::cout << "No" << std::endl;
        return 0;
    }

    std::string S1 = S.substr(0, N / 2);
    std::string S2 = S.substr(N / 2, N);

    if (S1.compare(S2) == 0) {
      std::cout << "Yes" << std::endl;
    } else {
      std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())

ans = 0

c = collections.Counter(prime_factorize(n))

for key in c.keys():
    for i in range(1, c[key] + 1):
        if n % (key ** i) == 0:
            n //= (key ** i)
            ans += 1


print(ans)

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

int main() {
  int n;
  string s;

  cin >> n >> s;

  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    int half = n / 2;
    bool yes = true;
    for(int i=0;i<half;i++) {
      if(s.at(i) == s.at(i+half)) {
        continue;
      } else {
        yes = false;
        break;
      }
    }

    if(yes) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#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 all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(n % (a + b), a) + n / (a + b) * a << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main 
{
	public static int n;
	public static long[] nums;
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		nums = new long[n];
		for(int i = 0; i < n; i++)
			nums[i] = Long.parseLong(st.nextToken());
		long sum = nums[0];
		if(sum == 0)
			pw.println(Math.min(solve(1L, 1L), solve(-1L, 1L)));
		else if(sum > 0)
			pw.println(Math.min(solve(sum, 0L), solve(-1L, sum + 1L)));
		else if(sum < 0)
			pw.println(Math.min(solve(sum, 0L), solve(1L, -sum + 1L)));
		br.close();
		pw.close();
		System.exit(0);
	}
	public static long solve(long sum, long ans)
	{
		for(int i = 1; i < n; i++)
		{
			long num = nums[i];
			if(sum > 0)
			{
				sum += num;
				if(sum >= 0)
				{
					ans += sum + 1;
					sum = -1;
				}
			}
			else if(sum < 0)
			{
				sum += num;
				if(sum <= 0)
				{
					ans += -sum + 1;
					sum = 1;
				}
			}
		}
		return ans;
	}
}

Measured memory_bytes: 36608
#include <iostream>
#include <cmath>
#include <cstdio>
#define PI 3.14159265358

using namespace std;

int main(void){

  int go,kakudo;
  char ten;
  double x,y;
  int R = 90;
  x = y = 0;
  while(1){
    cin >> go >> ten >> kakudo;
    if( go == 0 && kakudo == 0 )break;
    x += go * sin(R*PI/180);
    y += go * cos(R*PI/180);
    R -= kakudo;
  }
  printf("%d\n%d\n", (int)y, (int)x);  
  return 0;
}

Measured memory_bytes: 1148
s=input()
n=0
if(s[0]=='k'or s[len(s)-7]=='k'):
  n+=1
if(s[1]=='e'or s[len(s)-6]=='e'):
  n+=1
if(s[2]=='y'or s[len(s)-5]=='y'):
  n+=1
if(s[3]=='e'or s[len(s)-4]=='e'):
  n+=1
if(s[4]=='n'or s[len(s)-3]=='n'):
  n+=1
if(s[5]=='c'or s[len(s)-2]=='c'):
  n+=1
if(s[6]=='e'or s[len(s)-1]=='e'):
  n+=1
if(n==7):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#define pi 3.14159265358979

int main(void) {
  double x = 0, y = 0;
  int d = 90;
  while( 1 ) {
    int a, b;
    scanf("%d,%d", &a, &b);
    if(!a && !b) break;
    x += cos((double)d / 180.0 * pi) * a;
    y += sin((double)d / 180.0 * pi) * a;
    //printf("%d %d %d\n", d, (int)x, (int)y);
    d -= b;
    d %= 360;
  }
  printf("%d\n%d\n", (int)x, (int)y);
  return 0;
}


Measured memory_bytes: 3140
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc158_c();
	}
  
  	public static void solve_abc158_c(){

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = -1;
		
		for(int i=1;i<=1250;i++){
			
			int c = (int)Math.floor(i * 0.08);
			int d = (int)Math.floor(i * 0.1);
			
			if(c == A && d == B){
				ans = i;
				break;
			}
			
		}
		System.out.println(ans);

		sc.close();

	}
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

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

  if (a % 2 == 0 || b % 2 == 0) cout << "No" << endl;
  else cout << "Yes" << endl;

  return (0);
}


Measured memory_bytes: 3652
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int main(void){
   int a[4];
   int b[4];
   int c[4][4];

   for(int i=1;i<=3;i++){
       for(int j=1;j<=3;j++){
           cin >> c[i][j];
       }
   }
   for(int i=1;i<3;i++){
       if(c[1][i] - c[2][i] != c[1][i+1] - c[2][i+1]){
           cout << "No" << endl;
           return 0;
       }
   }
   for(int i=1;i<3;i++){
       if(c[2][i] - c[3][i] != c[2][i+1] - c[3][i+1]){
           cout << "No" << endl;
           return 0;
       }
   }
   for(int i=1;i<3;i++){
       if(c[i][1] - c[i][2] != c[i+1][1] - c[i+1][2]){
           cout << "No" << endl;
           return 0;
       }
   }
   for(int i=1;i<3;i++){
       if(c[i][2] - c[i][3] != c[i+1][2] - c[i+1][3]){
           cout << "No" << endl;
           return 0;
       }
   }
   cout << "Yes" << endl;
   return 0;
}

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

const int INF = 1001001001;

int main() {
	int h, n; cin >> h >> n;
	vector<int>dp(h + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		for (int j = 0; j < h; j++) {
			int nj = min(j + a, h);
			dp[nj] = min(dp[nj], dp[j] + b);
		}
	}
	cout << dp[h] << endl;

	return 0;
}

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

long max_route(long x[], long l, long n) {
    long b[n];
    b[n - 1] = x[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        b[i] = b[i + 1] - x[n - 1 - ((n - 1 - i) >> 1)] + l - x[n - 1 - ((n - 2 - i) >> 1)] + (x[i] << 1);
    }
    return b[max_element(b, b + n) - b];
}

int main() {
    long l, n;
    cin >> l >> n;
    long x[n], x_rev[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        x_rev[n - i - 1] = l - x[i];
    }

    cout << max(max_route(x, l, n), max_route(x_rev, l, n)) << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
ll power(ll x,ll n)
{
 ll r=1;
 while(n>0)
 {if(n & 1)r=(r*x)%mod;n/=2;x=(x*x)%mod;}
 return r;
}
int main(void){
    // Your code here!
 ll ans,n;
 ans=1;
 cin >> n;
 ans=power(10,n);
 ans=(ans-power(9,n)+mod)%mod;
 ans=(ans-power(9,n)+mod)%mod;
 ans=(ans+power(8,n))%mod;
 cout << ans;
 return 0;
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		char[] ch = br.readLine().toCharArray();
		
		if(ch[2] == ch[3] && ch[4] == ch [5])
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 32700