akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/arc062/tasks/arc062_a

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second > b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)
#define BIGNUM (ll(1e18))

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;
    ll vT = 1;
    ll vA = 1;
    REP(i, N) {
        ll T, A;
        cin >> T >> A;
        ll m = (vT+vA+T+A-1)/(T+A);
        ll mT = (vT+T-1)/(T);
        ll mA = (vA+A-1)/(A);
        m = max(m, max(mT, mA));
        vT = m*T;
        vA = m*A;
    }
    cout << vT+vA << endl;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1, N+1):
    if i == p[i-1]:
        ans += 1
        if i == N:
            pass
        else:
            p[i-1], p[i] = p[i], p[i-1]
print(ans)


Measured memory_bytes: 14008
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

cnt = 0
for i in range(n):
    cnt1 = 0
    cnt2 = 0

    for j in range(i):
        if a[i] > a[j]:
            cnt2 += 1

    for j in range(i+1, n):
        if a[i] > a[j]:
            cnt1 += 1
            cnt2 += 1

    cnt += cnt1*k + (k-1)*k//2*cnt2

print(cnt % 1000000007)

Measured memory_bytes: 9220
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  long a, b, k;
  readf("%s %s %s\n", &a, &b, &k);

  auto d = min(a, k);
  a -= d;
  k -= d;
  b -= min(b, k);
  writefln("%s %s", a, b);
}


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

int main () {
  ll N;
  cin >> N;

  ll result = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      result += i;
    }
  }
  cout << result;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    ll n,a,b;
    cin >> n >> a >> b;



               ll val = a+b;
               ll ans = a * (n/val);
               ans += min((n%val),a);
               cout << ans << endl;


    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int n,m;
	cin>>n>>m;
	vector<long long int> map(n+1,0);
	if(m==0){

		map[0]=1,map[1]=1;
		for(int k=2;k<=n;k++){
			map[k]=(map[k-1]%1000000007)+(map[k-2]%1000000007);
		}
	cout<<map[n]%1000000007<<endl;









	}else{
	vector<int> a(m);
	rep(i,m) cin>>a[i];
	int head=0;
	map[0]=1;
	if(a[head]==1){
		map[1]=0;
		while(a[head]==1&&head<m) head++;
	}else{
		map[1]=1;
	}

	for(int k=2;k<=n;k++){
		if(a[head]==k){
			map[k]=0;
			while(a[head]==k&&head<m)head++;
		}else{
			map[k]=(map[k-1]%1000000007)+(map[k-2]%1000000007);
		}
	}
	cout<<map[n]%1000000007<<endl;
	}



	return 0;
}

Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

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

  ll n;
  cin>>n;
  ll l_max=0,r_min=1e10;
  vector<vector<ll>> v(n);
  ll res = 0;
  FOR(i,0,n){
    ll in,in1;
    cin>>in>>in1;
    in1++;
    v[i].push_back(0);
    v[i].push_back(in);
    v[i].push_back(in1);
    l_max = max(l_max,in);
    r_min = min(r_min,in1);
    res = max(res, in1-in);//max_width
  }
  res = res + max(r_min - l_max, (ll) 0);

  FOR(i,0,n) v[i][0] = max((ll)0, v[i][2]-l_max);
  sortAl(v);
  ll r=1e10,l=0;
  vector<ll> a(n),b(n);
  FOR(i,0,n){
    r = min(r,v[i][2]);
    l = max(l,v[i][1]);
    a[i] = max(r-l,(ll)0);
  }
  r = 1e10;
  l = 0;
  FORr(i,0,n-1){
    r = min(r,v[i][2]);
    l = max(l,v[i][1]);
    b[i] = max(r-l,(ll)0);
  }

  ll ans=0;
  FOR(i,0,n-1) ans = max(ans, a[i] + b[i+1]);
  cout<<max(ans,res)<<endl;
  


}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long; using ll = long long; using ld = long double;
using pi = pair<int, int>; using pll = pair<ll, ll>;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
template<typename T> using minQ = priority_queue<T, vector<T>, greater<T>>;

#define endl '\n'
#define ALL(a)       (a).begin(),(a).end()
#define FOR(i,a,b)   for(ll i = (ll)(a); i < (ll)(b); ++i)
#define FORO(i,a,b)  for(ll i = (ll)(a); i <= (ll)(b); ++i)
#define RFOR(i,a,b)  for(ll i = (ll)(b) - 1; i >= (ll)(a); --i)
#define RFORO(i,a,b) for(ll i = (ll)(b); i >= (ll)(a); --i)
#define REP(i,n)     for(ll i = 0; i < (ll)(n); ++i)
#define REPO(i,n)    for(ll i = 1; i <= (ll)(n); ++i)
#define RREP(i,n)    for(ll i = (ll)(n) - 1; i >= 0; --i)
#define RREPO(i,n)   for(ll i = (ll)(n); i >= 1; --i)
#define SORT(a)      sort(ALL(a))
#define UNIQ(a)      a.erase(unique(ALL(a)), a.end())
#define SUNIQ(a)     SORT(a), UNIQ(a)
#define MINI(a,b)    a=min(a,(b))
#define MAXI(a,b)    a=max(a,(b))

