akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int game(int n, int p){
	int x[50]={0};
	int loop = 0;
	int stones = p;
	while(1){
		if(loop == n)
			loop = 0;
		if(stones > 0){
			x[loop]++;
			stones--;
			if(x[loop] == p)
				return loop;
		}
		else if(x[loop] != 0){
				stones = x[loop];
				x[loop] = 0;
		}
		loop++;
	}
}

int main(){
	int n, p;
	scanf("%d %d",&n ,&p);
	while((n!=0)||(p!=0)){
		printf("%d\n", game(n, p));
		scanf("%d %d",&n ,&p);
	}
	return 0;
}

Measured memory_bytes: 600
def solve(N, S):
    # print(N, ",", S)
    balance = 0
    start = 0
    for i in range(N):
        if S[i] == ")":
            if balance == 0:
                start += 1
            else:
                balance -= 1
        else:
            balance += 1
    return "(" * start + S + ")" * balance

if __name__ == "__main__":
    N = int(input())
    S = input()
    print(solve(N, S))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1100000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};
const int max_n = 1 << 20;


signed main() {
	string s;int k;cin>>s>>k;int ans = 0;int n = s.length();
  if(s[0] != s[n-1]){
    rep(i,n-1){
      if(s[i] == s[i+1]){
        ans++;s[i+1] = '#';
      }
    }
    ans *= k;
  }else{
    int sen = 0, kou = 0, a = 0, seq = 1;
    rep(i,n-1){
      if(s[i] == s[i+1])seq++;
      else{
        if(!sen)sen = seq;
        else a += seq / 2;
        seq = 1;
      }
    }
    if(!sen){
      ans = n*k/2;
    }else{
      kou = seq;
      ans = a * k + sen/2 + kou/2;
      ans += (sen+kou)/2 * (k-1);
    }

  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int n, m;
char s[110][110];
int mem[101][101][2];

vector<pair<int, int>> v[101][101];
int xx, yy;
bool vis[101][101];
void dfs(int x, int y){
	if(vis[x][y]){
		return;
	}
	vis[x][y]=1;
	v[xx][yy].push_back(mk(x, y));
	if(x<n-1 && s[x+1][y]=='#'){
		dfs(x+1, y);
	}
	if(y<m-1 && s[x][y+1]=='#'){
		dfs(x, y+1);
	}
}
int dp(int x, int y, int inv){
	if(x>=n || y>=m){
		return 1000000;
	}
	if(x==n-1 && y==m-1){
		if(s[x][y]=='.' || inv==1){
			return 0;
		}
		return 1;
	}
	if(mem[x][y][inv]!=-1){
		return mem[x][y][inv];
	}
	int res=1000000;
	if(s[x][y]=='#'){
		if(inv){
			res=min(dp(x, y+1, 0), dp(x+1, y, 0));
		}
		else{
			for(int i=0; i<v[x][y].size(); ++i){
				res=min(res, 1+dp(v[x][y][i].fs, v[x][y][i].sc, 1));
			}
		}
	}
	else{
		res=min(dp(x, y+1, 0), dp(x+1, y, 0));
	}
	mem[x][y][inv]=res;
	return res;
}
int main(){
    while(cin>>n>>m){
        ll ans=0;
        for(int i=0; i<n; ++i){
         //    for(int j=0; j<m; ++j){
        	// 	s[i][j]='#';
        	// }
            scanf("%s",s[i]);
        }
        for(int i=0; i<n; ++i){
        	for(int j=0; j<m; ++j){
        		if(s[i][j]=='#'){
        			memset(vis, 0, sizeof vis);
        			xx=i;yy=j;
	        		dfs(i, j);
        		}
        	}
        }
        memset(mem, -1, sizeof mem);
        ans=dp(0, 0, 0);
        printf("%lld\n",ans);
    }
  return 0;
}




Measured memory_bytes: 227200
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  
  int j = 0 ;
  while(j<=25){
    REP(i,n){
      if(s.at(i)==(char)('a'+j)){
        j++ ;
        break ;
      }
      else if(i==n-1){
        cout << (char)('a'+j)<<endl ;
        return 0 ;
      }
    }
  }
  
  cout <<"None"<<endl ;
      
        
        

  return 0 ;
}




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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

vector<int> G[maxn];

int Ans[maxn],vis[maxn];

void dfs(int u,int f){
	int t=0;
	for(auto v:G[u])if(v!=f){
		dfs(v,u);
		t|=vis[u]&vis[v];
		vis[u]|=vis[v];
	}
	while((1<<Ans[u])<=t||((vis[u]>>Ans[u])&1))Ans[u]++;
	vis[u]&=~((1<<Ans[u])-1);
	vis[u]|=1<<Ans[u];
}

void Work(){
	dfs(1,0);
	int ans=0;
	REP(i,1,n)ans=max(ans,Ans[i]);
	iout(ans);
}

void Init(){
	read(n);
	REP(i,2,n){
		int u,v;
		read(u,v);
		G[u].PB(v);G[v].PB(u);
	}
}

int main(){
	Init();
	Work();
	return 0;
}


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  string str;
  cin >> str;
  int a = 0;
  int b = 0;
  rep(i, str.size()){
    if(str[i] == '0') a++;
    else if (str[i] == '1') b++;
  }
  int ans = str.size() - (max(a, b) - min(a,b));
  cout << ans << endl;
}




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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

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

