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

void rotate(vector<pair<int,int>> &coo){
    for(int i=0;i<coo.size();i++){
        int prex=coo[i].first,prey=coo[i].second;
        coo[i].first=prey;
        coo[i].second=-prex;
    }

}
void edit(vector<pair<int,int>> &coo){
    int minx=1e6,miny=1e6;
    for(int i=0;i<coo.size();i++){
        minx=min(minx,coo[i].first);
        miny=min(miny,coo[i].second);
    }
    for(int i=0;i<coo.size();i++){
        coo[i].first-=minx;
        coo[i].second-=miny;
    }

}
int main(){
    int n;
    while(cin>>n,n){
        vector<int> m(n+1);
        vector<vector<pair<int,int>>> xy(n+1);
        for(int i=0;i<=n;i++){
            cin>>m[i];
            xy[i].resize(m[i]);
            for(int j=0;j<m[i];j++){
                int x,y;
                cin>>x>>y;
                xy[i][j]=make_pair(x,y);
            }
        }
        vector<int> res;
        edit(xy[0]);
        vector<vector<pair<int,int>>> base(4);
        for(int j=0;j<4;j++){
            base[j]=xy[0];
            rotate(xy[0]);
            edit(xy[0]);
        }
        for(int i=1;i<=n;i++){
            if(m[i]!=m[0]) continue;
            bool isok=false;
            edit(xy[i]);
            for(int j=0;j<4;j++){
                bool ismatch=true;
                for(int k=0;k<m[i];k++){
                    if(xy[i][k]!=base[j][k]) ismatch=false;
                }
                isok|=ismatch;
                ismatch=true;
               for(int k=0;k<m[i];k++){
                    if(xy[i][k]!=base[j][m[i]-k-1]) ismatch=false;
                }
                isok|=ismatch;
            }
            if(isok) res.push_back(i);
        }
        for(int i=0;i<res.size();i++) cout<<res[i]<<endl;;
        cout<<"+++++"<<endl;
    }
}
                         

Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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 Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX / 10000;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	Vl A(n + 1), B(m + 1);
	A[0] = B[0] = 0;
	lrep(i, 1, n + 1) {
		int t;
		cin >> t;
		A[i] = A[i - 1] + t;
	}
	lrep(i, 1, m + 1) {
		int t;
		cin >> t;
		B[i] = B[i - 1] + t;
	}
	int ans = 0;
	rep(i, n + 1) {
		if (A[i] > k) break;
		ll s = k - A[i];
		int h = upper_bound(B.begin(), B.end(), s) - B.begin();
		ans = max(ans, i + h - 1);
		//cout << ans << endl;
	}
	cout << ans << endl;
}



Measured memory_bytes: 6352
#include<stdio.h>
#define N 10000
#define M 500

int linearSearch(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key) i++;
  if(i == n) return 0;
  return 1;
}

int main(){
  int i,n,A[N + 1],q,key,sum = 0;

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&key);
    if(linearSearch(A,q,key)) sum++;
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2052
N=int(input())
d=dict()
A=[]
ma=0
for i in range(N):
  s=input()
  if s not in d:
    d[s]=0
  d[s]+=1
ma=max(d.values())
for i,j in sorted(d.items()):
  if j==ma:
    print(i)


Measured memory_bytes: 44124
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<ll> Y(M), P(M);
    REP(i, M){
        cin >> P[i] >> Y[i];
    }

    vector<vector<ll>> V(N);
    REP(i, M) V[P[i]-1].pb(Y[i]);
    REP(i, N){
        SORT(V[i]);
    }
    REP(i, M){
        int id = lower_bound(ALL(V[P[i]-1]), Y[i]) - V[P[i]-1].begin();
        printf("%06d%06d\n", (int)P[i], id+1);
    }
}

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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;

//iostream::sync_with_stdio(false);

const int maxn = 1e4 + 5;

