akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 998244353
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n,k;
	rd(n,k);
	vector<int>arr(n+2,0);
	arr[1]=1;
	vector<pint>a;
	FOR(i,k){
		int l,r;
		rd(l,r);
		a.pb({l,r});
	}
	int sum=0;
	rep(i,1,n+1){
		sum+=arr[i]%MOD;
		if(sum<=0)continue;
		for(auto v:a){
			int l=v.ft;
			int r=v.se;
			if(l+i>n)continue;
			l=min(n,l+i);
			r=min(n,r+i);
			arr[l]+=sum;
			arr[r+1]-=sum;
		}
		if(i==1)sum=0;
	}
	pp(sum%MOD);
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 4768
#include <iostream>
 
int main()
{
  int N, alice = 0, bob = 0, cards[100];
  std::cin >> N;
  
  for(int i = 0; i < N; i++)
  {
    std::cin >> cards[i];
  }

  for(int i = 0; i < N; i++)
  {
    for(int k = 0; k < N; k++)
    {
      if(cards[i] > cards[k])
      {
        int temp = cards[i];
        cards[i] = cards[k];
        cards[k] = temp;
      }
    }
  }

  for(int i = 0; i < N; i++)
  {
    if(i % 2 == 0)
    {
      alice += cards[i];
    }
    else
    {
      bob += cards[i];
    }
  }  
  
  std::cout << alice - bob;
  return 0;
}

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

const int maxn = 2E+5 + 5;

int n, k, c;
int tot, a[maxn], f1[maxn][2];
int back;
vector<int> Get[maxn];
int cnt, res[maxn];
int head, tail, q[maxn];
char s[maxn];

int main()
{
	scanf("%d%d%d\n%s", &n, &k, &c, s + 1);
	for(int i = 1; i <= n; ++i)
		if(s[i] == 'o') a[++tot] = i;
	
	back = 0, head = 1, tail = 0;
	for(int i = 1; i <= tot; ++i) {
		f1[i][0] = max(f1[i - 1][0], f1[i - 1][1]);
		
		while(a[back + 1] + c < a[i]) ++back;
		f1[i][1] = max(f1[back][0], f1[back][1]) + 1;
	}
	int ans = max(f1[tot][0], f1[tot][1]);
	
	if(ans != k) return 0;
	
	int last = 0;
	for(int i = tot; i >= 1; --i) {
		if(f1[i][1] != f1[i - 1][1] && (f1[i][1] != f1[i + 1][1] || i == last)) res[++cnt] = i;
		
		last = 0;
		for(int j = i; j >= 1; --j)
			if(a[j] + c < a[i]) {
				last = j;
				break;
			}
		i = last + 1;
	}
	
	for(int i = cnt; i >= 1; --i)
		printf("%d\n", a[res[i]]);
}

Measured memory_bytes: 9472
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
		}
		Arrays.sort(d);
		int m = n / 2;
		System.out.println(d[m] - d[m - 1]);
	}
}


Measured memory_bytes: 51572
#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
  cin >> S;
  int count = 0;
  int slen = S.length();
  for(int i = 0; i < slen; ++i) {
    if(S.at(i) == '+') {
      count++;
    }else {
      count--;
    }
  }
  
  cout << count << endl;
}

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

#define N 101

using namespace std;

const int infty = 1<<28;

struct Node{
  vector<int> cons;
  vector<int> costs;
};

struct Edge{
  int src,dst;
  Edge():src(0),dst(0){}
  Edge(int s,int d):src(s),dst(d){}
};

int BruteForceMST(const vector<Node> &G){
  int ret = 0;
  bool inMST[G.size()];
  vector< Node > MST;
  vector< Edge > MSTE;

  fill( inMST, inMST+G.size(), false );
  MST.push_back( G[0] );
  inMST[0]=true;
  while( MST.size() < G.size() ){
    int from_id = 0;
    int next_id = 0;
    int mincost = infty;

    for(int i = 0; i < MST.size(); ++i){
      for(int j = 0; j < MST[i].cons.size(); ++j){
	if( !inMST[ MST[i].cons[j] ] &&
	    mincost > MST[i].costs[j] ){
	  from_id = i;
	  next_id = MST[i].cons[j];
	  mincost = MST[i].costs[j];
	}
      }
    }

    inMST[ next_id ] = true;
    ret += mincost;
    MST.push_back( G[next_id] );
    MSTE.push_back( Edge(from_id, next_id) );
  }

  return ret;
}