//library----------------------------------------------

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

const int NMAX = 100;
bool flag;

bool cmp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    CIN(N,K);
    int ans=1;
    rep(i,N){
        if(ans*2<ans+K){
            ans*=2;
        }else{
            ans+=K;
        }
    }
    printf("%d\n",ans);

    return 0;
}

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

const int DIM = 5e2 + 5;

pair<int, int> arr1[DIM], arr2[DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr1[i].first >> arr1[i].second;
    for( int i = 1; i <= m; i ++ )
        cin >> arr2[i].first >> arr2[i].second;
    
    for( int i = 1; i <= n; i ++ ) {
        int ans = 1e9, pos = 0;
        
        for( int j = 1; j <= m; j ++ ) {
            if( ans > abs( arr1[i].first  - arr2[j].first  ) +
                      abs( arr1[i].second - arr2[j].second ) ) {
                ans = abs( arr1[i].first  - arr2[j].first  ) +
                      abs( arr1[i].second - arr2[j].second );
                pos = j;
            }
        }
        
        cout << pos << endl;
    }
        
    return 0;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<600007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	forci(0,n)	cin>>a[i];
	for(int i=0;i<min(k,45LL);i++){
		int b[n]={0};
		for(int i=0;i<n;i++){
			int l=max(0LL,i-a[i]);
			int r=min(n-1,i+a[i]);
			b[l]++;
			if(r+1<n)
				b[r+1]--;
		}
		for(int i=1;i<n;i++)
			b[i]+=b[i-1];
		forci(0,n)
			a[i]=b[i];

	}
	forci(0,n)	cout<<a[i]<<" ";
	cout<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 6672
q=int(input())
query=[input() for _ in range(q)]
from bisect import bisect_left
ary=[-float('inf')]
for qq in query:
  if qq[0]=='1':
    _,a,_=map(int,qq.split())
    ary.append(a)
ary.sort()
ary.append(float('inf'))

class SegmentTree():
  def __init__(self,size,f=lambda x,y:x+y,default=0):
    self.size=pow(2,(size-1).bit_length())
    self.f=f
    self.default=default
    self.data=[default]*(self.size*2)
  def update(self,i,x):
    i+=self.size
    self.data[i]=x
    while i:
      i>>=1
      self.data[i]=self.f(self.data[i*2],self.data[i*2+1])
  # 区間[l,r)へのクエリ
  def query(self,l,r):
    l,r=l+self.size,r+self.size
    lret,rret=self.default,self.default
    while l<r:
      if l&1:
        lret=self.f(self.data[l],lret)
        l+=1
      if r&1:
        r-=1
        rret=self.f(self.data[r],rret)
      l>>=1
      r>>=1
    return self.f(lret,rret)
  def get(self,i):
    return self.data[self.size+i]
  def add(self,i,x):
    self.update(i,self.get(i)+x)

ml,mr=0,len(ary)+1
mv=0
st=SegmentTree(len(ary))
for qq in query:
  if qq[0]=='2':
    print(ary[ml],mv)
  else:
    _,a,b=map(int,qq.split())
    a=bisect_left(ary,a)
    st.add(0,-1)
    st.add(a,2)
    if ml<=a<mr:
      mv+=b
      ml,mr=a,a+1
    else:
      l,r=0,len(ary)+1
      # はじめて0以上になる場所を二分探索→ここがml
      while r-l>1:
        x=(r+l)//2
        if st.query(0,x)>=0:
          l,r=l,x
        else:
          l,r=x,r
      # はじめて1以上になる場所を二分探索→ここがmr
      mv+=b
      mv+=min(abs(ary[l]-ary[ml]),abs(ary[l]-ary[mr]))+abs(ary[l]-ary[a])
      ml=l
      l,r=0,len(ary)+1
      while r-l>1:
        x=(r+l)//2
        if st.query(0,x)>0:
          l,r=l,x
        else:
          l,r=x,r
      mr=l


Measured memory_bytes: 117732
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n,k ;
    cin >>n>>k;
    int kazu = 0;
    for(int i = 0;i<n;i++){
      int t; cin >> t;
      if(t >= k) kazu++;
    }
    cout<<kazu;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	string s;
	cin >> s;

	ll ans = 0;
	ll sum = 0;
	rep(i, s.length() - 1) {
		if (s[i] == 'A') {
			++sum;
		}
		else {
			if (s.substr(i, 2) == "BC") {
				ans += sum;

				++i;
			}
			else {
				sum = 0;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}



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

const int m = 2019;

int main(void){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int n = s.size();
  int tot = 0;
  int x = 1;
  ll ans = 0;
  vector<int> cnt(m);
  
  rep(i,n) {
    cnt[tot]++;
    tot += (s[i] - '0') * x;
    tot %= m;
    ans += cnt[tot];
    x = x * 10 % m;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	() => ( get().parse::<i64>().unwrap() ) }
	
    let a = get!();
    let b = get!();
    let c = get!();
    let d = get!();
    
    if (a+b) > (c+d) {
    	println!("Left");
    } else if (a+b) < (c+d) {
    	println!("Right");
    } else {
    	println!("Balanced");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, p;
  std::cin >> n >> p;
  std::vector<int> pwr(n + 1);
  std::vector<std::vector<int>> c(n + 1), s(n + 1); 
  for (int i = 0; i <= n; ++i) {
    c[i].resize(i + 1);
    c[i][0] = c[i][i] = 1;
    s[i].resize(i + 1);
    s[i][0] = s[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;
      s[i][j] = (s[i - 1][j - 1] + 1ll * s[i - 1][j] * (j + 1)) % p; 
    }
  }
  pwr[0] = 1;
  for (int i = 1; i <= n; ++i)
    pwr[i] = 1ll * pwr[i - 1] * 2 % (p - 1);
  auto power = [&](int a, int b) {
    int res = 1;
    while (b) {
      if (b & 1)
        res = 1ll * res * a % p;
      a = 1ll * a * a % p;
      b >>= 1; 
    }
    return res;
  };
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    int res = 0;
    int par = power(2, n - i), cur = 1;
    for (int j = 0; j <= i; ++j) {
      res = (res + 1ll * s[i][j] * cur) % p;
      cur = 1ll * cur * par % p;
    }
    res = 1ll * res * power(2, pwr[n - i]) % p * c[n][i] % p;
    if (i & 1) 
      ans = (ans - res + p) % p;
    else
      ans = (ans + res) % p;
  }
  std::cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 38556
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
	int k;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		k = readln().strip().to!int;
	}
}

auto main2(Input* input)
{
	with (input)
	{
        string s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        auto array = s.split(",").map!(a => a.strip()).array();
        return array[k - 1];
	}
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
            `6`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == "2");
	}

	unittest // example2
	{
		string example =
            `27`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == "5");
	}

	unittest // example3
	{
		string example =
            ``;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == _placeholder_);
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		struct Adapter
		{
			string[] _lines;
			this(string input) { _lines = input.splitLines(); }
			string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
		}
		parseInput(input, Adapter(example));
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toLong() }.toMutableList()

    aa.add(0, 0)
    aa.add(0)

    val s = (0..n).map { Math.abs(aa[it] - aa[it + 1]) }.sum()

    for (i in 1..n) {
        val x = Math.abs(aa[i - 1] - aa[i]) + Math.abs(aa[i] - aa[i + 1])
        val y = Math.abs(aa[i - 1] - aa[i + 1])
        val ans = s - x + y
        println(ans)
    }
}

