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

int main(void) {
    vector<int> a(3);
    vector<int> b(3);
    vector<vector<int>> c(3,vector<int>(3));
    bool check = true;
    
    for(int i=0;i<3;i++) {
        for(int j=0;j<3;j++) {
            cin >> c[i][j];
        }
    }

    
    vector<int> diffh(2);
    vector<int> diffw(2);
    int diff ;
    for(int j=1;j<3;j++) {
        diffw[j-1] = c[0][j] - c[0][j-1];
    }
    for(int i=1;i<3;i++) {
        for(int j=1;j<3;j++) {
            diff = c[i][j] - c[i][j-1];
            if(diff != diffw[j-1]) {
                check = false;
                break;
            }
        }
    }
    for(int i=1;i<3;i++) {
        diffh[i-1] = c[i][0] - c[i-1][0];
    }
    for(int j=1;j<3;j++) {
        for(int i=1;i<3;i++) {
            diff = c[i][j] - c[i-1][j];
            if(diff != diffh[i-1]) {
                check = false;
                break;
            }
        }
    }
    
    if(check) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  else return gcd(b, a % b);
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll x = gcd(A, B);
  
  vector<ll> numbers;
  for (ll i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      numbers.push_back(i);
      numbers.push_back(x / i);
    }
  }
  if (x != 1) numbers.push_back(x);
  sort(numbers.begin(), numbers.end());
  
  vector<ll> ps;
  for (auto n : numbers) {
    bool is_prime = true;
    for (auto p : ps) {
      if (n % p == 0) {
	is_prime = false;
	break;
      }
    }
    if (is_prime) ps.push_back(n);
  }

  cout << 1 + ps.size() << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		string h = "";
		h += s[(int)s.size() - 1];
		for (int j = 0; j < s.size()-1; j++) {
			h += s[j];
		}
		if (h == t) {
			cout << "Yes\n";
			return 0;
		}
		s = h;
	}
	cout << "No\n";
}

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

