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

int main(void){
   int N;
   cin>>N;
   vector<int> l(N),r(N);
   for(int i=0;i<N;i++){
      cin>>l[i]>>r[i];
   }
   int ans=0;
   for(int i=0;i<N;i++){
      ans+=(r[i]-l[i]+1);
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("No");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	
	void main()
	{
		int n=qread(),now=0,x=0,y=0;
		while(n--)
		{
			int t=qread(),gx=qread(),gy=qread();
			int dis=abs(gx-x)+abs(gy-y);
			if(dis<=t-now and (dis-t+now)%2==0) ; else GG();
		}puts("Yes");
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//����Ԥ����ģ����
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 117376
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(c-(a-b),0)<<endl;



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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

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

		Scanner sysin = new Scanner(System.in);
		final int n = sysin.nextInt();
		final int l = sysin.nextInt();
		sysin.close();

		System.out.println(
			IntStream.range(l, l + n)
				.boxed()
				.sorted((a, b) -> Math.abs(a) - Math.abs(b))
			//	.peek(System.out::println)
				.skip(1)
				.mapToInt(Integer::intValue)
				.sum()
		);
	}
}

Measured memory_bytes: 27220
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int S;
  cin>>S;
  int a=0,b=1000000000;
  while(abs(a-b)>1){
    int c=(a+b)/2;
    if(c*c<=S)
      a=c;
    else
      b=c;
  }
  if(a*a>=S)
    cout<<a<<" 1 "<<a*a-S<<' '<<a;
  else
    cout<<b<<" 1 "<<b*b-S<<' '<<b;
  cout<<" 0 0\n";
}

Measured memory_bytes: 3568
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,a[2*N],sum,l,r;
long long ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	r=1; 
	for(l=1;l<=n;l++)
	{
		for(;r<=n;r++)
		{
			if((sum+a[r])!=(sum^a[r]))
				break;
			sum+=a[r],ans+=r-l+1;
		}
		sum-=a[l];
	}	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
"""
1 2 3 4 5 6 ... N
任意のiについて
iの倍数が書かれた箱に入っているボールの個数の和を2で割ったあまりがai
"""

N = int(input())
As = list(map(int, input().split()))

"""
1 2 3 4 5 6
0 1 0 1 0 1

i = 1  sum(As)%2 
i = 2  sum(As[::2]%2)

1    1 1 1 1 1 1 1 1 1 1
2    0 1 0 1 0 1 0 1 0 1
3    0 0 1 0 0 1 0 0 1 0
4    0 0 0 1 0 0 0 1 0 0
5    0 0 0 0 1 0 0 0 0 1
6    0 0 0 0 0 1 0 0 0 0
7    0 0 0 0 0 0 1 0 0 0
8    0 0 0 0 0 0 0 1 0 0 
9    0 0 0 0 0 0 0 0 1 0
10   0 0 0 0 0 0 0 0 0 1

後ろから決めていく？
"""
Bs = [0] * N
inball = []
for i in [N-i for i in range(N)]:
    n = N//i
    cnt = 0
    for j in [n-i for i in range(n)]:
        cnt += Bs[i*j-1]
    Bs[i-1] = (cnt+As[i-1]) % 2

ans = [i+1 for i,b in enumerate(Bs) if b==1]
M = len(ans)
print(M)
if M > 0:
    print(*ans)



Measured memory_bytes: 22616
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <pii, int> oc ; 
    int n; cin>>n; 
    ld a;
    while (n--){ 
        cin >> a ; 
        int x = (llround)(a*1e9) ; 
        int two=0,five=0; 
        while (x%2 == 0){ 
            two++; x /= 2; 
        } 
        while (x%5 == 0){ 
            five++; x /= 5; 
        } 
        oc[{two,five}]++ ; 
        // cout << two << " " << five << " = " << oc[{two,five}] << endl ; 
    } 
    int ans = 0 ; 
    for (auto  &it1: oc) { 
        for (auto  &it2: oc) { 
            if (it1.ff.ff+it2.ff.ff>=18 and it1.ff.ss+it2.ff.ss>=18) { 
                if(it1 < it2) { 
                    ans += it1.ss * it2.ss ; 
                } 
                else if(it1 == it2) { 
                    ans += it1.ss * (it1.ss-1)/2 ; 
                } 
            } 
        } 
    } 
    co ( ans ) ; 
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3808
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
const int maxx=100100;
vector<int> A[maxx];
int color[maxx];
int n,c=1;