Measured memory_bytes: 58340
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>ans(3);
    int A=0;
  int B=0;
  
  for(int i=0;i<3;i++){
    cin>>ans.at(i);
    if(ans.at(i)==7){
A++;
    }
    
    else if(ans.at(i)==5){
B++;
    }
    
  }
  
if(A==1&&B==2){
  cout<<"YES"<<endl;
}
  
  else{
    cout<<"NO"<<endl;
  }


}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    for ai, bi in zip(a, b):
        ans = mindist = None
        for j in range(M):
            dist = abs(ai - c[j]) + abs(bi - d[j])
            if mindist is None or dist < mindist:
                ans = j + 1
                mindist = dist
        print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (M)  # type: "List[int]"
    d = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, a, b, c, d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	al := make([]int, n)

	for i := 0; i < n; i++ {
		al[i] = nextInt()
	}

	cnt := 0

	for {
		alleven := true
		for j := 0; j < n; j++ {
			if al[j]%2 != 0 {
				alleven = false
				break
			}
		}
		if alleven == true {
			for j := 0; j < n; j++ {
				al[j] >>= 1
			}
			cnt++
		} else {
			break
		}
	}

	//fmt.Println(al)
	fmt.Println(cnt)

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
	int shiharai=0,motikin=0,oturi=0;
	int m10=0,m50=0,m100=0,m500=0;
	int o10=0,o50=0,o100=0,o500=0;

	bool firstline = true;
	while(1){

		cin >> shiharai;
		if(shiharai==0) break;
		if(!firstline) cout << endl;
		firstline = false;


		cin >> m10 >> m50 >> m100 >> m500;

		motikin = 10*m10 + 50*m50 + 100*m100 + 500*m500;
		//cout << "motikin=" << motikin << endl;

		oturi = motikin - shiharai;
		//cout << "oturi=" << oturi << endl;

		while(500<=oturi){
			oturi = oturi - 500;
			o500++;
		}
		while(100<=oturi){
			oturi = oturi - 100;
			o100++;
		}
		while(50<=oturi){
			oturi = oturi - 50;
			o50++;
		}
		if(oturi!=0) o10 = oturi / 10;

		//cout << "o500=" << o500 << endl;
		//cout << "o100=" << o100 << endl;
		//cout << "o50=" << o50 << endl;
		//cout << "o10=" << o10 << endl;

		if(m10-o10>0) cout << "10" << " " << m10-o10 << endl;
		if(m50-o50>0) cout << "50" << " " << m50-o50 << endl;
		if(m100-o100>0) cout << "100" << " " << m100-o100 << endl;
		if(m500-o500>0) cout << "500" << " " << m500-o500 << endl;

		shiharai=0,motikin=0,oturi=0;
		m10=0,m50=0,m100=0,m500=0;
		o10=0,o50=0,o100=0,o500=0;

		//cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(10**6)
n = int(input())
B = list(map(int, input().split()))

INF = 1001001001
B = [INF]+B+[INF]

ans = 0
for i in range(n):
    ans += min(B[i],B[i+1])
print(ans)

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

int main(){
    int n;
    int l;
    int count = 0;
    vector<int> v;
    cin >> n;
    for(int i = 0; i < n;i++){
        cin >> l;
        v.push_back(l);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size();i++){
        for(int j = i+1; j < v.size();j++){
            for(int k = j+1; k < v.size();k++){
                if(v[i] != v[j] && v[i] != v[k] && v[j] != v[k]){
                    if (v[i] + v[j] > v[k]) {
                        count+=1;
                    }
                }   
            }
        }
    }
    cout << count;
    return 0;
}

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

int main(){
 int x,y;
 int num_x[3000];
 int num_y[3000];

 int count=0;
 while(1){
  cin >> x >> y;
  if( x==0 && y==0 ){
   break;
  }
  num_x[count] = x;
  num_y[count] = y;
  count++;
 }

 for( int i=0; i<count; i++ ){
  if( num_x[i]>num_y[i] ){
   cout << num_y[i] << " " << num_x[i] << endl;
  }else{
   cout << num_x[i] << " " << num_y[i] << endl;
  }
 }

 return 0;
}


Measured memory_bytes: 3028
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val (n,m,k) = readints()
    val a = readlongs().toLongArray()
    val b = readlongs().toLongArray()
    for(i in 0 until n - 1){
        a[i + 1] += a[i]
    }
    for(i in 0 until m - 1){
        b[i + 1] += b[i]
    }
    var ans = 0
    for(i in 0 until n){
        if(a[i] <= k) ans = i + 1
    }
    for(i in 0 until m){
        if(b[i] > k) break
        var l = -1
        var r = n
        while(Math.abs(r - l) > 1){
            val mid = (r + l) / 2
            if(a[mid] + b[i] <= k) l = mid
            else r = mid
        }
        ans = Math.max(ans, i + 1 + l + 1)
    }
    println(ans)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << c << " " << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            // 自力で解けず解説見た
            int n = in.nextInt();
            int k = in.nextInt();
            int q = in.nextInt();
            int[] a = new int[n + 1];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                List<Integer> candidates = new ArrayList<>();
                List<Integer> list = new ArrayList<>();
                for (int j = 0; j <= n; j++) {
                    if (a[j] < a[i]) {
                        if (!list.isEmpty()) {
                            if (list.size() - k >= 0) {
                                Collections.sort(list);
                                for (int l = 0; l < list.size() - k + 1; l++) {
                                    candidates.add(list.get(l));
                                }
                            }
                            list = new ArrayList<>();
                        }
                    } else {
                        list.add(a[j]);
                    }
                }

                if (candidates.size() < q) {
                    continue;
                }

                Collections.sort(candidates);
                ans = Math.min(ans, candidates.get(q - 1) - a[i]);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 81692
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int k, t;
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		k = tmp[0], t = tmp[1];
		}
	
	int[] as = readln.chomp.split.map!(to!int).array;
	
	int amax = as.reduce!("max(a,b)");
	
	int ans;
	
	if(k % 2 == 0){
		if(amax <= k / 2) ans = 0;
		else ans = (amax - (k / 2)) * 2 - 1;
		}
	else{
		if(amax <= (k + 1) / 2) ans = 0;
		else ans = (amax - ((k + 1) / 2)) * 2;
		}
	
	ans.writeln;
	
	}
	

