akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;
const int MAX = 5100000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	COMinit();
	int x, y; cin >> x >> y;
	int sum = x + y;
	if (sum % 3 != 0) {
		cout << 0 << endl; return 0;
	}
	cout << COM((x + y) / 3, x - (x + y) / 3) << endl;
	return 0;
}

Measured memory_bytes: 119808
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int N; cin >> N;
  int a[N]; int p,max,second; max=second=0;
  
  for(int i=0; i<N; i++){
    cin >> a[i];
    if(a[i]>max){second=max; max=a[i]; p=i;}
    else if(a[i]>second){second = a[i];}
  }
  
  for(int i=0; i<N; i++){
    if(i==p){cout << second;}
    else{cout << max;}
    if(i<N-1){cout << endl;}
  }
  
  return 0;
}

Measured memory_bytes: 2432
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ANS = 0;

	cin >> N;

	vector<SINT32> DATA(N);
	vector<SINT32> DATA2(N);
	
	rep(i,0,N) {
		cin >> DATA[i];
	}
	rep(i,0,N) {
		cin >> DATA2[i];

		if (DATA[i] > DATA2[i]) {
			ANS = ANS + (DATA[i]-DATA2[i]);
		}
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int n;
    cin>>n;
    vector<vector<int> > dp(n,vector<int>(3,0));
    for(int i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        if(i==0)
            dp[i][0]=a,dp[i][1]=b,dp[i][2]=c;
        else{
            dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
            dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
            dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 8720
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

constexpr int P = 26;

int main() {
	vector<char> c(30);
	for (int i = 0; i < 30; i++) {
		c[i] = ('a' + i);
	}
	
	long long n;
	cin >> n;
	n--;
	
	string s = "";
	while (n >= P) {
		int i = (n % P);
		s += c[i];
		n /= 26;
		n--;
	}
	s += c[n];

	reverse(s.begin(), s.end());
	cout << s << '\n';
	
	return 0;
}

Measured memory_bytes: 3656
s = input()
left = -1;right = -1
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        left = i+1;right=i+2
        break
    if not i == len(s)-2:
        if s[i]==s[i+2]:
            left = i+1;right=i+3
            break
print(left, right)

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x[] = new long[N];
		long y[] = new long[N];
		for (int i = 0; i < x.length; i++) {
			x[i] = sc.nextLong();
			y[i] = x[i];
		}
		Arrays.sort(y);
		double median = ((double)y[N/2-1]+(double)y[N/2])/2;
		if (N == 2) {
			System.out.println(y[1]);
			System.out.println(y[0]);
			return;
		}
		for (int i = 0; i < x.length; i++) {
			if ((double)x[i] <= median) {
				System.out.println(y[N/2]);
			} else {
				System.out.println(y[(N-2)/2]);
			}
		}
	}
}


Measured memory_bytes: 96552
N = gets.to_i
A = []
N.times do
  A << gets.to_i
end

success = false
i = 0
t = 0
N.times do
  t += 1
  if A[i] == 2
    success = true
    break
  end
  i = A[i] - 1
end
puts success ? t : -1

Measured memory_bytes: 2996
#include<iostream>
main(){int p[30001],M=30001,T,a,i,j,k;for(i=1;i*i++<M;)for(j=i+i;!p[i]&j<M;j+=i)p[j]=1;for(;std::cin>>T,T;printf("%d\n",a))for(a=0,i=2;i<T;i++)for(j=i;!p[i]&j<=(k=T-i-j);j++){if(p[j]||p[k]||i+j<=k)continue;a++;}}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int a,b,c,d=0,count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(a;a<=b;a++){
		d=a;
		if(c%d==0){
			count++;
		}
	}	
		printf("%d\n",count);
			
	
	return 0;
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)

typedef long long LL;

LL A, B, C, D;

LL gcd(LL x, LL y) {
	return !y ? x : gcd(y, x % y);
}