int main() {
    int n,s=0,mx=0;
    cin>>n;
    while (n--) {
        int l;cin>>l;
        s+=l;
        mx=max(mx,l);
    }
    if (mx<s-mx)
        puts("Yes");
    else
        puts("No");
    return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> P;
    vector<int> Q;
    rep(i,N){
        int p; cin >> p;
        P.push_back(p);
    }
    rep(i,N){
        int q; cin >> q;
        Q.push_back(q);
    }
    vector<int> S(N);
    iota(S.begin(),S.end(),1);
    int cnt1 = 0;
    while(S != P){
        next_permutation(S.begin(),S.end());
        cnt1++;
    }
    iota(S.begin(),S.end(),1);
    int cnt2 = 0;
    while(S != Q){
        next_permutation(S.begin(),S.end());
        cnt2++;
    }
    cout << abs(cnt1-cnt2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int a, b;
    int c;
    int d[128] = {0};
    int i, j;
    int cal;
    int price;

    scanf("%d", &n);
    scanf("%d %d", &a, &b);
    scanf("%d", &c);
    for (i = 0; i < n; i++) scanf("%d", d + i);
    for (i = 0; i < n - 1; i++){
        for (j = 0; j < n - i - 1; j++){
            if (d[j] < d[j + 1]){
                int t = d[j];
                d[j] = d[j + 1];
                d[j + 1] = t;
            }
        }
    }
    cal = c;
    price = a;
    for (i = 0; i < n; i++){
        if ((cal + d[i]) / (price + b) >= cal / price){
            cal += d[i];
            price += b;
        }
    }
    printf("%d\n", cal / price);

    return 0;
}

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

int main(){
	int A,B,C,D,W,L;
    cin>>A>>B>>C>>D;
    while(A>0&&C>0){
    C-=B;
    A-=D;
    if(C<=0){
    cout<<"Yes"<<endl;
      continue;
    }else if(A<=0){
    cout<<"No"<<endl;
      continue;
    }
    }
    
}

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

int main(){

  double a,b,c,d,e,f;
  double x,y;
  
  while(cin>>a>>b>>c>>d>>e>>f){

            y = (a*f-d*c)/(a*e-b*d);
        x = (c-b*y)/a;

    printf("%.3f %.3f\n",x,y);
    
  }

}



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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

ll d[1005][20005];

struct Data {
	int w, s;
	ll v;
	Data(int __w = 0, int __s = 0, ll __v = 0): w(__w), s(__s), v(__v) {}

	bool operator < (Data &x) {
		return s + w < x.s + x.w;
	}
};

Data a[1005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
 	int n;
 	cin >> n;

 	FOR (i, 1, n) {
 		cin >> a[i].w >> a[i].s >> a[i].v;
  	}   

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

  	FOR (i, 1, n) {
	  	FOR (j, 0, 20000) {
	  		d[i][j] = d[i - 1][j];
	  	}

	  	FOR (j, 0, 10000) {
	  		if (j <= a[i].s) {
	  			d[i][j + a[i].w] = max(d[i][j + a[i].w], d[i - 1][j] + a[i].v); 
	  		}
	  	}
  	}

  	ll res = 0;
  	FOR (j, 0, 20000) {
  		res = max(res, d[n][j]);
  	}

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

Measured memory_bytes: 156544
row = [True] * 8
col = [True] * 8
dpos = [True] * 15
dneg = [True] * 15


board = [['.', '.', '.', '.', '.', '.', '.', '.'] for i in range(8)]

import sys

file_input = sys.stdin

k = int(file_input.readline())

for line in file_input:
    r, c = map(int, line.split())
    row[r] = "INIT"
    col[c] = "INIT"
    dpos[r + c] = False
    dneg[r + (7 - c)] = False
    board[r][c] = 'Q'

def dfs(i = 0):
    if i == 8:
        for line in board:
            print(*line, sep='')
        return
    if row[i] == "INIT":
        dfs(i + 1)
    elif row[i]:
        for j in range(8):
            if col[j] == "INIT":
                pass
            elif col[j] and dpos[i + j] and dneg[i + (7 - j)]:
                row[i] = False
                col[j] = False
                dpos[i + j] = False
                dneg[i + (7 - j)] = False
                board[i][j] = 'Q'
                dfs(i + 1)
                row[i] = True
                col[j] = True
                dpos[i + j] = True
                dneg[i + (7 - j)] = True
                board[i][j] = '.'

dfs()

Measured memory_bytes: 7872
from itertools import product
from operator import add


class SegTree():
    def __init__(self, N, e, operator_func=add):
        self.e = e # 単位元
        self.size = N
        self.node = [self.e] * (2*N)
        self.operator_func = operator_func # 処理(add or xor max minなど)

    def set_list(self, l):
        for i in range(self.size):
            self.node[i+self.size-1] = l[i]
        for i in range(self.size-1)[::-1]:
            self.node[i] = self.operator_func(self.node[2*i+1], self.node[2*i+2])
    
    def update(self, k, x):
        k += self.size-1
        self.node[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.node[k] = self.operator_func(self.node[2*k+1], self.node[2*k+2])

    def get(self, l, r):
        # [l, r) についてqueryを求める
        x = self.e
        l += self.size
        r += self.size

        while l<r:
            if l&1:
                x = self.operator_func(x, self.node[l-1])
                l += 1
            if r&1:
                r -= 1
                x = self.operator_func(x, self.node[r-1])
            l >>= 1
            r >>= 1
        return x


N = int(input())
l = [tuple(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x:(x[0], -x[1]))

#1 [lmax, rmin] [*, *]
#2 [lmax, *] [*, rmin]

lmax = 0
rmin = 10**12
a, b = 0, 0

for i in range(N):
    if lmax < l[i][0]:
        lmax = l[i][0]
        a = i
    if rmin > l[i][1]:
        rmin = l[i][1]
        b = i

#1
ans1 = 0
for i in range(N):
    if i==a or i==b:
        continue
    buf = max(l[b][1]-l[a][0]+1, 0)+max(l[i][1]-l[i][0]+1, 0)
    ans1 = max(ans1, buf)

#2
ans2 = 0
tree = SegTree(N, 10**12, min)
tree.set_list([i[1] for i in l])

for i in range(N-1):
    p1 = l[i][0]
    p2 = tree.get(i+1, N)
    buf = max(l[b][1]-p1+1, 0)+max(p2-l[a][0]+1, 0)
    ans2 = max(ans2, buf)

ans = max(ans1, ans2)
print(ans)


Measured memory_bytes: 97352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int x, y, z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 123456

char isNotPrime[MAX];

void ef(void) {
	int i, j;
	isNotPrime[0] = isNotPrime[1] = 1;
	for (i = 2; i * i < MAX; i++) {
		if (!isNotPrime[i]) {
			for (j = i * i; j < MAX; j += i) isNotPrime[j] = 1;
		}
	}
}

int ruisekiwa[MAX];

void rsw(void) {
	int i;
	for (i = 3; i < MAX; i += 2) {
		if (!isNotPrime[i] && !isNotPrime[(i + 1) / 2]) ruisekiwa[i] = 1;
	}
	for (i = 1; i < MAX; i++) {
		ruisekiwa[i] += ruisekiwa[i - 1];
	}
}

int Q;
int l[MAX], r[MAX];

int main(void) {
	int i;
	ef();
	rsw();
	if (scanf("%d", &Q) != 1) return 1;
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d", &l[i], &r[i]) != 2) return 1;
	}
	for (i = 0; i < Q; i++) {
		printf("%d\n", ruisekiwa[r[i]] - ruisekiwa[l[i] - 1]);
	}
	return 0;
}


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

  int n, m, sum;
  cin >> n;
  int t[102], p[102], x[102];
  
  for(int i=1; i<=n; i++) {
    cin >> t[i]; 
 	sum += t[i]; 
  }
  
  cin >> m;

  for(int i=1; i<=m; i++) {
    	cin >> p[i] >> x[i];
    	cout << sum - t[p[i]] + x[i] << endl;
    }

}

Measured memory_bytes: 256
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    for(int i=0; i<n; i++) {
        for(int j=i + 1; j<n; j++) {
            for(int k=j + 1; k<n; k++) {

                a = arr[i] , b = arr[j] , c = arr[k];

                if(a + b >c && b + c > a && c + a > b && a!=b && b!=c && c!=a)
                    count++;
            }
        }
    }

    cout<<count<<endl;  
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


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


int main(){
    int N; cin >> N;
    vector<ll> A(N+1);
    map<ll,ll> mp;
    ll sum = 0;
    rep(i,N)
    {
        cin >> A[i];
        mp[A[i]]++;
    }


    for(auto it : mp){
        if(it.second >= 2) sum += (it.second * (it.second - 1) / 2);
    }

    rep(i,N){
        cout << sum - mp[A[i]] + 1 << endl;
    }
}

Measured memory_bytes: 12712
def main():
    import copy
    n = int(input())
    a = list(map(int,input().split()))
    A = copy.deepcopy(a)
    mod = 10**9+7
    l = {}
    for i in range(n):
        for j in range(2,int(a[i]**0.5)+1):
            if a[i]%j==0:
                cnt = 0
                while a[i]%j==0:
                    cnt += 1
                    a[i] = a[i]//j
                if l.get(j)==None:
                    l[j] = cnt
                else:
                    l[j] = max(cnt,l[j])
        if a[i]!=1:
            if l.get(a[i])==None:
                l[a[i]] = 1
    L = 1
    for k in l.keys():
        L *= pow(k,l[k],mod)
    L = L%mod
    ans = 0
    for i in range(n):
        ans += L * pow(A[i],mod-2,mod) % mod
        ans = ans % mod
    print(ans)

if __name__ == "__main__":
    main()


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

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

    if ( a * b <= 0){
        cout << "Zero" << endl;
    }
    else if(0 < a){
        cout << "Positive" << endl;
    }
    else if((b - a + 1) == 0){
        cout << "Negative" << endl;
    }
    else if((b - a + 1) % 2 == 0){
        cout << "Positive" << endl;
    }
    else{
        cout << "Negative" << endl;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    static void gcd(int a, int b){
            int x = Math.max(a,b);
            int y = Math.min(a,b);
            int t = 0;
            while (y>0){
                t = x;
                x = y;
                y = t%y;
            }
            System.out.println(x);
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int ans = 0;
        gcd(a,b);
    }
}

Measured memory_bytes: 17088
#include <bits/stdc++.h>
using namespace std;
int main (){
  int i,n,c=0;
  cin>>n;
  vector <int> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0);
      else c++;
    }
  }
  if(c==0)
  cout<<"APPROVED"<<endl;
  else
  {
    cout<<"DENIED"<<endl;
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;

ll a, b, c, x, y;

void input(){
    cin >> a >> b >> c >> x >> y;
}

ll case_p(){
    ll ans = LLONG_MAX;
    for(int p = 0; p <= x; p++){
        ans = min(ans, (a - 2LL * c) * p + 2LL * c * x + b * max(0LL,y-x+p));
    }
    return ans;
}

ll case_q(){
    ll ans = LLONG_MAX;
    for(int q = 0; q <= y; q++){
        ans = min(ans, (b - 2LL * c) * q + 2LL * c * y + a * max(0LL,x-y+q));
    }
    return ans;
}

int main(){
    input();
    cout << min(case_p(), case_q()) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	ll ans = 0;
	ll n,k;
	cin>>n>>k;
	ll bunbo = 1<<20;
	reps(i,n){
		int must = 0;
		int ten = i;
		while(ten < k){
			must++;
			ten *= 2;
		}
		ans += bunbo/(ll)pow(2,must);
	}
	cout<<setprecision(12)<<ans/(bunbo*n*1.0)<<endl;
	return 0;
}


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

int main() {
  ll x;
  cin >> x;
  rep(i,1000){
    if((x-100*i <= 5*i)&&(x-100*i >= 0)){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,sum=0,ave;
	int data[5];
	for(i=0;i<5;i++){
		scanf("%d",&data[i]);
	}
	for(i=0;i<5;i++){
		if(data[i]<40){
			data[i]=40;
		}
	}
	for(i=0;i<5;i++){
		sum=sum+data[i];
	}
	ave=sum/5;
	printf("%d\n",ave);
	return 0;
}

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

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

    string s;
    cin >> s;

    if(s.size() >= 4){
        if(s.substr(0, 4) == "YAKI"){
            puts("Yes");
            return 0;
        }
    }
    puts("No");

    return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.util.Properties;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static Properties pps = System.getProperties();
	static boolean dbg = true;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String str=ns();

		System.out.println(solve(str));

	}

	private static int solve(String a) {
		// TODO Auto-generated method stub

		int b=0;
		for(char c:a.toCharArray()) {
			if(c=='1')
				b++;
		}
		return Math.min(b, a.length()-b)*2;


	}

	public static void out(String str) {

		if (dbg)
			System.out.println(str);
	}

	public static void out(int str) {

		if (dbg)
			System.out.println(str);
	}

	public static int ni() {
		sc.nextLine();
		return sc.nextInt();

	}

	public static String ns() {

		return sc.nextLine();
	}

	public static int[] ni(int k) {
		int[] res = new int[k];
		for (int i = 0; i < k; i++)
			res[i] = sc.nextInt();
		sc.nextLine();
		return res;
	}

	public static String[] ns(int k) {
		String[] res = new String[k];
		for (int i = 0; i < k; i++)
			res[i] = sc.nextLine();
		return res;
	}

	public static int[][] ni(int a, int b) {
		int[][] res = new int[a][b];
		for (int i = 0; i < a; i++)
			for (int j = 0; j < b; j++)
				res[i][j] = sc.nextInt();
		sc.nextLine();
		return res;
	}
}


Measured memory_bytes: 26436
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        if(S.length()+1 == T.length() && S.equals(T.substring(0, S.length()))){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	auto sgn = [](int a){
		if(a < 0) return -1;
		if(a > 0) return 1;
		return 0;
	};
	int ans = 0, j = 0;
	for(int i = 0; i < n; i = j){
		j++;
		int sg = 0;
		if(i + 1 < n) sg = sgn(a[i + 1] - a[i]);
		while(j + 1 <  n && abs(sg -  sgn(a[j + 1] - a[j])) <= 1){
			if(sg == 0) sg = sgn(a[j + 1] - a[j]);
			j++;
		}
		ans++;
		j++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s; cin >> s;
    if(s == "RRR") cout << 3 << endl;
    else if(s == "RRS" or s == "SRR") cout << 2 << endl;
    else if(s == "SSS") cout << 0 << endl;
    else cout << 1 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

int N,M,a[1000],b[1000],d[1000];

int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++)scanf("%d",&a[i]);
	for(int i=0;i<M;i++)scanf("%d",&b[i]);
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++)if(b[i]>=a[j]){d[j]++;break;}
	}
	int res=0;
	for(int i=0;i<N;i++)if(d[res]<d[i])res=i;
	printf("%d\n",res+1);
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll x,y;
    cin>>x>>y;
    if(x%y==0) cout<<-1<<endl;
    else cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=1LL<<60;