int main(){
  while(true){
    int n,m;
    vector<Node> G;
    cin >> n >> m;
    if( n == 0 && m == 0 ) break;
    G.resize(n);
    for(int i = 0; i < m; ++i){
      int a,b,cost;
      cin>>a>>b>>cost;
      G[a].cons.push_back( b );
      G[a].costs.push_back( cost );
      G[b].cons.push_back( a );
      G[b].costs.push_back( cost );
    }
    cout << BruteForceMST(G) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
vector<long long> a;
pair<long long,long long> gekoing[2][200000] = {};
int main() {
#define int long long
	int n;
	cin >> n;
	REP(i, n) {
		long long hoge;
		cin >> hoge;
		a.push_back(hoge);
	}
	for (int i = 0; i < 200000; ++i) {
		gekoing[0][i] = make_pair(-1, -1);
		gekoing[1][i] = make_pair(-1, -1);
	}
	long long ans = LONG_INF;
	for (int tere = 0; tere < 2; ++tere) {
		long long hoge = a[1];
		long long tmp = a[0];
		gekoing[tere][1] = make_pair(hoge, tmp);
		long long now_itr = 1;
		for (int i = 2; i < n; ++i) {
			hoge += a[i];
			while (now_itr < n) {
				long long base = llabs((tmp + a[now_itr]) - (hoge - a[now_itr]));
				if (llabs(hoge - tmp) <= base) break;
				tmp += a[now_itr];
				hoge -= a[now_itr];
				now_itr++;
			}
			gekoing[tere][i] = make_pair(tmp, hoge);
		}
		reverse(a.begin(), a.end());
	}
	for (int i = 1; i < n-2; ++i) {
		vector<long long> hoge;
		hoge.push_back(gekoing[0][i].first);
		hoge.push_back(gekoing[0][i].second);
		hoge.push_back(gekoing[1][n - i - 2].first);
		hoge.push_back(gekoing[1][n - i - 2].second);
		sort(hoge.begin(), hoge.end());
		ans = min(ans, hoge[3] - hoge[0]);
	}
	cout << ans << endl;
	return 0;
}

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

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

using namespace std;

using ll = long long;

ll f(ll b, ll n) {
    ll result = 0;
    while (n) {
        result += n % b;
        n /= b;
    }
    return result;
}

ll solve(ll n, ll s) {
    if (n == s) {
        return n + 1;
    }
    int sqrtN;
    for (ll i = 2; i <= n + 1; ++i) {
        if (i * i > n) {
            sqrtN = i - 1;
            break;
        }
    }
    FOR(b, 2, sqrtN + 1) {
        if (f(b, n) == s) {
            return b;
        }
    }
    for (ll p = sqrtN; p >= 1; --p) {
        if ((n - s) % p != 0) {
            continue;
        }
        ll b = (n - s) / p + 1;
        if (b < 2) {
            continue;
        }
        if (f(b, n) == s) {
            return b;
        }
    }
    return -1;
}

int main() {
    ll n, s;
    cin >> n >> s;
    cout << solve(n, s) << endl;
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    if 500 * a > X:
        continue
    for b in range(B+1):
        if 500 * a + 100 * b > X:
            continue
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c > X:
                continue
            sum = 500 * a + 100 * b + 50 *c
            if sum == X:
                count += 1

print(count)



Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int a,b,c;
	int d,e;
	int x;
	int A,B;
	
	scanf("%d %d %d",&a,&b,&c);
	if(a<b)x=a;
	else   x=b;
	
	if(x<c)A=x;
	else   A=c;
	
	scanf("%d %d",&d,&e);
	if(d<e)B=d;
	else   B=e;
	
	printf("%d\n",A+B-50);
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int he,cha,ji;
	he=a+b;
	cha=a-b;
	ji=a*b;
	if(he<cha) swap(he,cha);
	if(he<ji) swap(he,ji);
	if(cha<ji) swap(cha,ji);
	cout<<he;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll a, b;
    cin >> a >> b;
    
    vector<ll> cnt(3);
    cnt[a-1] = 1, cnt[b-1] = 1;
    REP(i, 3) if(cnt[i]==0) {
        cout << i+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2==1)cout<<"No"<<endl;
    else {
        int len=n/2;
        for(int i=0; i<len; i++){
            if(s[i]!=s[len+i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1

    def __call__(self, n):
        return self.fact(n)

    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        self._make(n)
        return self._factorial[n]

    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self._make_inv(n)
        return self._factorial_inv[n]

    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self.fact_inv(n-r)*self.fact_inv(r) % self.mod
        return self(n)*t % self.mod

    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self.fact_inv(n-1)*self.fact_inv(r) % self.mod
        return self(n+r-1)*t % self.mod

    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod

    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0

    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod

    def _make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1

    def _make_inv(self, n):
        if n >= self.mod:
            n = self.mod
        self._make(n)
        if self._size_inv < n+1:
            for i in range(self._size_inv, n+1):
                self._factorial_inv.append(self.modinv(self._factorial[i]))
            self._size_inv = n+1

x, y = sorted(map(int, input().split()))
comb = Factorial().comb
q, r = divmod(x+y, 3)
if r != 0:
    print(0)
else:
    print(comb(q, y-q))


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


int main(){
    ll N,K;cin>>N>>K;
    ll d[11],ju=0;
    rep(i,0,K)cin>>d[i];
    rep(i,N,99920000){
        ju=1;
        int di[6];
        string dig=to_string(i);
        rep(j,0,dig.size()){
            di[j]=dig.at(j)-'0';
            rep(k,0,K){
                if(di[j]==d[k])ju=0;
            }
        }
        if(ju){
            cout<<i<<endl;
            return 0;
        }

        
    }
    
}







Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    AB = [list(map(int, readline().rstrip().split())) for _ in range(N)]
    CD = [list(map(int, readline().rstrip().split())) for _ in range(M)]
    for a, b in AB:
        dist = 10**10
        ans = -1
        for i, (c, d) in enumerate(CD):
            if abs(a-c) + abs(b-d) < dist:
                dist = abs(a-c) + abs(b-d)
                ans = i + 1
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
<?php
 	fscanf(STDIN,"%d",$n);
	$zahyos = array();
	for($i=0;$i<$n;$i++){
		$zahyos[]= explode(" ",trim(fgets(STDIN)));
    }

//順列関数
function pat($a, $s = '')
{
  $r = array();
  if (count($a) && is_array($a)) {
    //第1引数に文字の配列を渡されたらループして処理
    foreach ($a as $k => $v) {
      //文字の配列から1文字もらってこちらにくっつけて
      $_s = $s . $v;
      //もらった1文字を除いた文字の配列を作って
      $_a = $a;
      unset($_a[$k]);
      //再帰呼び出し
      $_r = pat($_a, $_s);
      //返り値にする変数に結果を追加
      $r = array_merge($r, $_r);
    }
  } else {
    //第1引数が空っぽの配列だったら、再帰呼び出しはここでストップ
    //返り値はこれだけ
    $r[] = $s;
  }
  return $r;
}


for($i=1;$i<=$n;$i++){
  $a[]=$i;
}


$jyunretu = pat($a);
$sum=0;
foreach($jyunretu as $michi){
  for($i=0;$i<strlen($michi)-1;$i++){
    $city=$michi[$i]-1;
    $ncity=$michi[$i+1]-1;
   // echo $city."\n";
    $sum+=sqrt(($zahyos[$ncity][0]-$zahyos[$city][0])**2+
    ($zahyos[$ncity][1]-$zahyos[$city][1])**2); //ここで距離を計算
  }
}
  

echo ($sum/count($jyunretu))."\n";


Measured memory_bytes: 10744
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		
		long ans = (n%2==0)?n:2*(long)n;
		System.out.println(ans);

		
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>


using namespace std;

int main()
{
    int N;
    cin >> N;
    double ans = 0;
    for(int i =0; i < N; ++i){
        double a;
        cin >> a;
        ans += 1. / a;
    }
    printf("%.7f\n", 1.0 / ans);
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,l = 0;
    cin >> n;
    vector<int> list(n);
for(int i = 0; i < n; i++){
    cin >> list[i];
    l += list[i] - 1;
}
cout << l << endl;
}

Measured memory_bytes: 256
def solve(s: str) -> (int, int):
    for i in range(0, len(s) - 1):
        if s[i] == s[i + 1]:
            return (i + 1, i + 2)
    for i in range(0, len(s) - 2):
        if s[i] == s[i + 2]:
            return (i + 1, i + 3)
    return (-1, -1)

s = input()
print('{} {}'.format(*solve(s)))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())



int main (){
  ll n;
  cin>>n;
  cout<<((n-1)*n)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define timepass 1073741824
#define MAXN 200000 + 5
#define LOGN 20
using namespace std;
#define N 505

/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define sp(a , x) cout << fixed << setprecision(a) << x << endl; 
#define siz(temp) (ll)temp.size()
#define len(temp) (ll)temp.length()
#define int ll
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define pi acos(-1)
#define con continue
#define endl "\n"
#define w(q) while(q--)

//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace7(a, b, c, d, e, f , g) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | "<< #g <<": "<<g<<endl
#define trace8(a, b, c, d, e, f , g , h) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | " << #g <<": "<< g <<" | "<<#h<< ": " << h << endl

typedef pair<int , int> pii;
typedef pair<int , pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;

signed main()
{
    FAST;
    int x , y , a , b , c;
    cin >> x >> y >> a >> b >> c;
    vector<int> ra(a) , ga(b) , ca(c);
    rep(i , 0 , a)
        cin >> ra[i];
    rep(i , 0 , b)
        cin >> ga[i];
    rep(i , 0 , c)
        cin >> ca[i];
    rs(ra);
    rs(ga);
    vector<pair<int , int>> foo;
    rep(i , 0 , x){
        foo.pb(mp(ra[i] , 1));
    }
    rep(i , 0 , y)
        foo.pb(mp(ga[i] , 2));
    sort(all(foo));
    int ans = 0;
    rep(i , 0 , foo.size())
        ans += foo[i].ff;
    rs(ca);
    for (int i = 0 ; i < c ; i++){
        if (foo[i].ff >= ca[i])
            break;
        ans += ca[i] - foo[i].ff;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8816
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#define f first
#define s second
#define ms(a, b) memset(a,b,sizeof(a))
typedef long long ll;

using namespace std;

char _;

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

    int a;
    cin >> a;

    double c = 2.0 * 3.14159 * a;
    cout << setprecision(8) << c << endl;

    return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main(){
  string red,green,down;
  char buf;
  string right="";
  int r=0,g=0,d=0,i,j;
  cin >> red;
  while(red[0]!='-'){
    r=0;g=0;d=0;    
    cin>> green >> down;
    right="";
    buf = green[0];
    g++;
    while(buf!='-'){
      while(down[d]!=buf){
	right+=buf;
	buf=green[g];    
	g++;
      }
      
      buf=red[r];
      r++;d++;
      
      if(d==down.size()){
	right+=buf;
	  for(i=g;i<green.size();i++){
	    right+=green[i];
	  }
	  buf='-';
	}
      
      // cout << right << endl;
    }
    cout << right << endl;
    cin >> red;
  }
  
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;
typedef long long ll;

#define f first
#define s second

ll lcm, a[100002], n, m;

int main()
{
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  lcm = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ll x = a[i] / 2;
    lcm = lcm * x / __gcd(lcm, x);
    if (lcm > 1e9) {
      cout << 0;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if ((lcm / (a[i] / 2)) % 2 == 0) {
      cout << 0;
      return 0;
    }
  }
  cout << (m / lcm + 1) / 2;
  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    string S; cin >> S;
    ll ans(0);
    int blk(0);
    REP(i, S.length()){
        if(S[i] == 'B') ++blk;
        else ans += blk;
    }
    cout << ans << endl;
    return 0;
}


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N;
    ist >> N;

    vector<vector<int>> D;

    for (int i = 0; i < N; i++)
    {
        int input1, input2;
        ist >> input1 >> input2;
        D.emplace_back(0);

        D.at(i).emplace_back(input1);
        D.at(i).emplace_back(input2);
    }

    /* ------- 計算 ------- */

    int zorome_count = 0;
    int max_zorome_count = 0;

    for (int i = 0; i < N; i++)
    {
        if (D.at(i).at(0) == D.at(i).at(1))
        {
            zorome_count++;
            if (zorome_count > max_zorome_count)
            {
                max_zorome_count = zorome_count;
            }
        }
        else
        {
            zorome_count = 0;
        }
    }

    if (max_zorome_count >= 3)
    {
        ost << "Yes" << endl;
    }
    else
    {
        ost << "No" << endl;
    }
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3600
#include<iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  cin>>H;

  for(int i=1;i<=H;i++) cin>>A[i];
  for(int i=H/2;i>=1;i--) maxHeapify(i);

  for(int i=1;i<=H;i++){
    cout<<" "<<A[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 4968
#include<iostream>
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){int m,n,x,y,u[30]={0},g[30][30]={0};cin>>m>>n;rep(i,n){cin>>x>>y;g[x][y]=1;u[y]++;}rep(i,m)rep(j,m){if(!u[j]){rep(k,m)u[k]-=g[j][k];u[j]--;cout<<j<<endl;}}}

Measured memory_bytes: 1164
#include <stdio.h>
#include <math.h>
#include <new>

int main(void)
{
  int n;
  double a;
  int i;
  
  while(1){
    double sum=0;
    double m; //??????
    double to=0; //??????
    
    scanf("%d",&n);
    if(n==0){
      break;
    }
    
    double *s = new double[n]; //????????????????¢????
    for(i=0; i<n; i++){
      scanf("%lf",&s[i]);
      sum=sum + s[i];
    }
    m = sum / n;

    for(i=0; i<n; i++){
      if(s[i]>m){
	to =to + ((s[i] - m) * (s[i] - m));
      }else{
	to =to + ((m - s[i]) * (m - s[i]));
      }
    }

    a = sqrt(to/n);

    printf("%f\n",a);
    
    delete[] s;
  }
    
  return(0);
}

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

int main(){
    int X, Y, A, B, C;
    cin>>X>>Y>>A>>B>>C;
    vector<long>p, q, r;
    long tmp;
    for(int i=0;i<A;++i){
        cin>>tmp;
        p.push_back(tmp);
    }
    for(int i=0;i<B;++i){
        cin>>tmp;
        q.push_back(tmp);
    }
    for(int i=0;i<C;++i){
        cin>>tmp;
        r.push_back(tmp);
    }
    p.push_back(0);
    q.push_back(0);
    r.push_back(0);
    sort(p.begin(), p.end(), greater<long>());
    sort(q.begin(), q.end(), greater<long>());
    sort(r.begin(), r.end(), greater<long>());
    for(int i=0;i<A;++i){
        if(i>=X)p[i]=0;
    }
    for(int i=0;i<B;++i){
        if(i>=Y)q[i]=0;
    }

    int x=0, y=0;
    int inp=0, inq=0, inr=0;
    long ans = 0;
    long sum = 0;
    while((x<X | y<Y)& (sum<X+Y)){
        if(p[inp]>=q[inq] & p[inp]>=r[inr] & x<X & inp<A){
            //cout<<"aka"<<endl;
            x++;
            ans += p[inp];
            inp++;
        }
        else if(q[inq]>=p[inp] & q[inq]>=r[inr] & y<Y & inq<B){
            //cout<<"midori"<<endl;
            y++;
            ans += q[inq];
            inq++;
        }
        else {
            //cout<<"musyoku"<<endl;
            ans += r[inr];
            inr++;
        }
        sum++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a;
	int test[123456] = { 0 }; cin >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a;
		test[a] = h;
	}
	for (int h = 1; h <= n; h++) {
		cout << test[h] << ' ';
	}
	cout << endl;
	cin >> n;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;

int main(){
  ll h,w;
  cin>>h>>w;
  ll ans=(floor(h/2))*(2*ceil(w/2.0)-(w%2==0?0:1));
  if(h % 2==1) ans += ceil(w/2.0);
  if(h==1||w==1) cout<<"1";
  else cout<<ans;
}


Measured memory_bytes: 256
n = int(input())
ans = [0] * 100000
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      idx = x**2 + y**2 + z**2 + x*y + y*z + z*x
      ans[idx] += 1
for i in ans[1:n+1]:
  print(i)

Measured memory_bytes: 74996
#include<iostream>
#include<string>
using namespace std;
int dp[301][301][301];
int main()
{
	string str;
	int q;
	cin>>str>>q;
	int l=str.size();
//	cout<<l<<endl;
	for(int i=l-1;i>=0;i--)
	{
		for(int k=0;k<=q;k++)
			dp[i][i][k]=1;
	}
	for(int i=l-1;i>=0;i--)
	{
		
		for(int j=i+1;j<=l-1;j++)
		{
			for(int k=0;k<=q;k++)
			{
				//dp[i][i][k]=1; 
				if(str[i]==str[j]) dp[i][j][k]=max(dp[i+1][j-1][k]+2,dp[i][j][k]);
				else
				{
					dp[i][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
					dp[i][j][k]=max(dp[i][j-1][k],dp[i][j][k]);
					if(k!=0)
					{
						dp[i][j][k]=max(dp[i+1][j-1][k-1]+2,dp[i][j][k]);
					}
					
				}
			}
		}
	}
	int ans=0;
	for(int k=0;k<=q;k++)
			ans=max(ans,dp[0][l-1][k]);
	cout<<ans<<endl;
 } 

Measured memory_bytes: 106752
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100010
typedef long long ll;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
ll a[N],b[N],sum,pre[N],t[N];
pair<ll,ll> ans;
bool operator < (const pair<ll,ll> a,const pair<ll,ll> b){
	return (__int128)a.first*b.second<(__int128)a.second*b.first;
}
inline ll calc(int x,int k){
	ll val=max(a[x],b[x]);
	return t[k]<=val?pre[k]-val:pre[k];
}
int Find(int x){
	int l=1,r=n+1,ans=-1;
	while(l<r){
		int mid=(l+r)>>1;
		if(calc(x,mid)>=sum-b[x]){
			ans=r=mid;
		}
		else{
			l=mid+1;
		}
	}
	return ans;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read(),b[i]=read();
		sum+=a[i];
		t[i]=max(a[i],b[i]);
	}
	sort(t+1,t+n+1,greater<ll>());
	for(int i=1;i<=n;++i){
		pre[i]=pre[i-1]+t[i];
	}
	ans=make_pair(n,1);
	for(int i=1;i<=n;++i){
		int k=Find(i);
		if(!~k)continue;
		ll val=sum-calc(i,k);
		if(val<0)continue;
		if(t[k]<=max(a[i],b[i]))--k;
		pair<ll,ll> nw=make_pair(val+1LL*b[i]*k,b[i]);
		ans=(nw<ans?nw:ans);
	}
	ans.second*=n;
	ans.first=ans.second-ans.first;
	ll g=__gcd(ans.first,ans.second);
	ans.first/=g,ans.second/=g;
	printf("%lld %lld\n",ans.first,ans.second);
	return 0;
}



Measured memory_bytes: 6848
a,b,c=map(int,input().split())

ans = 0

while a%2 == b%2 == c%2 == 0:
  ans += 1
  newa=b//2+c//2
  newb=a//2+c//2
  newc=a//2+b//2
  a=newa
  b=newb
  c=newc
  if a == b == c:
    print("-1")
    break
else:
  print(ans)

Measured memory_bytes: 9144
N = int(input())
L = list(map(int, input().split()))

def judge(i, j, k):
    return (i + j > k) and (j + k > i) and (k + i > j) and (i != j) and (j != k) and (k != i)


sum = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if (i == j or j == k or k == i):
                continue
            else:
                if (judge(L[i], L[j], L[k])):
                    sum += 1

print(sum)

Measured memory_bytes: 9236
#include <iostream>
using namespace std;
using ll = long long;
using p = pair<int, int>;

bool a(string s)
{
  for (int i = 0; i < s.size() / 2; i++)
  {
    if (s[i] != s[s.size() - 1 - i])
    {
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  string ans = "No";
  if (a(s) && a(s.substr(0, (s.size() - 1) / 2)))
  {
    ans = "Yes";
  }

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


Measured memory_bytes: 384
a, b = map(int, open(0).read().split())

if a > 0:
    print('Positive')
elif a == 0 or b == 0:
    print('Zero')
elif a < 0 and b > 0:
    print('Zero')
elif (b-a)%2 == 1:
    print('Positive')
else:
    print('Negative')

Measured memory_bytes: 61820
package main

import (
	"fmt"
)

func main() {
	request := make([]int, 4)
	for i := 0; i < 4; i++ {
		fmt.Scanf("%d", &request[i])
	}
	size := request[3]

	result := linear(request[0], request[1], request[2], size)
	fmt.Printf("%d", result)
}

func linear(numA int, numB int, numC int, size int) int {
	sum := 0
	if numA < size {
		sum = numA
	} else {
		return size
	}
	remain := size - numA - numB
	if remain <= 0 {
		return sum
	}

	if remain <= numC {
		sum = sum - remain
	} else {
		sum = sum - numC
	}
	return sum
}

Measured memory_bytes: 1816
#include<iostream>
#include <vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);

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

    vector<int>B(N);
        for(int i=0;i<N;i++){
            B.at(i) = A.at(i); 
        }
    

    std::sort(A.begin(),A.end(),std::greater<int>());

    int f = A.at(0);

    int s = A.at(1);

    for(int i=0;i<N;i++){
        if(B.at(i) == f){
            cout << s << endl;
        }else{
            cout << f << endl;
        }
    }

    return 0;
}







Measured memory_bytes: 3200
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll 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 fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te    
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll N;
        cin >> N;
        //cout << "yeah" << endl;
        repA(i, 1, 3500) repA(j, 1, 3500){
            ll h = i, n = j;
            if(4*h*n - N*n - N*h <= 0) continue;
           // cout << (N*h*n) << " " << (4*h*n - N*n - N*h) << endl;
            if((N*h*n)%(4*h*n - N*n - N*h) == 0){
                ll w = (N*h*n)/(4*h*n - N*n - N*h);
                cout << i << " " << j << " " << w << endl;
                return;
            }
        }
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    } 

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

const int N=510;

int H,W,h,w,mp[N][N];

void Init() {
	scanf("%d%d%d%d",&H,&W,&h,&w);	
}

void Work(int H,int W,int h,int w) {
	int v=-H/h/(H%h)-1;
	for (int i=0;i<H;++i) {
		if (i%h==h-1) for (int j=0;j<W;++j) mp[i][j]=v*(h-1)-1;
		else for (int j=0;j<W;++j) mp[i][j]=-v;
	}
}

void Solve() {
	if (H%h) {
		printf("Yes\n");
		Work(H,W,h,w);
		for (int i=0;i<H;++i) {
			for (int j=0;j<W;++j) printf("%d%c",mp[i][j],j==W-1?'\n':' ');		
		}
	}else if (W%w) {
		printf("Yes\n");
		Work(W,H,w,h);
		for (int j=0;j<H;++j) {
			for (int i=0;i<W;++i) printf("%d%c",mp[i][j],i==W-1?'\n':' ');
		}
	}else printf("No\n");
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}

int main()
{
    int n,k;
    scanf("%i %i",&n,&k);
    vector<int> h(n+k+1,INT_MAX);
    for(int i=0;i<n;i++)
        cin >> h[i];
    vector<int> cost(n+k+1,INT_MAX);
    cost[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            cost[i+j]=min(cost[i+j],cost[i]+abs(h[i]-h[i+j]));
        }
    }
    printf("%i\n",cost[n-1]);
    return 0;
}


Measured memory_bytes: 1024
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input};
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

#[fastout]
fn main() {
    input! {
        N:usize
    }
    let mut ans = 0;
    for i in 1..N + 1 {
        let mut j = i;
        ans += j * (N / i) * (N / i + 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2108
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    int t = 0;
    long sum = 0;
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);
    for(int i = 0; i < n; i++) {
      if(i > 0) {
        if((2 * sum) < a[i]) t = i; 
      }
      sum += a[i];
    }
    System.out.println(n - t);
  }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
const bool multiple_queries = false;
#define rep(i, n) for(ll i = 0; i < (n) ; ++i)
#define For(i, a, b) for(ll i = (a); i < (b) ; ++i)
#define revrep(i, n) for(ll i = (n) - 1; i >= 0 ; --i)
#define revFor(i, b, a) for(ll i = (b) - 1; i >= (a) ; --i)
#define all(v) v.begin(), v.end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(i) __builtin_popcountl((i))
#define substring(s, start, end) s.substr((start), (end) - (start) + 1)

void print(){cout;}
void println(){cout << endl;}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class Head, class... Tail>
void println(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    println(forward<Tail>(tail)...);
}

typedef pair<ll, ll> pl;

void solve(){
    ll n; cin >> n;
    vl as, bs, ans(n), cnt(n + 1, 0);
    set<pl> s, sa, sb;
    vector<queue<ll>> ra(n + 1), rb(n + 1);
    rep(i, n){
        ll a; cin >> a;
        ra[a].push(i); ++cnt[a];
    }
    rep(i, n){
        ll b; cin >> b;
        rb[b].push(i); ++cnt[b];
    }
    rep(i, n + 1) if (cnt[i] > n){println("No"); return;}
    rep(i, n + 1){
        if (ra[i].size()) sa.insert({ra[i].size(), i});
        if (rb[i].size()) sb.insert({rb[i].size(), i});
        if (cnt[i]) s.insert({cnt[i], i});
    }

    auto update = [&](ll i1, ll i2){
        s.erase({cnt[i1], i1}), s.erase({cnt[i2], i2});
        if (--cnt[i1]) s.insert({cnt[i1], i1});
        if (--cnt[i2]) s.insert({cnt[i2], i2});
        if (!ra[i1].size() || !rb[i2].size()) swap(i1, i2);
        sa.erase({ra[i1].size(), i1}); sb.erase({rb[i2].size(), i2});
        ll id = ra[i1].front(); ra[i1].pop(); rb[i2].pop();
        if (ra[i1].size()) sa.insert({ra[i1].size(), i1});
        if (rb[i2].size()) sb.insert({rb[i2].size(), i2});
        ans[id] = i2;
    };

    revFor(res, n + 1, 1){
        ll c1, c2, i1, i2, _;
        if ((*s.rbegin()).first == res){
            tie(c1, i1) = *s.rbegin();
            tie(c2, i2) = *(++s.rbegin());
            update(i1, i2);
        }else{
            auto ita = sa.begin(), itb = sb.begin();
            if ((*ita).second == (*itb).second) ++itb;
            tie(_, i1) = *ita;
            tie(_, i2) = *itb;
            update(i1, i2);
        }
    }

    println("Yes");
    rep(i, n) print(ans[i], "");
    println("");
}

void test(ll num = 0, bool verbose = false){
    rep(i, max(1LL, num)){
        ll t = clock();
        if (verbose) cout << "\n#####" << " " << i + 1 << " " << "#####" << " " << "\n## Answer ##\n";
        solve();
        if (verbose) {cout << "\nElapsed Time:" << " " << 1000.0 * (clock() - t) / CLOCKS_PER_SEC << " " << "[ms]" << endl;}
    }
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef _LOCAL
        test(6, true);
    #else
        ll t = 0;
        if (multiple_queries) cin >> t;
        test(t, false);
    #endif
    return 0;
}


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

using namespace std;

int main(){
	int N, K, ans = 0; cin >> N >> K;
	for(int i = 0; i < N; ++i){
		int x; cin >> x;
	}
	int right = 0;
	while(1){
		if(right + K - 1 < N){
			ans++;
		}else{
			ans++;
			break;
		}
		right += K - 1;
		if(right == N - 1) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n, k := nextInt(), nextInt()
	a := nextInts(n)

	if k == 1 {
		fmt.Fprintln(out, 1)
		return
	}

	r := []int{1, a[0]}
	hl := 0
	ll := 0

	for {
		next := a[r[len(r)-1]-1]
		if next < 0 {
			for i := 0; i < len(r); i++ {
				if -next == r[i] {
					hl = i
					ll = len(r) - hl
					break
				}
			}
			break
		}
		a[r[len(r)-1]-1] = -next
		r = append(r, next)
	}
	//fmt.Fprintln(out, "[DEBUG]", r)

	ans := 0
	if k <= hl {
		ans = r[k]
	} else {
		ans = r[hl+(k-hl)%ll]
	}

	//fmt.Fprintln(out, "[DEBUG]", d)
	//fmt.Fprintln(out, "[DEBUG]", time.Now())
	fmt.Fprintln(out, ans)
}
func reverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 12536
#include <stdio.h>

int main(int argc, char *argv[])
{
    int numbers[6];
    char line[102];
    fgets(line, sizeof(line), stdin);
    sscanf(line, "%d%d%d%d%d%d", numbers, numbers + 1, numbers + 2, numbers + 3, numbers + 4, numbers + 5);
    fgets(line, sizeof(line), stdin);
    int top = 1, front = 2, right = 3, tmp;
    for (char *elm = line; *elm; ++elm)
    {
        switch (*elm)
        {
        case 'N':
            tmp = top, top = front, front = 7 - tmp;
            break;
        case 'E':
            tmp = right, right = top, top = 7 - tmp;
            break;
        case 'S':
            tmp = front, front = top, top = 7 - tmp;
            break;
        case 'W':
            tmp = top, top = right, right = 7 - tmp;
            break;
        }
    }
    printf("%d\n", numbers[top - 1]);
    return 0;
}



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

if 0 in a:
    print(0)

else:
    m=1

    for i in range(n):
        m*=a[i]
        if m>10**18:
            print(-1)
            break

    if m<=10**18:
        print(m)


Measured memory_bytes: 21640
//AtCoder ABC101 B - Digit Sums
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N; cin>>N;
    ll s=0;
    ll n=N;
    while(n>0){
        s+=n%10;
        n/=10;
    }
    cout<<(N%s==0?"Yes":"No")<<endl;
    return 0;
}

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


const int MAXN = 5005;
const int MAXK = 5005;


bool dp_pre[MAXN][MAXK];
bool dp_suf[MAXN][MAXK];
int a[MAXN];

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

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

    dp_pre[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            if (dp_pre[i-1][j])
            {
                dp_pre[i][j] = 1;
                if (j + a[i] < k)
                    dp_pre[i][j+a[i]] = 1;
            }
        }
    }

    dp_suf[n+1][0] = 1;
    for (int i = n; i >= 1; i--)
    {
        for (int j = 0; j < k; j++)
        {
            if (dp_suf[i+1][j])
            {
                dp_suf[i][j] = 1;
                if (j + a[i] < k)
                    dp_suf[i][j+a[i]] = 1;
            }
        }
    }

    int ans = n;

    for (int i = 1; i <= n; i++)
    {
        int l = 0; int r = k-1;
        while( l < k && !dp_pre[i-1][l]) l++;
        while(r >= 0 && !dp_suf[i+1][r]) r--;

        while(l < k && r >= 0)
        {
            if (l + r + a[i] < k)
            {
                l++;
                while( l < k && !dp_pre[i-1][l]) l++;
            }
            else if (l + r >= k)
            {
                r--;
                while(r >= 0 && !dp_suf[i+1][r]) r--;
            }
            else
            {
                ans--;
         //       cout << i << " ";
                break;
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 49152
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int i ,n ,large ,small ,ans;
  string nam ,tmp;
  cin >> n;
  for( i=0 ; i<n ; i++ ){
    cin >> nam;
    sort(nam.begin(),nam.end());
    small = atoi(nam.c_str());

    sort( nam.rbegin() ,nam.rend());
    large = atoi(nam.c_str());

    ans = large - small;

    cout << ans << endl;  
  }

  return 0;
}

Measured memory_bytes: 1228