int main() {

	scanf("%*d");
	while (scanf("%lld%lld%lld%lld", &A, &B, &C, &D) == 4) {
		if (A < B || B > D) { puts("No"); continue; }
		if (C >= B) { puts("Yes"); continue; }
		LL d = gcd(B, D);
		A %= d;
		LL x = C / d * d + A;
		if (x <= C) x += d;
		puts(x < B ? "No" : "Yes");
	}

	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
A = list(map(int, input().split()))
total = [i for i in range(-1, 102)]
for i in range(len(A)):
    total[A[i]+1] = 10000
dif = [0]*103
for i in range(103):
    dif[i] = abs(X-total[i])
min_index = dif.index(min(dif))

print(min_index-1)


Measured memory_bytes: 61768
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/


int main(){
    _cin;
    cout << setprecision(22);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n >> k;
    vll a(n);
    fo(i,n) cin >> a[i];
    vll dp(k+1);
    fo(i,k+1){
        fo(j,n){
            if(a[j]>i) break;
            dp[i] |= (dp[i-a[j]]^1);
        }
    }
    if(dp[k]) cout << "First";
    else cout << "Second";
    

}
 return 0;      
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

  int n; ll k;
  cin >> n >> k;
  vi a(n);
  trav(i, a) {
    cin >> i;
    --i;
  }

  int curr = 0;
  vi vis(n);
  int period = 0;
  int step = 0;
  while (step < k) {
    if (vis[curr]) break;
    vis[curr] = true;
    step++;
    curr = a[curr];
  }
  fill(all(vis), 0);
  while (step < k) {
    if (vis[curr]) break;
    vis[curr] = true;
    period++;
    step++;
    curr = a[curr];
  }
  if (step < k) {
    k -= step;
    auto rem = k % period;

    rep(iter, 0, rem) {
      curr = a[curr];
    }
  }
  cout << curr + 1 << '\n';
}


Measured memory_bytes: 4784
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
x = 1
while x<=n:
    x*=2
print(x//2)

Measured memory_bytes: 13668
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


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


int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  long long ans = 0;

  ans += min(a, k);
  k -= min(a, k);
  k -= min(b, k);
  ans -= min(c, k);
  cout << ans << endl;
}

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

int N, H;
vector<int> a, b;

signed main() {

  cin >> N >> H;

  for (int i = 0; i < N; ++i) {
    int p, q;
    cin >> p >> q;
    a.push_back(p);
    b.push_back(q);
  }

  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());

  int a_max = a[0];

  int res = 0;

  for (int pivot = 0; H > 0; ++res) {
    if (pivot >= N || a_max > b[pivot]) {
      res += (H + a_max - 1) / a_max;
      break;
    } else {
      H -= b[pivot++];
    }
  }

  cout << res << endl;

}


Measured memory_bytes: 1276
#include <iostream>
#include <vector>

using namespace std;

int count(vector<int>num,int n) {
	int cnt = 0;
	for (int i = 1; i < n - 1; ++i) {
		int a, b, c;
		a = num.at(i - 1);
		b = num.at(i);
		c = num.at(i + 1);
		if(a < b && b < c ||
			a > b && b > c)
			++cnt;
	}
	return cnt;
}