int main(){
    string n;
    cin>>n;
    for(ll i=0;i<n.size();i++){
        if(n[i]=='1')n[i]='9';
        else n[i]='1';
    }
    cout<<n<<endl;
}
 
   

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var k = int.Parse(Console.ReadLine());
        long ans = 0;

        for(int a = 1; a <= k; a++)
        {
            for (int b = 1; b <= k; b++)
            {
                for (int c = 1; c <= k; c++)
                {
                    var tmp = Gcd(a, b);
                    ans = ans + Gcd(tmp, c);
                }
            }
        }

        Console.WriteLine(ans);
    }

    /// <summary>
    /// 最大公約数
    /// </summary>
    public static long Gcd(long m, long n)
    {
        // 必ず m > n にする
        if (m < n)
        {
            var tmp = m;
            m = n;
            n = tmp;
        }

        while (true)
        {
            var r = m % n;
            if (r == 0) return n;
            m = n;
            n = r;
        }
    }
}

Measured memory_bytes: 17652
#include <iostream>
#include <cstdio>
#include <cctype>

using namespace std;

typedef long double db;

inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) f=ch=='-'?-1:f,ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

const int N=500005;

db x[N],y[N];
db vol,tem;
int head,tail,n,L;

int main()
{
	//freopen("dam.in","r",stdin),freopen("dam.out","w",stdout);
	n=read(),L=read(),head=1,tail=0,vol=tem=0.;
	for (int i=1,t,v;i<=n;++i)
	{
		t=read(),v=read();
		for (;vol+v>L;)
		{
			db dsc=min(x[head],vol+v-L);
			tem-=y[head]*dsc/x[head],y[head]-=y[head]*dsc/x[head];
			vol-=dsc,x[head]-=dsc;
			if (!x[head]) ++head;
		}
		vol+=x[++tail]=v,tem+=y[tail]=(db)v*t;
		for (;head<tail&&y[tail]/x[tail]<y[tail-1]/x[tail-1];y[tail-1]+=y[tail],x[tail-1]+=x[tail],--tail);
		printf("%.10lf\n",(double)(tem/vol));
	}
	//fclose(stdin),fclose(stdout);
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

void solve() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }

    vector<ll> AB, ABC;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(all(AB), greater<>());
    AB.erase(AB.begin() + min((int)AB.size(), K), AB.end());

    for (int k = 0; k < Z; k++) {
        for (int ij = 0; ij < AB.size(); ij++) {
            ABC.push_back(AB[ij] + C[k]);
        }
    }
    sort(all(ABC), greater<>());
    ABC.erase(ABC.begin() + min((int)ABC.size(), K), ABC.end());

    for (int i = 0; i < ABC.size(); i++) {
        cout << ABC[i] << endl;
    }
    
    
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 43160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N,M;
int P[100000],Y[100000]; vector<int> yd[100001];
int main () {
scanf("%d%d",&N,&M); rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]); rep(i,N)sort(yd[i+1].begin(),yd[i+1].end()); rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}