const ll mod = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LINF = 1000000000000000000ll;
const ld eps = 1e-8;
const ld PI = acosl(-1);

ll Nll() { ll a; cin >> a; return a; }
ld Nld() { ld a; cin >> a; return a; }
int Ni() { int a; cin >> a; return a; }
char Nc() { char a; cin >> a; return a; }
string Ns() { string a; cin >> a; return a; }

template <typename T>
void O(const T &a) { cout << a << endl; }
template <typename T>
void O(T &&a) { cout << a << endl; }
template <typename T>
void Os(const vector<T> &v) { REP(i, v.size() - 1) cout << v[i] << " \n"[i + 1 == (ll)v.size()]; }
template <typename T>
void Os(vector<T> &&v) { REP(i, v.size() - 1) cout << v[i] << " \n"[i + 1 == (ll)v.size()]; }
template <typename T>
void Is(vector<T> &v) { for (auto& t : v) cin >> t; }

void yes(bool f) { cout << (f ? "yes" : "no") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }

struct Edge {
	int from, to;
	Edge() {}
	Edge(int f, int t) : from(f), to(t) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void solve();

int main() { ios::sync_with_stdio(false), cin.tie(0); cout << fixed << setprecision(20); solve(); }

//-----------------------------------------------template-------------------------------------------------------------

//-----------------------------------------------library-------------------------------------------------------------

void solve()
{
	int N = Ni();
	Yes(N % 10 == N / 100);
}


Measured memory_bytes: 256
N = int(input())
d = dict()
for _ in range(N):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1

d_sorted = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxNum = d_sorted[0][1]
ans = [] 
for i in d_sorted:
    if i[1] == maxNum:
        ans.append(i[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 45788
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int h, w; cin >> h >> w;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    vector<vector<int>> ans(h,vector<int>(w));
    int now = 0;
    rep(i,h) {
        if (i%2==0) {
            rep(j,w) {
                if (a[now]==0) now++;
                ans[i][j] = now+1;
                a[now]--;
            }
        } else {
            repr(j,w-1) {
                if (a[now]==0) now++;
                ans[i][j] = now+1;
                a[now]--;
            }
        }
    }

    rep(i,h) {
        rep(j,w) cout << ans[i][j] << " ";
        cout << endl;
    }
    return 0;
}

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

vector<ll>g[200010];
ll a[200010], pp[200010];
map<ll,ll>m;
int main()
{
    ll n,k,b;
    cin>>n>>k;
    m.clear();

    for(int i=1; i<=n; i++)
    {
        scanf("%lld", &a[i]);
    }

    ll p=k;
    ll in=1, cnt=0, s=0,e=0;
    for(int i=1; i<=k; i++)
    {
        in=a[in];
        if(m[in])
        {
            s=m[in];
            e=cnt-1; break;
        }
        m[in]=cnt;
        pp[cnt]=in;
        cnt++;
    }

    if(k<=e || e==0)
    {
        cout<<pp[k-1];
    }
    else
    {
        k-=s;
        k%=(e-s+1);
        if(k==0) k=(e-s+1);
        cout<<pp[k+(s-1)];
    }
}
/*
5 4
3 4 2 5 1
*/


Measured memory_bytes: 21124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  sort(a,a+n);
  int b=0;
  for(int i=0;i<n;i++){
    x-=a[i];
    if(x>=0)b++;
    else break;
  }
  if(b==n&&x>0)b--;
  cout << b;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100001][4],f[100001][4]={0};
int main()
{
        int i,j,k,n;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
                for(j=1;j<=3;j++)
                        scanf("%d",&a[i][j]);
        for(i=1;i<=n;i++)
        {
                for(j=1;j<=3;j++)
                {
                        for(k=1;k<=3;k++)
                        {
                                if(k==j)
                                        continue;
                                f[i][j]=max(f[i][j],f[i-1][k]+a[i][j]);
                        }
                }
        }
        printf("%d",max(f[n][1],max(f[n][2],f[n][3])));
        return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int count = 0;
		int escape = 0;

		Scanner sc = new Scanner(System.in);

		int inputDigital = sc.nextInt();

		int[] ary = new int[inputDigital];

		for (int setDigital = 0; setDigital < ary.length; setDigital++) {

			ary[setDigital] = sc.nextInt();

		}

		for (;;) {

			for (int searchAry = 0; searchAry < ary.length; searchAry++) {

				if (ary[searchAry] % 2 == 1) {

					escape = 1;
					sc.close();
					System.out.println(count);
					break;

				}

				ary[searchAry] = ary[searchAry] / 2;

			}

			if (escape == 1) {
				break;
			}

			count++;
		}

	}
}