int main() {
	int n,temp,cnt;
	cin >> n;
	vector<int>num(n);
	for (int i = 0; i < n; ++i) {
		cin >> temp;
		num.at(i) = temp;
	}
	cnt = count(num, n);
	cout << cnt;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#define MM 2000000000
using namespace std;
int main(void)
{
	int v,e,i,j,k,a[100][100],s,t,d,flg;
	scanf("%d %d",&v,&e);
	for(i=0;i<v;i++)	{
		for(j=0;j<v;j++)	{
			if(i==j)	a[i][j]=0;
			else a[i][j]=MM;
		}
	}
	for(i=0;i<e;i++)	{
		scanf("%d %d %d",&s,&t,&d);
		a[s][t]=d;
	}
	
/*		for(i=0;i<v;i++)	{
			if(a[i][0]==MM)	printf("INF");
			else printf("%d",a[i][0]);
			for(j=1;j<v;j++)	{
				if(a[i][j]==MM)	printf(" INF");
				else printf(" %d",a[i][j]);	
			}
			printf("\n");
		}
*/	
	
	
	
	
	for(k=0;k<v;k++)	{
		for(i=0;i<v;i++)	{
			for(j=0;j<v;j++)	{
				if(a[i][k]!=MM && a[k][j]!=MM)	{
					a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
				}
			}
		}
	}
	flg=1;
	for(i=0;i<v;i++)	{
		if(a[i][i]<0)	{
			flg=0;	break;
		}
	}
	if(flg==0)	printf("NEGATIVE CYCLE\n");
	else {
		for(i=0;i<v;i++)	{
			if(a[i][0]==MM)	printf("INF");
			else printf("%d",a[i][0]);
			for(j=1;j<v;j++)	{
				if(a[i][j]==MM)	printf(" INF");
				else printf(" %d",a[i][j]);	
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int X, Y;
  scanf("%d %d", &X, &Y);

  if(Y%2==0 && Y/2-X>=0 && 2*X-Y/2>=0){
      printf("Yes\n");
  }else{
      printf("No\n");
  }
  
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int p) {
	int c = 1;
	while (b > 0) {
		if (b & 1)
			c = 1LL * c * a % p;
		a = 1LL * a * a % p;
		b >>= 1;
	}
	return c;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, p;
	cin >> n >> p;
	vector<vector<int>> dp(n + 1, vector<int>(n + 1)), c(n + 1, vector<int>(n + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < i; ++j) {
			dp[i][j] = (dp[i][j] + 1LL * dp[i - 1][j] * (j + 1)) % p;
			dp[i][j + 1] = (dp[i][j + 1] + dp[i - 1][j]) % p;
		}
	}
	for (int i = 0; i <= n; ++i) {
		c[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		int res = 0;
		int sets = power(2, n - i, p);
		for (int j = 0, x = 1; j <= i; ++j) {
			res = (res + 1LL * dp[i][j] * x) % p;
			x = 1LL * x * sets % p;
		}
		res = 1LL * res * power(2, power(2, n - i, p - 1), p) % p * c[n][i] % p;
		ans = (ans + (i % 2 == 0 ? res : p - res)) % p;
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  string s;
  cin >> s;
  bool a = false, b = false;
  REP(i, 3) {
    if (s[i] == 'A') a = true;
    if (s[i] == 'B') b = true;
  }
  if (a && b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <complex>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

#include <complex>

typedef complex<double> Complex;

// a.size must 2^x
vector<Complex> FFT(double theta, const vector<Complex> &a) {
  int n = a.size();
  vector<Complex> ret = a;
  for (int m = n; m >= 2; m >>= 1) {
    int mh = m >> 1;
    for (int i = 0; i < mh; i++) {
      Complex w = exp(i * theta * Complex(0, 1));
      for (int j = i; j < n; j += m) {
        int k = j + mh;
        Complex x = ret[j] - ret[k];
        ret[j] += ret[k];
        ret[k] = w * x;
      }
    }
    theta *= 2;
  }
  int i = 0;
  for (int j = 1; j < n - 1; j++) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1) {;}
    if (j < i) { swap(ret[i], ret[j]); }
  }
  return ret;
}

vector<double> Convolution(const vector<double> &lhs, const vector<double> &rhs) {
  int n = 1;
  while (n < (int)max(lhs.size(), rhs.size()) * 2) { n <<= 1; }
  vector<Complex> temp1(n);
  vector<Complex> temp2(n);
  for (int i = 0; i < n; i++) {
    if (i < (int)lhs.size()) {
      temp1[i] = Complex(lhs[i], 0);
    }
    if (i < (int)rhs.size()) {
      temp2[i] = Complex(rhs[i], 0);
    }
  }
  temp1 = FFT(2.0 * PI / n, temp1);
  temp2 = FFT(2.0 * PI / n, temp2);
  for (int i = 0; i < n; i++) { temp1[i] *= temp2[i]; }
  temp1 = FFT(-2.0 * PI / n, temp1);
  vector<double> ret;
  ret.resize(n + 1);
  for (int i = 0; i < n; i++) {
    ret[i + 1] = temp1[i].real() / n;
  }
  ret[0] = 1.0;
  return ret;
}

const int H = 60;
vector<double> anss[H + 1];
int main() {
  int n;
  while (scanf("%d", &n) > 0) {
    anss[0] = vector<double>(n + 1, 0);
    anss[0][0] = 1.0;

    FOREQ(h, 1, H) {
      anss[h] = Convolution(anss[h - 1], anss[h - 1]);
      anss[h].resize(n + 1);
      FOREQ(i, 1, n) {
        anss[h][i] /= i;
      }
    }

    FOREQ(h, 1, min(n, H)) {
      printf("%.8f\n", anss[h][n] - anss[h - 1][n] + EPS);
    }
    FOREQ(h, H + 1, n) {
      printf("%.8f\n", 0.0);
    }
  }
}

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

int main () {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ( (A+B)>(C+D) ) {
    cout << "Left" << endl;
  }
  else if ( (A+B)==(C+D) ) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(), (obj).end()

int N, M, C, ans = 0;

int main(){
    cin >> N >> M >> C;
    int B[M];
    REP(i, M){
        cin >> B[i];
    }
    int A[N][M];
    REP(i, N){
        REP(j, M){
            cin >> A[i][j];
        }
    }
    REP(i, N){
        int sum = 0;
        REP(j, M){
            sum += A[i][j] * B[j];
        }
        sum += C;
        if(sum > 0){
            ans++;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


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

    int ans = 0;
    rep(i,N){
        map<char,int> mp;
        ++mp[A[i]],++mp[B[i]],++mp[C[i]];
        if(mp.size() == 2) ++ans;
        else if(mp.size() == 3) ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            int ans = 0;
            if (a == b) ans = a + b;
            else
            {
                int t = (int)Math.Max(a, b);
                ans=2*t - 1;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27372
#include<iostream>
#include<string.h>
using namespace std;
int W, H;
int a[101][101];
int sum;
int n;


void bfs(int x, int y) {
	a[x][y] = 4;
	if (x > 1 && a[x - 1][y] == n) bfs(x - 1, y);
	if (x < H&&a[x + 1][y] == n) bfs(x + 1, y);
	if (y > 1 && a[x][y - 1] == n)bfs(x, y - 1);
	if (y < W&&a[x][y + 1] == n) bfs(x, y + 1);
}

int main()
{
	while (cin >> H >> W&&W != 0 && H != 0) {
		sum = 0;
		memset(a, 0, sizeof(a));
		char c;
		int x, y;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> c;
				if (c == '#') {
					a[i][j] = 1;
				}
				else if (c == '*') {
					a[i][j] = 2;
				}
				else if (c == '@') {
					a[i][j] = 3;
				}
			}
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (a[i][j] != 4) {
					n = a[i][j];
					bfs(i, j);
					sum++;
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}



Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    string x;
    int ans = 0;
    rep(i,n)cin >> s[i] >> t[i];
    cin >> x;
    bool pl = false;
    rep(i,n){
        if(pl)ans += t[i];
        if(s[i] == x)pl = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
import itertools
import copy

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = input()

l = len(s)-7


w = "keyence"
j=0
for i in range(len(s)):
	if s[i]==w[j]:
		j+=1
	else:
		if s[i+l:]==w[j:]:
			print("YES")
		else:
			print("NO")
		exit()

print("YES")

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n, k; cin >> n >> k;
    vi a(n + 1);
    FOR(i, 1, n) cin >> a[i];
    FOR(i, k + 1, n) {
        if (a[i] <= a[i - k])
            cout << "No\n";
        else 
            cout << "Yes\n";
    }
}

Measured memory_bytes: 4016
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

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

typedef long long ll;

#define EPS (1e-8)

const int q = -999999999;

typedef long long ll;

typedef vector<ll> vec;
typedef vector<vec> mat;

vec gauss_jordan(mat& A, vec& b) {
  int n = A.size();
  mat B(n, vec(n+1));
  rep(i, n) rep(j, n) B[i][j] = A[i][j];
  rep(i, n) B[i][n] = b[i];

  rep(i, n) {
    int pivot = i;
    REP(j, i, n) {
      if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
    }
    swap(B[i], B[pivot]);

    if(abs(B[i][i]) < EPS) return vec();

    REP(j, i+1, n+1) B[i][j] /= B[i][i];
    rep(j, n) {
      if(i != j) {
        REP(k, i+1, n+1) B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }

  vec x(n);
  rep(i, n) x[i] = B[i][n];
  return x;
}

int N, M;
mat in;
vector<pair<int, int>> qpos;

#define fail { cout << "NO\n"; goto next; }

int main() {

  bool first = 0;
  while(cin >> N >> M && N) {
    if(first) cout << endl;
    first = 1;
    bool remain = 0;
    in.clear(); in.resize(N + 1); rep(i, N + 1) in[i].resize(M + 1);
    qpos.clear();
    rep(i, N + 1) rep(j, M + 1) {
      string s; cin >> s;
      if(s == "?") in[i][j] = q, qpos.emplace_back(i, j);
      else in[i][j] = stoi(s);
    }

    rep(_, (N + 1) * (M + 1) + 10) {
    {
      rep(i, N + 1) {
        int xcnt = 0;
        ll sum = 0;
        int lastq = -1;
        rep(j, M) {
          if(in[i][j] == q) xcnt ++, lastq = j;
          else sum += in[i][j];
        }
        if(xcnt == 0) {
          if(in[i][M] == q) in[i][M] = sum;
          else if(in[i][M] != sum) fail;
        }
        else if(xcnt == 1) {
          if(in[i][M] == q) {}
          else in[i][lastq] = in[i][M] - sum;
        }
        else {}
      }
    }

    {
      rep(j, M + 1) {
        int xcnt = 0;
        ll sum = 0;
        int lastq = -1;
        rep(i, N) {
          if(in[i][j] == q) xcnt ++, lastq = i;
          else sum += in[i][j];
        }
        if(xcnt == 0) {
          if(in[N][j] == q) in[N][j] = sum;
          else if(in[N][j] != sum) fail;
        }
        else if(xcnt == 1) {
          if(in[N][j] == q) {}
          else in[lastq][j] = in[N][j] - sum;
        }
        else {}
      }
    }}

    rep(i, N + 1) rep(j, M + 1) {
      remain |= in[i][j] == q;
    }

    if(remain) fail;

    for(auto e: qpos) {
      cout << in[e.first][e.second] << endl;
    }

  next:;
  }
  
  return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using mpr = map<pr, int>;
struct mint {
  ll divisor = 1000000007;
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % divisor;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
};

void answer() {
  ll N;
  cin >> N;
  mpr iwashi;
  int i00, i01, i10;
  i00 = i01 = i10 = 0;
  rep(i,N) {
    ll a, b;
    cin >> a >> b;
    if(a == 0 && b == 0) {
      i00++;
    } else if(a == 0) {
      i01++;
    } else if(b == 0) {
      i10++;
    } else {
      if(a < 0) a *= -1, b *= -1;
      ll gcd = __gcd(abs(a), abs(b));
      iwashi[make_pair(a/gcd, b/gcd)]++;
    }
  }
  mint ans = 1;
  mpr checked;
  for(const auto& i : iwashi) {
    if(checked[i.first]) continue;
    ll a1 = i.first.first, b1 = i.first.second;
    ll a2 = b1, b2 = -a1;
    if(a2 < 0) a2 *= -1, b2 *= -1;
    ll n1 = i.second;
    ll n2 = iwashi[make_pair(a2, b2)];
    ans *= (modpow(mint(2), n1) + modpow(mint(2), n2) - 1);
    checked[i.first] = 1;
    checked[make_pair(a2, b2)] = 1;
  }
  ans *= (modpow(mint(2), i01) + modpow(mint(2), i10) - 1);
  ans += i00;
  cout << ans - 1 << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 53616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s ;
  cin >> t ;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
   
  if(s<t){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

int cal(int n)
{
  int retval = 0;

  while( n > 0 ) {
    retval += n % 10;
    n /= 10;
  }
  return retval;
}

int main()
{
  int N;
  int min = 999999;
  std::cin >> N;
  for ( int a = 1; a < N; a++ ) {
    int b = N - a;
    int tmp = cal(a) + cal(b);
    if ( min > tmp ) min = tmp;
  }
  std::cout << min << std::endl;
  return 0;
}


Measured memory_bytes: 256
module Main where

dist :: Double -> Double -> Double -> Double -> Double
dist a1 a2 b1 b2 = sqrt $ ((a1 - b1) ^ 2) + ((a2 - b2) ^ 2)

hToDeg = (* 30)
mToDeg = (* 6)
degToRad = (* (pi / 180))

toCarteesian :: Double -> Double -> (Double, Double)
toCarteesian v r = (r * cos v , r * sin v)

-- a is legth of hour
-- b length of minute
-- h:m is the time
main :: IO ()
main = do
	input <- getLine
	let (a:b:h:m:_) = map read $ words input
	let (a1, a2) = toCarteesian (degToRad . (+ m * (30 / 60)) . hToDeg $ h) a
	let (b1, b2) = toCarteesian (degToRad . mToDeg $ m) b
	putStrLn . show $ dist a1 a2 b1 b2



Measured memory_bytes: 4520
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int city = (n-1)*(m-1);
		System.out.println(city);	
		}	
	}

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

int main() {
  string S;
  int s=0,ans=0;
  
  cin >> S;
  for(int i=0;i<S.size();++i){
    char x = S.at(i);
    if(x == 'A' || x == 'C' || x == 'G' || x == 'T'){
      s+=1;
    }else{
      if(s > ans) ans = s;
      s = 0;
    }
  }
  if(s > ans) ans = s;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl "\n"
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fb(i, a, b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector <int>
#define vl vector <long long>
#define pi pair <int, int>
#define sz(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define M 100005
#define mod 1000000007
using namespace std;

void solve()
{
	ll n, ans = 0;
	cin>>n;
	ll a[n], x[n], y[n];
	f(i, 0, n) cin>>a[i];
	f(i, 0, n)
	{
		x[i] = a[i]+i;
		y[i] = a[i]-i;
	}
	sort(x, x+n);
	sort(y, y+n);
	// f(i, 0, n) cout<<x[i]<<' '; cout<<endl;
	// f(i, 0, n) cout<<y[i]<<' '; cout<<endl;
	f(i, 0, n) ans += UB(y, y+n, -x[i]) - LB(y, y+n, -x[i]);
	cout<<ans;
}

int main()
{
    IOS
    int t = 1;
    //cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 8352
use std::io::{self, Read};

fn main() {
	let mut input = String::new();
	let _ = io::stdin().read_to_string(&mut input);
	let lines: Vec<&str> = input.split("\n").collect();	
	let N = lines[0].parse::<usize>().unwrap_or(0);
	let a: Vec<i64> = lines[1].split(" ").map(|x| x.parse::<i64>().unwrap_or(0)).collect();
	let mut ans = 0;
	let mut cursor = 1;
	for i in 0..N {
		if a[i] != cursor {
			ans += 1;
		} else {
			cursor += 1;
		}
	}
	if ans == N {
		println!("{}", -1);
	} else {
		println!("{}", ans);
	}
}


Measured memory_bytes: 10492
def f(n):
    for i in range(1,n):
        n*=i
    return n
        
        
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=str(f(n))
        s=0
        l=len(a)
        for i in range(l-1,-1,-1):
            if a[i]=="0":
                s+=1
            else:
                break
        print(s)


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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> s(m);
	vector<char> c(m);
	for(int i = 0;i < m;i++){
		cin >> s[i] >> c[i];
	}
	if(n == 1){
		for(int i = 0;i < pow(10,n);i++){
			string u = to_string(i);
			int cnt = 0;
			for(int i = 0;i < m;i++){
				if(u[s[i]-1] != c[i]){
					cnt++;
				}
			}
			if(i == pow(10,n)-1 && cnt != 0){
				cout << -1 << endl;
				break;
			}
			if(cnt != 0){
				continue;
			}else{
				cout << i << endl;
				break;
			}
		}
	}else{
		for(int i = pow(10,(n-1));i < pow(10,n);i++){
			string u = to_string(i);
			int cnt = 0;
			for(int i = 0;i < m;i++){
				if(u[s[i]-1] != c[i]){
					cnt++;
				}
			}
			if(i == pow(10,n)-1 && cnt != 0){
				cout << -1 << endl;
				break;
			}
			if(cnt != 0){
				continue;
			}else{
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll a, b, x;
    cin >> a >> b >> x;

    if(a == 0){
        if(a == b){
            cout << 1 << endl;
        }else{
            cout << b / x + 1 << endl;
        }
    }else{
        cout << b / x - (a - 1) / x << endl;
    }
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,K;
    string S;
    cin >> N>>K;
    vector<ll> A(N);
    REP(i,N){
        cin >> A.at(i);
    }

    ll num = 0;
    REP(i, N)
    {
        if(A.at(i)==1){
            num = i;
            break;
        }
    }

    if(num==0||num==N-1){
        if((N-1)%(K-1)==0){
            cout << (N - 1) / (K - 1)  << endl;
        }
        else{
            cout << (N - 1) / (K - 1) + 1 << endl;
        }
        
    }
    else
    {
        if ((N - 1) % (K - 1) == 0)
        {
            cout << (N - 1) / (K - 1) << endl;
        }
        else
        {
            cout << (N - 1) / (K - 1) + 1 << endl;
        }
        /*ll num_L = num;
        ll num_R = N - num - 1;

        ll ans = 0;
        if(num_L%(K-1)==0){
            ans += num_L / (K - 1);
        }
        else{
            ans += num_L / (K - 1)+1;
        }
        if (num_R % (K - 1) == 0)
        {
            ans += num_R / (K - 1);
        }
        else
        {
            ans += num_R / (K - 1) + 1;
        }

        cout << ans << endl;*/
    }
}


Measured memory_bytes: 3972
N, C = map(int, input().split())

xv = []
for i in range(N):
    x,v = map(int, input().split())
    xv.append((x,v))

fa = [0] * N
fa[0] = xv[0][1] - xv[0][0]
fb = [0] * N
fb[0] = xv[-1][1] - (C - xv[-1][0])
for i in range(1,N):
    fa[i] = fa[i-1] + xv[i][1] + xv[i-1][0] - xv[i][0]
    fb[i] = fb[i-1] + xv[N-1-i][1] + (C - xv[N-i][0]) - (C - xv[N-1-i][0])


max_fa = [0] * (N+1)
max_fa[0] = 0
max_fa[1] = max(0,fa[0])
max_fb = [0] * (N+1)
max_fb[0] = 0
max_fb[1] = max(0,fb[0])
for i in range(2,N+1):
    max_fa[i] = max(max_fa[i-1], fa[i-1])
    max_fb[i] = max(max_fb[i-1], fb[i-1])

ans_a = ans_b = 0

for i in range(N):
    ans_a = max(ans_a, max_fa[N-1-i] + fb[i] - (C - xv[N-1-i][0]) )
    ans_b = max(ans_b, max_fb[N-1-i] + fa[i] - xv[i][0])

ans_a = max(ans_a, max_fa[-1]) # xbがスタート地点の時
ans_b = max(ans_b, max_fb[-1]) # xaがスタート地点の時
print(max(ans_a, ans_b))


Measured memory_bytes: 26136
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
const unsigned int M = 1000000007;
using namespace std;
int32_t main()
{
    IOS int t = 1;
    //cin >> t;
    while (t--)
    {
        char c;
        cin >> c;
        if (int(c) >= 97)
            cout << "a" << endl;
        else
            cout << "A" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
function Main(input) {
  let arr = parseInput(input);
  console.log(arr[0].every(n => n < 10) ? arr[0].reduce((ret, n) => ret *= n, 1) : -1)
}

function parseInput(input) {
  const lines = input.trim().split('\n');
  return lines.map(line => line.split(' '));
}

Main(require('fs').readFileSync("/dev/stdin", "utf8"));


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


int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true) {
        c -= b;
        if (c <= 0) {
            cout<<"Yes"<<endl;
            break;
        }
        a -= d;
        if(a<=0){cout<<"No"<<endl;break;}

    }
    return 0;

}



Measured memory_bytes: 3608
while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    
    catalog = list(map(int, input().split()))
    
    max_p = 0
    for i in range(n-1) :
        for j in range(1, n) :
            if i != j :
                x = catalog[i] + catalog[j]
                if x <= m and x > max_p :
                    max_p = x
    if max_p == 0 :
        print("NONE")
    else :
        print(max_p)


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


int main()
{
    int n;
    cin >> n;
    vector<int> a(0);
    rep(i,n)
    {
        int t;
        cin >> t;
        if(i % 2 == 1) continue;
        a.push_back(t);
    }
    //for(auto x:a) cout << x << " "; cout << endl;
    int ans = 0;
    for(auto x:a) if(x % 2 == 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys

p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def pbit(aa,L):
    for a in aa:print(format(a,"b").zfill(L))
    print()

def main():
    n=II()
    aa=[[int(c) for c in SI()] for _ in range(n-1)]
    #p2D(aa)

    # 人iが勝てる相手をbitで管理する
    win=[0]*n
    for i,row in enumerate(aa,1):
        for j,a in enumerate(row):
            if a:win[i]|=1<<j
            else:win[j]|=1<<i
    #pbit(win,n)

    # dpl[i]...[j,i]の範囲で優勝できるjをbitで
    # dpr[i]...[i,j]の範囲で優勝できるjをbitで
    dpl=[1<<i for i in range(n)]
    dpr=[1<<i for i in range(n)]
    for d in range(1,n):
        for i in range(n-d):
            j=i+d
            if dpl[j] & dpr[i+1] & win[i]:dpl[j]|=1<<i
        for i in range(d,n):
            j=i-d
            if dpl[i-1] & dpr[j] & win[i]:dpr[j]|=1<<i
    #pbit(dpl,n)
    #pbit(dpr,n)
    #print(format(dpl[n-1]&dpr[0],"b").zfill(n))
    print(bin(dpl[n-1]&dpr[0]).count("1"))

main()

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

int main() {
  long double pi = 3.1415926535;
  long double a, b, x;
  cin >> a >> b >> x;
  long double thita;
  
//  cout << x << " " << a*a*b << endl;
  
  if(2*x < a*a*b) {
  	long double y = (2*x) / (a*b);
	thita = pi/2 - atan(y/b);
  } else {
    long double anotherx = a*a*b - x;
    long double y = (2*anotherx) / (a*a);
    thita = atan(y/a);
  }
  
  cout << fixed << 180*thita/pi << endl; 
      
  return 0;
}


Measured memory_bytes: 3820
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node n){
  if(n != NIL){
    if(n->left != NIL) inorder(n->left);
    printf(" %d", n->key);
    if(n->right != NIL) inorder(n->right);
  }
}

void preorder(Node n){
  if(n != NIL){
    printf(" %d", n->key);
    if(n->left != NIL) preorder(n->left);
    if(n->right != NIL) preorder(n->right);
  }
}


int main(){
  int i, x, n;
  char com[20];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
import sys
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, K = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    F = np.array(list(map(int, input().split())))

    A.sort()
    F.sort()
    F = F[::-1]
    Asum = A.sum()

    left = -1
    right = 10 ** 12
    while left+1 < right:
        mid = (left+right) // 2
        if Asum - np.minimum(A, mid//F).sum() <= K:
            right = mid
        else:
            left = mid
    print(right)


if __name__ == '__main__':
    main()
    1


Measured memory_bytes: 38848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int ans = -INF;
	for(int i=1;i*i<=a[0];i++){
		if(a[0]%i != 0) continue;
		int x = 0;
		rep(j,n) if(a[j]%i != 0){
			x++;
			if(x == 2) break;
		}
		if(x < 2) ans = max(ans,i);
		int ii = a[0]/i;
		
		x = 0;
		rep(j,n) if(a[j]%ii != 0){
			x++;
			if(x == 2) break;
		}
		if(x < 2) ans = max(ans,ii);
	}
	for(int i=1;i*i<=a[1];i++){
		if(a[1]%i != 0) continue;
		int x = 0;
		rep(j,n) if(a[j]%i != 0){
			x++;
			if(x == 2) break;
		}
		if(x < 2) ans = max(ans,i);
		int ii = a[1]/i;
		
		x = 0;
		rep(j,n) if(a[j]%ii != 0){
			x++;
			if(x == 2) break;
		}
		if(x < 2) ans = max(ans,ii);
	}
	cout<<ans<<endl;
}

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

vector<vector<int> > G;

class Doubling{
	public:
	vector<vector<int> > parent;
	vector<int> depth;
	void dfs(int v, int p, int d){
		parent[0][v] = p;
		depth[v] = d;
		for(int i = 0; i < G[v].size(); i++){
			if(G[v][i] == p) continue;
			dfs(G[v][i], v, d + 1);
		}
	}
	Doubling(int V, int def_root){
		int log_v = 1;
		int pow_2 = 1;
		while(pow_2 < V){
			pow_2 *= 2;
			log_v++;
		}
		parent.assign(log_v, vector<int>(V, -1));
		depth.resize(V);
		dfs(def_root, -1, 0);
		for(int k = 0; k + 1 < parent.size(); k++){
			for(int v = 0; v < V; v++){
				if(parent[k][v] < 0) parent[k + 1][v] = -1;
				else parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}
	int lca(int u, int v){
		if(depth[u] > depth[v]) swap(u, v);
		for(int k = 0; k < parent.size(); k++){
			if((depth[v] - depth[u]) & (1 << k)){
				v = parent[k][v];
			}
		}
		if(u == v) return u;
		for(int k = parent.size() - 1; k >= 0; k--){
			if(parent[k][u] != parent[k][v]){
				u = parent[k][u];
				v = parent[k][v];
			}
		}
		return parent[0][u];
	}
};

int main(){
	int n;
	cin >> n;
	G.resize(n);
	for(int i = 0; i < n; i++){
		int k;
		cin >> k;
		for(int j = 0; j < k; j++){
			int c;
			cin >> c;
			G[i].push_back(c);
			G[c].push_back(i);
		}
	}
	Doubling T(n, 0);
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int u, v;
		cin >> u >> v;
		cout << T.lca(u, v) << endl;
	}
	return 0;
}



Measured memory_bytes: 18600