Measured memory_bytes: 256
weight=[]
value=[]
n,m=gets.split.map(&:to_i)
dp=Array.new(n+1,0)
for i in 0..n+1
    dp[i]=Array.new(1000000,0)
end

items=[]

#dpループ
for i in 0..n-1
    weight[i],value[i]=gets.split.map(&:to_i)
    item=[weight[i],value[i]]
    for w in 0..m
        #各状況における重さを全列挙し、選ばない場合は前の状況そのまま、選んだ
        #場合はその重さから荷物を引いた状態にvalueをたす
        if w>=item[0]
            #選ばない場合→dp[i][w]がそのまま遷移　、選んだ場合→dp[i][w]
            dp[i+1][w]=[dp[i][w-item[0]]+item[1],dp[i][w]].max
        else
         dp[i+1][w]=dp[i][w]
         end
    end
 end
    puts dp[n][m]

Measured memory_bytes: 811680
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<cmath>
using namespace std;

int main()
{
	int a = 0;
	string s;
	cin >> s;

	for (int i = 0;i < s.length() / 2;i++)
	{
		if (s[i] != s[s.length() - i-1])
			a++;
	}
	cout << a;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  int y = 114514;
  for(int i = 0; i < n; i++){
    int z;
    cin >> z;
    x -= z;
    y = min(z, y);
  }
  cout << n + x/y << endl;
  return 0;
}

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

