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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

//DP[i][j] best play for range [i, j);  
ll DP[3010][3010];

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	vi arr(n);
	M00(i, n) cin >> arr[i];
	
	M00(i, n) DP[i][i] = 0;
	for(int len = 1; len <= n; len++) {
		for(int i = 0; i < n; i++) {
			ll can = max(arr[i] - DP[i+1][i+len], arr[i+len-1] - DP[i][i+len-1]);
			DP[i][i+len] = can;
		}
	}
	cout << DP[0][n] << endl;
}


Measured memory_bytes: 70912
#include<iostream>//基本
#include<algorithm>//min,maxとか
#include<vector>//配列
#include<string>//文字化
#include<cmath>//
#include<map>//map<int,int>toka
#include<iomanip>//
#include<numeric>//
#include<queue>//
#include<functional>//
#include<tuple>//3tuizyounokumidemoOK
#include<math.h>//
#include<bitset>//
#include<stack>//
#include<set>//新しいものしか受け取らない配列
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define sec setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.1415926
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}

int main() {
	int n;
	cin >>n;
	ll sum =0;
	vector<ll>a(n);
	rip(i, n)cin >> a[i], sum += a[i];
	ll l = 0;
	ll k;
	for (int i = 0; i < n; i++) {
		l += a[i];
		if (l >= sum / 2) {
			k = i;
			break;
		}
	}
	ll p = l - a[k];
	ll q = sum - p;
	ll j = sum - l;
	cout << min(l - j, q - p) << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D; 
  int L = A+B;
  int R = C+D;
  if (L>R){
    cout << "Left" << endl;
  }
  else if (L==R){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#体力と必殺技
prm = input().split()
hp = int(prm[0])
ult = int(prm[1])

#各必殺技のダメージ
dmg = input().split()
alldmg = 0

for cdmg in dmg:
    alldmg += int(cdmg)

if alldmg >= hp:
    print("Yes")
else:
    print("No")

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

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

const int MAX = 1000000;

int	dp[MAX] = {};
int oddp[MAX];

int main() {
	REP( i, MAX ) dp[i] = oddp[i] = i;

	int i = 2, x = 4;
	while( x < MAX ) {
		for( int j = 0; j + x < MAX; j++ ) {
			dp[j + x] = min( dp[j + x], dp[j] + 1 );
			if( x % 2 == 1 ) {
				oddp[j + x] = min( oddp[j + x], oddp[j] + 1 );
			}

//			if( j + x > ( i + 8 ) * ( i + 9 ) * ( i + 10 ) / 2 ) break;
		}
		i++;
		x = i * ( i + 1 ) * ( i + 2 ) / 6;
	}


	int n;
	while( 1 ) {
		cin >> n; if( n == 0 ) break;
		cout << dp[n] << " " << oddp[n] << endl;
	}

	
}


Measured memory_bytes: 10896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N = 2000; 

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,z,w,a[N],ans;
	cin >> n >> z >> w;
	FOR(j,0,n)cin >> a[j];
 	ans = max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

typedef map<string, vector<int> > M;

int main() {
  M pairs;
  string word;
  while (cin >> word) {
    int page;
    cin >> page;
    pairs[word].push_back(page);
  }
  for (M::iterator i = pairs.begin(); i != pairs.end(); ++i) {
    cout << i->first << endl;
    sort(i->second.begin(), i->second.end());
    for (vector<int>::iterator j = i->second.begin();
         j != i->second.end()-1; ++j)
      cout << *j << ' ';
    cout << i->second.back() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>

int main(void) {
  int N;
  scanf("%d",&N);
  int v[N];
  for(int i=0;i<N;i++)
  scanf("%d",&v[i]);

  /*大きさ順に入れ替え*/
  double max[N];
  for(int i=0;i<N;i++)
    max[i]=0;

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++){
      if(max[i]<v[j])
      max[i]=v[j];
      if(j==N-1)
        for(int k=0;k<N;k++)
          if(max[i]==v[k]){
            v[k]=0;
            break;}
    }
  double sum=(max[N-1]+max[N-2])/2;
  if(N>2)
  for(int i=N-3;i>=0;i--)
    sum=(sum+max[i])/2;

  printf("%lf",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

ll a[maxn],ans[maxn];
signed main()
{
	ll n,now=0,sum=0,res=0;
	fin>>n;
	for(rgi i=0;i<=n;++i) fin>>a[i],sum+=a[i];
	ans[0]=1;
	int t=n+1;
	for(rgi i=0;i<=n;++i)
	{
		if(sum-now<ans[i]) {t=i; break;}
		now+=a[i];
		ans[i+1]=(ans[i]-a[i])*2;
		if(ans[i+1]<0) {puts("-1"); return 0;}
	}
	sum=0;
	for(rgi i=n;i>=t;--i) sum+=a[i],ans[i]=sum;
	for(rgi i=0;i<=n;++i) res+=ans[i];
	fout<<res;
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 5188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n;
   cin>>n;
   
   ll no =0;
   vll v;
   while(n>0)
   {
      n--;
      v.pb(n%26);
      n/=26;
   }
//    for(auto it:v)
//    {
//        cout<<it<<" ";
//    }
   reverse(all(v));
   for(auto it:v)
   {
       cout<<(char)(it+'a');
   }

    



}
 

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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
string fyes="Yay";
string fno=":(";
int n,a[111111];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int st=lower_bound(a,a+n,0)-a;
	if(st==0){
		int sum=0;
		rep(i,n){
			if(i==0)sum-=a[i];
			else sum+=a[i];
		}
		cout<<sum<<endl;
		rep(i,n-2){
			cout<<a[i]<<" "<<a[i+1]<<endl;
			a[i+1]=a[i]-a[i+1];
		}
		cout<<a[n-1]<<" "<<a[n-2]<<endl;
	}
	else if(st==n){
		int sum=0;
		rep(i,n){
			if(i==n-1)sum+=a[i];
			else sum-=a[i];
		}
		cout<<sum<<endl;
		rep(i,n-1){
			cout<<a[n-1]<<" "<<a[i]<<endl;
			a[n-1]-=a[i];
		}
	}
	else{
		int sum=0;
		rep(i,n){
			if(i<st)sum-=a[i];
			else sum+=a[i];
		}
		cout<<sum<<endl;
		for(int i=st-1;i<n-2;i++){
			cout<<a[i]<<" "<<a[i+1]<<endl;
			a[i+1]=a[i]-a[i+1];
		}
		cout<<a[n-1]<<" "<<a[n-2]<<endl;
		a[n-1]-=a[n-2];
		rep(i,st-1){
			cout<<a[n-1]<<" "<<a[i]<<endl;
			a[n-1]-=a[i];
		}
	}
	return 0;
}


Measured memory_bytes: 2688
n,m=map(int,input().split())

dp=[10**9]*(1<<n)
dp[0]=0
for _ in range(m):
    a,b=map(int,input().split())
    key=0
    for i in map(int,input().split()):
        key+=1<<(i-1)
    for i in range(1<<n):
        dp[i|key]=min(dp[i|key],dp[i]+a)
if dp[-1]>10**8:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

struct pct{
    int x,y,id;
};

int n,a,b,c,d,l,r;

vector <pct> p;

vector <int> q;

bool comp(pct a, pct b){
    int t1,t2;
    if(a.x==0) t1=0;
    else if(a.y==r) t1=1;
    else if(a.x==l) t1=2;
    else if(a.y==0) t1=3;
    if(b.x==0) t2=0;
    else if(b.y==r) t2=1;
    else if(b.x==l) t2=2;
    else if(b.y==0) t2=3;
    if(t1!=t2) return t1<t2;
    if(a.x==0) return a.y<b.y;
    if(a.y==r) return a.x<b.x;
    if(a.x==l) return a.y>b.y;
    if(a.y==0) return a.x>b.x;
}

int32_t main(){
    //ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> l >> r >> n;
    for(int i=1;i<=n;i++){
        cin >> a >> b >> c >> d;
        if((a==0 || a==l || b==0 || b==r) && (c==0 || c==l || d==0 || d==r)){
            p.pb({a,b,i});
            p.pb({c,d,i});
        }
    }
    sort(p.begin(),p.end(),comp);
    for(pct i : p){
        if(q.size() && q[q.size()-1]==i.id) q.pop_back();
        else q.push_back(i.id);
    }
    if(q.size()) cout << "NO";
    else cout << "YES";
}



Measured memory_bytes: 4852
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val R = sc.next().toInt()
        pw.println(Math.PI * R * 2)
    }
}


Measured memory_bytes: 36532
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        N : usize,
        K : usize,
        mut p : [i64; N]
    }
    p.sort();
    let res: i64 = p.iter().take(K).sum();
    print!("{}", res);
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  vector <int> c;
  ll N,num[100001];
  REP(i,100001){
    num[i] = 0;
  }
  ll K;
  cin >> N >> K;
  REP(i,N){
    int a,b;
    cin >> a >> b;
    num[a] += b;
  }
  ll sum = 0,n=0;
  REP(i,100001){
    sum += num[i];
    if(sum >= K){
      n = i;
      break;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#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(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, n; cin >> h >> w >> n;
  int mx = max(h, w);
  cout << (n+mx-1)/mx << endk;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int n;
	cin >> n;
	vector<int> b(n+1);
	for(int i=1; i<n; i++) {
		cin >> b[i];
	}
	vector<int> a(n+1);
	a[1] = b[1];
	for(int i=2; i<n; i++) {
		a[i] = min(b[i-1], b[i]);	
	}
	a[n] = b[n-1];
	int ans = 0;
	for(int i=1; i<=n; i++) {
		ans += a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
  	int	a;
  	int	b;
  	int	c;
  	int	d;
  
  	scanf("%d %d %d %d", &a, &b, &c, &d);
  	
  	while (a > 0 && c > 0)
    {
      	c = c - b;
      	if (c <= 0)
        {
          	printf("Yes");
          	break ;
        }
      	a = a - d;
      	if (a <= 0)
        {
          	printf("No");
          	break ;
        }
    }
  	return (0);
}

Measured memory_bytes: 1728
N,x = map(int,input().split())
ans = (list(range(1,2*N))*2)[(x-N)%(2*N-1):(x-N)%(2*N-1)+2*N-1]
if x==1 or x==2*N-1:ans = []
if ans:
    print("Yes")
    print(*ans)
else: print("No")

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

int main(){
  int N,L;cin>>N>>L;
  vector<int> tas(N);
  for(int i=0;i<N;i++){
      tas[i]=L+i;
  }
  vector<int> tasa(N);
  for(int i=0;i<N;i++){
      tasa[i]=abs(tas[i]);
  }
  sort(tasa.begin(),tasa.end());
  bool flg=true;
  int ans=0;
  for(int i=0;i<N;i++){
      if(tasa[0]!=abs(tas[i])){
          ans+=tas[i];
      }
      if(flg==false && tasa[0]==abs(tas[i])){
          ans+=tas[i];
      }
      if(flg==true && tasa[0]==abs(tas[i])){
          flg=false;
      }
  }
  cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int main() {
    int x;
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(void){
  int a[32] = {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};
  int K;
  scanf("%d", &K);
  
  printf("%d\n",a[K-1]);
  
  return 0;
}
  



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int a = x2-x1;
  int b = y2-y1;

  int x3, y3, x4, y4;

  x3 = x2-b;
  y3 = y2+a;
  x4 = x3-a;
  y4 = y3-b;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 5 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;

bint x(bint n ){
    int re = (n & 3);
    if(re==0){
        return n;
    }else if(re == 1){
        return 1LL;
    }else if(re == 2){
        return n+1;
    }else{
        return 0LL;
    }
}


auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    bint a , b;

    cin>>a >>b;

    cout<< ( x(a-1) ^ x(b))<<endl;



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("din","r",stdin);
    freopen("dout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;

const int mod = 2019;
string s;
map<int, int> mp;
int ans;

int main()
{
  cin >> s;
  int n = s.length();
  
  int rem = 0, ten = 1;
  for (int i = n-1; i >= 0; i--) {
    rem = ((s[i] - '0') * ten + rem) % mod;
    ten = ten * 10 % mod;
    mp[rem]++;
  }
  
  ans = mp[0];
  for (int i = 0; i < mod; i++) {
    ans += mp[i] * (mp[i] - 1) / 2;
  }
  
  cout << ans << endl;
  return 0;
}

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

#define loop(i) for(int lp = 0; (lp) < (i); (lp) ++)

using namespace std;

int main() {
  int n, r, p, c;
  vector<int> card;
  
  while(cin >> n >> r, n) {
    card.clear();
    for(int i = n; i > 0; i --) {
      card.push_back(i);
    }
    
    for(int i = 0; i < r; i ++) {
      cin >> p >> c;

      loop(c) {
	for(int j = (p-1)+(c-1); j > 0; j --) {
	  swap(card[j], card[j-1]);
	}
      }
    }

    cout << card[0] << endl;
  }
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    for (int i = 0; i < s.size(); i++) {
        if ('z' - s[i] + 1 <= k && s[i] != 'a') {
            k -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
    }
    if (k > 0) {
        k %= 26;
        for (int i = 0; i < k; i++) {
            if (s[s.size() - 1] < 'z') s[s.size() - 1]++;
            else s[s.size() - 1] = 'a';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Apr  7 20:59:43 2018
//
package main

import (
	"fmt"
)

var S string

func main() {
	fmt.Scan(&S)

	kind := make([]bool, 3)
	for i := range S {
		if int(S[i]-'a') > 2 || kind[int(S[i]-'a')] {
			fmt.Println("No")
			return
		}
		kind[int(S[i]-'a')] = true
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 512
import itertools
n,m=map(int,input().split())
lst=[]
for i in range(m):
    lst+=[list(map(int,input().split()))]



pair=[[0]*n for i in range(n)]
for i,j in lst:
    pair[i-1][j-1]=1
    pair[j-1][i-1]=1


def keiro(a):
    count=0
    for i in range(n-1):
        if pair[a[i]-1][a[i+1]-1]==0:
            break
    else:
        count+=1
    return count
cn=0
b=[i for i in range(2,n+1)]
for i in list(itertools.permutations(b)):
    a=[1]+list(i)
    if keiro(a)==1:
        cn+=1

print(cn)

Measured memory_bytes: 3572
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.printf("%d %d %.10f\n",a/b,a%b,(double)a/b);
	}
}



Measured memory_bytes: 26400
#include<iostream>
#include <vector> 
#include <algorithm>
#include<iomanip>
#include<math.h>
#include<string>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main() {
	double A,B,H,M,s1,s2;
	cin >> A >> B >> H >> M;
	s1 = (360 * H) / 12+(30*M)/60;
	s2 = (360 * M) / 60;
	cout<<fixed<<setprecision(15)<<sqrt(A * A + B * B - 2 * A * B * cos(abs(s1 - s2) * 3.1415926535 / 180)) << endl;
	return 0;
}

Measured memory_bytes: 4128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, d;
    cin >> n >> d;

    int a = n, b= 2*d+1;

    cout << (a + (b - 1)) / b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    REP(i, 1, 100000) {
        int x1 = i * 0.08;
        int x2 = i * 0.10;
        if(a == x1 && b == x2) {
            cout << i<< endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    string s1,s2;
    cin >> s1 >> s2;
    //cout << s1 <<endl<< s2 <<endl;
    int n = s1.size(), m= s2.size();
    vector < vector <int> > dp(n+1, vector <int>(m+1));
    s1 = " "+s1;
    s2 = " "+s2;
    for(int i =1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            if(s2[j]==s1[i])dp[i][j]= dp[i-1][j-1]+1;
        }
    }
    string s="";
    int i =n,j=m;
    while(i>0 && j>0){
        if(dp[i][j] !=dp[i][j-1] && dp[i][j]!=dp[i-1][j]){
                s+=s2[j];
            i--;j--;
        }else if(dp[i][j-1]>=dp[i-1][j]){
            j--;
        }else i--;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n, m;
    cin >> n >> m;
    int somawa = 0, somap = 0;
    vi pen(n + 1, 0);
    vector<bool> pas(n + 1, false);

    fo(i, m) {
        int q;
        string s;
        cin >> q >> s;

        if ( s == "WA" and !pas[q] ) {
            pen[q]++;
        } else {
            if ( !pas[q] ) {
                pas[q] = true;
                somawa += pen[q];
                somap++;
            }
        }
    }

    cout << somap << " " << somawa << endl;

    return 0;
}

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

class Main {

	void solve() {
		
		int a = inint(), b = inint();
		
		if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) out.println("Possible");
		else out.println("Impossible");
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}
	
	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21460
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
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 (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    TIN(string, s);
    if (s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n;
	cin>>n;
	ll sum = 0;
	for (ll i = 1; i<=n; i++){
		if (i % 3 != 0 && i%5 != 0){
			sum+=i;
		}
	}
	cout<<sum;
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll l, r;
  cin >> l >> r;


  ll mod = 2019;

  vector<ll> v;
  for(ll i = l; i <= r && i-l < 2020; i++){
    v.push_back(i%mod);
  }

  ll n = v.size();
  ll minn = mod;
  rep(i, n){
    for(int j = i+1; j < n; j++){
      minn = min(minn, (v[i]*v[j])%mod);
    }
  }

  cout << minn << endl;

  
  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int s = sc.nextInt();
    long MOD = 998244353;
    long[][] dp = new long[n + 1][s + 1];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
      int a = sc.nextInt();
      for(int j = 0; j <= s; j++) {
        dp[i][j] = (dp[i][j] + (2 * dp[i - 1][j])) % MOD;
        if(j >= a)  dp[i][j] = (dp[i][j] + dp[i - 1][j - a]) % MOD;
      }
    }
    System.out.println(dp[n][s]);
  }
}

Measured memory_bytes: 111304
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define F first
#define S second
const int NUM = 2e5 + 5;
const int N = 1e6 + 2;
int primes[N];
void sieve(){
    for(int i = 0; i < N; i++)
        primes[i] = i;
    for(int i = 2; i < N; i++)
        if(primes[i] == i)
        {
            for(int j = i+i ; j < N; j += i)
                primes[j] = min(primes[i],primes[j]);
        }
}
int ans = 0;
void pf(int n)
{
    int p = n, res = 1;
    while(p > 1)
    {
        int cn = 0;
        int x = primes[p];
        while(p%x == 0)
        {
            p/=x;
            cn++;
        }
        res *= (cn+1);
    }
    ans += res;
}
signed main(){
    int t = 1; //cin >> t;
    while(t--){
        int n; cin >> n;
        sieve();
        for(int i = 1; i < n; i++)
            pf(i);
        cout << ans;
    }    
}

Measured memory_bytes: 11440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>0 ?(a):-(a))
#define llong long long

int main(){
	int D; scanf("%d",&D);
	int c[26],s[D][26],t[D];
	rep(i,0,26) scanf("%d",c+i);
	rep(i,0,D) rep(j,0,26) scanf("%d",&s[i][j]);
	rep(i,0,D) scanf("%d",t+i);
	
	int last[26]={0};
	llong score=0;
	
	rep(i,0,D){
		int num = t[i]-1;	// コンテストタイプ
		score += s[i][num];
		last[num]=i+1;
		rep(j,0,26){
			score -= c[j]*(i+1-last[j]);
		}
		printf("%lld\n",score);
	}
	
	return 0;
}


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

using namespace std;

long long a[400001];
                                       
int main () {
	int  n, k, c;
	cin >> n >> c >> k;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	sort (a + 1, a + n + 1);
	int r = 0;
	int kol = 0, ans = 0;
	for (int i = 1;i <= n;i ++) {
		r = a[i];
		kol = 0;
		while (r + k >= a[i] && kol < c) {
			i ++;
			kol ++;
		}
		i --;
		ans ++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}
ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}
ll sosuu(ll x){
    for(int i = 2; i < x; i++){
        if(x % i == 0) return false;
    }

    return true;
}


//入力

ll hp[200010];

int main(){

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >>hp[i];
    }

    sort(hp, hp+n);

    ll ans = 0;

    for(int i = 0; i < n-k; i++){
        ans += hp[i];
    }

    cout << ans << endl;

    return 0;
}

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


int main()
{

	string tmp;
	int i = 0;

	cin >> tmp;
	if (tmp == "Sunny") cout << "Cloudy" << endl;
	if (tmp == "Cloudy") cout << "Rainy" << endl;
	if (tmp == "Rainy") cout << "Sunny" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define max 100005
using ll =long long;
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[200001]={};
    int anum[200001]={};
    for(int i=2;i<=n;i++)cin>>a[i];
    for(int j=2;j<=n;j++)anum[a[j]]++;
    for(int i=1;i<=n;i++)cout<<anum[i]<<endl;
}


Measured memory_bytes: 5240
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

signed main() {
  int N; cin >> N;
  cout << N * (N - 1) / 2 << endl;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define M int(1e9+7)
#define endl '\n'
#define largest(a,b,c) (a>b?(a>c? a:c):(b>c? b:c))
#define smallest(a,b,c) (a<b?(a<c? a:c):(b<c? b:c))

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;



int main() {
	fast_io; cout_precision;
	double d,t,s;	cin >> d >> t >> s;
	if(d/s <= t)	cout <<"Yes"<<endl;
	else	cout <<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>
 
int main()
{
    char s[52];
    int  v[52];
    int n, i, j, k;
 
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%s %d", &s[i], &v[i]);
    }
 
    for (j = 1; j < 14; j++){
        for (k = 0; k < n; k++){
            if (s[k] == 'S' && v[k] == j) break;
            if (k == n - 1) printf("S %d\n", j);
        } 
    }
    for (j = 1; j < 14; j++){
        for (k = 0; k < n; k++){
            if (s[k] == 'H' && v[k] == j) break;
            if (k == n - 1) printf("H %d\n", j);
        }
    }
    for (j = 1; j < 14; j++){
        for (k = 0; k < n; k++){
            if (s[k] == 'C' && v[k] == j) break;
            if (k == n - 1) printf("C %d\n", j);
        }
    }
    for (j = 1; j < 14; j++){
        for (k = 0; k < n; k++){
            if (s[k] == 'D' && v[k] == j) break;
            if (k == n - 1) printf("D %d\n", j);
        }
    }
    return 0;
}

Measured memory_bytes: 596
(let ((a (read))
    (b (read)))
    (if (string= a "H")
        (if (string= b "H")
            (princ "H")
            (princ "D")
        )
        (if (string= b "H")
            (princ "D")
            (princ "H")
        )
    )    
)

Measured memory_bytes: 24088
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100000 + 5;
struct node{
	int parent,leftchild,rightsibling,dep;
}tree[maxn];
int findDep(struct node t)
{
	if(t.dep!=-1)return t.dep;
	if(t.parent == -1)return t.dep = 0;
	return 	t.dep = 1 + findDep(tree[t.parent]);
}
void setDep(int u,int d){
	tree[u].dep = d;
	if(tree[u].rightsibling!=-1)setDep(tree[u].rightsibling,d);
	if(tree[u].leftchild!=-1)setDep(tree[u].leftchild,d+1);
}
int main()
{		
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)tree[i].parent = tree[i].leftchild = tree[i].rightsibling = tree[i].dep = -1;
	
	int id,k,c,rootid;
	for(int i=0;i<n;++i){	
		scanf("%d %d",&id,&k);
		if(k){
			int lemo;
			scanf("%d",&lemo);
			tree[lemo].parent = id;
			tree[id].leftchild = lemo;
			
			for(int i=1;i<k;++i){
				scanf("%d",&c);
				tree[c].parent = id;
				tree[lemo].rightsibling = c;
				lemo = c;
			}
		}
	}	
	for(int i=0;i<n;++i)if(tree[i].parent == -1){rootid = i;break;}
	
	setDep(rootid,0);
	
	for(int i=0;i<n;++i){
		printf("node %d: parent = %d, depth = %d, %s, [",i,tree[i].parent,tree[i].dep,tree[i].parent==-1?("root"):(tree[i].leftchild==-1?("leaf"):("internal node")));
		int child = tree[i].leftchild;
		if(child!=-1){printf("%d",child);child = tree[child].rightsibling;}
		while(child!=-1){
			printf(", %d",child);
			child = tree[child].rightsibling;
		}
		printf("]\n");
	}
	return 0;
}

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

int main() {
	long long a,b,n;
	cin>>a>>b>>n;
	long long res;
	long long m=min(b-1,n);
	res=a*m;
	res=res/b;
	cout<<res;
	return 0;
}


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

int main(){
    int A,B,C,D,L,R;
    cin >> A >> B >> C >> D;
    L = A + B;
    R = C + D;

    if(L > R)
        cout << "Left" << endl;
    else if(L == R)
        cout << "Balanced" << endl;
    else if(L < R)
        cout << "Right" << endl;
}

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

struct RollingHash{
  int n;
  vector<long long> base, mod;
  vector<vector<long long>> hash, power;
  RollingHash(string s){
    base = {1009,9973};
    mod = {1000000007,1000000009};
    n = s.size();
    hash = vector<vector<long long>>(n+1,vector<long long>(2));
    power = vector<vector<long long>>(n+1,vector<long long>(2,1));
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < 2; ++j){
        hash[i+1][j] = (hash[i][j]+s[i])*base[j]%mod[j];
        power[i+1][j] = power[i][j]*base[j]%mod[j];
      }
    }
  }
  vector<long long> get(int l, int r){//[l,r)
    vector<long long> ret(2);
    for(int i = 0; i < 2; ++i)
      ret[i] = ((hash[r][i]-hash[l][i]*power[r-l][i])%mod[i]+mod[i])%mod[i];
    return ret;
  }
};

struct RollingHash_64{
  int n;
  unsigned long long base;
  vector<long long> hash, power;
  RollingHash_64(string s){
    base = 1e9 + 7;
    n = s.size();
    hash = vector<long long>(n+1);
    power = vector<long long>(n+1,1);
    for(int i = 0; i < n; ++i){
      hash[i+1] = (hash[i]+s[i])*base;
      power[i+1] = power[i]*base;
    }
  }
  unsigned long long get(int l, int r){//[l,r)
    return hash[r]-hash[l]*power[r-l];
  }
};

int main(){
  int N;
  cin >> N;
  vector<string> S(2*N);
  for(int i = 0; i < N; ++i){
    cin >> S[i];
    S[i] += S[i];
    S[i+N] = S[i];
  }
  vector<RollingHash_64> H, V;
  int N_ = 2*N;
  for(int i = 0; i < N_; ++i) V.emplace_back(S[i]);
  for(int j = 0; j < N_; ++j){
    string s;
    for(int i = 0; i < N_; ++i){
      s += S[i][j];
    }
    H.emplace_back(s);
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N; ++j){
      bool f = true;
      for(int k = 0; k < N; ++k){
        auto v = V[i+k].get(j,j+N), h = H[j+k].get(i,i+N);
        if(v != h){
          f = false;
          break;
        }
      }
      if(f) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12160
n,k = map(int,input().split())
a = [0] + [int(input())-k for _ in range(n)]

for i in range(n):
  a[i+1] += a[i]
  
def comp(lis):
  dic = {x:i+1 for i,x in enumerate(sorted(list(set(lis))))}
  return list(map(lambda x:dic[x],lis))

a = comp(a)
 
class BIT:
    def __init__(self,n):
        self.n = n
        self.size = 1<<((n-1).bit_length())
        self.bit = [0]*(self.size+1)

    def bitsum(self,idx):
        tmp = 0
        while idx:
            tmp += self.bit[idx]
            idx -= idx & -idx
        return tmp

    def bitadd(self,idx,x):
        while idx <= self.n:
            self.bit[idx] += x
            idx += idx & -idx
        return

bit = BIT(max(a))
ans = 0
for x in a:
    ans += bit.bitsum(x)
    bit.bitadd(x,1)
print(ans)


Measured memory_bytes: 44788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int A[1000];
  cin >> N ;
  for(int i = 0;i<N;i++){
      cin >> A[i];
  }
  for(int i = N-1; i>=0;i--){
      if(i==0){
          cout << A[0]<<endl;;
          break;
      } 
      cout << A[i] << ' ';
  }
}


Measured memory_bytes: 3088
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();

 	if(n%2==0&&s.substring(0,(n/2)).equals(s.substring(n/2,n))){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
}

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

int main(){
  string s;
  cin >> s;
  int L=s.size();
  string Ans="";
  for(int i=0; i<L; i++){
    if(s.at(i)=='0'){
      Ans.push_back('0');
    }
    if(s.at(i)=='1'){
      Ans.push_back('1');
    }
    if(s.at(i)=='B'){
      if(Ans==""){
      }
      else{
        Ans.pop_back();
      }
    }
  }
  cout << Ans << endl;
}
    

Measured memory_bytes: 256
N=int(input())
S=[input() for _ in range(N)]

AC=0
WA=0
TLE=0
RE=0

for s in S:
    if s=='AC':
        AC+=1
    if s=='WA':
        WA+=1
    if s=='TLE':
        TLE+=1
    if s=='RE':
        RE+=1
print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(AC,WA,TLE,RE))

Measured memory_bytes: 82940
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, 3, 1, 2), [3, 0])

    def test_2(self):
        self.assertEqual(think(2, 2, 1, 1), [2, 1])


def solve():
    w, h, x, y = read()
    result = think(w, h, x, y)
    write(result)


def read():
    return read_int(4)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(w, h, x, y):
    area = calc_smaller_area(w, h)
    multiple_ways_exist = can_be_multiple_ways(w, h, x, y)
    return [area, 1 if multiple_ways_exist else 0]


def write(result):
    print('{0:f} {1:d}'.format(result[0], result[1]))


def calc_smaller_area(w, h):
    return w * h / 2.0


def can_be_multiple_ways(w, h, x, y):
    return x == w / 2.0 and y == h / 2.0


if __name__ == '__main__':
    # unittest.main()
    solve()

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

int abs(int x) {
  x = max(x, -x);
  return x;
}

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i=0; i<N; i++) {
    cin >> W[i];
  }
  
  int ans = 100000;
  int left = 0;
  int right = 0;
  for (int i=0; i<N; i++) {
    right += W[i];
  }
  
  for (int i=0; i<N; i++) {
    left += W[i];
    right -= W[i];
    int gap = abs(left - right);
    ans = min(ans, gap);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
# dp[l][r]=min(区間[l,r]を合成するための最小コスト)
n=int(input())
a=list(map(int,input().split()))
INF=10**15
dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
# 合成するときの必要経費を構成
for i in range(n-1):
    for j in range(i+1,n):
        dp[i][j]=dp[i][j-1]+a[j]
dp[0][-1]=0
# dp[i][j]=min(dp[i][k]+dp[k+1][j])+必要経費 で斜め(0,1),(1,2),(0,2),(1,3),...の順に見ていく
# ループの書き方に手間取った
for i in range(n-1):
    for j in range(i+1,n):
        ans=INF
        x=j-i-1
        for k in range(x,j):
            ans=min(ans,dp[x][k]+dp[k+1][j])
        dp[x][j]+=ans
print(dp[0][-1])

Measured memory_bytes: 43244
#include<bits/stdc++.h>
#define int long long
#define mx 100005
#define inf 1e18
using namespace std;
int n;
int arr[mx];
int brr[mx];
int crr[mx];
int dp[mx][3];
int dfs(int n,int a,int b,int c){
	if(n == 0){
		return 0;
	}
	if(a == 1 && dp[n][0] != -1){
		return dp[n][0];	
	}
	if(b == 1 && dp[n][1] != -1){
		return dp[n][1];	
	}
	if(c == 1 && dp[n][2] != -1){
		return dp[n][2];	
	}
	if(a == 1){
		dp[n][0] = arr[n] + max(dfs(n-1,0,1,0),dfs(n-1,0,0,1));
		return dp[n][0];
	}
	else if(b == 1){
		dp[n][1] = brr[n] + max(dfs(n-1,1,0,0),dfs(n-1,0,0,1));
		return dp[n][1];
	}
	else if(c == 1){
		dp[n][2]= crr[n] + max(dfs(n-1,0,1,0),dfs(n-1,1,0,0));
		return dp[n][2];
	}
}
signed main(){
	//freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i]>>brr[i]>>crr[i];
	}
	memset(dp,-1,sizeof(dp));
	int ret = 0;
	ret = max(ret,dfs(n,1,0,0));
	ret = max(ret,dfs(n,0,1,0));
	ret = max(ret,dfs(n,0,0,1));
	cout<<ret;
}

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

const int MAX = 1000001;
const int MOD = 1000000007;
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;
}


int main(){
  int x,y;
  cin >> x >> y;
  
  ll res = 0; 
  int flg = 0;
  if(2*x-y < 0 || (2*x-y)%3 != 0){
    flg = 1;  
  }
  
  if(2*y-x < 0 || (2*y-x)%3 != 0){
    flg = 1;  
  }
  int p,q;
  if(flg == 0){
    p = (2*x-y)/3;
    q = (2*y-x)/3; 
    COMinit();
    res = COM(p+q,p);  
  }
  cout << res;
  
}


Measured memory_bytes: 27036
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="SUN")cout<<"7";
	if(s=="MON")cout<<"6";
	if(s=="TUE")cout<<"5";
	if(s=="WED")cout<<"4";

	if(s=="THU")cout<<"3";
	if(s=="FRI")cout<<"2";
	if(s=="SAT")cout<<"1";
	
	return 0;
} 

Measured memory_bytes: 256
//Life is inherently meaningless unless you find something which gives it meaning
 

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    string s;
    cin>>s;
    if(s[s.length()-1]=='s') cout<<(s+"es");
    else cout<<s+"s";
}

Measured memory_bytes: 3628