void dfs(int u){
	if(color[u]!=-1) return ;//当该节点已经属于某一联通分量时，不需要染色
	color[u]=c;
	int si=A[u].size();
	for(int i=0;i<si;i++){
		if(color[A[u][i]]==-1){//注意是对A[u][i]进行染色
			dfs(A[u][i]);
		}
	}
	return ;
}

int main(){
	int q,a,b;//这里有个问题，n如果放在global里定义的话会出现问题，只能在main里定义，不知道为什么
	cin>>n>>q;
//	
//	cout<<&n<<endl<<&color<<endl<<&color[109]<<endl;
//	cout<<n<<endl;
	for(int i=0;i<=maxx;i++) color[i]=-1;
//	cout<<n<<endl;
	for(int i=1;i<=q;i++){
		cin>>a>>b;
		A[a].push_back(b);
		A[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		dfs(i);
		c++;
	}
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>a>>b;
		if(color[a]==color[b]) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 12128
#include<bits/stdc++.h>
#define ks ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pa;
template<class T>inline void read(T &res){
    char c;T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b >>= 1;}return ans;}
struct chongzai{int c; bool operator<(const chongzai &b )const{ return c>b.c; } }s;

const int maxn=4e5+177;
const ll mod=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
int maxx=1;
int fa[maxn],siz[maxn];
int d[maxn];
int get(int now){
    if(now==fa[now]){
        return now;
    }
    int root=get(fa[now]);
    d[now]+=d[fa[now]];
    return fa[now]=root;
}

void bcj(int x,int y){
    int xx=get(x);
    int yy=get(y);

    if(xx!=yy){
        fa[xx]=yy;
        d[xx]=siz[yy];
        siz[yy]+=siz[xx];
        maxx=max(maxx,siz[yy]);
    }

}


int main(){
    int n,m;
    scanf("%d%d",&n,&m);

    for(int i=1;i<=n;i++){
        fa[i]=i;
        siz[i]=1;
    }

    int a,b;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        bcj(a,b);
    }
    printf("%d\n",maxx);


}


Measured memory_bytes: 6188
#include<iostream>
#include<string>
using namespace std;
int ans,w,h,f;
string m[25];
void solve(int x,int y){
  if(x<0 || y<0 || x>=h || y>=w) return;
  if(m[x][y]=='#') return;
  m[x][y]='#';
  ans++;
  solve(x+1,y);
  solve(x-1,y);
  solve(x,y+1);
  solve(x,y-1);
}
int main(void){
  for(;;){
    cin >> w >> h;
    if(!w && !h) break;
    for(int i=0;i<h;i++) cin >> m[i];
    ans=0;
    f=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(m[i][j]=='@'){
	  solve(i,j);
	  f=1;
	  break;  
	}
      }
      if(f) break;
    }
    cout << ans << endl;
  }
}


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

int main() {
	long n,i,j,ans,h,w,k,cur,b,l;
	cin >> h >> w >> k;
	vector<vector<char>> a(h,vector<char>(w,'-'));
	vector<vector<long>> t(h+1,vector<long>(w+1,0));
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			cin >> a[i][j];
		}
		
	}
	
	for(j=0; j<w; j++){
		cur=0;
		for(i=0; i<h; i++){
			if(a[i][j]=='1') cur++;
			t[i+1][j]=cur;
		}
	}
	for(i=0; i<=h; i++){
		t[i][w]=100000*i;
	}
	
	/*
	for(i=0; i<=h; i++){
		for(j=0; j<=w; j++){
			cout << t[i][j] << ' ';
		}
		cout << endl;
	}
	*/
	vector<long> jud;
	ans=100000;
	for(b=0; b<(1<<h-1); b++){
		while(jud.size()){
			jud.pop_back();
		}
		
		jud.push_back(0);
		for(i=0; i<h-1; i++){
			if((1<<i)&b){
				jud.push_back(i+1);
			}
		}
		jud.push_back(h);
		
		/*
		for(l=0; l<jud.size(); l++){
			cout << jud[l] << ' ';
		}
		cout << endl;
		*/
		vector<long> res(jud.size()-1,0);
		long i1,i2,flg,flg2;
		cur=jud.size()-2;
		flg2=0;
		for(j=0; j<w; j++){
			flg=0;
			for(l=1; l<jud.size(); l++){
				i1=jud[l-1]; i2=jud[l];
				res[l-1]+=t[i2][j]-t[i1][j];
				if(t[i2][j]-t[i1][j]>k){
					flg2=1;
				}
				if(res[l-1]>k){
					flg=1;
				}
			}
			if(flg){
				cur++;
				for(l=1; l<jud.size(); l++){
					i1=jud[l-1]; i2=jud[l];
					res[l-1]=t[i2][j]-t[i1][j];
				}
			}
			
		}
		// cout << b << ' ' << flg2 << ' ' << cur << endl;
		if(flg2==0){
			ans=min(cur,ans);
		}
	}
	cout << ans << endl;
	
}

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