int main() {
	string S;
	cin >> S;
	long long int count = 0;
	for( size_t i = 0; i < S.length(); i++ ) {
		if( i == 0 || i == S.length() - 1 ) {
			continue;
		}
		if( S[i - 1] != S[i + 1] ) {
			count++;
			S.erase( i, 1 );
			i -= 2;
		}
	}
	cout << (count % 2 ? "First" : "Second") << endl;
}

Measured memory_bytes: 512
require 'pp'

n, m = gets.split.map(&:to_i)
pathes = Array.new(m)
graph = {}
m.times do |i|
    a, b = gets.split.map(&:to_i)
    pathes[i] = [a, b]
    graph[a] ||= {}
    graph[b] ||= {}
    graph[a][b] = 1
    graph[b][a] = 1
end

visited = Array.new(n + 1, -1)
visited[1] = 0
queue = graph[1].map {|k, _| visited[k] = 1; [k, 1] }

while queue.empty?.!
    x, d = queue.shift
    graph[x].each do |k, _|
        next if visited[k] != -1

        visited[k] = x
        queue.push([k, d + 1])
    end
end

puts "Yes"

2.upto(n) do |i|
    puts visited[i]
end


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n){
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n % 2 == 1) x *= 2;
    return x;
}

mint choose(int n, int a){
    mint x = 1, y = 1;
    for(int i = 0; i < a; i++){
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    mint ans = f(n) - 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans << endl;
}

Measured memory_bytes: 3644
from collections import defaultdict
s = input()
t = input()
d = defaultdict(str)
e = defaultdict(str)
for i in range(len(s)):
    c1,c2 = s[i],t[i]
    if d[c1] == "":
        d[c1] = c2
    elif d[c1] != c2:
        print("No")
        exit(0)
    if e[c2] == "":
        e[c2] = c1
    elif e[c2] != c1:
        print("No")
        exit(0)
print("Yes")


Measured memory_bytes: 4016
#include <stdio.h>
#include <stdlib.h>
int main()
{   int a,b,c;
   scanf("%d %d",&a,&b);
  if(a==1&&b==2) printf("3");
  if(a==1&&b==3) printf("2");
  if(a==2&&b==1) printf("3");
  if(a==2&&b==3) printf("1");
  if(a==3&&b==1) printf("2");
  if(a==3&&b==2) printf("1");
    return 0;
}


Measured memory_bytes: 128
def divisors(n):
    ds = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ds.append(i)
            if i != n // i:# and i != 1:
                ds.append(n//i)
    # divisors.sort()
    return ds

n = int(input())
aa = list(map(int, input().split()))
counts = {}
balls = {}


for i in range(len(aa)):
    if aa[i] == 1:
        counts[i + 1] = 1
    else:
        counts[i + 1] = 0

for i in range(n, 0, -1):
    #print(f'i = {i}, counts={counts}')
    if counts[i] % 2 == 0:
        continue
    # put ball in i
    balls[i] = True
    ds = divisors(i)
    for d in ds:
        counts[d] += 1
balls = list(balls.keys())
print(len(balls))
if len(balls) > 0:
    print(' '.join(map(str, balls)))



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

static inline vector<vector<int>> read(vector<vector<int>> v)
{
    for (auto &x: v)
        for (int &y : x)
            cin >> y;
    return move(v);
}

int main(void)
{
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> a(n, vector<int>(m));
    vector<vector<int>> b(m, vector<int>(l));
    a = read(move(a));
    b = read(move(b));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            long sum = 0;
            for (int k = 0; k < m; k++)
                sum += a[i][k] * b[k][j];
            if (j)
                cout << " ";
            cout << sum;
        }
        cout << endl;
    }

    return 0;
}



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