Measured memory_bytes: 7808
N = int(input())

## Nの正の公約数をリストで返す（ソートしたい場合は#外す）
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            #if i != n // i:
            #    divisors.append(n//i)
    divisors.sort()
    return divisors

## 入力整数Nの桁数を出力する
## 10**(out-1) <= in < 10**out
def int2digit(num):
  return(len(str(num)))

lst = make_divisors(N)
B = N // lst[-1]
ans = int2digit(B)

print(ans)
  
  

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

void trace(vector<int> V){
  int N = V.size();
  for ( int i = 0 ; i < N ; i++ ){
  	cout << V.at(i) ;
    if( i == N-1 ) 
      cout << endl;
    else
      cout << " ";
  }
  return;
}

int selectionSort(vector<int> &A){
  int N = A.size();
  int cnt = 0;
  for ( int i = 0 ; i < N ; i++ ){
  	int minj = i;
    for ( int j = i ; j < N ; j++){
    	if( A.at(j) < A.at(minj) ){
          	minj = j ;
        }
    }
    if ( minj != i ){
      swap( A.at(minj) , A.at(i) );
      cnt++;
    }
  }
  return cnt;
}

int main() {
  int N;
  cin >> N ;
  
  vector<int> V(N);
  for ( int i = 0 ; i < N ; i++ ){
    cin >> V.at(i);
  }

  int cnt = selectionSort(V);
  trace(V);
  cout << cnt << endl;
}


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