const int maxn=2e5+10;

int h[maxn];

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);

	for (int i = 1; i <= n; i++)
		scanf("%d", &h[i]);

	sort(h + 1, h + n + 1);


    int ans = 2e9;

    for (int i = k; i <= n; i++)
	{
		ans = min(ans, h[i] - h[i - k + 1]);
	}
	cout << ans << endl;



}


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

int main(){
    int ans = 0;
    int n, k; cin >> n; cin >> k;
    vector<int> x(n); rep(i, n) cin >> x.at(i);

    rep(i,n){
        ans += min(x.at(i)*2,abs(x.at(i)-k)*2);
    }

    cout << ans << endl;
}

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

using namespace std;

const int NMax = 100003;

int nn,n,k;
string x;
int v[NMax],preff[NMax],suff[NMax],pref[NMax];
vector<int> par, impar;

bool cmp_par(int x, int y){
    if(v[x] > v[y]){
        return 1;
    }
    return 0;
}
bool cmp_impar(int x, int y){
    if(v[x] < v[y]){
        return 1;
    }
    return 0;
}
int main(){
    cin >> nn >> k;
    cin >> x;
    for(int i = 0; i < x.size(); ++i){
        if(i == 0){
            v[n] = 1;
        }else{
            if(x[i] == x[i - 1]){
                v[n] ++;
            }else{
                n++;
                v[n] = 1;
            }
        }
    }
    n++;
    pref[0] = v[0];
    for(int i = 1; i < n; ++i){
        pref[i] = pref[i - 1] + v[i];
    }
    preff[0] = v[0] - 1;
    for(int i = 1; i < n; ++i){
        preff[i] = preff[i - 1] + v[i] - 1;
    }
    suff[0] = v[n - 1] - 1;
    for(int i = n - 2; i >= 0; --i){
        suff[i] = suff[i + 1] + v[i] - 1;
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(i - (2 * k + 1) < 0){
            ans = max(ans, pref[i] - 1 + suff[i + 1]);
        }else{
            ans = max(ans, preff[i - (2 * k + 1)] + pref[i] - pref[i - (2 * k + 1)] - 1 + suff[i + 1]);
        }
        //ans = max(ans,   max(pref[i] - pref[i - (2 * k + 1))]) );
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
//void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c)
{
	stack<int> S;
	S.push(r);
	color[r] = c;
	while (!S.empty())
	{
		int u = S.top(); S.pop();
		REP(G[u].size())
		{
			int v = G[u][i];
			if (color[v] == NIL)
			{
				color[v] = c;
				S.push(v);
			}
		}
	}
}

void assignColor()
{
	int id = 1;
	REP(n) color[i] = NIL;
	REP(n) if (color[i] == NIL) dfs(i, id++);
}


int main()
{
	int s, t, m, q;
	
	cin >> n >> m;
	
	REP(m)
	{
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	assignColor();
	
	cin >> q;
	
	REP(q)
	{
		cin >> s >> t;
		if (color[s] == color[t])
		{
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	
	return 0;
}


/*
void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}
*/


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 7060
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		int ans = 1;
		for (int i=1; i<=n; i++) {
			ans += i;
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(in.hasNext()) solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 26292
using System;
using System.Collections.Generic;
using System.IO;

class Solve {
    static void Main(string[] args) {
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = arr[0], M = arr[1];
        var set = new HashSet<int>();
        for (int i = 0; i < M; i++) {
            set.Add(int.Parse(Console.ReadLine()));
        }
        var dp = new long[N + 1];
        dp[0] = 1;
        if (N >= 1) {
            dp[1] = set.Contains(1) ? 0 : 1;
            for (int i = 2; i <= N; i++) {
                if (set.Contains(i)) continue;
                var a = set.Contains(i - 1);
                var b = set.Contains(i - 2);
                dp[i] = a && b ? 0 :
                        a ? dp[i - 2] : 
                        b ? dp[i - 1] : (dp[i - 1] + dp[i - 2]) % 1000000007;
            }   
        }
        var answer = dp[^1];
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 34184
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;


int main(){
    char c; cin >> c;
    if('z'>=c && c>='a') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env ruby

n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

count_mainasu = a.count {|aa| aa < 0}
min = 0
sum_all = a.map {|aa| aa < 0 ? -1 * aa : aa }.tap{|ary| min = ary.min}.map(&:to_i).inject(:+)
ans = count_mainasu%2 == 0 ? sum_all : ( sum_all - 2 * min )

puts ans

Measured memory_bytes: 11268
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m = s.len();

    let mut l = Vec::new();
    let mut i = 0;
    while i < m {
        let mut j = i;
        let mut cnt = 1;
        while j < m - 1 && s[j] == s[j + 1] {
            cnt += 1;
            j += 1;
        }
        l.push(cnt);
        i = j + 1;
    }
    if l.len() == 1 {
        println!("{}", l[0] * n / 2);
        return;
    }
    let mut ans = 0;
    for i in 1..l.len() - 1 {
        if l[i] != 1 {
            ans += l[i] / 2 * n;
        }
    }
    ans += l[0] / 2;
    ans += l[l.len() - 1] / 2;
    if s[0] == s[s.len() - 1] {
        ans += (l[0] + l[l.len() - 1]) / 2 * (n - 1);
    } else {
        ans += l[0] / 2 * (n - 1);
        ans += l[l.len() - 1] / 2 * (n - 1);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
use proconio::input;
use proconio::marker::Chars;
fn main() {
    input! {
        chars: Chars,
    };
    let mut count = 0;
    if chars[0] == '1' {
        count += 1
    };
    if chars[1] == '1' {
        count += 1
    };
    if chars[2] == '1' {
        count += 1
    };

    println!("{}", count);
}


Measured memory_bytes: 2084
#include <cstdio>
int n,k,c,f[200003][2];
char s[200003];
int main(){
    scanf("%d%d%d%s",&n,&k,&c,s+1);
    int i,j=0;
    for(i=1;i<=n;i++){
        if(s[i]=='o'&&i>j) f[i][0]=f[i-1][0]+1,j=i+c;
        else f[i][0]=f[i-1][0];
    }
    j=n+1;
    for(i=n;i>=1;i--){
        if(s[i]=='o'&&i<j) f[i][1]=f[i+1][1]+1,j=i-c;
        else f[i][1]=f[i+1][1];
    }
    for(int i=1;i<=n;i++) if(f[i-1][0]+1+f[i+1][1]==k) printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 3484
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search of Tree (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


# --------------------------------------------

dp = None


def main():
    N, x = li_input()
    A = sorted(li_input())

    ans = 0

    for i, a in enumerate(A):
        if x >= a:
            if i != N - 1 or i == N-1 and x == a:
                x -= a
                ans += 1

    print(ans)


main()


Measured memory_bytes: 5176
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static class NameTime {
		String name;
		int time;
		
	}
	
	public static void queue1(Queue<NameTime> q, int t) {
		int time = 0;
		while (!q.isEmpty()) {
			NameTime nt = q.remove();
			if (nt.time > t) {
				time += t;
				nt.time -= t;
				q.add(nt);
			}
			else {
				time += nt.time;
				System.out.println(nt.name + " " + time);
			}
		}
	}
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		Queue<NameTime> q = new LinkedList<>();
		int n = scan.nextInt();
		int t = scan.nextInt();
		
		for (int i = 0; i < n; ++i) {
			NameTime nt = new NameTime();
			nt.name = scan.next();
			nt.time = scan.nextInt();
			q.add(nt);
		}
		queue1(q, t);
		
	}
}



Measured memory_bytes: 75864
import math

n = int(input())
if n == 0:
  print(0)
elif n % 2 == 0:
  m = math.ceil(math.log(n, 5))
  ans = 0
  for i in range(1, m+1):
    ans += n // (2*5**i)
  print(ans)
else:
  print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    
    cout<<pow(2,M)*(1900*M+100*(N-M))<<endl;
    
    return 0;
}


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

using namespace std;

int main() {
  int n, m;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  cin >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i], a[i]--;
  }
  for (int i = 0; i < m; i++) {
    bool ok = true;
    for (int j = 0; j < n; j++) {
      if (x[a[i]] + 1 == x[j]) ok = false;
    }
    if (ok && x[a[i]] + 1 != 2020) {
      x[a[i]]++;
    }
  }

  for (auto &v : x) {
    cout << v << endl;
  }

  return 0;
}


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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  int a = 0;
  for(int i = 0; i < 10; i++) {
    a = r*x - D;
    cout << a << endl;
    x = a;
  }
}


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

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

using namespace std;

using ll = long long;

using P = pair<int,int>;



int main() {

  int n ,m ;
  cin >>n>>m ;
  vector<int> A(m) ;
  rep(i,m) cin>> A[i] ;
  int ans=n ;
  rep(i,m){
      ans-=A[i] ;
  }
 if(ans<0)
 cout <<-1<<endl ;
else
cout<< ans<< endl ;
    return 0;

}


Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#define MAX 100000
using namespace std;

int n, A[MAX + 1], L[MAX];

int lis() {
	L[0] = A[0];
	int length = 1;

	for (int i = 1; i < n; i++) {
		if (L[length - 1] < A[i]) {
			L[length++] = A[i];
		}
		else {
			*lower_bound(L, L + length, A[i]) = A[i];
		}
	}

	return length;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	cout << lis() << endl;

	return 0;
}


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

using namespace std;
#define ll long long
#define cni const int
#define cnl const long long

const int maxn = 1e5+20;
ll dp[120][maxn];
ll inf=1e18+10;
int mod=1e9 + 7;
ll w[maxn], v[maxn];

int main() 
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	
	int n, W;
	cin >> n >> W;
	
	for(int i=1;i<=n;i++)
		cin >> w[i] >> v[i];
		
	for(int i=1;i<=n;i++)
		for(int j=1;j<=W;j++)
			dp[i][j]=-inf;
	
	for(int i=1;i<=n;i++)
		for(int j=1;j<=W;j++)
		{ 
			if(w[i] > j)
				dp[i][j]=dp[i-1][j];
			else 
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]] + v[i]);
		}
		
	ll mx=0;
	for(int i=1;i<=W;i++)
		mx=max(dp[n][i], mx);
		
	cout << mx;
}


Measured memory_bytes: 80128
#include <cstdio>
const int MAXN=1E5+10;
int N,K,src[MAXN<<2];
int ansl,ansr;
struct wrc {
	int cnt,cl,cr;
	wrc(){cnt=cl=cr=0;}
	wrc(int a,int b,int c) {
		cnt=a;
		cl=b;cr=c;
	}
}w[MAXN<<2];
wrc operator + (const wrc&a,const wrc&b) {
	wrc c(a.cnt+b.cnt,a.cl,b.cr);
	if(a.cr==1&&b.cl==1)c.cnt-=1;
	return c;
}
void build(int root,int l,int r) {
	if(l==r) {
		w[root]=wrc(src[l],src[l],src[l]);
		return ;
	}
	int mid=(l+r)>>1;
	build(root<<1,l,mid);
	build(root<<1|1,mid+1,r);
	w[root]=w[root<<1]+w[root<<1|1];
}
wrc find(int root,int l,int r) {
	if(ansl<=l&&r<=ansr) return w[root];
	int mid=(l+r)>>1;
	if(ansr<=mid)return find(root<<1,l,mid);
	if(ansl> mid)return find(root<<1|1,mid+1,r);
	return find(root<<1,l,mid)+find(root<<1|1,mid+1,r);
}
int clac(int l,int r) {
	ansl=l;ansr=r;
	return find(1,1,N).cnt;
}
int doubleDivide(int len) {
	for(int i=1;i<=N;++i) {
		if(i+len-1>N)break;
		if(clac(i,i+len-1)<=K)
			return true;
	}return false;
}
int main() {
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;++i) {
		scanf("%1d",&src[i]);
		src[i]^=1;
	}
	build(1,1,N);
	int ans=0; 
	double l=0,r=1E6;
	for(int t=1;t<=32;++t) {
		double mid=(l+r)/2;
		//printf("%lf (%lf) %lf \n",l,mid,r);
		if(doubleDivide(mid)) {
			ans=mid;
			l=mid;
		}else r=mid;
	} 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1000000007;
const double eps = 0.000001;

int32_t main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (i * m + j * n - 2 * i * j == k)
            {
                cout << "Yes" << endl; return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n);
	vector<int> b(n);
	REP(i,n) cin>>b[i];

	vector<int> ans;
  RFOR(i,1,n+1){
		bool ok = false;
		bool one = false;
		REP(i,b.size()){
			if(b[i]==1) one = true;
		}
		if(!one){
			OUT(-1)BR;
			return 0;
		}
		if(b.empty()) break;
	  for(int j=b.size()+1;j>=1;--j){
			if(j-1<b.size() && j==b[j-1]) {
				ans.push_back(j);
				//debug(j);
				//debug(b[j-1]);

				b.erase(b.begin()+j-1);
				ok = true;
				//debug("ok");
				break;
			}
		}
		if(!ok) {
			//debug(i);
			OUT(-1)BR;
			return 0;
		}
	}

	bool isFirst = true;
	//debug(ans.size());
	RREP(i,ans.size()){
		OUT(ans[i])BR;
	}
	
  
  return 0;
}


Measured memory_bytes: 888
import numpy as np
a,b,k = map(int,input().split())
c = np.array(list(range(1,min(a,b)+1))) #a,bのうち小さい方の数字までのリスト
#両方が０のインデックスのリストを返して、後ろからk番目のインデックス番号のcをprint
e = [f for f,g in enumerate(zip(a%c,b%c)) if g == (0,0)]
print(c[e[-k]])

Measured memory_bytes: 22192
#include <stdio.h>

int main()
{
    int N,TATE,YOKO,i,count=0;
    int tate,yoko;

    scanf("%d%d%d",&N,&TATE,&YOKO);

    for(i=0;i<N;i++){
        scanf("%d%d",&tate,&yoko);
        if(tate>=TATE && yoko>=YOKO){
            count++;
        }
    }

    printf("%d",count);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long

int main() {
    int d;
    cin >> d;
    vector<vector<int>> s(d+1, vector<int>(26+1, 0));
    vector<int> c(26+1);
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    /////////////////
    vector<int> t(d);
    for(int i = 0; i < d; i++) {
        t[i] = i+1;
    }
    for(int i = 0; i < d; i++) cin >> t[i];

    ///////////////
    int m;
    cin >> m;
    vector<pair<int, int>> dq(m);
    for(int i = 0; i < m; i++) {
        cin >> dq[i].first >> dq[i].second;
    }
    vector<ll> ans(d, 0);
    ll v = 0;
    ll tmp = 0;
    map<ll, int> mp;
    priority_queue<ll> que;
    int num = 0;
    for(int k = 0; k < m; k++) {
        tmp = t[dq[k].first-1];
        t[dq[k].first-1] = dq[k].second; 
        vector<ll> last(26+1, 0);
        for(int i = 0; i < d; i++) {
            v += s[i][t[i]-1];
            last[t[i]-1] = i+1;
            for(int j = 0; j < 26; j++) {
                v -= c[j]*((i+1)-last[j]);
            }    
        }
        cout << v << endl;
        que.push(v);
        mp[v] = k;
        v = 0;
    }
    return 0;
}

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

struct QuickFind{
  vector<int> r,p;
  vector<vector<int> > v;
  QuickFind(){}
  QuickFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    v.resize(size);
    for(int i=0;i<size;i++){
      r[i]=1,p[i]=i;
      v[i].resize(1,i);
    }
  }
  bool same(int x,int y){
    return p[x]==p[y];
  }
  void unite(int x,int y){
    x=p[x];y=p[y];
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    for(int i=0;i<(int)v[y].size();i++){
      p[v[y][i]]=x;
      v[x].push_back(v[y][i]);
    }
    v[y].clear();
  }
};
signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<int> b(a);
  sort(b.begin(),b.end());
  map<int,int> p,q;
  for(int i=0;i<n;i++){
    p[a[i]]=i;
    q[b[i]]=i;
  }
  QuickFind qf(n);
  for(int i=0;i<n;i++) 
    qf.unite(i,p[b[i]]);
  //for(int i=0;i<n;i++) cout<<i<<" "<<p[b[i]]<<endl;
  int ans=0;
  for(int i=0;i<n;i++){
    int k=qf.v[i].size();
    if(qf.p[i]!=i||k==1) continue;
    int m=a[qf.v[i][0]];
    int tmp=0;
    for(int j=0;j<k;j++){
      //cout<<" "<<a[qf.v[i][j]];
      tmp+=a[qf.v[i][j]];
      m=min(m,a[qf.v[i][j]]);
    }
    //cout<<endl;
    ans+=min(tmp+m*(k-2),tmp+m+b[0]*(k+1));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3384
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
int n,m,q;
char chr[2001][2001];
bool a[2001][2001];
int sum1[2001][2001];//A unit
int sum2[2001][2001];//Two unit:right and left
int sum3[2001][2001];//Two unit:up and down
int main()
{
	cin>>n>>m>>q;
	int i,j;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			while(chr[i][j]!='1'&&chr[i][j]!='0')scanf("%c",&chr[i][j]);
			a[i][j]=chr[i][j]-'0';
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			sum1[i][j]=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1];
			if(a[i][j])sum1[i][j]++;
			//cerr<<sum1[i][j];
		}
		//cerr<<endl;
	}
	cerr<<endl;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			sum2[i][j]=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1];
			if(a[i][j]&&a[i][j-1])
			{
				sum2[i][j]++;
				//sum2[i][j-1]++;
			}
			//cerr<<sum2[i][j];
		}
		//cerr<<endl;
	}
	//cerr<<endl;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			sum3[i][j]=sum3[i-1][j]+sum3[i][j-1]-sum3[i-1][j-1];
			if(a[i][j]&&a[i-1][j])
			{
				sum3[i][j]++;
				//sum3[i-1][j]++;
			}
			//cerr<<sum3[i][j];
		}
		//cerr<<endl;
	}
	int t1,t2,t3,t4;
	while(q--)
	{
		scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
		printf("%d\n",(sum1[t3][t4]-sum1[t3][t2-1]-sum1[t1-1][t4]+sum1[t1-1][t2-1])-(sum2[t3][t4]-sum2[t3][t2]-sum2[t1-1][t4]+sum2[t1-1][t2])-(sum3[t3][t4]-sum3[t3][t2-1]-sum3[t1][t4]+sum3[t1][t2-1]));
	}
	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