//各桁の和を計算する関数
int findSumOfDisits(int n){
	int sum = 0;
  	while(n>0){
    	sum += n%10;
    	n/=10;
    }
	return sum;
}

int main(){
	int N,A,B;
  	cin >> N >> A >> B;
  	int total = 0;
  	for(int i =1;i <= N;++i){
    	int sum = findSumOfDisits(i);
      	if (sum >= A && sum <= B){
        	total += i;
        }
    }
  cout << total << endl;
  
}
 

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
//#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;





int main() {
	
	string s, t;
	cin >> s >> t;
	ll res = abs((ll)s.size() - (ll)t.size());
	for (int i = 0; i < min((ll)s.size() , (ll)t.size()); i++){
		if (s[i] != t[i])res++;
	}

	cout << res;
	return 0;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

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

    ll n,m;cin>>n>>m;
    vector<ll> ary(n), s(n+1);
    rep(i,n) cin >> ary[i];
    sort(ary.begin(), ary.end());
    rep(i,n) s[i+1] = s[i]+ary[i];
    ll ok = 0;
    ll ng = 1e6;
    while(ng-ok>1)
    {
        ll mid = (ok+ng)/2;
        ll num = 0;
        rep(i,n)
        {
            num += ary.end() - lower_bound(ary.begin(), ary.end(), mid - ary[i]);
        }
        (num >= m ? ok : ng) = mid;
    }
    ll ans = 0, num=0;
    rep(i,n)
    {
        ll amari = lower_bound(ary.begin(), ary.end(), ok-ary[i]) - ary.begin();
        ans += s[n] - s[amari];
        ans += (ll)(n-amari) * ary[i];
        num+=n-amari;
    }
    // 余剰分を引いている
    ans += ok * (m-num);
    cout << ans << endl;

}

