akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
T gcd(T a, T b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main()
{
    int T;
    cin >> T;
    vector<bool> ans(T);
    for(int i=0; i<T; i++){
        ll A, B, C, D;
        cin >> A >> B >> C >> D;

        if(A<B){ans[i] = false; continue;}
        if(B>D){ans[i] = false; continue;}
        if(B-1<=C){ans[i] = true; continue;}

        ll u = (C+1-A>=0) ? (C+1-A)%B : B-(-(C+1-A)%B);
        ll v = (B-1-A>=0) ? (B-1-A)%B : B-(-(B-1-A)%B);
        D %= B;
        ll d = gcd(B, D);
        if(u<=v && u%d!=0 && u/d == v/d){ans[i] = true; continue;}
        // if(u>v && v<d && B-d<u){ans[i] = true; continue;}
        ans[i] = false;
    }

    for(int i=0; i<T; i++){
        if(ans[i]) cout << "Yes\n";
        else cout << "No\n";
    }
}

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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>

const int mod=1e9+7;
int lowbit(int x) {return x&(-x);}

int n;
vector <int> edge[100010];
int f[100010][2];

int getf(int node,int c,int lst) {
	if (f[node][c]!=-1) return f[node][c];
	if (edge[node].size()==1&&edge[node][0]==lst) return 1;
	if (c==1) {
		ll res=1ll;
		for (int i=0;i<edge[node].size();i++) 
			if (edge[node][i]!=lst)
				res=getf(edge[node][i],0,node)*res%mod;
		return f[node][c]=res;
	}
	else {
		ll res=1ll;
		for (int i=0;i<edge[node].size();i++) {
			if (edge[node][i]==lst) continue;
			res*=(getf(edge[node][i],0,node)+getf(edge[node][i],1,node))%mod;
			res%=mod;
		}
		return f[node][c]=res;
	}
}

int main(){
	memset(f,-1,sizeof(f));
	scanf("%d",&n);
	for (int i=0;i<n-1;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		edge[x].pb(y);
		edge[y].pb(x);
	}
	cout<<(getf(1,0,-1)+getf(1,1,-1))%mod;
	return 0;
}

Measured memory_bytes: 13440
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> tree(n,vector<int>());
    vector<vector<int>> sideId(n,vector<int>());
    for(int i = 0; i < n-1; ++i)
    {
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        tree[a].push_back(b);
        sideId[a].push_back(i);
        tree[b].push_back(a);
        sideId[b].push_back(i);
    }

    vector<int> colors(n-1);
    vector<bool> checker(n);
    queue<pair<int,int>> que;

    que.push(make_pair(0,-1));
    checker[0] = true;
    int variation = 0;
    while(!que.empty())
    {
        pair<int,int> p = que.front();
        int cur = p.first;
        que.pop();
        int tSize = (int)tree[cur].size();
        int color = 0;
        for(int i = 0; i < tSize; ++i)
        {
            int next = tree[cur][i];
            if(checker[next])
            {
                continue;
            }
            int sid = sideId[cur][i];
            int diff = 1;
            if(p.second >= 0)
            {
                diff = p.second == color+1 ? 2 : 1;
            }
            color += diff;
            colors[sid] = color;
            que.push(make_pair(next,color));
            checker[next] = true;
            variation = max(variation,color);
        }
    }
    cout << variation << endl;
    for(int i : colors)
    {
        cout << i << endl;
    }
}

Measured memory_bytes: 12160
N,K = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]
 
where_li = []
pre = 0
for i in range(N):
	where_li.append(A[pre])
	pre = A[pre]-1

len_w = len(where_li)
a = where_li.index(A[pre])
mod_s = len_w-a
if K<=len_w:
	print(where_li[K-1])
else:
	if (K-len_w)%mod_s==0:
		d = mod_s
	else:
		d = (K-len_w)%mod_s
	print(where_li[d-1+a])

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

int main(){
  	int n , w;
    cin>>n>>w;
    int W[n] , v[n];
    
    for(int i = 0 ;i < n ; i++ ){
        cin>>W[i]>>v[i];
    }
    
    long long int dp[n+1][w+1];
    memset(dp , 0 , sizeof(dp));
       
    for(int i = 1 ;  i <= n ; i++){
        for(int j = 1 ; j <= w ; j++){
            dp[i][j] = max( W[i-1] <= j ? (dp[i-1][j - W[i-1]] + v[i-1] ) : 0 , dp[i-1][j]);
        }
    }
    
 
    
    cout<<dp[n][w]<<endl;
   
    
	return 0;
}