int main()
{
	ll x;
	cin >> x;
	ll n = 100;
	ll p = 0;
	while (1)
	{
		ll k = n * 0.01;
		n += k;
		p++;
		if (n >= x)
		{
			cout << p;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
h,w,p=map(int,input().split())
A=[]
ans=0

for i in range(h):
    A.append(list(input()))

for i in range(2**h):
    hs=[False]*h
    for j in range(h):
        if ((i>>j)&1):
            hs[j]=True
    for k in range(2**w):
        ws=[False]*w
        for l in range(w):
            if ((k>>l)&1):
                ws[l]=True
        cnt=0
        for a in range(h):
            if hs[a]==True:
                for b in range(w):
                    if ws[b]==True:
                        if A[a][b]=='#':
                            cnt+=1
        if cnt==p:
            ans+=1
print(ans)

Measured memory_bytes: 8916
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

void disp_paper (vector <vector <int> > paper )
{
	int i,j;

	cout << endl;
	cout << "n:";
	for (i = 0; i < 10; ++i){
		cout << i << ' ';
	} // end for
	cout << endl;

	for (i = 2; i < 12; ++i){
		cout << (i-2) << ' ';
		for (j = 2; j < 12; ++j){
			cout << paper[i][j] << ' ';
		} // end for
		cout << endl;
	} // end for
	cout << endl;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.di", "r", stdin);
	const int small[][3] = { 
					{ 0, 1 ,0 },
					{ 1, 1, 1 },
					{ 0, 1, 0 } 
				};
	const int medium[][3] = {
					{ 1, 1, 1 },
					{ 1, 1, 1 },
					{ 1, 1, 1 }
				};
	const int large[][5] = {
					{ 0, 0, 1, 0, 0 },
					{ 0, 1, 1, 1, 0 },
					{ 1, 1, 1, 1, 1 },
					{ 0, 1, 1, 1, 0 },
					{ 0, 0, 1, 0, 0 }
				};
										
	string str = "";
	vector <vector <int> > paper (14, vector <int> (14, 0 ) );
	vector <int> px, py, size;

	while (getline (cin, str ) ){
		int x, y, s;
		while (str.find(',') != string::npos ){
			str = str.replace(str.find(','), 1, " ");
		} // end while
		stringstream ss(str);
		ss >> x >> y >> s;
		px.push_back(x); py.push_back(y); size.push_back(s);		
	} // end for
	
	int n = px.size();
	int i,j,k;

//	for (i = 0; i < n; ++i){
//		cout << px[i] << ' ' << py[i] << ' ' << size[i] << endl;
//	} // end for

	for (k = 0; k < n; ++k){
		if (size[k] == 1){
			for (i = -1; i <= 1; ++i){
				for (j = -1; j <= 1; ++j){
					paper[ py[k] + 2 + i][ px[k] + 2 + j] += small[i+1][j+1];
				} // end for
			} // end for
		}else if (size[k] == 2){
			for (i = -1; i <= 1; ++i){
				for (j = -1; j <= 1; ++j){
					paper[ py[k] + 2 + i][ px[k] + 2 + j] += medium[i+1][j+1];
				} // end for
			} // end for
		}else if (size[k] == 3){
			for (i = -2; i <= 2; ++i){
				for (j = -2; j <= 2; ++j){
					paper[ py[k] + 2 + i][ px[k] + 2 + j] += large[i+2][j+2];
				} // end for
			} // end for
		} // end if
//		disp_paper (paper );
	} // end for

	int res = 0;
	int maxd = 0;
	for (i = 2; i < 12; ++i){
//		cout << (i-2) << ' ';
		for (j = 2; j < 12; ++j){
			if (paper[i][j] == 0){
				++res;
			}else{
				maxd = max (maxd, paper[i][j]);
			} // end if
//			cout << paper[i][j] << ' ';
		} // end for
//		cout << endl;
	} // end for

	cout << res << endl;
	cout << maxd << endl;
		
	return 0;
}

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

int main() {

	int n, thou, hun, ten, one;

	cin >> n;
	thou = n / 1000;
	hun = (n - thou * 1000) / 100;
	ten = (n - thou * 1000 - hun * 100) / 10;
	one = n - thou * 1000 - hun * 100 - ten * 10;
	
	//debug
	//cout << thou << endl;
	//cout << hun << endl;
	//cout << ten << endl;
	//cout << one << endl;

	if (thou == hun && hun == ten) {
		cout << "Yes";
	}
	else if (hun == ten && ten == one) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        long k = sc.nextLong();
        
        int onelast = -1;
        char next = 'a';
        for (int i = 0; i < c.length; i++) {
            if (c[i] != '1') {
                next = c[i];
                break;
            }
            onelast = i;
        }
        onelast++;
        
        if (k <= onelast) {
            System.out.println(1);
        } else {
            System.out.println(next);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    n--;
    int s[n],t[n],u[n];
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i]>>u[i];
    }
    for(int i=0;i<n;i++){
        int ti=0;
        for(int j=i;j<n;j++){
            if(t[j]>=ti){
                ti=t[j]+s[j];
            }
            else{
                ti=((ti-t[j]-1)/u[j]+1)*u[j]+t[j]+s[j];
            }
        }
        cout<<ti<<endl;
    }
    cout<<0<<endl;
}


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

int main() {
    std::vector<char> s(5);
    for(int i = 1; i <= 4; i++) std::cin >> s[i];
    int ans = 0;
    for(int i = 1; i <= 4; i++){
        if(s[i] == '+') ans++;
        else ans--;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	init_C(410000);
	long long ret=0;
	for(int i=0;i<=c;i++){
		int S=a-i;
		if(S<=0)continue;
		long long ks=b*pw(b-1,S-1)%mod;
		ks=ks*Comb(S-1+i,S-1)%mod;
		ret+=ks;
	}
	ret%=mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 11352
fn main() {
    let n: i64 = read();
    let y: i64 = read();
    for a in 0..n + 1 {
        if a * 10000 > y {
            continue;
        }
        for b in 0..n + 1 {
            let c = n - (a + b);
            if c < 0 {
                continue;
            }
            if y == 10000 * a + 5000 * b + 1000 * c {
                println!("{} {} {}", a, b, c);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

priority_queue<double> qu;

int main()
{
    int N;
    cin >> N;
    rep(i,1,N) {
        double tmp;
        cin >> tmp;
        qu.push(-tmp);
    }
    while (qu.size() >= 2) {
        double x1 = -qu.top();qu.pop();
        double x2 = -qu.top();qu.pop();
        double x3 = (x1+x2)/2;
        qu.push(-x3);
    }
    double ans = -qu.top();
    printf("%.12f\n",ans);
}




Measured memory_bytes: 256
use proconio::input;
use std::i32;

fn main() {
    input! {
        x: i32,
        n: i32,
        p: [i32; n],
    }

    let mut ans = (i32::MAX, 0);
    for i in 0..102 {
        if p.contains(&i) {
            continue;
        }
        if (x - i).abs() < ans.0 {
            ans = ((x - i).abs(), i);
        }
    }

    println!("{}", ans.1);
}


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

#define       sf                 scanf
#define       pf                 printf
#define       pb                 push_back
#define       sz                 200005
#define       MOD                1000000007
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef       long long int      ll;

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

int main()
{
	// READ
	optimize

	int a, b;

	cin >> a >> b;

	cout << a*b << endl;



    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void setIO(string name = "c") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(), "r", stdin);
    freopen((name+".out").c_str(), "w", stdout);
}

int main() {
    //setIO();
    ll n, m; cin >> n >> m;
    vector <ll> v (n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll ans = max(v[0], m) - m; v[0] -= max(v[0], m) - m;
    for (int i = 0; i < n - 1; i++) {
        ans += max(v[i] + v[i + 1], m) - m;
        v[i + 1] -= max(v[i] + v[i + 1], m) - m;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3972
#include<stdio.h>

int main(){
	long long h,w,x,y;
	scanf("%lld%lld%lld%lld",&w,&h,&x,&y);
	float anss=(w%2)*(h%2);
	printf("%lld",w*h/2);
	if((w*h)%2==1)printf(".500");
	if(w%2==0&&h%2==0&&w/2==x&&h/2==y)puts(" 1");
	else puts(" 0");
	return 0;
}

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

int main() {
    int c[3][3];
    for(int i = 0; i<3; i++) {
        for(int j = 0; j<3; j++) {
            cin >> c[i][j];
        }
    }

    int x[3] = {0};
    int y[3] = {0};
    for(int i = 0; i<3; i++) {
        x[i] = c[i][0] - y[0];
    }
    for(int i = 0; i<3; i++) {
        y[i] = c[0][i] - x[0];
    }
    int cnt = 0;
    for(int i = 0; i<3; i++) {
        for(int j = 0; j<3; j++) {
            if(x[i] + y[j] != c[i][j]) cnt++;
        }
    }
    cout << ( cnt > 0 ? "No" : "Yes") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int n;
vector<long> v;

using P = pair<int,int>;

vector<P> solve(int l, int r){
  if(l+1 >= r) return {};

  bool ok = true;
  rep(i,l,r-1) if(v[i] > v[i+1]) ok = false;
  if(ok) return {};

  int mx = 0;
  int mi = -1;
  rep(i,l,r){
    if(abs(v[i]) > mx || (v[i] == -mx)){
      mx = abs(v[i]);
      mi = i;
    }
  }
  assert(mi>=0);

  if(v[mi]>0){
    auto ret = solve(l, mi);
    rep(i,mi,r) if(i < n-1){
      while(v[i] > v[i+1]){
        ret.pb(mp(i,i+1));
        v[i+1] += v[i];
      }
    }
    return ret;
  }
  else {
    auto ret = solve(mi+1, r);
    for(int i=mi; i>=l; i--) if(i > 0){
      while(v[i-1] > v[i]){
        ret.pb(mp(i, i-1));
        v[i-1] += v[i];
      }
    }
    return ret;
  }
}

int main(){
  cin>>n;
  v.resize(n);
  rep(i,n) cin>>v[i];

  auto ans = solve(0,n);
// dbg(v);
  cout << ans.size() << endl;
  for(auto &p : ans) cout << p.fi+1 << " " << p.se+1 << "\n";

  return 0;
}


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

using namespace std;

int main(){
 int N, M, X, Y;
 cin >> N >> M >> X >> Y;
 vector<int> x(N), y(M);
 for(int i = 0; i < N; i++){
  cin >> x.at(i);
 }
 for(int i = 0; i < M; i++){
  cin >> y.at(i);
 }
 sort(x.begin(), x.end());
 sort(y.begin(), y.end());
 int Z = y.at(0);
 if(X < Z && Z <= Y && x.at(N - 1) < Z && y.at(0) <= Z){
  cout << "No War" << endl;
 }else{
  cout << "War" << endl;
 }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=1e4+10;
int n,l,ans,a,b,ba; char s[N];

int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%s",s+1),l=strlen(s+1);
		if (s[1]=='B'&&s[l]=='A') ba++;
		else if (s[1]=='B') b++;
		else if (s[l]=='A') a++;
		rep (j,1,l-1) if (s[j]=='A'&&s[j+1]=='B') ans++;
	}
	ans+=min(a,b)+ba;
	if (!a&&!b&&ba) ans--;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
T = int(input())
import heapq
ans = []
for _ in range(T):
    n = int(input())
    ans = 0
    q1,q2,l1,l2 = [],[],[],[]
    for _ in range(n):
        k,l,r = map(int,input().split())
        if l>r:
            l1 += [(k,l-r)]
        else:
            l2 += [(n-k,r-l)]
        ans += min(l,r)
    l1.sort()
    l2.sort()
    #一番大きい差分のものからpushする
    for k,d in l1:
        heapq.heappush(q1, d)
        if len(q1)>k: heapq.heappop(q1)
    for k,d in l2:
        heapq.heappush(q2,d)
        if len(q2)>k: heapq.heappop(q2)
    ans += sum(q1) + sum(q2)
    print(ans)

Measured memory_bytes: 100500
from itertools import accumulate
from bisect import bisect

N = int(input())
C = [0]+list(accumulate(map(int,input().split())))
S = C[N]

def solve(x):
  cx = C[x]
  k = bisect(C, cx//2, lo=1,hi=x)
  _,a,b = min((abs(cx-2*c),cx-c,c) for c in (C[k-1],C[k]))
  k = bisect(C, (S+cx)//2, lo=x+1,hi=N)
  _,c,d = min((abs(cx+S-2*c),S-c,c-cx) for c in (C[k-1],C[k]))
  L = (a,b,c,d)
  return max(L)-min(L)

print(min(solve(i) for i in range(2,N-1)))

Measured memory_bytes: 25972
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 1;
        int ans = 1;
        while (true) {
            int a = (int) Math.pow(count, 2);
            if (a <= n) {
                ans = a;
                count++;
            } else {
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let mut a: Vec<u32> = (0..n).map(|_| read()).collect();
    a.sort();
    a.reverse();
    let mut alice = 0;
    let mut bob = 0;
    for(i, &v) in a.iter().enumerate() {
        if i % 2 == 0 {
            alice += v;
        } else {
            bob += v;
        }
    }
    println!("{}", alice - bob);
}

Measured memory_bytes: 4352
import java.util.Scanner;

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

		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println((n - h + 1) * (n - w + 1));

		sc.close();
	}
}



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


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

  int a,b,c;
  set<int> s;
  cin >> a >> b >> c;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  if(s.size()==2) cout << "Yes" << endl;
  else cout << "No" << endl;


  
  
  return 0;
    

}


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

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

using namespace std;

int main(){
	int n,t[50]; cin>>n;
	string s[50],x;
	rep(i,n) cin>>s[i]>>t[i];
	cin>>x;

	rep(i,n) if(s[i]==x) cout<<accumulate(t+i+1,t+n,0)<<'\n';

	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
	#define LENGTH 256
     
     
    int main(void){
    	int n,a,b,c;
      	1 <= n <= 20;
        1 <= a <= 50;
        1 <= b <= 50;
        scanf("%d %d %d", &n, &a, &b);
        c = a * n;
        if(c > b){
            printf("%d\n", b);
        }else{
            printf("%d\n", c);
        }
    }

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  cout << min(n*a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, perm[10], a[10], b[10];
bool ok_a, ok_b;
void check()
{
    for(int i = 0; i < n; i++)
        if(perm[i] != a[i])
            ok_a = false;
    for(int i = 0; i < n; i++)
        if(perm[i] != b[i])
            ok_b = false;
}
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++)
        perm[i] = i + 1;
    int first = -1, second = -1, cntr = 1;
    do
    {
        ok_a = true; ok_b = true;
        check();
        if(ok_a && first == -1)
            first = cntr;
        if(ok_b && second == -1)
            second = cntr;
        cntr++;
    }
    while(next_permutation(perm, perm + n));
    cout << abs(first - second);
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 1000005

int main(){
	int ans = 0;
	string str;
	cin >> str;
	for(int i = 0;i < str.size();i++){
		if(str[i] == '1')ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 1e5+10;
int main()
{
    _SAD()
    int a[3],x;
    cin>>a[0]>>a[1]>>a[2];
    x=a[2];
    SRT(a,3);
    if(x==a[1])
    {
        cout<<"Yes"<<nl;
    }
    else
    {
        cout<<"No"<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[210000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next().toUpperCase();
      	String b = sc.next().toUpperCase();
      	String c = sc.next().toUpperCase();
      
      
      System.out.print(a.charAt(0));
      System.out.print(b.charAt(0));
      System.out.print(c.charAt(0));
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e5;
const ll bits = 62;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

struct item{
    ll a,b;

    bool operator < (item other){
        return a < other.a;
    }
};

ll dp[N];


int main(){
    FASTIO;
    PRECISION;

    ll h,n;
    cin>>h>>n;

    vector<item>arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i].a>>arr[i].b;
    }

    sort(arr.begin(),arr.end());

    for(int i=0;i<=h;i++){
        dp[i] = inf;
    }

    dp[h]=0;

    for(int i=h;i>0;i--){
        for(int j=0;j<n;j++){
            if(i+arr[j].a<=h)
                dp[i] = min(dp[i],arr[j].b + dp[i+arr[j].a]);
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=0;j<n;j++){
            if(i- arr[j].a <=0){
                // cout<<i<<" "<<arr[j].a<<" "<<dp[i]<<" "<<arr[j].b<<"\n";
                dp[0] = min(dp[0],arr[j].b+dp[i]);
            }
        }
        
    }
        

    // for(int i=0;i<=h;i++){
    //     cout<<dp[i]<<" ";
    // }

    cout<<dp[0]<<"\n";

    

}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,lb=1,ub=1e18,mid,dp[20][20][2][2];

string tostr(LL x)
{
	string ret="";
	while(x>0)
	{
		ret=(char)(x%10+'0')+ret;
		x/=10;
	}
	return ret;
}

bool check()
{
	string s=tostr(mid);
	memset(dp,0,sizeof(dp));
	dp[1][0][1][0]=1;
	repn(i,s[0]-'0'-1) dp[1][i][1][1]=1;
	dp[1][s[0]-'0'][0][1]=1;
	LL ret=0;
	repn(i,s.size()-1)
	{
		rep(j,10)
		{
			rep(k,2)
			{
				rep(p,2)
				{
					if(dp[i][j][k][p]==0) continue;
					if(p==1)
					{
						if(k==0)
						{
							if(abs(s[i]-'0'-j)<2) dp[i+1][s[i]-'0'][0][p|(s[i]-'0'>0)]+=dp[i][j][k][p];
							rep(r,s[i]-'0') if(abs(r-j)<2) dp[i+1][r][1][p|(r>0)]+=dp[i][j][k][p];
						}
						else rep(r,10) if(abs(r-j)<2) dp[i+1][r][1][p|(r>0)]+=dp[i][j][k][p];
					}
					else
					{
						dp[i+1][0][1][0]+=dp[i][j][k][p];
						repn(r,9) dp[i+1][r][1][1]+=dp[i][j][k][p];
					}
				}
			}
		}
	}
	rep(i,10) ret+=dp[s.size()][i][1][1];
	return ret<n;
}

int main()
{
	cin>>n;
	while(lb<ub)
	{
		mid=(lb+ub+1)/2;
		if(check()) lb=mid;
		else ub=mid-1;
	}
	cout<<lb<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	
	int n[3];
	for (int i = 0; i < 3; i++)cin >> n[i];
	sort(n, n + 3);
	int ans = 0, a[2];
	

	for (int i = 0; i < 2; i++) {
		ans += (n[2] - n[i]) / 2;
		a[i] = (n[2] - n[i]) % 2;
	}
	if (a[0] == 1 && a[1] == 1)ans++;
	else if (a[0] != a[1])ans += 2;

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

Measured memory_bytes: 256
// 大文字と小文字変換

#include <stdio.h>
#include <string.h>

int main(void){
  int i;
  char str[1200];

  fgets(str, 1200, stdin); // scanf だとスペース入力以降の文字を読み込んでくれない

  for(i=0; i<=strlen(str); i++){
    if(str[i]>=97 && str[i]<=122) // 小文字だったら
      str[i] = str[i]-32;
    else if(str[i]>=65 && str[i]<=90) // 大文字だったら
      str[i] = str[i]+32;
  }

  printf("%s", str);
  return 0;
}



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

int main()
{
    string s;
    cin >> s;
    
    int total = 0;
    for(int i = 0; i < s.size() - 1; ++i)
    {
        if(s[i] != s[i + 1])
        {
               total++;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}

int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
int d,t,s;
cin>>d>>t>>s;
if(t*s>=d)
{
	cout<<"Yes"<<endl;
}
else
{
	cout<<"No"<<endl;
}
}
 

Measured memory_bytes: 3620
use std::cmp::*;
use std::collections::*;
use std::io::*;

use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut bc: Vec<(i64, i64)> = Vec::new();
    for i in 0..m {
        let b: i64 = read();
        let c: i64 = read();
        let t = (c, b);
        bc.push(t);
    }
    bc.sort();
    bc.reverse();
    let mut d: Vec<i64> = vec![0; n];
    let mut id: usize = 0;
    let mut id = 0;
    for i in 0..bc.len() {
        if id >= n {
            break;
        } else {
            for j in 0..bc[i].1 {
                if (id >= n) {
                    break;
                }
                d[id] = bc[i].0;
                id += 1;
            }
        }
    }
    a.sort();
    for i in 0..n {
        if d[i] < a[i] {
            break;
        } else {
            a[i] = d[i];
        }
    }
    let mut ans = 0;
    for i in a {
        ans += i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5264
#include<iostream>
using namespace std;
string s;
int n,c0,c1,c2,c3;
int main(){
	cin>>n;
  while(n--){
    cin>>s;
    if(s=="AC") c0++;
    if(s=="WA") c1++;
    if(s=="TLE") c2++;
    if(s=="RE") c3++;
  }
  cout<<"AC x "<<c0<<endl;
  cout<<"WA x "<<c1<<endl;
  cout<<"TLE x "<<c2<<endl;
  cout<<"RE x "<<c3<<endl;
  
}

Measured memory_bytes: 3620
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int R[n], G[n], B[n];
    for (int i=0;i<n;i++) {
        if (i) {
            R[i]=R[i-1];
            G[i]=G[i-1];
            B[i]=B[i-1];
            if (s[i]=='R') R[i]++;
            if (s[i]=='G') G[i]++;
            if (s[i]=='B') B[i]++;
        }
        else {
            R[i]=G[i]=B[i]=0;
            if (s[i]=='R') R[i]++;
            if (s[i]=='G') G[i]++;
            if (s[i]=='B') B[i]++;
        }
    }
    // for (int i=0;i<n;i++) printf("%d %d %d\n", R[i], G[i], B[i]);
    long long int sum=0;
    for (int i=0;i<n;i++) {
        for (int j=i+1;j<n-1;j++) {
            if (s[i]!=s[j]) {
                int lim=j+(j-i);
                if (lim>=n) {
                    if (s[i]=='R'&&s[j]=='G'||s[i]=='G'&&s[j]=='R') sum+=B[n-1]-B[j];
                    if (s[i]=='R'&&s[j]=='B'||s[i]=='B'&&s[j]=='R') sum+=G[n-1]-G[j];
                    if (s[i]=='G'&&s[j]=='B'||s[i]=='B'&&s[j]=='G') sum+=R[n-1]-R[j];
                }
                else {
                    if (s[i]=='R'&&s[j]=='G'||s[i]=='G'&&s[j]=='R') {
                        sum+=B[lim-1]-B[j];
                        sum+=B[n-1]-B[lim];
                    }
                    if (s[i]=='R'&&s[j]=='B'||s[i]=='B'&&s[j]=='R') {
                        sum+=G[lim-1]-G[j];
                        sum+=G[n-1]-G[lim];
                    }
                    if (s[i]=='G'&&s[j]=='B'||s[i]=='B'&&s[j]=='G') {
                        sum+=R[lim-1]-R[j];
                        sum+=R[n-1]-R[lim];
                    }
                }
            }
        }
    }
    printf("%lld\n", sum);
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,p;
	cin>>n>>p;
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	if(p==2||p==5){
		ll ans=0;
		for(ll i=0;i<n;i++){
			ll now=s[i]-'0';
			if(now%p==0){
				ans+=n-i;
			}
		}
		cout <<ans;
		return 0;
	}
	ll keta=1;
	ll ch[200010];
	for(ll i=0;i<n;i++){
		ll now=s[i]-'0';
		now*=keta;
		now%=p;
		ch[i]=now;
		keta*=10;
		keta%=p;
	}
	map<ll,ll>q;
	q[0]++;
	ll ans=0;
	ll ch2[200010]={};
	for(ll i=0;i<n;i++){
		ch2[i+1]=ch2[i]+ch[i];
		ch2[i+1]%=p;
		q[ch2[i+1]]++;
		ans+=q[ch2[i+1]]-1;
	}
	cout <<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    ll g = 1;
    ll ans = 1;
    cin >> n;
    rep(i,n){
        ll x;
        cin >> x;
        if(x < g){
            ans *= (x / 2 + 1);
            ans %= MOD;
        }
        else{
            ans *= (g / 2 + 1);
            ans %= MOD;
            g += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<ll>> a(10, vector<ll>(10, 0));
    REP1(i, n) {
        string s = to_string(i);
        int m = sz(s);
        a[s[0] - '0'][s[m - 1] - '0']++;
    }
    ll ans = 0;
    REP(i, 10) REP(j, 10) ans += a[i][j] * a[j][i];
    cout << ans << EOL;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main(){
  ll n,m;
  cin >> n >> m;
  if(n < m)cout << "0" << endl;
  else cout << "10" << endl;
}

Measured memory_bytes: 256
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
# import math
from fractions import gcd
a, b, c, d = map(int, input().split())
# cd_lcm = (c * d) // math.gcd(c, d)
cd_lcm = (c * d) // gcd(c, d)
ab_c = b//c - (a-1)//c
ab_d = b//d - (a-1)//d
ab_cd_both = b//cd_lcm - (a-1)//cd_lcm
ab_cd_either = ab_c + ab_d - ab_cd_both
ab_cd_neither = b-a+1 - ab_cd_either

print(ab_cd_neither)


Measured memory_bytes: 5052
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn,now,ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7904
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;

    vector<vector<int64_t>> dp(S.size()+1,vector<int64_t>(13));
    dp.at(0).at(0)=1;

    int mod=1000000007;
    int p=1;
    for(int i=1;i<S.size()+1;i++){
        if(S.at(S.size()-i)=='?'){
            for(int n=0;n<10;n++){
                for(int a=0;a<13;a++){
                    dp.at(i).at((p*n+a)%13)+=dp.at(i-1).at(a);
                    dp.at(i).at((p*n+a)%13)%=mod;
                }
            }
        }
        else{
            int n=0;
            n=(int)(S.at(S.size()-i)-'0');
            for(int a=0;a<13;a++){
                dp.at(i).at((p*n+a)%13)+=dp.at(i-1).at(a);
                dp.at(i).at((p*n+a)%13)%=mod;
            }
        }
        p=(p*10)%13;
    }
    cout<<dp.at(S.size()).at(5)<<endl;
}

Measured memory_bytes: 13696
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    D = list(map(int, sys.stdin.buffer.readline().split()))
    D.sort()
    print(D[N//2]-D[N//2-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 11644
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		if(a==b) {
			if(a==c) {
				if(b==c) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}else {
				System.out.println("No");
			}
			
		}else {
			System.out.println("No");
		}
		

	}

}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    string str;
    cin>>str;
    s=0;
    ans=0;
    n=str.length();
    for(i=0;i<n;i++)
    {
        if(str[i]=='g')
        {
            if(s){ans++;s--;}
            else s++;
        }
        else
        {
            if(s){s--;}
            else {ans--;s++;}
        }
    }
    cout<<ans;
}

Measured memory_bytes: 512
N = int(raw_input())

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

T = int(raw_input())
if N == 1:
    print T
else:
    f = T
    for i in xrange(1, N):
        T = int(raw_input())
        g = gcd(f, T)
        f = f / g * T
    print f

Measured memory_bytes: 2568
from math import sqrt

while True:
    e = int(input())
    if e == 0: break
    m = e
    for z in range(e):
        if z**3 > e: break
        y = int(sqrt(e - z**3))
        x = e - (y**2 + z**3)
        m = min(m, x+y+z)
    print(m)

Measured memory_bytes: 7648