Measured memory_bytes: 1792
// ABC 086

// inputに入力データ全体が入る
function Main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  const nums = args.slice(1, N + 1);
  const isValid = nums.every((n) => {
    var ns = n.split(" ");

    var t = parseInt(ns[0],10);
    var x = parseInt(ns[1],10);
    var y = parseInt(ns[2],10);
    var sum = x + y;
    return (t >= sum) && ((t % 2) === (sum % 2));
  })

  if (isValid) {
    console.log('Yes');
  } else {
    console.log('No');
  }

}

function check(before,after) {

  // プラス方向に進んだ場合
  if(before < after) {
    return after - before;
  } else {
    return before - after;
  }
};

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


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

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

  int ans;
  int N;
  cin >> N;
  vector<int> X(N);
  FOR(i, 0, N) { cin >> X[i]; }
  vector<int> T = X;

  sort(X.begin(), X.end());
  int temp = X[N / 2];

  FOR(i, 0, N) {
    if (T[i] >= temp) {
      ans = X[N / 2 - 1];
    } else {
      ans = temp;
    }

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

  return 0;
}

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

int main() {
	// your code goes here
	int h,a;
	cin>>h>>a;
	if(h<=a)
	cout<<"1";
	else
	{
	    int c=h%a;
	    if(c==0)
	    {
	        cout<<((h/a));
	    }
	    else
	    cout<<(h/a)+1;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long t = long.Parse(input[1]);
    long answer = 0;

    long[][] vertexes = new long[n][];
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      vertexes[i] = new long[2];
      vertexes[i][0] = nums[0];
      vertexes[i][1] = nums[1];
    }

    Array.Sort(vertexes, (a, b) => a[0].CompareTo(b[0]));

    for(long i = 0; i < n; i++)
    {
      if(vertexes[i][1] <= t)
      {
        Console.WriteLine(vertexes[i][0]);
        answer = 1;
        break;
      }
    }

		if(answer == 0) Console.WriteLine("TLE");
	}
}

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

