akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int x;cin >> x;
  int a = x/100;
  int b = x%100;
  int bc =  b/5;
  if(b%5!=0) ++bc;
  if(bc>a){
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

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

int prime(int x){
    if(x<2) return 0;
    else if(x==2) return 1;
    else if(x%2==0) return 0;
    for(int i=3;i*i<=x;i=i+2){
        if(x%i==0) return 0;
    }
    return 1;
}

int main()
{
    int x;cin>>x;
    if(prime(x)) cout<<x;
    else{
            int i;
        for(i=x+1;;i++)
        {
            if(prime(i)) break;
        }
        cout<<i;
    }
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int a; cin >> a;
  cout << a+a*a+a*a*a << endl;
  return 0;
}


Measured memory_bytes: 3588
package main
 
import (
	"fmt"
)
 
func main() {
	var s, t string
	fmt.Scan(&s, &t)
	len := len(s)
	res := 0
	for i := 0; i < len; i++ {
		if s[i] != t[i] {
			res++
		}
	}
	fmt.Println(res)
}

Measured memory_bytes: 3388
package main

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

func main() {
	n := 0
	sc := bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}
	A := make([]int, n)
	for i := 0; i < n; i++ {
		if !sc.Scan() {
			break
		}
		A[i], _ = strconv.Atoi(sc.Text())
	}

	G, count := []int{}, 0
	A, G, count = shellSort(A, n)
	fmt.Println(len(G))
	fmt.Println(String(G))
	fmt.Println(count)
	fmt.Println(Stringln(A))
}

func insertionSort(A []int, n, g int) ([]int, int) {
	cnt := 0
	for i := g; i < n; i++ {
		v := A[i]
		j := i - g
		for j >= 0 && A[j] > v {
			A[j+g] = A[j]
			j = j - g
			cnt++
		}
		A[j+g] = v
	}
	return A, cnt
}

func shellSort(A []int, n int) ([]int, []int, int) {
	cnt, tmp := 0, 0
	var G []int

	for h := 1; h <= n; {
		G = append(G, 0)
		copy(G[1:], G[0:])
		G[0] = h
		h = 3*h + 1
	}

	for i := 0; i < len(G); i++ {
		A, tmp = insertionSort(A, n, G[i])
		cnt += tmp
	}
	return A, G, cnt
}

func String(A []int) string {
	return strings.Trim(fmt.Sprint(A), "[]")
}

func Stringln(A []int) string {
	text := strings.Trim(fmt.Sprint(A), "[]")
	return strings.Replace(text, " ", "\n", -1)
}



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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    long long x = a + b + c;
    for (int i = 0; i < 10'000'000; i++){
        if (a % 2 || b % 2 || c % 2) {
            cout << i << endl;
            exit(0);
        }
        a = (x - a) / 2;
        b = (x - b) / 2;
        c = (x - c) / 2;
    }
    cout << - 1 << endl;
}

Measured memory_bytes: 256
#参考　https://atcoder.jp/contests/abc124/submissions/4948803
from itertools import accumulate

n, k = map(int,input().split())
p = list(input())
a = []
pre = '1'
cnt = 0
for i in range(n):
     if pre != p[i]:
          a.append(cnt)
          cnt = 1
          pre = p[i]
     else:
          cnt += 1
a.append(cnt)
if pre == '0':
     a.append(0)

w = 2*k+1

if w >= len(a):
     print(n)
else:
     acc = list(accumulate(a))
     ans = 0
     acc = [0] + acc
     for i in range(0,len(a)-w+1,2):
          ans = max(ans,acc[i+w]-acc[i])
     print(ans)

Measured memory_bytes: 9384
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	int a = n/100;
	int b = n%100;
	bool f = false, s = false;
	if(a <= 12 and a > 0) f = true;
	if(b <= 12 and b > 0) s = true;
	if(s and f) cout << "AMBIGUOUS";
	else if(!s and !f) cout << "NA";
	else if(s and !f) cout << "YYMM";
	else cout << "MMYY";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
k=int(input())
curr=7
curr=curr%k
count=1
if(k%2==0 or k%5==0):
	print(-1)
else:
	for i in range(1,k+1):
		if(curr==0):
			print(count)
			break
		else:
			curr=(curr*10+7)%k
			count+=1

Measured memory_bytes: 9176
import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max
c = 0
p = len(cand_h)*len(cand_w)
cand_h = set(cand_h)
cand_w = set(cand_w)
if M >= p:
   for i in range(len(object)):
      if object[i][0] in cand_h and object[i][1] in cand_w:
         c += 1
print(ans - (c == p))