int main() {
  int a11, a12, a13, a21, a22, a23, a31, a32, a33;
  cin >> a11 >> a12 >> a13;
  cin >> a21 >> a22 >> a23;
  cin >> a31 >> a32 >> a33;
  map<int,int> a;
  a[a11] = 1;
  a[a12] = 2;
  a[a13] = 3;
  a[a21] = 4;
  a[a22] = 5;
  a[a23] = 6;
  a[a31] = 7;
  a[a32] = 8;
  a[a33] = 9;

  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    int b;
    cin >> b;
    auto it = a.find(b);
    if(it != a.end()){
      it->second = 0;
    }
  }

  if (( ((a[a11] == 0) * (a[a12] == 0) * (a[a13] == 0)) + ((a[a21] == 0) * (a[a22] == 0) * (a[a23] == 0)) + ((a[a31] == 0) * (a[a32] == 0) * (a[a33] == 0))  + ((a[a11] == 0) * (a[a21] == 0) * (a[a31] == 0))  + ((a[a12] == 0) * (a[a22] == 0) * (a[a32] == 0))  + ((a[a13] == 0) * (a[a23] == 0) * (a[a33] == 0))  + ((a[a11] == 0) * (a[a22] == 0) * (a[a33] == 0))  + ((a[a13] == 0) * (a[a22] == 0) * (a[a31] == 0)) ) == 0){
  cout << "No" << endl;
  } else {
  cout << "Yes" << endl;
  }

}


Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map(&:to_i)