using namespace std;



typedef long long ll;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	ll h;
  cin >> h;

  ll sum=0;
  while(h>=1){
  		h=h/2;
      sum++;

}
ll ans;
ans=pow(2,sum)-1;
cout<<ans<<endl;
}


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

int main(){
	string s; cin>>s;
	if(s=="SSS") cout<<0<<endl;
	else if(s=="SSR"||s=="SRS"||s=="RSR"||s=="RSS") cout<<1<<endl;
	else if(s=="RRS"||s=="SRR"||s=="RSR") cout<<2<<endl;
	else if(s=="RRR") cout<<3<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int s[m],c[m];
    for(int i=0;i<m;i++)
    {
        cin>>s[i]>>c[i];
        s[i]--;
    }
    int a[n];
    memset(a,-1,sizeof(a));
    bool p=true;
    for(int i=0;i<m;i++)
    {
        int temp=c[i];
        if(a[s[i]]==-1)
        {
            if(temp==0 && s[i]==0 && n>1)
            {
                p=false;
                break;
            }
            else
            {
                a[s[i]]=temp;
            }
        }
        else
        {
            if(a[s[i]]!=temp)
            {
                p=false;
                break;
            }
            else
            {
                continue;
            }
        }
    }
    if(p==false)
    {
        cout<<-1;
    }
    else
    {
        if(n==1)
        {
            if(a[0]==-1)
            {
                a[0]=0;
            }
        }
        for(int i=0;i<n;i++)
        {
            if(a[i]==-1)
            {
                if(i==0)
                {
                    a[i]=1;
                }
                else
                {
                    a[i]=0;
                }
            }
            cout<<a[i];
        }
    }
    return 0;
}







Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

long long solve(long long t, const vector<long long>& a, const vector<long long>& b)
{
    int n = a.size();
    int i = 0;
    long long ans = 0;
    long long sum = 0;
    for(int j=0; j<n; ++j){
        sum += b[j] - a[j];
        while(b[i] < b[j] - t){
            sum -= b[i] - a[i];
            ++ i;
        }
        ans = max(ans, sum - max(0LL, (b[j] - t) - a[i]));
    }
    return ans;
}

int main()
{
    const long long MAX = 1000000000000000LL;

    long long t;
    int n;
    cin >> t >> n;
    vector<long long> a(n), b(n), c(n), d(n);
    for(int i=0; i<n; ++i){
        cin >> a[i] >> b[i];
        c[n-1-i] = MAX - b[i];
        d[n-1-i] = MAX - a[i];
    }

    long long ans = max(solve(t, a, b), solve(t, c, d));
    cout << ans << endl;

    return 0;
}

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

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

    int count = 0;
    if(N < 10){
        count += N;
    }
    if(N >= 10){
        count += 9;
    }
    if(N >= 1000){
        count += 900;
    }
    if(N < 1000 && N >= 100){
        count += N - 100 + 1;
    }
    if(N >= 100000){
        count += 90000;
    }
    if(N < 100000 && N >= 10000){
        count += N - 10000 + 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256