Measured memory_bytes: 217212
#include<stdio.h>
#include<math.h>
#include<string.h>
int a[200005];
int b[200005];
int num[200005]={0};
int sum[200005]={0};
int main ()
{
	int n,m,i,j,s=0,d=0,g=0; 
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		if(a[i]==1)
			num[b[i]]++;
		if(b[i]==n)
		    sum[a[i]]++;
	}
		for(i=1;i<n;i++)
		{
			if(num[i]>=1&&sum[i]>=1)
			{
				printf("POSSIBLE\n");
				return 0;
			}
		}
		printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<map>
#include<cmath>
#include<cstring>
#include<vector>
#define pb push_back
#define For(i,j,k)	for(ll i=j;i<=k;++i)
#define Dow(i,j,k)	for(ll i=k;i>=j;--i)
#define ll  long long
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
vector<ll>	vec[2001];
ll cnt[2001],f[300001],ans,n;
char s[200001];
ll l=20000001,r=0,len;
bool vis[200001];
char ch;
inline void add(ll x,ll v){for(;x<=n+2;x+=x&-x)	f[x]+=v;}
inline ll get(ll x){ll sum=0;for(;x;x-=x&-x)	sum+=f[x];return sum;}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	For(i,1,n)
	{
		cnt[s[i]]++;
		vec[s[i]].pb(i);	
	}
	ll no=0;
	For(i,'a','z')	
		if(cnt[i]&1)	no++;
	if(no>1)	{puts("-1");return 0;}
	For(i,1,n+1)	add(i,1);
	For(i,1,n)
	{
		if(!vis[i])
		{
			ch=s[i];
			ll tmp=vec[ch].size();
			ll las=vec[ch][tmp-1];
			if(i==las)
				ans+=(get(n)-get(i))/2;
				else
					ans+=get(n)-get(las);
			add(las,-1);add(i,-1);
			vis[las]=1;vis[i]=1;
			vec[ch].erase(vec[ch].end()-1);
		}
	}
	cout<<ans<<endl;
}

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

// 1 3 5 3 の4枚の餅がある。1 < 3 < 5 で3段の鏡餅ができる
// つまり等しい大きさの餅は積めないので、昇順ソートし差分が0の箇所を引く