using namespace std;
long long f(long long a, long long k){
	while(a % k){
		long long d = a / k;
		long long mx = d * k;
		long long take = (a - mx + d) / (d + 1);
		a -= take * (d + 1);
		if(a % k == 0) return a / k;
		a -= a/k + 1;
	}
	return a / k;
}
int main(){
	int n; cin >> n;
	long long ans = 0;
	for(int i = 0; i < n; i++){
		long long a, k; cin >> a >> k;
		ans ^= f(a, k);
	}
	if(ans) printf("Takahashi\n");
	else printf("Aoki\n");
	return 0;
}


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

int main(){
  int N;
  cin >>N;
  vector<string> s(N);
  rep(i,N){
    cin >>s[i];
    sort(s[i]);
  }
  sort(s);
  s.push_back("end");
  ll cnt = 0;
  ll ans = 0;
  rep(i,N+1){
    if(i == 0){
      cnt++;
      continue;
    }
    if(s[i-1] == s[i]) cnt++;
    else{
      ans += cnt*(cnt-1)/2;
      cnt = 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h, tmp;
    vector<vector<int>> route;
    rep(i, n){
        int H;
        cin >> H;
        h.push_back(H);
        route.push_back(tmp);
    }

    rep(i, m){
        int A, B;
        cin >> A >> B;
        route[A-1].push_back(B-1);
        route[B-1].push_back(A-1);
    }

    int ans=0;
    rep(i, n){
        int route_size = route[i].size();
        int height = h[i];
        bool flag=true;
        rep(j, route_size){
            if(height<=h[route[i][j]]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }

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

Measured memory_bytes: 8800
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int64_t A,B,C,D;
 cin>>A>>B>>C>>D;
 int64_t c=(B-A+1)-(B/C-(A-1)/C);
 int64_t d=(B-A+1)-(B/D-(A-1)/D);
 int64_t k=C*D/__gcd(C,D);
 int64_t cd=(B-A+1)-(B/k-(A-1)/k);
 cout<<c+d-cd<<endl;
 return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = pair<int, int>;

vector<P> runlength(const string& a) {
  vector<P> res;
  for (int i = 0; i < a.size(); i++) {
    if (i == 0 || a[i - 1] != a[i]) {
      res.push_back(P(a[i], i));
    }
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, K;
  string S;
  while (cin >> N >> K >> S) {
    auto R = runlength(S);
    int res = 0;
    for (int i = 0; i < R.size(); i++) {
      int j;
      if (R[i].fst == '1') {
        j = i + 2 * K;
      } else {
        j = i + 2 * K - 1;
      }
      ++j;
      int score;
      if (j >= R.size()) {
        score = N - R[i].snd;
      } else {
        score = R[j].snd - R[i].snd;
      }
      res = max(res, score);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1528
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

// http://caprest.hatenablog.com/entry/2016/05/29/181102
std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,
                                        std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

void solve(long long N, long long A, long long B, std::vector<long long> v) {
  sort(all(v), greater<ll>());
  double maxAvg = 0.0;
  rep(n, 0, A) { maxAvg += v[n]; }
  maxAvg /= (double)A;

  vector<vl> combnations = comb(50, 50);

  ll com = 0;

  // A番目以降を入れても平均が下がらないのは、1種類しか使われていないときだけ
  bool hasOneValue = true;
  rep(n, 0, A) { hasOneValue = hasOneValue && (v[n] == v[0]); }

  if (hasOneValue) {
    ll sameNum = 0;
    ll n = 0;
    while (v[n++] == v[0]) {
      sameNum++;
    }
    rep(n, A, min(sameNum, B) + 1) { com += combnations[sameNum][n]; }
  } else {
    // A番目と同じ価値のものを選ぶ組み合わせが答えの組み合わせ
    ll sameNum = 0;
    ll aValueStart = -1;
    rep(n, 0, N) {
      if (v[n] == v[A - 1]) {
        if (aValueStart == -1) {
          aValueStart = n;
        }
        sameNum++;
      }
    }
    ll need = A - aValueStart;
    com = combnations[sameNum][need];
  }

  printf("%.6f\n", maxAvg);
  print(com);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  std::vector<long long> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &v[i]);
  }
  solve(N, A, B, std::move(v));
  return 0;
}


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

using namespace std;
const int N = 10;
int g[N][N];
char g2[N][N];

int u[N][N];
int main()
{
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);

	for (int i = 0; i < h; ++i) scanf("%s", g2 + i);

	int sum = 0;
	for(int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
		{
			if (g2[i][j] == '#')
			{
				g[i][j] = 1;
				++sum;
			}
			else
				g[i][j] = 0;
		}

	int res = 0;
	for (int i = 0; i < (1 << h); ++i)
	{
		vector<int> v1;
		for (int k = 0; k < h; ++k)
		{
			if ((i >> k) & 1)
				v1.push_back(k);
		}
		for (int j = 0; j < (1 << w); ++j)
		{
			vector<int> v2;
			for (int k = 0; k < w; ++k)
			{
				if ((j >> k) & 1)
					v2.push_back(k);
			}

			for (int i = 0; i < h; ++i)
				for (int j = 0; j < w; ++j)
				{
					u[i][j] = g[i][j];
				}
			for (int i = 0; i < v1.size(); ++i)
			{
				for (int j = 0; j < w; ++j)
					u[v1[i]][j] = 0;
			}

			for (int i = 0; i < v2.size(); ++i)
			{
				for (int j = 0; j < h; ++j)
					u[j][v2[i]] = 0;
			}
			
			int c = 0;
			for(int i = 0; i < h; ++i)
				for (int j = 0; j < w; ++j)
				{
					if (u[i][j] == 1)
						++c;
				}
			if (c == k)
			{
				++res;
			}
		}
	}

	printf("%d\n", res);


	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
		if(i*m+j*n-2*i*j==k)
		{
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
import math
k = int(input())
ans = 0
d = 0
e = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            d = math.gcd(a, b)
            e = math.gcd(d, c)
            ans += e
print(ans)

Measured memory_bytes: 67740
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,ll> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;


ll bellman_ford(vector<vector<P> > g,int s,int t){
	int n = g.size();
	vector<ll> dist(n,1e18+10);
	dist[s] = 0;
	vector<bool> nega(n,false);
	for (int i = 0; i < n; i++){
		bool update = false;
		for (int j = 0; j < n; j++){
			for (int k = 0; k < g[j].size(); k++){
				int from = j,to = g[j][k].first;
				ll cost = g[j][k].second;
				if(dist[from] + cost < dist[to]){
					dist[to] = dist[from] + cost;
					update = true;
					if(i==n-1) nega[to] = true;
				}
				if(nega[j]) nega[to] = true;
			}
		}
		if(!update){
			break;
		}
		// for(auto x: dist){
		// 	cout<<x<< " ";
		// }cout<<endl;
	}
	return (!nega[t]?dist[t]:1e18+10);
}

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<P> > g(n,vector<P>());
	for (int i = 0; i < m; i++){
		int a,b;
		ll c;
		cin>>a>>b>>c;
		a--;b--;
		c *= -1;
		g[a].push_back(P(b,c));
	}

	ll ans = bellman_ford(g,0,n-1);
	if(ans==1e18+10) cout<<"inf"<<endl;
	else cout<<ans*(-1)<<endl;
	return 0;
}

Measured memory_bytes: 384