Measured memory_bytes: 79104
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  string s;cin>>s;
  int nw = 0;
  int ans = 0;
  for(int i = 0; s.size() > i; i++){
    if(s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T'){
      nw++;
    }else{
      ans = max(ans,nw);
      nw = 0;
    }
  }
  cout << max(ans,nw) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define pb push_back
using namespace std;
signed main()
{
    fastio;
    int n;
    cin>>n;
    double d;
    cin>>d;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        double dist=sqrt(pow(x,2)+pow(y,2));
        if(dist<=d)
        sum++;
    }      
    cout<<sum;
           
return 0;
}

Measured memory_bytes: 3792
Dlist = [11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451]

N = int(input())

for i in range(N):
    print(Dlist[i], end='')
    if i == N - 1:
        print()
    else:
        print(' ', end='')


Measured memory_bytes: 3064
# frozen_string_literal: true

n, a, b = gets.split.map(&:to_i)
s = gets.chomp.chars
qa = qb = 0

s.each_with_index do |c, idx|
  q = qa + qb

  if q == a + b
    (n - idx).times { puts :No }
    exit
  end

  if c == 'a'
    qa += 1
    puts :Yes
  elsif c == 'b' && qb < b
    qb += 1
    puts :Yes
  else
    puts :No
  end
end

Measured memory_bytes: 9980
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

#define ll signed long long 
const ll MOD = 1000000007;
const ll MAX = 200001;

ll fac[MAX], fac_inv[MAX], inv[MAX];

// テーブルを作る前処理
void combination_init() {
  fac[0] = fac[1] = 1;
  fac_inv[0] = fac_inv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    fac_inv[i] = fac_inv[i - 1] * inv[i] % MOD;
  }
}

ll combination(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (fac_inv[k] * fac_inv[n - k] % MOD) % MOD;
}

ll pow(ll n, ll k) {
  ll ret = 1;
  while (k > 0) {
    if (k & 1) {
      ret = ret * n;
      ret %= MOD;
    }
    n = n * n;
    n %= MOD;
    k >>= 1;
  }
  return ret;
}


ll modulo(ll k) {
  while (k < 0) {
    k += MOD;
  }
  return k %= MOD;
}