int main(){
    int N;
    cin >> N;
    vector<int> mochi(N,0);
    for (int i = 0; i < mochi.size(); i++){
        cin >> mochi.at(i);
    }
    sort(mochi.begin(), mochi.end());

    int ans = N;

    for (int j = 1; j < mochi.size(); j++){
        if (mochi.at(j) - mochi.at(j-1) == 0){
            ans -= 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

const ll mod = 1000000007;
const ll contest = 26;

int main(){
    ll d, csum = 0; cin >> d;
    vector<ll> c(contest);
    vector<vector<ll>> s(d, vector<ll>(contest));
    rep(i, contest){
        cin >> c[i];
        csum += c[i];
    }
    rep(i, d) rep(j, contest) cin >> s[i][j];
    vector<ll> last(contest, 0);
    ll sum = 0;
    rep(i, d){
        ll maxx = 0, tt = 1, score = 0;
        rep(t, contest){
            score = sum + s[i][t];
            rep(j, contest){
                if(t == j) continue;
                score -= c[j]*((i+1)-last[j]);
            }
            if(score > maxx){
                tt = t;
                maxx = score;
            }
        }
        last[tt] = i+1;
        sum += maxx % mod;
        cout << tt+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
string S;
int sum[3][4001];

int main() {
	cin >> N >> S;
	
	map<char, int> mm;
	char tmpc[3] = {'R', 'G', 'B'};
	REP(i, 3) mm[tmpc[i]] = i;
	
	REP(i, N) {
		++sum[mm[S[i]]][i + 1];
		REP(j, 3) sum[j][i + 1] += sum[j][i];
	}
	
	ll ans = 0;
	for (int i = N - 1; i >= 0; --i) {
		for (int j = i - 1; j >= 0; --j) {
			if (S[i] == S[j]) continue;
			bool f[3] {};
			f[mm[S[i]]] = true;
			f[mm[S[j]]] = true;
			
			int cc;
			REP(k, 3) if (!f[k]) cc = k;
			ans += sum[cc][j];
			
			
			int k = j - (i - j);
			if (k >= 0 && S[k] != S[i] && S[k] != S[j]) --ans;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int C(int n,int m)
{
	int ans=1;
	for(int i=1;i<=m;i++)
		ans=ans*(n-m+i)/i;
	return ans;
}

int main()
{
	int n,m;
	cin>>n>>m;
	
	cout<<C(n,2)+C(m,2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define ss second
#define ff first 
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
const ll M=1000000007;
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0)return (power((x*x)%M,n/2))%M;else return ((x%M)*power(x,n-1)%M);}
ll ncr(int n,int r){if(r>n)return 0;if(r > n - r) r = n - r;ll ans = 1;
int i;for(i = 1; i <= r; i++){ans *= n - r + i;ans /= i;}return ans;}
ll nCrModpDP(ll n, ll r, ll p){ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
    for (ll i = 1; i <= n; i++){ 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll ncrmod(ll n, ll r, ll p){ 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
   return (ncrmod(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p;  
} 
ll modInverse(ll a,ll m) 
{ 
   ll m0 = m; 
   ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
       ll q = a / m; 
       ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
const int m=1000001;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll prime[m];
for(int i=1; i<=1000000; i++){
prime[i]=i;
}
for(int i=2; i*i<=1000000; i++){
if(prime[i]){
for(int j=i*i; j<=1000000; j+=i)
prime[j]=i;
}
}
ll n;
cin>>n;
ll num[n];
int f=0,g=0;
for(int i=0; i<n; i++)
cin>>num[i];
unordered_map<ll,ll>mp;
for(int i=0; i<n; i++){
// cin>>num[i];
ll x=num[i];
map<ll,ll>vec;
while(x!=1){
// cout<<prime[x]<<" ";
vec[prime[x]]++;
x/=prime[x];
}
for(auto i=vec.begin(); i!=vec.end(); i++){
if(mp[i->ff]==0)
mp[i->ff]++;
else{
f+=1;
ll gcd=0;
for(int j=0; j<n; j++){
gcd=(ll)__gcd(gcd,num[j]);
}
if(gcd==1){
g+=1;
break;
}else{
break;
}
}
}
if(f>0)
break;
}
if(f==0){
cout<<"pairwise coprime";
}
else if(g>0){
cout<<"setwise coprime";
}else{
cout<<"not coprime";
}
return 0;
}

Measured memory_bytes: 19252
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    xy = sys.stdin.read().split()
    if xy[0] == xy[1]: print('=')
    else:
        if xy == sorted(xy): print('<')
        else: print('>')


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e6+2;
ll fact[inf];
void factfill()
{
    fact[0]=1;
    for(ll i=1; i<inf; i++)
        fact[i] = ( fact[i-1]*i ) % mod;
}

ll powmod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b%2) res = ( res*a )%mod;
        a = (a*a)%mod;
        b/=2;
    }
    return res;
}

ll inv(ll x)
{
    return powmod(x,mod-2) % mod;
}

ll choose(ll n, ll r)
{
    return ( (fact[n]* inv(fact[n-r] ) )%mod *inv(fact[r]))%mod;
}
void solve()
{   

    ll n; cin >> n;
    cout << n*(n+1)/2 ;
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        //factfill();
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A, B, C, K;
    cin >> A >> B >> C >> K ;
    
    if(K < A){
        cout << K << endl;
    }else if(A <= K and K <= (A + B)){
        cout << A << endl;
    }else{
        cout << A - (K - (A + B)) << endl;
    }
    


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long K = GetLong();
		var A = new long[N - 1];
		var B = new long[N - 1];
		var adj = Range(0, N).Select(_ => new List<long>()).ToArray();
		for(long i = 0; i < N - 1; i++)
		{
			A[i] = GetLong() - 1;
			B[i] = GetLong() - 1;
			adj[A[i]].Add(B[i]);
			adj[B[i]].Add(A[i]);
		}

		void dfs(long v, long p, long[] d)
		{
			foreach(var u in adj[v])
			{
				if(u != p)
				{
					d[u] = d[v] + 1;
					dfs(u, v, d);
				}
			}
		}

		long ans = long.MaxValue;
		if(K % 2 == 0)
		{
			for(long i = 0; i < N; i++)
			{
				var d = new long[N];
				dfs(i, -1, d);
				chmin(ref ans, d.Count(x => (x > K / 2)));
			}
		}
		else
		{
			for(long i = 0; i < N - 1; i++)
			{
				var d = new long[N];
				dfs(A[i], B[i], d);
				dfs(B[i], A[i], d);
				chmin(ref ans, d.Count(x => (x > (K - 1) / 2)));
			}
		}

		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

#define    Boost      ios_base::sync_with_stdio(false);cin.tie(NULL);
#define    end        '\n'
#define    long long    int ;

using namespace std;
int main()
{
    Boost;
    int n,x,i;
    cin>>n;
    int a[n+1]= {0};
    for(i=1; i<n; i++)
    {
        cin>>x;
        a[x-1]++;
    }
    for(i=0; i<n; i++)
        cout<<a[i]<<endl;

            return 0;
}


Measured memory_bytes: 4420
import sys
import math
import numpy as np
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


inf = float("inf")
mod = 10 ** 9 + 7

k = I()
s = S()

if len(s) <= k:
    print(s)
else:
    print(s[:k] + "...")


Measured memory_bytes: 27092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

string f(int n) {
    rep (i, 1000) {
        if (i * i == n) return "Yes";
    }
    return "No";
}
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // int a, b; cin >> a >> b;
    string a, b; cin >> a >> b;
    // cout << atoi((a + b).c_str()) << "\n";
    cout << f(atoi((a + b).c_str())) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 101
#define V 100001
typedef long long int lli;
lli dp[N][V];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	for(int i=0; i<N; i++)
		for(int j=0; j<V; j++)
			dp[i][j] = 1e18;
	int n;
	lli w;
	cin>>n>>w;
	vector<lli> wei(n); 
	vector<int> val(n);
	for(int i=0; i<n; i++) cin>>wei[i]>>val[i];
	for(int i=1; i<=n; i++){
		for(int j=0; j<V; j++) dp[i][j] = dp[i-1][j];
		dp[i][val[i-1]] = min(dp[i][val[i-1]], wei[i-1]);
		for(int j=0; j<V; j++)
			if(j+val[i-1] <= V)
				dp[i][j+val[i-1]] = min(dp[i][j+val[i-1]], dp[i-1][j]+wei[i-1]);
	}
	// for(int i=1; i<=n; i++){
	// 	for(int j=0; j<=w; j++) cout<<dp[i][j]<<' ';
	// 	cout<<endl;
	// }
	lli ans = 0;
	for(int j=0; j<V; j++)
		if(dp[n][j] <= w)
			ans = j;
	cout<<ans;
	return 0;
}

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

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  int p[n],i,j,tmp,total=0;
  
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for (i=0; i<n; i++) {
    for (j=i+1; j<n; j++) {
      if (p[i] > p[j]) {
        tmp =  p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
  for(i=0;i<k;i++){
    total += p[i];
  }
  printf("%d",total);
    
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,K;
double dd,cc;
ll i, j, k,l;
int main(){
    scanf("%lld%lld", &N,&K);
    cc = ((double)1)/N;
    l = 0;
    for (i = N; i >= 0;i--)
    {
        if((i<<l)>=K){
            k++;
            continue;
        }
        //printf("%lld,%lld\n", k, l);
        dd += cc * k;
        if(i==0)
            break;
        while((i<<l)<K){
            cc /= 2;
            l++;
        }
        k=1;
    }
    printf("%.12lf",dd);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int N,A[20],B[20],C[20],i,S=0;
   scanf("%d",&N);
   for(i=0;i<N;i++){
       scanf("%d",&A[i]);
   }
    for(i=0;i<N;i++){
       scanf("%d",&B[i]);
       S+=B[i];
   }
   
   for(i=1;i<N;i++){
       scanf("%d",&C[i]);
   }
   
   for(i=0;i<N-1;i++){
       if(A[i]+1==A[i+1])
       S+=C[A[i]];
   }
   printf("%d",S);
   return(0); 
}


Measured memory_bytes: 384
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var v = Array(n+1).fill(0).map(a=>[]);
  for(var i = 0; i < m; i++){
    var t = o.l();
    v[t[0]].push(t[1]);
    v[t[1]].push(t[0]);
  }
  var f = 0, s = 0, q = [];
  for(i = 1; i <= n; i++){
    var a = v[i].length;
    if(a & 1)return "No";
    if(a >= 6)s = 1;
    if(a === 4){q.push(i);}
  }
  return dfs() ? "Yes" : "No";

  function dfs(){
    if(s || q.length > 2)return 1;
    if(q.length < 2)return;
    var x = q[0], y = q[1];
    for(var i = 0; i < 3; i++){
      var b = v[x][i], c = x;
      while(b !== y){
        var t = b;
        b = v[b][0] + v[b][1] - c;
        c = t;
        if(b === x)return 1;
      }
    }
  }
}

Measured memory_bytes: 62616
n = int(input())
b = list(map(int, input().split()))
a = [0]*n
a[0] = b[0]
a[-1] = b[-1]

for i in range(n-2):
  a[i+1] = min(b[i], b[i+1])
  
ret = sum(a)

print(ret)

Measured memory_bytes: 3064
#include <iostream>
typedef long long ll;
using namespace std;
int main(int argc, char *argv[]) {
	int n; cin>>n;
	ll ans=0;
	for(int i=1;i<=n;++i){
		if((!(i%3))||(!(i%5)))
			continue;
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	char a;
	
	cin>>a;
	
	if('A' <= a && a <= 'Z') cout<<"A"<<endl;
	else cout<<"a"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

#define N 100000
#define Q 50000

int main(){

    int i,n,q,count=0;
    int S[N],T[Q];  
    int left,right,mid;

    scanf("%d",&n);

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

scanf("%d",&q);

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

for(i=0;i<q;i++){
    left=0;
    right=n;
 while(left<right){
   mid=(left+right)/2;
   if(S[mid]==T[i]){
       count++;
       break;
   }  
   else if(T[i] < S[mid]) right=mid;
   else left=mid+1;
 }
}

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

return 0;

}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define deb(x) cout<<"-->  "<<#x<<" :  "<<x<<endl;
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }

class cmp{
    public:
    bool operator()(array<ll,3>&a,array<ll,3>&b){
        return a[2]>b[2];
    }
};

void solve(vector<array<ll,3>> edges[],pair<ll,ll> change[],vector<ll> distance[],ll n,ll maxi,ll s){
    priority_queue<array<ll,3>,vector<array<ll,3>>,cmp> pq; //{vert,coins,min}
    pq.push({0,s,0});
    {
        ll time=0;
        while(s+change[0].first<maxi){
            s+=change[0].first;
            time+=change[0].second;
            distance[0][s]=time;
            pq.push({0,s,time});
        }
    }
    while(!pq.empty()){
        auto pa=pq.top();
        pq.pop();
        ll u=pa[0];
        ll silver=pa[1];
        ll time=pa[2];
        for(auto ed:edges[u]){
            ll v=ed[0];
            ll cost=ed[1];
            ll more=ed[2];
            ll temp_s=silver-cost;
            if(temp_s<0)continue;
            ll temp_t=time+more;
            while(temp_s<maxi){
                if(temp_t<distance[v][temp_s]){
                    distance[v][temp_s]=temp_t;
                    pq.push({v,temp_s,temp_t});
                }                
                temp_s+=change[v].first;
                temp_t+=change[v].second;                
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,s;
    cin>>n>>m>>s;
    vector<array<ll,3>> edges[n];
    ll maxi=1;
    for(int x=0;x<m;x++){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;
        v--;
        maxi+=a;
        edges[u].push_back({v,a,b});
        edges[v].push_back({u,a,b});
    }
    pair<ll,ll> change[n];
    for(int x=0;x<n;x++){
        cin>>change[x].first>>change[x].second;
    }
    vector<ll> distance[n];
    for(int x=0;x<n;x++){
        distance[x].resize(maxi);
        for(int y=0;y<maxi;y++){
            distance[x][y]=inf;
        }
    }
    if(s>maxi){
        s=maxi-1;
    }
    distance[0][s]=0;
    solve(edges,change,distance,n,maxi,s);
    for(int x=1;x<n;x++){
        ll mini=inf;
        for(ll y=0;y<maxi;y++){
            mini=min(mini,distance[x][y]);
        }
        cout<<mini<<endl;
    }
    return 0;
}

Measured memory_bytes: 53436
#include<stdio.h>
#include<string.h>

int const N = 1300;
int const M = 256;
int main()
{
	char str[N];
	int atr[M];
	for(int i = 0; i < M; i++)
	{
		atr[i] = 0;
	}
	while(fgets(str, N, stdin))
	{
		for(int i = 0; i < strlen(str) - 1; i++)
		{
			if(str[i] >= 'A' && str[i] <= 'Z')
			{
				atr[str[i]+32]++;
			}
			else
			{
				atr[str[i]]++;
			}
		}		
	}
	for(char i = 'a'; i <= 'z'; i++)
	{
		printf("%c : %d\n", i, atr[i]);
	}
	
}


Measured memory_bytes: 2692
#!/usr/bin/env python3
N, x = map(int, input().split())
if 1 < x < 2 * N - 1:
    print('Yes')
    order = (1, -1)[x > N]
    l = list(range(1, 2 * N)[::order])
    for i in range(2 * N - 1):
        print(l[i - abs(x - N)])
else:
    print('No')


Measured memory_bytes: 12532
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>L(M), R(M);
	rep(i, M) in >> L[i] >> R[i];

	LL left = -1, right = N + 1;
	rep(i, M)
	{
		left = std::max(left, L[i]);
		right = std::min(right, R[i]);
	}

	out << std::max(right - left + 1, 0LL) << std::endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define f first 
#define s second
#define fw(i,start,end) for(lli i=start;i<end;++i)
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
        lli a;
        cin>>a;
        lli b=(a/500);
        lli c=(a-b*500);
        lli d=(c/5);
        cout<<b*1000+d*5<<endl;
        
    return 0;
}

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

int main() {
  string s;
  int count=0,ans=0;
  cin >> s;
  r(i,s.size()){
    if(count){
      if(s[i]=='S')count++;
      else count--;
    }
    else if(!count&&s[i]=='S')count++;
    else ans++;
  }
  cout<<ans*2<<endl;
}

Measured memory_bytes: 640
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	string s;
	cin>>s;
	while(s.size()!=0){
	    s.pop_back();
	    s.pop_back();
		string s1 = s.substr(0,s.size()/2);
		string s2 = s.substr(s.size()/2,s.size()/2);
		//cout<<s1<<endl;
		//cout<<s2<<endl;
		if(s1.compare(s2)==0){
 			cout<<s.size()<<endl;
 			return;
 		}
	}
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <string>
using namespace std;

int main(){
  long long a[10];
  a[0] = 0;
  for(long long i=1, j=9;i<10;i++){
    a[i] = a[i-1] + j*i;
    j *= 10;
  }
  
  for (;;) {
    int n, k, x, y;
    scanf("%d %d", &n, &k);
    if (n == 0 && k == 0)
      break;
    
    for(int i=0;i<10;i++){
      if(n > a[i] && n <= a[i+1]){
	if (i == 0) {
	  x = n;
	  y = 1;
	} else {
	  x = (n-a[i])/(i+1);
	  // x += a[i] + 1;
	  x += pow(10, i);
	  y = (n-a[i])%(i+1);
	  if (y == 0) {
	    y = i + 1;
	    x -= 1;
	  }
	}
	break;
      }
    }

    stringstream ss;
    ss << x;
    for (int i = 1; i <= k; ++i)
      ss << x + i;
    //cout << ss.str() << endl;
    cout << ss.str().substr(y - 1, k) << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;
const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long X){
    if(A<= X && X<= A+B)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long X;
    scanf("%lld",&X);
    solve(A, B, X);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
dic={}
ans=0
for i in range(n):
	s=input()
	alpha=[0 for j in range(26)]
	for c in s:
		alpha[ord(c)-97]+=1
	val=int(''.join(str(x) for x in alpha))
	if(val in dic.keys()):
		dic[val]+=1
	else:
		dic[val]=1
for k in list(dic.values()):
	val=k-1
	ans+=((val*(val+1))//2)
print(ans)

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

using namespace std;

#define int long long

int ans = 0;
string s;
int n;

void solve(int ind, int res)
{
	if (ind >= n)
	{
		ans += res;
		return;
	}

	string cur = "";
	for (int i = ind; i < s.size(); i++)
	{
		cur += s[i];
		solve(i + 1, res + stoll(cur));
	}
}

signed main()
{
	cout.tie(0), cin.tie(0), ios::sync_with_stdio(0);

	cin >> s;
	n = s.size();
	solve(0, 0);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
x = int(input())

y = x // 100
r = x % 100

vs = [5, 4, 3, 2, 1]
t = 0
for i in range(5):
    n = r // vs[i]
    r -= n * vs[i]
    t += n
    if r == 0:
        break
if t <= y:
    print(1)
else:
    print(0)

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> H(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> H[i];
    }
    const ll INF = 1LL<<60;
    vector<ll> dp(N, INF);
    dp[0] = 0;
    for ( int i = 1; i < N; i++ ) {
        for ( int j = 1; j <= 2; j++ ) {
            int k = i - j;
            if ( k < 0 ) continue;
            dp[i] = min(dp[i], dp[k] + abs(H[i]-H[k]));
        }
    }
    return dp[N-1];
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

const ll MOD = 1e9 + 7;

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

    ll N;
    cin >> N;
    ll ans = 1;
    for (ll i = 1; i <= N; ++i) {
        ans = ans * i % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# nCk 前処理メモ化
MOD = 10 ** 9 + 7
N = 2000
@fac = [1, 1]
@inv = [1, 1]
@finv = [1, 1]

(2..N).each do |i|
  @fac[i] = @fac[i - 1] * i % MOD
  @inv[i] = MOD - @inv[MOD % i] * (MOD / i) % MOD
  @finv[i] = @finv[i - 1] * @inv[i] % MOD
end

def nCk(n, k)
  return 0 if n < k || n < 0 || k < 0
  @fac[n] * (@finv[k] * @finv[n - k] % MOD) % MOD
end

n = gets.to_i
balls = gets.split.map(&:to_i)

memo = [0, 0, 1]
3.upto(200_000) do |i|
  memo[i] = memo[i - 1] * i / (i - 2)
end

hash_memo = Hash.new(0)

balls.each do |ball|
  hash_memo[ball] += 1
end

sum = 0
balls.uniq.each do |ball|
  sum += memo[hash_memo[ball]]
end

# puts sum

balls.each do |ball|
  # original_count = hash_memo[ball]
  # original = memo[hash_memo[ball]]
  # deduction = original * original_count
  deduction = memo[hash_memo[ball]]
  increment = memo[hash_memo[ball] - 1]
  puts sum - deduction + increment
end



Measured memory_bytes: 34336
#include <cstdio>
using namespace std;

const int MAX_N = 1000;
int J[MAX_N + 1][MAX_N + 1];
int O[MAX_N + 1][MAX_N + 1];
int I[MAX_N + 1][MAX_N + 1];
char input[MAX_N + 10][MAX_N + 10];
int N, M, K;
int plus_j, plus_o, plus_i;
int a, b, c, d;
int res_j, res_o, res_i;

int main(){
	scanf("%d%d", &M, &N);
	scanf("%d", &K);
	for(int i = 0; i < M; i++){
		scanf("%s", input[i]);
	}
	
	for(int i = 0; i <= M; i++){
		for(int j = 0; j <= N; j++){
			if(i == 0 || j == 0){
				J[i][j] = 0; O[i][j] = 0; I[i][j] = 0;
			}
			else{
				plus_j = 0; plus_o = 0; plus_i = 0;
				if(input[i - 1][j - 1] == 'J') plus_j = 1;
				else if(input[i - 1][j - 1] == 'O') plus_o = 1;
				else if(input[i - 1][j - 1] == 'I') plus_i = 1;
				
				J[i][j] = J[i - 1][j] + J[i][j - 1] - J[i - 1][j - 1] + plus_j;
				O[i][j] = O[i - 1][j] + O[i][j - 1] - O[i - 1][j - 1] + plus_o;
				I[i][j] = I[i - 1][j] + I[i][j - 1] - I[i - 1][j - 1] + plus_i;
			}
		}
	}
	
	for(int i = 0; i < K; i++){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		res_j = J[c][d] - (J[a - 1][d] + J[c][b - 1] - J[a - 1][b - 1]);
		res_o = O[c][d] - (O[a - 1][d] + O[c][b - 1] - O[a - 1][b - 1]);
		res_i = I[c][d] - (I[a - 1][d] + I[c][b - 1] - I[a - 1][b - 1]);
		printf("%d %d %d\n", res_j, res_o, res_i);
	}
	
	return 0;
}

Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += min(v[i] * 2, abs(v[i] - k) * 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int a[101],b[10];
int main(){
  int n,c,i;

  for(i=1;i<=9;i++){
	   scanf("%d",&n);
	    a[n]=i;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%d",&c);
  	b[a[c]]=1;
  }
  if((b[1]*b[2]*b[3])==1||(b[4]*b[5]*b[6])==1||(b[7]*b[8]*b[9])==1||(b[1]*b[4]*b[7])==1||(b[2]*b[5]*b[8])==1||(b[3]*b[6]*b[9])==1||(b[1]*b[5]*b[9])==1||(b[3]*b[5]*b[7])==1){
  	printf("Yes");
  }else{
  	printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#nm=list(map(int,input().split()))
#n=nm[0]
#m=nm[1]
n,m=map(int,input().split())
#py=[]
y=[]
#py=[[[]]*m]
py=[[]]*m
#y=[[]]*n
#print(py)
#for i in range(m):
#    py.append([])
for i in range (n):
    y.append([])
for i in range(m):
    py[i]=list(map(int,input().split()))
    y[py[i][0]-1].append(py[i][1])#yの初期化を＊でするとyの要素全てにappendされてしまう
for i in range(n):
    y[i].sort()
#print(py)
#print(y)
d_y={}
for i in range(n):
    for j in range(len(y[i])):
        d_y[y[i][j]]=j+1
for i in range(m):
    if py[i][0]<10:
        print("00000"+str(py[i][0]*10**6+d_y[py[i][1]]))
    elif  py[i][0]<100:
        print("0000"+str(py[i][0]*10**6+d_y[py[i][1]]))
    elif py[i][0]<1000:
        print("000"+str(py[i][0]*10**6+d_y[py[i][1]]))
    elif py[i][0]<10000:
        print("00"+str(py[i][0]*10**6+d_y[py[i][1]]))
    elif py[i][0]<100000:
        print("0"+str(py[i][0]*10**6+d_y[py[i][1]]))
    else:
        print(str(py[i][0]*10**6+d_y[py[i][1]]))


Measured memory_bytes: 47448
N = int(input())
p = list(map(int, input().split()))

ans = 0
bin_box = []

for i in range(len(p)):
    if i+1 == p[i]:
        bin_box.append(1)
    else:
        bin_box.append(0)

bin_box.append(0)

i = 0
while i < len(bin_box):
    if bin_box[i] == 1:
        ans += 1
        if bin_box[i+1] == 1:
            i += 1
    
    i += 1
    
print(ans)
            

Measured memory_bytes: 14008
N = int(input())
TravelTimeList = []
StartTimeList = []
WaitTimeList = []
for i in range(N - 1):
    c , s , f = map(int,input().split())
    TravelTimeList.append(c)
    StartTimeList.append(s)
    WaitTimeList.append(f)

sum_val = 0
for i in range(N - 1):
    sum_val = StartTimeList[i] + TravelTimeList[i]
    for j in range(i + 1 , N - 1):
        sum_val = max(sum_val , StartTimeList[j])
        WaitTime = (WaitTimeList[j] - ((sum_val - StartTimeList[j]) % WaitTimeList[j])) % WaitTimeList[j]
        sum_val += TravelTimeList[j] + WaitTime
    print(sum_val)
print("0")


Measured memory_bytes: 3064
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

import numpy as np
N = int(input())
d = LI()
d.sort()
cnt = 0
ans = d[N//2]-d[N//2-1]
print(ans)


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

using namespace std;

typedef long long ll;

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  scanf("%d", &N);
  int res = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    while ((a & 1) == 0) a >>= 1, res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

double w,h,x,y;
signed main(){
  cin>>w>>h>>x>>y;
  double d = w*h;
  bool b = false;
  if(x*2 == w && y*2 == h)b = true;
  cout << d/2 << " " << (b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << (a + b > c + d ? "Left" : (a + b < c + d ? "Right" : "Balanced")) << endl;
    return 0;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
3
1 2 3
'''

def solve(l,n):
	m = len(l)
	d = dict(Counter(l))
	dp = [0]*(n+1)
	dp[0] = 1
	mod = 10**9 + 7
	if(1 not in d):
		dp[1] = 1
	for i in range(2,n+1):
		if(i not in d):
			dp[i] = dp[i-1] + dp[i-2]
			dp[i] %= mod
	return dp[n]

N,M = list(map(int, stdin.readline().rstrip().split()))
l = []
for m in range(M):
	l.append(int(input()))
ans = solve(l,N)
print(ans)



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

int main() {

    int n;

    cin >> n;

    long long int a[n];

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

    long long int ans = 1LL << 60;

    for(long long int target = -200; target <= 200; target++){
        long long int all_cost = 0;
        for(int i=0; i<n; i++){
            all_cost += (target-a[i]) * (target-a[i]);
        }
        ans = min(ans,all_cost);
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;

int main(){
    ll 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];
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    sort(B.begin(),B.end());
    reverse(B.begin(),B.end());
    sort(C.begin(),C.end());
    reverse(C.begin(),C.end());
    vector<ll> ABC;
    for (int i=0;i<X;i++){
        for (int j=0;j<Y;j++){
            if ((i+1)*(j+1) > K) break;
            for (int k=0;k<Z;k++){
                if ((i+1)*(j+1)*(k+1) > K) break;
                ABC.push_back(A[i]+B[j]+C[k]);
            }
        }
    }
    sort(ABC.begin(),ABC.end());
    reverse(ABC.begin(),ABC.end());
    for (int i=0;i<K;i++){
        cout << ABC[i] << endl;
    }
}

Measured memory_bytes: 1404
def main():
    #input
    N=int(input())
    l=list("zabcdefghijklmnopqrstuvwxy")
    if N<26:
        print(l[N])
    else:
        name=[]
        n=N
        while n>=26:
            mod=n%26
            if mod!=0:
                n//=26
            else:
                n//=26
                n-=1
            name.append(l[mod])
        if n!=0:
            name.append(l[n])
        name=[name[n] for n in reversed(range(len(name)))]
        print("".join(name))

if __name__=="__main__":
    main()
    

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ++mp[s];
  }
  
  auto fac = [&](ll n) {
    ll res = 0;
    for(ll a = 1; a <= n-1; ++a) {
      res += a;
    }
    return res;
  };
  
  ll ans = 0;
  for(auto i = mp.begin(); i != mp.end(); ++i) {
    ans += fac(i->second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11360
#include<iostream>
#include<string>
#include<cmath>
#include<climits>
using namespace std;
int f(long long a, long long b){
    string sa = to_string(a);
    string sb = to_string(b);
    return max(sa.size(),sb.size());
}
int main(void){
    long long n;
    cin>>n;
    int min(INT_MAX);
    int sqrt_num((int)sqrt(n));
    for(int i(sqrt_num);i>=1;i--){
        if(n%i == 0){
            cout<<f(i,n/i)<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 888