ans = 0
loop do
    sum = 0
    N.times do |i|
        q = (as[i]-N) / (N+1) + 1
        sum += q
        as[i] -= q * (N+1)
    end
    if sum == 0
        puts ans
        exit
    else
        ans += sum
        N.times do |i|
            as[i] += sum
        end
    end
end


Measured memory_bytes: 1788
N = int(input())
A = list(map(int,input().split()))

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

L = [0]
R = [0]
for i in range(N):
  L.append(gcd(L[i], A[i]))
  R.append(gcd(R[i], A[-(i+1)]))
R = R[::-1]
ans = 0
for i in range(N):
  ans = max(ans, gcd(L[i], R[i+1]))
print(ans)

Measured memory_bytes: 14052
package main

import "fmt"

func main() {
	var o, e string
	fmt.Scan(&o, &e)

	ol := len(o)
	el := len(e)
	for i := 0; i < ol; i++ {
		fmt.Printf("%c", o[i])
		if i < el {
			fmt.Printf("%c", e[i])
		}
	}
	fmt.Println()
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
  int h, a;
  cin >> h >> a;
  int ans = (h + a - 1) / a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
m = len(t)
ans = float("inf")
for i in range(n-m+1):
    temp = 0
    for j in range(m):
        if s[i+j] != t[j]:
            temp += 1
    ans = min(ans, temp)
print(ans)

Measured memory_bytes: 9048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;


const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int to_number(int& i, string& s) {
  int number = 0;
  while(isdigit(s[i])) {
    number = number * 10 + (s[i] - '0');
    i++;
  }
  return number;
}

string init(string s) {
  string ret = "";
  for(int i = 0; i < s.size(); i++) {
    if(isdigit(s[i])) {
      ret += to_string((to_number(i, s) + 1) / 2);
      i--;
    } else {
      ret += s[i];
    }
  }
  return ret;
}

int simulate(int& i, string& s) {
  vector<int> vec;
  for(; i < s.size(); i++) {
    if(isdigit(s[i])) {
      int ret = 0;
      while(isdigit(s[i])) {
	ret = ret * 10 + (s[i] - '0');
	i++;
      }
      vec.push_back(ret);
      i--;
    }else if(s[i] == ']' && s[i + 1] == ']') break;
  }
  sort(all(vec));
  int sum = 0;
  for(int j = 0; j < (vec.size() + 1) / 2; j++) {
    sum += vec[j];
  }
  return sum;
}

void solve(string s) {
  s = init(s);
  while(1) {
    // cout << s << endl;
    if(s[2] != '[') break;
    string ss = "";
    for(int i = 0; i < s.size(); i++) {
      if(isdigit(s[i])){
        ss += "[";
	ss += to_string(simulate(i, s));
	// cout << "i: " << ss << endl;
	 ss += "]";
	i++;
      } else if(i + 1 < s.size() && isdigit(s[i + 1])) {
	ss.pop_back();
	continue;
      } else {
	ss += s[i];
      }
    }
    s = ss;
  }

  int i = 0;
  for(; ; i++) if(isdigit(s[i])) break;
  cout << simulate(i, s) << endl;;
}

int main() {
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    solve(s);
  }
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
string s; int ans=0;
int main(){
  cin >> s;
  for (size_t i = 0; i < s.size()-1; i++) {
    if(s[i] != s[i+1])ans++;
  }
  cout << ans << endl; 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  if (N.at(0) == N.at(1) && N.at(1) == N.at(2) ){
    cout << "Yes" << endl;
  } else if (N.at(1) == N.at(2) && N.at(2) == N.at(3)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

const int MAXN = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n;
vector<int> G[MAXN];
vector<int> a;
vector<int> ans;
vector<int> dp;
stack<pair<int, int> > sk;

int bs(int x) {
    int res = n;
    int l = 0, r = n - 1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (x <= dp[mid]) {
            res = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    return res;
}

int gao() {
    int l = 0, r = n - 1;
    int res = 1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (dp[mid] != INF) {
            res = mid + 1;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    return res;
}

void dfs(int u, int p) {
    int k = bs(a[u]);
    if (k == n) {
        sk.push({n - 1, dp[n - 1]});
    } else {
        sk.push({k, dp[k]});
        dp[k] = a[u];
    }

    ans[u] = gao();
    for (int i = 0; i < (int)G[u].size(); i++) {
        int v = G[u][i];
        if (v == p) {
            continue;
        }
        dfs(v, u);
    }
    auto w = sk.top();
    sk.pop();
    dp[w.first] = w.second;
}

int main() {
    scanf("%d", &n);// don't forget &
    a.resize(n);
    dp.resize(n);
    ans.resize(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);// don't forget &
        dp[i] = INF;
    }
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        scanf("%d%d", &u, &v);// don't forget &
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(0, -1);
    for (int i = 0; i < n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 29632
X=int(input())
if X >= 1800:
  Y=1
else:
  if X>=1600:
    Y=2
  else:
    if X>=1400:
     Y=3
    else:
      if X>=1200:
        Y=4
      else:
        if X>=1000:
          Y=5
        else:
          if X>=800:
            Y=6
          else:
            if X>=600:
              Y=7
            else:
              if X>=400:
                Y=8
print(Y)

Measured memory_bytes: 9172
#include<iostream>
using namespace std;
 
int main(){
    char ch;
    int count[26] = {};
    while ( cin >> ch ){
        if ( ch >='A' && ch <='Z' ) {
            count[ch-'A']++;
        }
        if ( ch >='a' && ch <='z' ) {
            count[ch-'a']++;
        }
    }
    for ( int i = 0 ;i<26 ;i++ ) {
        ch = 'a'+i;
        cout << ch << " : " << count[i] << endl;
    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


int n, l;
string s[101];

int main(){
	cin >> n >> l;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	sort(s,s+n);
	
	for(int i = 0; i < n; i++){
		cout << s[i];
	}
	cout << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	string s;

	cin >> n;
	cin >> s;

	if (n == 1)
		cout << "No" << endl;
	else {
		if (n % 2 == 0) {
			string s1 = s.substr(0, n / 2);
			string s2 = s.substr(n / 2, n / 2);
			if (s1 == s2)
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}
		else
			cout << "No" << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int cnt=0;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n-1;i++)
        for(int j=n-1;j>=i+1;j--)
        if(a[j]<a[j-1])
        swap(a[j],a[j-1]),cnt++;
    for(int i=0;i<n;i++)
    {
        if(i)
            cout<<" ";
        cout<<a[i];
    }
    cout<<"\n";
    cout<<cnt<<"\n";
return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
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<bool> vb;
typedef vector<double> vd;
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 irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#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 rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{
    string s;
    cin >> s;
    rep(i, (ll)s.size()) {
        if (i % 2 == 0) {
            cout << s[i];
        }
    }
}

Measured memory_bytes: 3640
#include <stdio.h>

int gcd(int a, int b) {
	int c = a%b;
	while (c) {
		a = b;
		b = c;
		c = a%b;
	}
	return b;
}

int lcm(int a, int b) {
	return (a/gcd(a, b)) * b;
}

int main(void) {
	int a, b;
	while (scanf("%d%d", &a, &b) == 2) {
		printf("%d %d\n", gcd(a, b), lcm(a, b));
	}
	return 0;
}

Measured memory_bytes: 0
using System;

public class Hello
{
    public static void Main()
    {
        var a = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        string[] line = a.Split(',');
        var k = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine(int.Parse(line[k - 1]));
    }
}

Measured memory_bytes: 11092
import math
def com(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,M,K = map(int,input().split())
mod = 10**9+7

ans=0
for i in range(M):
  l=(0+i)*(i+1)+(M-1-i)*(M-i)
  ans+=l//2*N*N%mod
  
for i in range(N):
  l=(0+i)*(i+1)+(N-1-i)*(N-i)
  ans+=l//2*M*M%mod

         
print(ans*com(N*M-2,K-2)//2%mod)

Measured memory_bytes: 74588
import sys
input = sys.stdin.readline

from collections import deque

L = deque([])
i = 0

Q = int(input())

for _ in range(Q):
    q = list(map(int,input().split()))
    if q[0] == 0:
        L.append(q[1])
    elif q[0] == 1:
        L.rotate(q[1])
        i -= q[1]
    else:
        L.pop()

L.rotate(i)
L.reverse()

print(*L,sep='\n')



Measured memory_bytes: 24708
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = b[a[0] - 1]
for i in range(1, len(a)):
    ans += b[a[i] - 1]
    if a[i] - a[i-1] == 1:
        ans += c[a[i-1]-1]
print(ans)

Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define MOD 1000000007
int main()
{
   ll N,M;
   cin>>N>>M;
   ll A[N],sum=0;
   for(int i=0;i<N;i++)
   {
       cin>>A[i];
       sum+=A[i];
   }
   sort(A,A+N);
   vector<pair<ll,ll> >V(M);
   for(int i=0;i<M;i++)
   {
      ll x,y;
      cin>>x>>y;
      V[i]={y,x};
   }
   sort(V.begin(),V.end(),greater<pair<int,int> >());
   ll i=0,j=0;
   while(i<M && j<N)
   {
       ll x=V[i].first;
       ll y=V[i].second;
       if(x>A[j])
       {
           while(y && j<N && x>A[j])
           {
               sum+=(x-A[j]);
               y--;
               j++;
           }
           i++;
       }
       else break;
       
   }
   cout<<sum;
    return 0;

    
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top;
int S[1000];

void push(int x)
{
  S[++top]=x;
}

int pop()
{
  top--;
  return S[top+1];
}

int main()
{
  int a,b;
  top=0;
  char num[100];

  while(scanf("%s",num)!=EOF){
    if(num[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else  if(num[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
   else if(num[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(num));
    }
  }
  printf("%d\n",pop());

  return 0;
}

Measured memory_bytes: 548
#include <iostream>
using namespace std;
int main(){
  int A, B, answer;
  cin >> A >> B;
  for (int i = 1; i < 1000000; i++){
    if (i == 1){
      answer = A;
    }
    else{
      answer += A - 1;
    }
    if (answer >= B){
      if (B == 1) cout << 0;
      else cout << i;
      break;
    }
  }
}


Measured memory_bytes: 3588
N,M = map(int,input().split())
shita=0
ue=N
for i in range(M):
  L,R = map(int,input().split())
  shita=max(shita,L)
  ue=min(ue,R)
  
if ue-shita >= 0:
  print(ue-shita+1)
else:
  print(0)

Measured memory_bytes: 3060
#!/usr/bin/env pypy3


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    n, = get_ints()

    inp = [get_ints() for _ in range(n)]
    x, y, h = zip(*inp)

    def calc(cx, cy):
        low = 1
        high = max(h) + 2000

        for x_, y_, h_ in zip(x, y, h):
            if h_ > 0:
                H = abs(cx - x_) + abs(cy - y_) + h_
                if low <= H <= high:
                    low = high = H
                else:
                    return None
            else:
                H = abs(cx - x_) + abs(cy - y_) + h_
                high = min(high, H)
                if low > high:
                    return None
                    
        if low == high:
            return low
        else:
            return None

    for cx in range(101):
        for cy in range(101):
            ans = calc(cx, cy)
            if ans is not None:
                print(cx, cy, ans)
                return
    assert False


if __name__ == '__main__':
    main()

Measured memory_bytes: 43996
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> sum(n + 1, 0);
    for (ll i = 0; i < n; i++)
    {
        sum[i + 1] = sum[i] + a[i];
    }
    ll ans = LLINF;
    for (ll i = 0; i < n; i++)
    {
        ll p = sum[i];
        ll q = sum[n] - sum[i];
        chmin(ans, llabs(p - q));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
h,n=(int(i) for i in input().split())
l=[]
for i in range(n):
  a,b=(int(i) for i in input().split())
  l.append([a,b])
pocket=[0]
for i in range(h):
  mini=pocket[max(0,i+1-l[0][0])]+l[0][1]
  for j in range(n-1):
    a=l[j+1][0]
    b=l[j+1][1]
    if pocket[max(0,i+1-a)]+b<mini:
      mini=pocket[max(0,i+1-a)]+b
  pocket.append(mini)
print(pocket[h])

Measured memory_bytes: 43100