Measured memory_bytes: 35920
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n,k=parseMap(split(readline()))
    r,s,p=parseMap(split(readline()))
    t=chomp(readline())
    good=""
    win=Dict{Char,Char}('r'=>'p','s'=>'r','p'=>'s')
    point=Dict{Char,Int}('r'=>r,'s'=>s,'p'=>p)
    ans=0
    good=join([win[i] for i in t])
    ok=[true for i in 1:n]
    for i in 1:n
        if i<=k || good[i-k]!=good[i] || !ok[i-k]
            ans+=point[good[i]]
        else
            ok[i]=false
        end
    end
    println(ans)
end
main()

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

int N;
int d[110];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> d[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ans += d[i] * d[j];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

const int N = 2005, INF = 2e9;
int mn[N][N];



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

    int n, x;
    cin>>n>>x;

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

    auto it = min_element(a.begin(), a.end());
    rotate(a.begin(), it, a.end());

    for (int i=0; i<n; i++) {
        mn[i][i-1] = INF;
        for (int j=i; j<n; j++) mn[i][j] = min(a[j], mn[i][j-1]);
    }

    long long ans = 1e18;
    for (int i=0; i<n; i++) {
        long long cur = 1LL*i*x;
        for (int j=0; j<n; j++) {
            int l = max(0, j-i);
            int r = j;
            cur += mn[l][r];
        }
        ans = min(ans, cur);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 17428
n = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(1,n-1):
    pp = [p[i-1], p[i], p[i+1]]
    if max(pp) != p[i] and min(pp) != p[i]:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

#define MAX 100

int cnt = 0;
int post_cnt = 0;
int n;
int pre[MAX], in[MAX], post[MAX];

int find(int u){
    int i;
    for(i = 0; i < n; i++){
        if(u == in[i]){
            return i;
        }
    }


    return -1;
}

void reconstruct(int l, int r){
    if (l >= r) return;
    int root = pre[cnt++];
    int mid = find(root);

    reconstruct(l, mid);
    reconstruct(mid + 1, r);
    post[post_cnt++] = root;
}

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

    for(i = 0; i < n; i++) scanf("%d", &pre[i]);
    for(i = 0; i < n; i++) scanf("%d", &in[i]);

    reconstruct(0, n);
    
    for(i = 0; i < n; i++){
        if(!i) printf("%d", post[i]);
        else printf(" %d", post[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2104
N=int(input())
a=list(map(int,input().split()))
b=[1]
c=1
for i in range(1,len(a)):
    if a[i-1]==a[i]:
        c+=1
        b.append(c)
    if a[i-1]!=a[i]:
        c=1
        b.append(c)
d=[]
for i in range(len(b)-1):
    if b[i]>=b[i+1]:
        d.append(b[i])
d.append(b[len(b)-1])
e=0
for i in range(len(d)):
    e+=d[i]//2
print(e)

Measured memory_bytes: 62036
function Main(input) {
	input = input.trim();
  input = input.split(" ").map((list)=>Number(list));
  var A = input[0];
  var B = input[1];
  if(B == 1){
     console.log(0);
    return;
     }else if(B < A){
         console.log(1);
    return;     
              }
  var output = 1;
  while(A < B){
    var tmpA = A;
    A += input[0] - 1;
    //console.log(A);
    output++;
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H,W,A,B; cin>>H>>W>>A>>B;
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			int cur=0;
			if(i>=B) cur++;
			if(j>=A) cur++;
			cur%=2;
			cout<<cur;
		}
		cout<<"\n";
	}
	return 0;
}

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

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

	if (d != 0) {
		cout << setprecision(10) << 2.0*(n - d)*(m - 1) / n / n << endl;
	}
	else {
		cout << setprecision(10) << 1.0*(m - 1) / n << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

void solve(){
    
    int a, b;

    cin >> a >> b;

    for(int i=1; i<=1000; i++){
        if(i * 8 / 100 == a && i * 10 / 100 == b){
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 256
// F - Strings of Eternity
#include <bits/stdc++.h>

using namespace std;

void z_func(const string &p, vector<int> &z)
{
	int n = p.size();
	z.assign(n, 0);
	for (int l = 0, r = 0, i = 1; i < n; i++)
		if (r >= i && z[i - l] < r - i + 1) {
			z[i] = z[i - l];
		} else {
			if (i > r) r = i;
			for (l = i; r < n && p[r - l] == p[r]; ) r++;
			z[i] = r - l;
			r--;
		}
}

int find(const string &s, const string &t)
{
	int m = t.size();
	string r = t + "|" + s;
	vector<int> z;
	z_func(r, z);
	vector<int> dp(z.size() + 1);
	for (int i = m; i < z.size(); i++)
		if (z[i] == m) dp[i + m] = max(dp[i + m], dp[i] + 1);
	return *max_element(dp.begin(), dp.end());
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	string s, t;
	cin >> s >> t;
	string r = s;
	while (r.size() <= s.size() + t.size() * 2) r += s;

	int ans = find(r, t);
	if (ans > 0 && find(r + r, t) != ans)
		ans = -1;

	cout << ans << endl;

	return 0;
}


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

int main(){
	
	int A, B, C;
	cin >> A >> B >> C;
	if ( A == B ){
		cout << C << endl;
	} else if ( A == C ){
		cout << B << endl;
	} else {
		cout << A << endl;
	} 
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//英小文字の配列
	static readonly char[] alphabet = new char[26]{'a','b','c','d','e','f','g',
																		'h','i','j','k','l','m','n','o','p','q',
																		'r','s','t','u','v','w','x','y','z'};

	//文字数の転換点の配列
	static long[] multiArr;
	//26^nを保存
	static long[] powerArr;
	//各桁を格納する配列
	static int[] alphaIndex;

	//Main
	static void Main(string[] args)
	{
		//初期化
		multiArr = new long[11];
		powerArr = new long[11];
		long sum = 1;
		long inc = 1;
		multiArr[0] = 1;
		powerArr[0] = 1;
		for(int i=1; i<11; i++){
			inc *= 26;
			sum += inc;
			multiArr[i] = sum;
			powerArr[i] = inc;
		}

		//読み込む
		long N = long.Parse(Console.ReadLine());

		//まず、全体の文字数を取得
		int len = 0;
		for(int i=0; i<10; i++){
			if(multiArr[i] <= N && N < multiArr[i+1]){
				len = i+1;
				break;
			}
		}
		if(len == 0){
			len = 11;
		}

		alphaIndex = new int[len];
		//順番にインデックスを埋める
		long tempo = N - multiArr[len-1];
		long rem = 0;
		long div = 0;
		long pow = len-1;
		for(int i=0; i<len; i++){
			div = tempo / powerArr[pow];
			rem = tempo % powerArr[pow];
			alphaIndex[i] = (int)div;
			tempo = rem;
			pow --;
		}

		//答えを作成
		string ans = "";
		StringBuilder sb = new StringBuilder("");
		foreach(int idx in alphaIndex){
			sb.Append(alphabet[idx]);
		}
		ans = sb.ToString();

		/*debug
		foreach(long num in multiArr){
			Console.WriteLine(num);
		}
		foreach(long num in powerArr){
			Console.WriteLine(num);
		}
		*/

		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 17744
from collections import deque
import sys
sys.setrecursionlimit(10**8)
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
fennec = [10**5 + 10] * n
fennec[0] = 0
snuke = [10**5 + 10] * n
snuke[n - 1] = 0


def bfs(arr, q):
    while len(q) > 0:
        qq = q.popleft()
        for nex in graph[qq[0]]:
            if arr[nex] > qq[1] + 1:
                arr[nex] = qq[1] + 1
                q.append([nex, arr[nex]])


sq, gq = deque(), deque()
sq.append([0, 0])
gq.append([n - 1, 0])
bfs(fennec, sq)
bfs(snuke, gq)
ans = 0
for i in range(n):
    if fennec[i] <= snuke[i]:
        ans += 1
    else:
        ans -= 1
# なんでans>=0じゃないん？？？？？？？？？？？
print("Fennec" if ans > 0 else "Snuke")

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

using namespace std;

typedef long long ll;
int N,M;
ll A[5];
ll B[5];

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

int main(){

  cin>>N>>M;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<M;i++)cin>>B[i];
  ll g=A[0];
  for(int i=1;i<N;i++)g=gcd(g,A[i]);
  vector<ll> divs;
  for(ll i=1;i*i<=g;i++){
    if(g%i==0){
      divs.push_back(i);
      if(i!=g/i)divs.push_back(g/i);
    }
  }
  ll cnt=0;
  for(ll d : divs){
    bool ok=true;
    for(int i=0;i<M;i++){
      if(d%B[i]!=0){
        ok=false;
      }
    }
    if(ok)cnt++;
  }
  cout<<cnt<<endl;
  
  return 0;
}


Measured memory_bytes: 1348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			int weight = scan.nextInt();
			
			String[] str = {"1", "2", "4", "8", "16", "32", "64", "128", "256", "512", };
			
			int[] bit = new int[10];
			
			for (int i = 0; i < 10; i++) {
				bit[i] = weight % 2;
				weight /= 2;
			}
			
			StringBuffer out = new StringBuffer();
			for (int i = 0; i < 10; i++) {
				if (bit[i] == 1) out.append(str[i] + " ");
			}
			out.delete(out.length() - 1, out.length());
			System.out.println(out);
		}
	}
	
	private void debug() {
		System.out.println();
	}

}

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

int A[100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
        cin >> A[i];

    for(int i=N-1; i>=1; i--)
    {
        if(A[i] > A[i+1])
            A[i]--;
        
        if(A[i] > A[i+1])
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool flag=false;
int main()
{
	string str;
	cin>>str;
	string x,y;
	x=y="";
	int q;
	cin>>q;
	while(q--)
	{
		int T,a;
		char ch;
		cin>>T;T--;
		if(T==0)
			flag=!flag;
		else
		{
			cin>>a>>ch;
				a--;
			if(flag^a==0)
				x+=ch;
			else 
				y+=ch;
		}
	}
	reverse(x.begin(),x.end());
	str=x+str+y;
	if(flag)
		reverse(str.begin(),str.end());
	cout<<str<<endl;
	return 0;
}


Measured memory_bytes: 1348
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N >> M;
	vector< int > A(M);
	rep(i, M) cin >> A[i];
	sort(A.begin(), A.end());
	vector< pii > dp(N + 1, pii(-1, 0));
	dp[0] = pii(0, 0);
	int table[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	rep(k, M) {
		int a = A[k];
		rep(i, N) {
			if (dp[i].first != -1 && i + table[a] <= N) {
				if (dp[i + table[a]].first <= dp[i].first + 1) {
					if (dp[i + table[a]].first == dp[i].first + 1) {
						chmax(dp[i + table[a]].second, a);
					} else {
						dp[i + table[a]].first = dp[i].first + 1;
						dp[i + table[a]].second = a;
					}
				}
			}
		}
	}
	vector< int > ans;
	int i = N;
	while (i > 0) {
		ans.push_back(dp[i].second);
		i -= table[dp[i].second];
	}
	sort(ans.rbegin(), ans.rend());
	rep(i, ans.size()) cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> c(n, 0);
  rep(i, n) c[a[i] - 1]++;
  sort(c.begin(), c.end(), greater<int>());

  int ans = n;
  rep(i, k) ans -= c[i];
  cout << ans << endl;
  


  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    ll x, k, d, t;
    cin >> x >> k >> d;
    if (x < 0) {
        x *= -1;
    }
    // while (x > 0 && k > 0){
    //     t = x;
    //     x -= d;
    //     k--;
    // }
    ll ans = 0;
    ans = (x - d * (x/d));
    if ((x / d) >= k){
        cout << (x - d * k) << endl;
        return 0;
    }
    k -= (x / d);
    t = abs(ans - d);
    if (k % 2 == 0) cout << ans << endl;
    else cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);

template<class T> inline T sqr(T x) {return x*x;}

int main() {
	int a,b;
	cin >> a >> b;
	if (a > b) swap(a,b);
	if (a <= 0 && b >= 0) cout << "Zero" << endl;
	else if (a > 0) cout << "Positive" << endl;
	else if ((a + b) % 2 == 0) cout << "Negative" << endl;
	else cout << "Positive" << endl;
	
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

# エラトステネスの篩
def prime_eratosthenes(n):
    prime_list = []
    num_set = set()
    for i in range(2, n + 1):
        if i not in num_set:
            prime_list.append(i)
            for j in range(i * i, n + 1, i):
                num_set.add(j)
    return prime_list


l1 = set(prime_eratosthenes(10 ** 5))
l2 = set()
l3 = [0] * 10 ** 5

for i in l1:
    if (i + 1) // 2 in l1:
        l2.add(i)
for i in l2:
    l3[i] = 1

# 累積和
ans = list(accumulate(l3))


for i in range(int(input())):
    l, r = map(int, input().split())
    print(ans[r] - ans[l - 1])

Measured memory_bytes: 17228
n,k = gets.split.map(&:to_i)
int = gets.split.map(&:to_i)

bucket = Array.new(200000,0)

int.each do |i|
  bucket[i] += 1 if bucket[i] != nil
end

sort_b = bucket.sort.reverse
p n - sort_b[0..k-1].inject(:+)

Measured memory_bytes: 21888
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>i>>j>>k;
	if((i+j+k)>=22){
		cout<<"bust";
	}else{
		cout<<"win";
	}
	return 0;
}
//.........

Measured memory_bytes: 256
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()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())
n, l = map(int, input().split())
minv = 300
sumv = 0
it = 0
for i in range(n):
    sumv += (l + i)
    if abs(l + i) < minv:
        it = i
        minv = abs(l + i)
print(sumv - (l + it))

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;
const int MAX_V=10000;

int main(){
	string s;
	cin>>s;
	int x[26];
	fill(x,x+26,0);
	int len=s.size();
	for(int i=0;i<len;i++){
		x[s[i]-'a']++;
	}
	if(len<26){
		for(int i=0;i<26;i++){
			if(x[i]==0){
				cout<<s;
				cout<<char('a'+i)<<endl;
				return 0;
			}
		}
	}else{
		int idx=-1;
		bool judge=true;
		bool used[26];
		fill(used,used+26,false);
		for(int i=0;i<len-1;i++){
			if(s[i]-'a'<s[i+1]-'a'){
				idx=max(idx,i);
			}
		}
		if(idx==-1){
			cout<<-1<<endl;
			return 0;
		}
		for(int i=0;i<idx;i++){
			cout<<s[i];
			used[s[i]-'a']=true;
		}
		for(int i=0;i<26;i++){
			if(!used[i] && s[idx]-'a'<i){
				cout<<(char)('a'+i)<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct RollingHash{
  const LL B1, B2, M1, M2;
  vector<LL> hash1, hash2, pow1, pow2;
  RollingHash(string& str): B1(1009), B2(1007), M1(1000000007), M2(1000000009){
	int N = str.size();
	hash1.assign(N+1,0);
	hash2.assign(N+1,0);
	pow1.assign(N+1,1);
	pow2.assign(N+1,1);

	for(int i=0;i<N;++i){
	  hash1[i+1] = (hash1[i] + str[i]) * B1 % M1;
	  hash2[i+1] = (hash2[i] + str[i]) * B2 % M2;
	  pow1[i+1] = pow1[i] * B1 % M1;
	  pow2[i+1] = pow2[i] * B2 % M2;
	}
  }

  // [l,r), 0 <= l < r <= n
  pair<LL,LL> hash(int l, int r){
	pair<LL,LL> res;
	res.first = ((hash1[r] - hash1[l] * pow1[r-l]) % M1 + M1) % M1;
	res.second = ((hash2[r] - hash2[l] * pow2[r-l]) % M2 + M2) % M2;
	return res;
  }
};

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

  int N, M; cin >> N >> M;
  string S; cin >> S;
  RollingHash rh(S);
  map<int, set<int>> mem;
  int l = 0, sz = 1;
  while(M--){
	string q; cin >> q;
	if(q[0] == 'L'){
	  if(q[1] == '-'){
		++sz; --l;
	  }
	  else{
		++l; --sz;
	  }
	}
	else{
	  if(q[1] == '-'){
		--sz;
	  }
	  else{
		++sz;
	  }
	}
	mem[sz].insert(l);
  }

  int ans = 0;
  for(auto isi: mem){
	sz = isi.first;
	set<pair<LL,LL>> s;
	for(int left: isi.second){
	  s.insert(rh.hash(left,left+sz));
	}
	ans += SZ(s);
  }

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

Measured memory_bytes: 52896
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
 
#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using ll = long long int;
using pll = pair<ll, ll>;
 
ll N, M;
 
const int MAXN = 100000;
const int MAXM = MAXN;
ll A[MAXN];
// ll B[MAXM];
// ll C[MAXM];

pair<ll, ll> CB[MAXM];
 
 
int main()
{
    cin >> N >> M;
 
    rep (i, N) { cin >> A[i]; }
    rep (i, M) { cin >> CB[i].second >> CB[i].first; }

    sort(CB, CB + M);
    reverse(CB, CB + M);
 
    priority_queue<ll, vector<ll>, greater<ll> > Q;
    rep (i, N) { Q.push(A[i]); }
 
    rep (i, M)
    {
        rep (j, CB[i].second)
        {
            const ll val = Q.top();
            if (val >= CB[i].first) { break; }
 
            Q.pop();
            Q.push(CB[i].first);
        }
    }
 
    ll ans = 0;
 
    while (!Q.empty())
    {
        ans += Q.top();
        Q.pop();
    }
 
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 3704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int N = int.Parse(line[0]);
            int M = int.Parse(line[1]);

            S = Console.ReadLine();
            line = S.Split();

            int[] A = new int[M];

            for(int i=0; i<M; i++)
            {
                A[i] = int.Parse(line[i]);          
            }

            if(A.Sum() <= N)
            {
                Console.WriteLine(N - A.Sum());
            }
            else
            {
                Console.WriteLine("-1");
            }
            


        }
    }
}

Measured memory_bytes: 29040
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a*b % 2 == 0)
		cout << "Even" << endl;
	else cout << "Odd" << endl;

	return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  vector<int> a(3);
  for(int i=0;i<3;i++)cin>>a[i];
  sort(a.begin(), a.end());
  if(a[0]==5&&a[1]==5&&a[2]==7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

long long co=0;

void merge(vector<int> &da,int le,int mi,int ri){
    int n1=mi-le;
    int n2=ri-mi;
    vector<int> L(n1+1),R(n2+1);
    for(int i=0;i<n1;i++){
        L[i]=da[le+i];
    }
    for(int i=0;i<n2;i++){
        R[i]=da[mi+i];
    }
    L[n1]=INT_MAX;R[n2]=INT_MAX;
    int i=0,j=0;
    for(int k=le;k<ri;k++){
        if(L[i]<R[j]){
            da[k]=L[i];
            i++;
        }
        else{
            da[k]=R[j];
            j++;
            co+=n1-i;
        }
    }
}

void mergesort(vector<int> &da,int le,int ri){
    if (le+1<ri){
        int mi=(le+ri)/2;
        mergesort(da,le,mi);
        mergesort(da,mi,ri);
        merge(da,le,mi,ri);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> da(n);
    for(int i=0;i<n;i++){
        cin >> da[i];
    }
    mergesort(da,0,n);
    cout << co << endl;
}



Measured memory_bytes: 4324
package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return val
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	sc.Split(bufio.ScanWords)
	s := nextLine()
	m := make(map[byte]int)
	ok := true
	for i := 0; i < len(s); i++ {
		if m[s[i]] > 0 {
			ok = false
			break
		}
		m[s[i]]++
	}
	if ok {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}


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

int main(int argc, char *argv[]) {
  int K;
  cin >> K;
  if(K % 2 == 0) {
    cout << (K / 2) * (K / 2) << endl;
  } else {
    cout << (K / 2) * ((K / 2) + 1) << endl;
  }
  return 0;
}


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

// header area

int main(){
    string S;
    string T;
    cin >> S;
    cin >> T;

    int count=0;
    rep(i, S.length()){
        if(S[i] != T[i]) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3864
/*
1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 0 から N-1 まで
3     minj = i
4     for j が i から N-1 まで
5       if A[j] < A[minj]
6         minj = j
7     A[i] と A[minj] を交換
*/
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> &A){
    for(int i=0;i<A.size();i++){
        cout << A.at(i);
        if(i == A.size()-1){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
}

void selectionSort(vector<int> &A,int &cnt){
    for(int i=0; i<A.size();i++){
        int minj = i;
        for(int j=i;j<A.size();j++){
            if(A.at(j) < A.at(minj)){
                minj = j;
            }
        }
        if(i != minj){
            cnt++;
            swap(A.at(i),A.at(minj));
        }
    }
}
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    int cnt =0;
    selectionSort(A,cnt);
    print_vec(A);
    cout << cnt << endl;
}   


Measured memory_bytes: 3104
#define NDEBUG
#include <cassert>
#include <vector>

template <typename SemiLattice> class SparseTable {
public:
	using value_type = SemiLattice;
	using container_type = std::vector<value_type>;
	using size_type = typename container_type::size_type;

private:
	static size_type clz32(size_type c) {
#ifdef __GNUC__
		return 31 ^ __builtin_clz(c);
#else
		size_type ret = 0;
		if (c & 0xFFFF0000)
			c &= 0xFFFF0000, ret |= 16;
		if (c & 0xFF00FF00)
			c &= 0xFF00FF00, ret |= 8;
		if (c & 0xF0F0F0F0)
			c &= 0xF0F0F0F0, ret |= 4;
		if (c & 0xCCCCCCCC)
			c &= 0xCCCCCCCC, ret |= 2;
		if (c & 0xAAAAAAAA)
			ret |= 1;
		return ret;
#endif
	}
	std::vector<container_type> matrix;

public:
	SparseTable(const container_type &a)
		: matrix(a.empty() ? 0 : clz32(a.size()) + 1) {
		if (!a.empty())
			matrix[0].reserve(a.size());
		for (size_type i = 0; i < a.size(); ++i)
			matrix[0].emplace_back(a[i]);
		for (size_type i = 1; i < matrix.size(); ++i) {
			const size_type msiz = a.size() + 1 - (static_cast<size_type>(1) << i);
			matrix[i].reserve(msiz);
			for (size_type j = 0; j < msiz; ++j)
				matrix[i].emplace_back(
					matrix[i - 1][j] +
					matrix[i - 1][j + (static_cast<size_type>(1) << (i - 1))]);
		}
	}
	value_type range(const size_type begin, const size_type end) const {
		assert(begin < end);
		assert(begin < size());
		assert(end <= size());
		const size_type t = clz32(end - begin);
		return matrix[t][begin] + matrix[t][end - (static_cast<size_type>(1) << t)];
	}
	size_type size() const noexcept { return empty() ? 0 : matrix[0].size(); }
	bool empty() const noexcept { return matrix.empty(); }
};
#include <algorithm>
#include <limits>
template <typename T> struct Mini {
	using value_type = T;
	T a;
	explicit Mini(const T &x = std::numeric_limits<T>::max()) : a(x) {}
	Mini operator+(const Mini &o) const { return Mini(std::min(a, o.a)); }
};
#include<cstdio>
#include<vector>
int main() {
	using M = Mini<int>;
	int n, l;
	scanf("%d %d", &n, &l);
	std::vector<M> a(n);
	for (auto &x : a)scanf("%d", &x.a);
	SparseTable<M> T(a);
	for (int i = 0;i <= n - l;++i)
		printf("%d%c", T.range(i, i + l).a, " \n"[i == n - l]);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  if(N % 1110 <= 9 || N % 1000 % 111 == 0){
     cout << "Yes" << endl;
  }
  else{
     cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int MOD = 1000000007;

int keta(ll a, ll b){
    return(max(to_string(a).length(), to_string(b).length()));
}

int main(){
    std::ios_base::sync_with_stdio(false);

    ll n; cin >> n;
    int ans = INF;
    for(ll i = 1LL; i*i<=n; i++){
        if(n%i==0){
            ans = min(ans, keta(i, n/i));
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
inline int gcd(int a,int b){
	if(a%b==0) return b;
	return gcd(b,a%b);
}
inline int gcd(int a,int b,int c){
	return gcd(gcd(a,b),c);
}
int main(int argc, char *argv[]) {
	int k; cin>>k;
	int ans=0;
	for(int i=1;i<=k;++i){
		for(int j=1;j<=k;++j){
			for(int t=1;t<=k;++t)
				ans += gcd(i,j,t);
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;

  if (1 <= N && N <= 1000) {
    cout << 1000 - N << endl;
  }
  else if (1001 <= N && N <= 2000) {
    cout << 2000 - N << endl;
  }
  else if (2001 <= N && N <= 3000) {
    cout << 3000 - N << endl;
  }
  else if (3001 <= N && N <= 4000) {
    cout << 4000 - N << endl;
  }
  else if (4001 <= N && N <= 5000) {
    cout << 5000 - N << endl;
  }
  else if (5001 <= N && N <= 6000) {
    cout << 6000 - N << endl;
  }
  else if (6001 <= N && N <= 7000) {
    cout << 7000 - N << endl;
  }
  else if (7001 <= N && N<= 8000) {
    cout << 8000 - N << endl;
  }
  else if (8001 <= N && N <= 9000) {
    cout << 9000 - N << endl;
  }
  else {
    cout << 10000 - N << endl;
  }
}


Measured memory_bytes: 3592
import java.util.HashMap
import java.util.ArrayList

fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" "). map { it.toInt() }
    val map = HashMap<String, Int>(100000)
    var max = 0
    for (i in 0 until N) {
        val s = readLine()!!
        var count = map[s] ?: 0
        count++
        map[s] = count
        max = Math.max(max, count)
    }
    val list : MutableList<String> = ArrayList(100000)
    map.filter {
        it.value == max
    }.forEach {
        list.add(it.key)
    }
    list.sortedBy { it }.forEach { println(it) }
}

Measured memory_bytes: 99112
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

void Print(int A[],int N)
{
	for (int i = 0; i < N-1; i++)
	{
		cout << A[i] << " ";
	}
	cout <<A[N-1]<< endl;
}

int main()
{
	int A[100];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N; i++)
	{
		int tmp = A[i];
		int j = i-1;
		while (A[j] >tmp && j >= 0)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j + 1] = tmp;
		Print(A, N);
	}
	return 0;
}


Measured memory_bytes: 3088