int main() {
  combination_init();
  ll N, K;
  cin >> N >> K;
  K = min(K, N - 1);

  ll ans = 0;
  for (ll k = 1; k <= K; ++k) {
    ll s = 0;
    s = combination(N, k);
    ll n = N - k;

    ll t = combination(n + k, k) - combination(n + k - 1, k - 1);
    t = modulo(t);
    ans += t * s;
    ans = modulo(ans);
  }
  ans += 1;
  ans = modulo(ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 105

char buf[3][SIZE];

int main(){

	int len[3];

	for(int i = 0; i < 3; i++){

		scanf("%s",buf[i]);
	}
	for(int i = 0; i < 3; i++){
		for(len[i] = 0; buf[i][len[i]] != '\0'; len[i]++);
	}

	int loc[3] = {0,0,0};
	int turn = 0;

	while(true){

		if(loc[turn] == len[turn]){

			printf("%c\n",'A'+turn);
			return 0;
		}
		char ch = buf[turn][loc[turn]];
		loc[turn]++;

		turn = ch-'a';
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>

using namespace std;

#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
const int MAXV = 1e9;



int main(){
  int X, Y; cin >> X >> Y;
  bool ans = false;
  rep(i,X+1){
    if (i*2+(X-i)*4 == Y){
      ans = true;
    }
  }
  if (ans) cout << "Yes";
  else cout << "No";


  return 0;
}

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

int n;
pair<int, int> a[100000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i].first, a[i].second = i + 1;
	sort(a, a + n);
	for(int i = 0; i < n; i++) cout << a[i].second << ((i == n - 1) ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> hateList = new ArrayList<>();
        String n = scanner.next();
        int k = scanner.nextInt();
        for(int i = 0; i < k; i++){
            hateList.add(scanner.next());
        }
        for(;;){
            Boolean flag = true;
            for(int i = 0; i < k; i++){
                if(n.indexOf(hateList.get(i)) != -1){
                    int num = Integer.valueOf(n);
                    num++;
                    n = String.valueOf(num);
                    flag = false;
                }
            }
            if(flag == true){
                System.out.println(n);
                break;
            }
        }
    }
}


Measured memory_bytes: 15820
# -*- coding:utf-8 -*-
import sys
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
a = {}
for tmp in range(len(d)):
    if d[tmp] in a:
        a[d[tmp]] += 1
    else:
        a[d[tmp]] = 1
for tmp in range(len(t)):
    if t[tmp] in a:
        if a[t[tmp]] == 0:
            print("NO")
            sys.exit()
        else:
            a[t[tmp]] -= 1
    else:
        print("NO")
        sys.exit()
print("YES")

Measured memory_bytes: 41944
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
 
int main() {
  int Aa,Bb,Cc,p,q,r;
  
  int judge = 0;
  
  
    cin >> Aa;
    cin >> Bb;
    cin >> Cc;
    
  p = Aa+Bb;
  q = Aa+Cc;
  r = Bb+Cc;
  
 judge = min({p,q,r});
  
  
      cout << judge  << endl;
  
  
  
}


Measured memory_bytes: 256
/// wa ^3^

#pragma GCC optimize("O3")

#include<iostream>
#include<iomanip>
                           
using namespace std;

const int MOD = 1e9 + 7;

const int N = 2e5;

int cnt[N], a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int dp = -1, r = 0;
    for (int x; n--;) {
        cin >> x;
        if (x != dp)
            a[r++] = x;
        dp = x;            
    }
    dp = 1;
    for (int i = 0; i < r; ++i) {
        int x = a[i];
        cnt[x] += dp;
        if (cnt[x] >= MOD)
            cnt[x] -= MOD;
        dp = cnt[x];    
    }
    cout << dp;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll ans = 700;
    string s; cin >> s;
    rep(i,3){
        if(s[i]=='o') ans += 100;
    }
    cout << ans << endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool U[30];

int main()
{
    string S;
    cin >> S;
    REP(i, S.length())
    {
        U[S[i] - 'a'] = true;
    }
    REP(i, 26)
    {
        if (!U[i])
        {
            cout << S << (char)('a' + i) << endl;
            return 0;
        }
    }
    for (int i = S.length() - 1; i >= 0; --i)
    {
        FOR(j, 26, S[i] - 'a' + 1)
        {
            if (!U[j])
            {
                REP(k, i)
                {
                    cout << S[k];
                }
                cout << (char)('a' + j) << endl;
                return 0;
            }
        }
        U[S[i] - 'a'] = false;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 2e5 + 5;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a+b/2);
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(3)
#include <bits/stdc++.h>

using namespace std;

long long n, ans, i;

int main()
{
	cin>>n;
	if(n % 2 == 1)
	{
		cout<<0;
		return 0;
	}
	else
	{
		if(n < 10)
		{
			cout<<0;
			return 0;
		}
		for(i = 1; (long long) pow(5, i) < n; i ++)
			ans += (n / (long long)pow(5, i)) / 2;
		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
   int n,i,j;
   cin>>n;
  int h[n];
  for(i=0;i<n;i++)
  cin>>h[i];
  vector<int>dp(n,INT_MAX);
  dp[0]=0;
  for(i=0;i<n;i++)
  {
      if(i+1<n)
      {
          dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
      }
      if(i+2<n)
      {
           dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
      }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int i,n,t;
	int tmin, tmax;
	long long int tsum;

	scanf("%d\n", &n);
	for(i=0,tsum=0,tmax=-1000000,tmin=1000000;i<n;i++) {
		scanf("%d", &t);
		tsum += t;
		if(t>tmax) tmax = t;
		if(t<tmin) tmin = t;
	}
	
	printf("%d %d %lld\n", tmin, tmax, tsum);
	
	return 0;
}

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

using namespace std;

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string s;
using ll = long long;

ll f(int S) {
    ll n = s[0] - '0';
    ll ret = 0;
    rep(i, s.size()) if (i) {
        if (S >> (i - 1) & 1) {
            ret += n;
            n = s[i] - '0';
        } else {
            n = n * 10 + s[i] - '0';
        }
    }
    ret += n;

    return ret;
}
int main() {
    cin >> s;
    ll ans = 0;
    int n = s.size() - 1;
    rep(S, 1 << n) { ans += f(S); }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<math.h>
using namespace std;

int taro,hana;
int *s[2];
int n,m;
int ans,se;

int cmp(const void *a,const void *b){
	return (*(int*)a-*(int*)b);
}

int search(int min,int max,int se){
	int avg=(max+min)/2;
	if(s[1][avg]==se) return avg;
	if(max<=min) return -1;
	if(s[1][avg]>se) return search(min,avg-1,se);
	return search(avg+1,max,se);
}

int main(){
	int i;
	while(cin>>n>>m){
		if(n==0 && m==0) break;
		s[0]=new int[n];
		s[1]=new int[m];
		taro=0;
		hana=0;
		for(i=0;i<n;i++){
			cin>>s[0][i];
			taro+=s[0][i];
		}
		for(i=0;i<m;i++){
			cin>>s[1][i];
			hana+=s[1][i];
		}
		qsort(s[0],n,sizeof(int),cmp);
		qsort(s[1],m,sizeof(int),cmp);
		ans=(taro-hana);
		if(abs(ans)%2==1){
			cout<<-1<<endl;
			delete []s[0];
			delete []s[1];
			continue;
		}
		ans/=2;
		for(i=0;i<n;i++){
			se=s[0][i]-ans;
			if(se<s[1][0]) continue;
			se=search(0,m,se);
			if(se!=-1){
				cout<<s[0][i]<<" "<<s[1][se]<<endl;
				break;
			}
		}
		if(i==n) cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
#define ll long long
int main()
{
    ios::sync_with_stdio(false);
    int ans = 0;
    int l , r, d;
    cin >> l >> r >> d;
    for (int i = l ; i <= r ; i++){
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int a = cin.Int();
			int b = cin.Int();
			int c = cin.Int();

			if (a == b && b == c) {
				Console.WriteLine("No");
				return;
			}

			if (a == b || b == c || c == a) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  private void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      int[] mHeap = new int[heapSize+1];
      mHeap[0] = heapSize;
      for(int i=1; i<=heapSize; i++)
        mHeap[i] = Integer.parseInt( keys[i-1] );

      buildMaxHeap(mHeap);

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<mHeap.length; i++) 
        buf.append(" ").append(mHeap[i]);

      System.out.println(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
  private void buildMaxHeap(int[] heap) {
    for(int i= heap[0]/2; i>0; i--)
      maxHeapify(heap, i);
  }
  private void maxHeapify(int[] heap, int node) {
    int t,left,right,largest;
    left  = nodeLeft(node);
    right = nodeRight(node);

    if( (left <= heap[0]) && (heap[left] > heap[node]) )
      largest = left;
    else
      largest = node;
    if( (right <= heap[0]) && (heap[right] > heap[largest]) )
      largest = right;

    if( largest != node ) {
      t = heap[node]; heap[node] = heap[largest]; heap[largest] = t;

      maxHeapify(heap, largest);
    }
  }
  private int nodeLeft(int node) {
    return node*2;
  }
  private int nodeRight(int node) {
    return node*2+1;
  }
}


Measured memory_bytes: 75328
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string S,T;
    cin>>S>>T;
    int ss=S.size(),ts=T.size();
    int ans = ts;
    for(int i=0; i<=ss - ts; i++){
        
        int hoge = 0;
        for(int k=0; k<ts; k++){

            if(S[i+k] != T[k]){
               
                hoge++;
            }

            

        }

      ans = min (ans,hoge);



    }

    

    cout<<ans<<endl;

    return 0;

  
  
  
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===



int main() {
	int N;
	cin >> N;
	Vi A(N);
	int first = 0, second = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		A[i] = a;
		if (a >= first) {
			second = first;
			first = a;
		}
		else if (a >= second) {
			second = a;
		}
	}
	Vi ans(N);
	for (int i = 0; i < N; ++i) {
		if (A[i] == first) {
			ans[i] = second;
		}
		else {
			ans[i] = first;
		}
	}
	for (const auto& v : ans) {
		cout << v << endl;
	}
}

Measured memory_bytes: 3200
from heapq import heappush, heappop

x, y, z, k = map(int, input().split())
a = [int(m) for m in input().split()]
b = [int(m) for m in input().split()]
c = [int(m) for m in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
Q = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
ansli = []
se = set()
se.add("0,0,0")
for i in range(k):
    tmp = heappop(Q)
    ansli.append(tmp)
    if tmp[1] != x - 1 and str(tmp[1] + 1) + "," + str(tmp[2]) + "," + str(tmp[3]) not in se:
        heappush(Q, [-(a[tmp[1] + 1] + b[tmp[2]] + c[tmp[3]]), tmp[1] + 1, tmp[2], tmp[3]])
        se.add(str(tmp[1] + 1) + "," + str(tmp[2]) + "," + str(tmp[3]))
    if tmp[2] != y - 1 and str(tmp[1]) + "," + str(tmp[2] + 1) + "," + str(tmp[3]) not in se:
        heappush(Q, [-(a[tmp[1]] + b[tmp[2] + 1] + c[tmp[3]]), tmp[1], tmp[2] + 1, tmp[3]])
        se.add(str(tmp[1]) + "," + str(tmp[2] + 1) + "," + str(tmp[3]))
    if tmp[3] != z - 1 and str(tmp[1]) + "," + str(tmp[2]) + "," + str(tmp[3] + 1) not in se:
        heappush(Q, [-(a[tmp[1]] + b[tmp[2]] + c[tmp[3] + 1]), tmp[1], tmp[2], tmp[3] + 1])
        se.add(str(tmp[1]) + "," + str(tmp[2]) + "," + str(tmp[3] + 1))

for i in range(k):
    print(-ansli[i][0])

Measured memory_bytes: 56536
#include <iostream>
#include <cstdlib>
#include <vector>
#include <bitset>

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long f[N][10];
    long long b[110] = {0};
    for (int i=0; i<N; ++i)
    {
        for (int j=0; j<10; ++j)
        {
            cin >> f[i][j];
            b[i] |= (f[i][j]<<j);
        }
    }

    long long cost[N][10+1];
    for (int i=0; i<N; ++i)
    {
        for (int j=0; j<11; ++j)
        {
            cin >> cost[i][j];
        }
    }
        
    // long long ans = (-1)*11*(1e7);
    long long ans = -(1 << 30);
    for (int bit=1; bit<(1<<10); ++bit)
    {
        long long tmp = 0;
        for (int i=0; i<N; ++i)
        {
            bitset<10> bs;
            bs = (bit & b[i]);
            tmp += cost[i][bs.count()];
        }
        if(ans<tmp) ans = tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define NMAX 10000
#define NMIN 1
#define MAX 100000000
#define MIN 2
int main(){
  int i,n,j,num[NMAX],count=0;
  scanf("%d",&n);
  if(n>NMAX||n<NMIN) exit(1);
  for(i=n;i>0;i--){
    scanf("%d",&num[i]);
    if(num[i]>=MIN&&num[i]<=MAX){
      if(num[i]!=2&&num[i]%2==0) count++;
      else{
	for(j=3;j<=sqrt(num[i]);j+=2){
	  if(num[i]%j==0){
	    count++;
	    break;
	  }
	}
      }
    }
    else break;
  }
  printf("%d\n",n-count);
  return 0;
}



Measured memory_bytes: 2056
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<PI> qs(Q);
  for(auto &q: qs) {
    cin >> q.first >> q.second;
  }
  VI cup(N+2, 0);
  int pos = 1;
  cup[1] = 1;
  cup[2] = 1;
  for(auto &q: qs) {
    int a = q.first;
    int b = q.second;
    swap(cup[a], cup[b]);
    if(a == pos) {
      pos = b;
    } else if(b == pos) {
      pos = a;
    }
    if(pos-1 >= 1) {
      cup[pos-1] = 1;
    }
    if(pos+1 <= N) {
      cup[pos+1] = 1;
    }
  }
  int ans = 0;
  REP(i,1,N+1) {
    if(cup[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n; cin >> n;
  map<int,int> A;
  ll ans = 0;
  rep(i,n) {
    int a; cin >> a;
    A[a]++;
    ans += a;
  }
  int q; cin >> q;
  rep(i,q) {
    int b,c; cin >> b >> c;
    A[c] += A[b];
    ans += (c-b) * A[b];
    A[b] = 0;
    cout << ans << endl;
  }
}

Measured memory_bytes: 8056
p = 10 ** 9 + 7
 
def mod_inverse(a, p):
    mod = 1
    p_bin = bin(p-2)
    for i in range(len(p_bin) - 1, 1, -1):
        if i == len(p_bin) - 1:
            mul = a
            mul %= p
            mod *= (mul ** int(p_bin[i]))
            mod %= p
        else:
            mul = mul ** 2
            mul %= p
            mod *= (mul ** int(p_bin[i]))
            mod %= p
    return mod
 
def combination(n, k, p):
    a = 1
    for i in range(n, n - k, -1):
        a *= i
        a %= p
    b = 1
    for i in range(k):
        b *= (i + 1)
        b %= p
    return (a * mod_inverse(b, p)) % p

X,Y = input().split()
X,Y = int(X),int(Y)

if((X-2*Y)%3 !=0 or (2*X-Y)%3 != 0):
    print(0)
    
else:
    a = (-X+2*Y)//3
    b = (2*X-Y)//3
    if(a<0 or b<0):
        print(0)
    else:
        
        print(combination(a+b,b,p))

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

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int cnt=0;
    set<int>st;
    for(int i=a;i<=b;i++)
    {
        if(cnt<k)
        {
            st.insert(i);
            cnt++;
        }
        else break;
    }
    cnt=0;

    for(int i=max(a,b-k+1);i<=b;i++)
    {
        st.insert(i);
    }
    for(set<int>::iterator it = st.begin();it!=st.end();it++)
        cout<<*it<<endl;
    return 0;
}


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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const ll mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    while(cin >> a >> b >> c){
        int need = a - b;
        c = max(0,c-need);
        cout << c << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200000];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n==1)
	{
		cout<<a[0];
		return 0;
	}
	int mx=0,mx2=0,mxn=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]==mx)
		{
			mxn++;
		}
		if(a[i]>mx)
		{
			mx=a[i];
			mxn=1;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]!=mx)
		mx2=max(a[i],mx2);
	}
	for(int i=0;i<n;i++)
	{
		if(mxn>1)
		cout<<mx<<endl;
		else
		{
			if(a[i]==mx)
			cout<<mx2<<endl;
			else
			cout<<mx<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>

int main() {
	int count = 0;
	char Zx[14], Yz[14] = {};
	scanf("%s", &Zx);
	
	for (int u = 0; Zx[u] != '\0'; u++) {
		if (Zx[u] == '0') {
			Yz[count] = '0';
			count++;
		}
		else if (Zx[u] == '1') {
			Yz[count] = '1';
			count++;
		}
		else if (count != 0) {
            if (Zx[u] == 'B') {
                Yz[count - 1] = '0';
                count -= 1;
            }
    	}
	}
	Yz[count] = '\0';
    printf("%s", Yz);
	return 0;
}

Measured memory_bytes: 1708
// Hack it and have it ;) //
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include      <bits/stdc++.h>
#include      <ext/pb_ds/assoc_container.hpp>
#include      <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC   optimize ("Ofast")
#pragma GCC   optimize ("unroll-loops")
#pragma GCC   target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS   ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC  cout.precision (10); cout << fixed
#define x     first
#define y     second
#define bg(x) " [ " << #x << " : " << (x) << " ] "
#define un(x) sort(x.begin(), x.end()), \
              x.erase(unique(x.begin(), x.end()), x.end())
using   ll  = long long;
using   ull = unsigned long long;
using   ff  = long double;
using   pii = pair<int,int>;
using   pil = pair<int,ll>;
typedef tree
< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;

struct chash {
   int operator()(pii x) const { return x.x*31 + x.y; }
};
gp_hash_table <pii, int, chash> mp;

seed_seq seq{
   (uint64_t) chrono::duration_cast<chrono::nanoseconds>
      (chrono::high_resolution_clock::now().time_since_epoch()).count(),
      (uint64_t) __builtin_ia32_rdtsc(),
      (uint64_t) (uintptr_t) make_unique<char>().get()
};
mt19937 rng(seq); //uniform_int_distribution<int> (l, h)(rng); //[low, high]

#define debug(args...) { \
   /* WARNING : do NOT compile this debug func calls with following flags: // \
    * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); \
   istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) {
   it->empty(); cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
   cerr << fixed << setprecision(15)
      << " [ " <<  *it << " : " << a  << " ] "<< ' ';
   err(++it, args...);
}
/*****************************************************************************/

vector <string> anag;
int n;

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 0; i < n; ++i) {
      string foo;
      cin >> foo;
      sort(foo.begin(), foo.end());
      anag.push_back(foo);
   }
   sort(anag.begin(), anag.end());
   ll ans = 0;
   int curx = 1;
   string lst_anag = anag[0];
   for (int i = 1; i < (int)anag.size(); ++i) {
      if (lst_anag == anag[i]) {
         ++curx;
      }
      else {
         ans += (1ll * curx * (curx - 1))/2;
         lst_anag = anag[i];
         curx = 1;
      }
   }
   ans += (1ll * curx * (curx - 1))/2;
   cout << ans << '\n';

   return EXIT_SUCCESS;
}


Measured memory_bytes: 5748
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int N, W, H, x, y, w, s, t, imosx[100001], imosy[100001];
 
int main()
{
    std::cin >> N >> W >> H;
 
    for (int i = 0; i < N; i++)
    {
        std::cin >> x >> y >> w;
        
        int lx = max(x - w, 0);
        int rx = min(x + w, W);
        int ly = max(y - w, 0);
        int ry = min(y + w, H);
        
        imosx[lx]++;
        imosx[rx]--;
        imosy[ly]++;
        imosy[ry]--;
    }
 
    bool okx = true;
    
    int sumx = 0;
    
    for(int i = 0; i < W; i++)
    {
        sumx += imosx[i];
        
        if(!sumx) okx = false;
    }
    
    bool oky = true;
    
    int sumy = 0;
    
    for(int i = 0; i < H; i++)
    {
        sumy += imosy[i];
        
        if(!sumy) oky = false;
    }
 
    printf("%s\n", okx || oky ? "Yes" : "No");
 
    return 0;
}

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

int main(void){
	char str[20];

    cin >> str;

	int n = strlen(str);

	for (int i = 0; i < (n / 2); i++){
		int tmp = str[i];
		str[i] = str[n - 1 - i];
		str[n - 1 - i] = tmp;
	}

	cout << str << endl;

	return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   200010

using namespace std;




int main()
{

    ll i,j,c=0,n,d;

    string s;

    cin>>n>>s;

    for(i=0;i<=n-3;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')c++;
    }

    cout<<c<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {

  char x;
  cin >> x;
  
  cout << (x<='Z'?"A":"a") << endl;
  
}


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

using namespace std;
int mod=1e9+7;
int tot[100005];
bool vis[100005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int t;
        scanf("%d",&t);
        vis[t]++;
    }
    tot[0]=!vis[0];
    tot[1]=!vis[1];
    for(int i=2;i<=n;i++)
    {
        if(vis[i])continue;
        tot[i]=(tot[i-1]+tot[i-2])%mod;
    }
    printf("%d",tot[n]);
    return 0;
}


Measured memory_bytes: 768
/*s1190073  Rina Sato
 File name: prog3a.c
 This is a program that finds an answer of reverse polish notation using a stack.*/

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

void push(int);
int pop(void);

int S[101];
int j=0;

int main(void){
  char s[400];
  int x,m,n,i=0,count=0;
  
  while(1){  /*enter characters and recognize as a string*/
    scanf("%c",&s[i]);
    if(s[i] == '\n'){
      s[i]='\0';
      break;
    }    
    i++;
  }

  for(i = 0 ; i < strlen(s) ; i++){

    for(count=i ; s[count] != ' ' ; count++);  /*count a number of entering until                                                                          space*/
    
    if(s[i] >= '0' && '9' >= s[i]){ 
      x = atoi(s+i);  /*transform characters'0'~'9' into numerals*/
      i = count; 
      push(x);  
    }
    else if(s[i] == '+'){ /*add numbers picked up*/
      m = pop(); 
      n = pop(); 
      push(n+m);
      
    }
    else if(s[i] == '-'){ /*subtract numbers picked up*/
      m = pop();
      n = pop(); 
      push(n-m);
      
    }
    else if(s[i] == '*'){ /*do multiplication numbers picked up*/
      m = pop();
      n = pop(); 
      push(n*m);
      
    }  
  }
  printf("%d\n",S[0]);
  return 0;
}

void push(int x)
{ /*enter numbers*/
  S[j++] = x; 
}

int pop(void)
{ /*pick up numbers*/
  return S[--j];
}

Measured memory_bytes: 0
package main

import (
    "fmt"
    "math"
    )

func main() {
    var a, b, c int
    var n float64
    fmt.Scan(&a, &b, &c, &n)
   fmt.Println(a+b+c+max(a,b,c)*(int(math.Pow(2, n))-1))
}

func max(nums ...int) int{
    max := 0
    for _, v := range nums {
        if v > max {
            max = v
        }
    }
    return max
}

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

int M[200][200];
string color[200];
int d[200];
int p[200];
int n;
const int INF = 1001001001;

void dijkstra(int s){
    rep(i, n){
        color[i] = "WHITE";
        d[i] = INF;
    }
    d[s] = 0;
    p[s] = -1;

    int u;
    while(true){
        int mincost = INF;
        for (int i = 0; i < n; i++){
            if(color[i] != "BLACK" && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }
        if(mincost == INF){
            break;
        }
        color[u] = "BLACK";
        
        for (int v = 0; v < n; v++){
            if(color[v] != "BLACK" && M[u][v] != INF){
                if(d[u] + M[u][v] < d[v]){
                    d[v] = d[u] + M[u][v];
                    p[v] = u;
                    color[v] = "GRAY";
                }
            }
        }
    }
}

int main() {
    cin >> n;
    rep(i, n){
        rep(j, n){
            M[i][j] = INF;
        }
    }
    rep(i, n){
        int u; cin >> u;
        int k; cin >> k;
        rep(j, k){
            int c, v; cin >> c >> v;
            M[u][c] = v;
        }
    }
    dijkstra(0);
    rep(i, n){
        cout << i << " " << d[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
    int n;
    cin >> n;
    map<string,int> res;

    for (int i = 0; i < n; i++) {
        string in;
        cin >> in;
        res[in] += 1;
    }
    int i = 0;
    for (auto itr = res.begin(); itr != res.end(); itr++) i++;
    cout << i;
}


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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right){
  int i, j, k;
  llong cnt = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i = 0 ; i < n1 ; i++) L[i] = A[left + i];
  for(int i = 0 ; i < n2 ; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for(k = left ; k < right ; k++){

    if(L[i] <= R[j]){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
  int mid;
  llong v1, v2, v3;
  if(left + 1 < right){
    mid = (left + right) / 2;
    v1 = mergeSort(A, n, left, mid);
    v2 = mergeSort(A, n, mid, right);
    v3 = merge(A, n, left, mid, right);
    return v1 + v2 + v3;
  }else return 0;
}

int main(){
  int A[MAX], n, i;

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

  llong ans = mergeSort(A, n, 0, n);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 4624
def main():
  N, K = map(int, input().split())
  ans = 0
  for b in range(K+1, N+1):
    ans += ((N+1)//b*(b-K)+max(0, (N+1)%b-K))
    #print(b, ans)
  if K == 0:
    ans -= (N-K)
  print(ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;





int main(){

	int table[1000];

	for(int i = 1; i <= 999; i++){

		table[i] = (i*(i+1))/2;
	}

	int a,b;
	scanf("%d %d",&a,&b);

	for(int i = 1; i <= 998; i++){

		if(table[i+1]-table[i] == b-a){

			printf("%d\n",table[i]-a);
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    string S;
    cin >> S;
    Yes((S[0] == S[1] && S[1] == S[2]) || S[1] == S[2] && S[2] == S[3]);
}

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

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

typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<long long int> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvll;

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

  map<int, vector<int>> jobs;

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

  auto it = jobs.begin();
  long long int ans = 0;
  vector<int> jobsPool(0);

  for(int i=1;i<=m;i++) {
    if(it!=jobs.end() && it->first == i) {
      jobsPool.insert(jobsPool.end(), (it->second).begin(), (it->second).end());
      sort(jobsPool.begin(), jobsPool.end());
      it++;
    }

    if(jobsPool.empty()) continue;
    else {
      ans += jobsPool.back();jobsPool.pop_back();
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7;

int main(){
    ll a, b;
    cin >> a >> b;
    cout << b*a;
    return 0;
}
//                              **!!_Sumit_!!**

Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int a,b,c;
    cin >> a >> b >> c;
    if(a*c < b) cout << c << endl;
    else cout << b/a << 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 argc, char const *argv[]) {
	int n, m; cin >> n >> m;

	set<int> ac_set;
	int penalty = 0;
	vector<int> flag(n, 0), cnt(n, 0);
	rep(i, m) {
		int p; string s;
		cin >> p >> s;
		if (s == "AC") {
			ac_set.insert(p);
			if (not flag[p]) {
				penalty += cnt[p];
				flag[p] = 1;
			}
		}
		cnt[p]++;
	}
	cout << ac_set.size() << " " << penalty << endl;

	return 0;
}


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

using namespace std;

void solve() {
    int n; cin >> n;
    vector<int> vt(n);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> vt[i];
        if (vt[i] && i && vt[i - 1])
            vt[i - 1]--, vt[i]--, ans++;
        ans += vt[i] / 2;
        vt[i] = vt[i] % 2;
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 640
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define u64 uint64_t
#define ll long long
#define endl "\n"
#define PI acos(-1)
#define pi pair<ll,ll>
#define fi first
#define si second
#define mkp make_pair
#define pb push_back
#define clr(arr) memset(arr,0,sizeof(arr))
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
deque<ll>dq;
map<ll,ll>mp;
set<ll>st;
vector<ll>vt;
ll mod=1e9+7;
const int N=1e6+5;
ll arr[N];

int main()
{
    IOS;
    ll n,m,x,y,z,i,j,k,p,f=0,tc,cnt=0,sum=0,mul=1,mi=1e18,ma=-1e18,a,b,c,d,sz;
    string str;
    char ch;
    double db;
    //code
    map<char,ll>mpc;
    cin>>str;
    sz=str.size();
    for(i=0;i<sz;i++)
    {
        mpc[str[i]]++;
    }
    f=0;
    for(i=0;i<sz;i++)
    {
        if(mpc[str[i]]%2!=0)
        {
            f=1;
            break;
        }
    }
    if(f==1)
        cout<<"No\n";
    else
        cout<<"Yes\n";



    //code
    return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%s", (abs(c-a)<=d) || (abs(b-a)<=d && abs(c-b)<=d) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    string s;
    cin >> s;
    string ans = string(s);
    string temp = s.substr(1,s.length()-2);
    ans = s[0] + to_string(temp.length()) + s[s.length()-1];
    cout << ans << endl;
    return 0;
}


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

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 1e5+10;
const long long int MINN = 1e5+10;
const long long int inf = 1e9+10;

typedef long long ll; 
typedef long double ld; 
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS
    int n,a[MAXN],dp[MAXN];
    cin>>n;
    repA(i,1,n) cin>>a[i];
    dp[2]=abs(a[2]-a[1]);
    dp[1]=0;
    repA(i,3,n){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N;
int C[200001];
int X[200001];
vector<int> E[200001];
void dfs(int p, int prev, int c) {
	int k = c + X[p];
	C[p] = k;
	for (int to : E[p]) {
		if (to != prev) dfs(to, p, k);
	}
}


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


	int N, Q;
	cin >> N >> Q;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}
	rep(i, Q) {
		int p, x;
		cin >> p >> x;
		X[p] += x;
	}
	dfs(1, 0, 0);

	rep1(i, N) cosp(C[i]);

	Would you please return 0;
}

Measured memory_bytes: 24320