akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint x;
    cin >> x;
    lint num_times;
    num_times = x / 11 * 2;
    lint rest = x - (11 * num_times / 2);
    if (rest > 6) num_times += 2;
    else if (rest > 0) num_times += 1;
    cout << num_times << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll a;
  string s;
  cin>>a>>s;
  if(a>=3200){cout<<s<<endl;}
  else{cout<<"red"<<endl;}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>

using namespace std;

long long vals[55];
int N;
long long all;

void print(){
	for(int i = 0; i < N; ++i) printf("%lld ", vals[i]);
	printf("\n");
}

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%lld", vals + i);
}

void simulate(int id, long long x){
	vals[id] -= x * (N + 1);
	for(int i = 0; i < N; ++i){
		vals[i] += x;
	}
}

long long c[55];

long long solve(){
	long long ans = 0;
	all = 0;
	for(int i = 0; i < N; ++i) all += vals[i];
	for(int i = 0; i < N; ++i){
		long long tmp = vals[i] + all - N * N - N;
	//	printf("%lld\n", tmp);
		tmp /= (N + 1);
		if(tmp < 0) tmp = 0;
		c[i] = tmp;
//		simulate(i, tmp);
//		ans += tmp;
	}
	for(int i = 0; i < N; ++i){
		simulate(i, c[i]);
		ans += c[i];
	}
	while(true){
		int id = -1;
		for(int i = 0; i < N; ++i){
			if(vals[i] >= N){
				id = i;
				break;
			}
		}
		if(id == -1) break;
		simulate(id, 1);
		ans++;
	}
	return ans;
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

int main(int argc, const char *argv[])
{
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);

  cout << x << " ";
  cout << y << " ";
  cout << z << "\n";
  return 0;
}

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

using namespace std;

int main()
{
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    int mat[H][W];
    memset(mat,0,sizeof(mat));
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<W; j++)
        {
            mat[i][j]=1;
        }
    }
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<w; j++)
        {
            mat[i][j]=1;
        }
    }



   int cnt=0;
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            if(mat[i][j]==0)
            {
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<str, ll> msl;
typedef std::map<char, ll> mcl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100000;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))

int main(void){
    ll x;
    in1(x);
    ll answer = 1;
    ll pow = 2;
    
    while(pow < 10){
        For(i,2,32){
            ll a = 1;
            rep(_,pow) a *= i;
            if (a <= x) answer = max(a,answer); 
        }
        pow ++;
    }
    
    prl(answer);

    return 0;
}

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,q,a,b,now=1;
  cin >> n >> q;
  while(q--) {
    cin >> a >> b;
    if(!a) {
      if(now+b-1>n) {
        cout << now+b-1-n << "\n";
      }
      else {
        cout << now+b-1 << "\n";
      }
    }
    else {
      if(now+b>n) {
        now=now+b-n;
      }
      else {
        now=now+b;
      }
    }
  }
}


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

using namespace std;

int main(){
    int N,sum=0;
    cin >> N;
    vector<int> a(N+1),b(N+1,0);
    a[0] = 0;
    for(int i=1;i<=N;i++){
        cin >> a[i];
    }

    for(int i=N;1<=i;i--){
        int c=0,add=i;
        for(int j=i;j<=N;j += add){
            if(b[j]==1){
                c++;
            }
        }
        if(c%2==1 && a[i]==0){
            b[i]=1;
            sum++;
        }else if(c%2==0 && a[i]==1){
            b[i] = 1;
            sum++;
        }
    }

    cout << sum << endl;

    for(int i=1;i<=N;i++){
        if(b[i]==1){
            cout << i << " ";
        }
    }
}

Measured memory_bytes: 2432
import 'dart:io';

void main() {
  int n = int.parse(stdin.readLineSync());
  List di = [];

  for (int i = 0; i < n; i++) {
    di.add(int.parse(stdin.readLineSync()));
  }
  // print(di.toSet()); このイテレータブルの要素を含むセットを作成します。
  // print(di.toList()); // リストにします
  var reducedDi = di.toSet().toList(); //大事
  print(reducedDi.length);
}

Measured memory_bytes: 13112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;	
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	cout << n*n << endl;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    RLE = []
    before = ""
    for s in S:
        if before == s:
            RLE[-1]+=1
        else:
            RLE.append(1)
            before = s
    if len(RLE)==1 or (len(RLE)==2 and RLE[-1] in (1,3)):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

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

public class Main{

	public static void main(String argv[]) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String str;
		String Array[] = new String[2];
		long a, b;
		long kouyaku = 0;
		while ((str = br.readLine()) != null) {
			Array = str.split(" ");
			a = Long.parseLong(Array[0]);
			b = Long.parseLong(Array[1]);
			kouyaku = gcd(a, b);
			System.out.printf("%d %d\n", kouyaku, a * b / kouyaku);

		}
	}

	public static long gcd(long a, long b) {
		return b==0 ? a : gcd(b,a%b);
	}

}

Measured memory_bytes: 24596
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

l.sort(key=lambda x: x[2], reverse=True)
#print(l)

for cx in range(0, 101):
  for cy in range(0, 101):
    x = l[0][0]
    y = l[0][1]
    h = l[0][2]
    H = h+abs(x-cx)+abs(y-cy)
    #print(cx, cy, H)
    for i in range(1, n):
      x = l[i][0]
      y = l[i][1]
      h = l[i][2]
      if h != max(H-abs(x-cx)-abs(y-cy), 0):
        break
    else:
      print(cx, cy, H)
      exit()

Measured memory_bytes: 3064
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const SX = parseInt(arg[0].split(" ")[0]);
    const SY = parseInt(arg[0].split(" ")[1]);
    const TX = parseInt(arg[0].split(" ")[2]);
    const TY = parseInt(arg[0].split(" ")[3]);
    
    const DX = TX - SX;
    const DY = TY - SY;
    
    let answer = [];
    
    for(let i=0; i<DX; i++) {
        answer.push("R");
    }
    
    for(let i=0; i<DY; i++) {
        answer.push("U");
    }
    
    for(let i=0; i<DX; i++) {
        answer.push("L");
    }
    
    for(let i=0; i<DY; i++) {
        answer.push("D");
    }
    
    answer.push("L");
    
    for(let i=0; i<DY+1; i++) {
        answer.push("U");
    }
    
    for(let i=0; i<DX+1; i++) {
        answer.push("R");
    }
    
    answer.push("D");
    
    answer.push("R");
    
    for(let i=0; i<DY+1; i++) {
        answer.push("D");
    }
    
    for(let i=0; i<DX+1; i++) {
        answer.push("L");
    }
    
    answer.push("U");
    
    console.log(answer.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8132
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n+1);
  rep1(i,n)cin>>a[i];
  vector<vector<int>> dp(n+2,vector<int>(k*2+5,0));
  dp[0][0]=1;
  rep1(i,n){
      rep(j,k+5){
          dp[i][j]+=dp[i-1][j];
          dp[i][j+a[i]+1]-=dp[i-1][j];
      }
      rep1(j,k+5){
          dp[i][j]+=dp[i][j-1]+MOD;
          dp[i][j]%=MOD;
      }
  }
  cout<<dp[n][k]%MOD<<"\n";
  return 0;
}

Measured memory_bytes: 161280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int n,a[100005],dp[100005];
	cin>>n;
	a[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
	{
		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 <iostream>
#include <algorithm>
using namespace std;

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

	sort(l, l+n);
	int lg = l[n-1];
	int sum = 0;
	string ans;
	for (int i = 0; i < n-1; i++) {
		sum += l[i];
	}
	if (lg < sum) {
		ans = "Yes";
	} else {
		ans = "No";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 100005
const int inf=1e9;
int mygcd(int a,int b){
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main()
{
    ios_base::sync_with_stdio(false);
    int n,k,x,mx,gcd,flag;
    cin>>n>>k>>x;
    mx=gcd=x;
    rep(i,0,n-1){
        cin>>x;
        mx=max(mx,x);
        gcd=mygcd(gcd,x);
    }
    if(mx>=k&&k%gcd==0) flag=1;
    else flag=0;


    printf("%s\n",flag?"POSSIBLE":"IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
print(((n - 2) // (k - 1) + 1))


Measured memory_bytes: 11624
def move_dice(d, dir):
    if(dir == 'N'):
        d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
    if(dir == 'S'):
        d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
    if(dir == 'E'):
        d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
    if(dir == 'W'):
        d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]

def rotate_right_dice(d):
    d[1], d[2], d[3], d[4] = d[3], d[1], d[4], d[2]

def to_up_dice(d, num_index):
    move_num = {0:0, 1:3, 2:2, 3:0, 4:1, 5:2}
    if(num_index==2 or num_index==3):
        move_dice(d, 'E')
    for _ in range(move_num[num_index]):
        move_dice(d, 'N')

def to_front_dice(d, num):
    while(d[1] != num):
        rotate_right_dice(d)

def equal_dice(d1, d2):
    for i in range(6):
        tmp_d = list(d1)
        to_up_dice(tmp_d, i)
        for _ in range(4):
            if(tmp_d == d2): return 'Yes'
            else: rotate_right_dice(tmp_d)
    return 'No'

def equal_dice_n(d_list, n):
    for i in range(n-1):
        for j in range(i+1, n):
            if(equal_dice(d_list[i], d_list[j]) == 'Yes'):
                return 'No'
    return 'Yes'

n = int(input())
d_list = [list(map(int, input().split())) for _ in range(n)]
print(equal_dice_n(d_list, n))

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

template<class T> struct dual_segment_tree {
    using F = function<T(T, T)>;
	using value_type = T;
private : 
    int n, hight;
    const F f;
    value_type ie;
    vector<value_type> node;

public : 
    dual_segment_tree (const F &f, const value_type &ie) : f(f), ie(ie) { }

    void resize (int sz) {
        n = 1; hight = 0;
        while (n < sz) { n <<= 1; hight++; }
        node.resize(2 * n, ie);
        fill(node.begin(), node.end(), ie);
    }

	void resize (int _n, const value_type &e) {
		n = 1; hight = 0;
		while (n < _n) { n <<= 1; hight++; }
		node.resize(2 * n);
		fill(node.begin(), node.end(), ie);
		for (int i = n; i < 2 * n; i++) node[i] = e;
	}

	void build (auto l, auto r) {
		resize(r - l);
		for (int i = n; l != r; i++, l++) node[i] = (*l);
	}

	void propagate (int i) {
		if (node[i] == ie) return;
		node[i << 1 | 0] = f(node[i << 1 | 0], node[i]);
		node[i << 1 | 1] = f(node[i << 1 | 1], node[i]);
		node[i] = ie;
	}

	inline void apply (int i) {
		for (int j = hight; j > 0; j--) propagate(i >> j);
	}

    void update (int a, int b, value_type x) {
        apply(a + n); apply(b + n - 1);
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) { node[l] = f(node[l], x); l++; }
            if (r & 1) { r--; node[r] = f(node[r], x); }
        }
    }

    const value_type &operator[] (int i) {
        apply(i + n);
        return node[i + n];
    }

	void swap (dual_segment_tree &s) {
		(this->node).swap(s.node);
	}

};

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &e : a) cin >> e;
	
	auto f = [](int a, int b) { return (a + b); };
	dual_segment_tree<int> seg(f, 0);
	seg.build(a.begin(), a.end());

	for (int _ = 0; _ < k; _++) {
		dual_segment_tree<int> buff(f, 0);
		buff.resize(n);
		for (int i = 0; i < n; i++) {
			int d = seg[i];
			buff.update(max(0, i - d), min(n, i + d + 1), 1);
		}
		bool fin = true;
		for (int i = 0; i < n; i++) {
			fin &= (buff[i] == n);
		}
		seg.swap(buff);
		if (fin) break;
	}
	
	for (int i = 0; i < n; i++) cout << seg[i] << ' ';
	
	return 0;
}

Measured memory_bytes: 8204
#include<stdio.h>
#include<math.h>
int main(){
    int n, d;
    double x[1000000],y[1000000];
    double z;
    int ans=0;
    scanf("%d %d", &n, &d);
    for(int i=0;i<n;i++) scanf("%lf %lf",&x[i], &y[i]);
    for(int i=0; i<n ;i++){
        z=sqrt(x[i]*x[i]+y[i]*y[i]);
        if(z<=d) ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 5288
import std.stdio, std.string, std.conv, std.range;

void main() {
	readln;
	auto d = new int[][][](4,3,10);
	foreach (string l; lines(stdin)) {
		auto r = l.chomp.split.to!(int[]);
		d[r[0]-1][r[1]-1][r[2]-1] += r[3];
	}
	foreach (j; 0..4) {
		foreach (i; d[j]) {
			" %s".writefln(i.to!(string[]).join(" "));
		}
		if (j != 3) "#".repeat(20).join.writeln;
	}
}

Measured memory_bytes: 2476
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);


vector<ll> get_divisors(ll m) {
  vector<ll> divisors;
  for (ll i = 1; i*i <= m; i++) {
    if (m % i == 0) {
      divisors.push_back(i);
      if (i != m / i) {
        divisors.push_back(m / i);
      }
    }
  }
  return divisors;
}

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

  ll n;
  cin >> n;
  ll ans = 0;

  // n-1 の約数を求める
  vector<ll> divisors = get_divisors(n-1);
  ans += divisors.size() - 1;

  divisors = get_divisors(n);

  for (auto& k : divisors) {
    if (k == 1) continue;
    ll m = n;
    while (m%k == 0) m /= k;
    m %= k;
    if (m == 1) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(void){
    const long long mod=1e9+7;
    int n, m;
    cin>>n>>m;
    vector<int>oks(n+1, true);
    rep(i, m){
        int a;
        cin>>a;
        oks[a]=false;
    }
    vector<ll>dp(n+1);
    dp[0]=1;
    rep(now, n){
        for(int next=now+1;next<=min(n, now+2);next++){
            if(oks[next]){
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }

    
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


ll g = 101;
ll ans = 0;


ll solv(vector<pair<ll, ll>> &p, vector<bool> h) {

  ll val = 0;

  if (h.size() == p.size()) {
    long count = 0;
    val = 1;
    for (int i = 0; i < p.size(); i++) {
      if (h[i] == true) {
        count += p[i].first;
      }
      if (h[i] == true)val *= p[i].second;
    }
    if (count == 75) {
      return val;
    } else {
      return 0;
    }
  }

  vector<bool> h1 = h;
  vector<bool> h2 = h;
  h1.push_back(true);
  h2.push_back(false);

  val += solv(p, h1);
  val += solv(p, h2);

  return val;
}




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






  vector<vector<ll>> np(n + 1, vector<ll>(g, 0));

  for (ll i = 1; i <= n; i++) {
    ll t = i;
    np[i][1] = 1;

    for (int k = 2; k <= g; k++) {
      if (t % k == 0) {
        t /= k;
        // num[i]++;
        np[i][k]++;
        k--;
      }
    }
  }

  vector<vector<pair<ll, ll>>> npMin(n + 1, vector<pair<ll, ll>>());

  for (ll i = 1; i <= n; i++) {
    for (int j = 1; j < 101; ++j) {
      if (np[i][j] > 0) {
        npMin[i].push_back(make_pair(j, np[i][j]));
      }
    }
  }


  vector<ll> num(n + 1, 0); //全体の素因数の数

  for (int i = 1; i < n + 1; ++i) {
    // cerr << " num = "<<i <<endl;
    for (auto v : npMin[i]) {
      // for(int u=0;u<v.second;u++){
      //   cerr << v.first <<" , ";
      // }
      num[v.first] += v.second;

    }
    // cerr <<endl;
  }

  for (int i = 1; i < n + 1; ++i) {
    cerr << i << "  -  " << num[i] << endl;
  }



  //パターンごとに求める
  // num[1] = 1;
  ans = 0;
  for (int i = 2; i < n + 1; ++i) {
    if (num[i] >= 74)ans++;
  }

  ll t1 = 0, t2 = 0, t3 = 0;

  for (int i = 2; i < n + 1; ++i) {
    if (num[i] >= 14 )t1++;
    if (num[i] >= 4 )t2++;
  }
  ans += t1 * max((ll)0, (t2 - 1));
  cerr << "t1 : " << t1 << "   t2 :" << t2 << "   t3:" << t3 << endl;

  t1 = 0; t2 = 0; t3 = 0;
  for (int i = 2; i < n + 1; ++i) {
    if (num[i] >= 24 )t1++;
    if (num[i] >= 2 )t2++;
  }
  ans += t1 * max((ll)0, (t2 - 1));

  cerr << "t1 : " << t1 << "   t2 :" << t2 << "   t3:" << t3 << endl;

  t1 = 0; t2 = 0; t3 = 0;
  for (int i = 2; i < n + 1; ++i) {
    if (num[i] >= 4 )t1++;
    if (num[i] >= 2 )t2++;
  }
  ans += t1 * (t1 - 1) * max((ll)0, (t2 - 2))/2;
  cerr << "t1 : " << t1 << "   t2 :" << t2 << "   t3:" << t3 << endl;

  cout << ans ;

}




















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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k << endl;
  }
  else if (k <= a + b) {
    cout << a << endl;
  }
  else {
    cout << a - (k - a - b) << endl;
  }  
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x == 0 && y == 0)break;
		if(x < y)System.out.println(x+" "+y);
		    else System.out.println(y+" "+x);
		}
	}
	}

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

int main() {

  int H,N,Sum;
  cin >> H >> N;
  Sum=0;
  
  vector<int> A(N);  
// A入力
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
  Sum+=A.at(i);
}

//読み込んだ値の確認
//  cout<<H<<endl;
//  cout<<N<<endl;  
//for (int i = 0; i < N; i++) {
//  cout<<A.at(i)<<endl;
//}   
//  cout<<Sum<<endl;
  
  if (H<=Sum){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
    
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mp make_pair
#define fi fisrt
#define se second

using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f3f3f3f;

vector<int> vec[N];

int n,m,k,ans,sum;
int ji;
int a[N];
int num[N];
string s,t;
int lens,lent;
signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) sum+=a[i];
	sum%=mod;
	for (int i=1;i<=n;i++) ans+=(a[i]*(sum-a[i])%mod+mod)%mod;
	if (ans%2==1) ans+=mod;
	ans/=2;
	ans%=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 9836
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s, t; cin >> s >> t;
  int n = SZ(s), m = SZ(t);

  vvi is(26);
  REP(i,n) is[s[i]-'a'].PB(i);
  REP(i,n) is[s[i]-'a'].PB(i+n);

  ll ans = 0;
  int pos = 0;
  REP(i,m) {
    int c = t[i] - 'a';
    if (SZ(is[c]) == 0) {
      puts("-1");
      return 0;
    }
    pos = *lower_bound(ALL(is[c]),pos)+1;
    if (pos >= n) {
      pos -= n;
      ans += n;
    }
  }

  ans += pos;
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 1724
#include <stdio.h>
int chk(
	double x1,double y1,
	double x2,double y2,
	double x3,double y3,
	double x4,double y4
	);
int main(){

	double x1,y1,x2,y2,x3,y3,x4,y4;
	int sn;
	int i;

	scanf("%d",&sn);
	for(i=0;i<sn;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		printf(chk(x1,y1,x2,y2,x3,y3,x4,y4)?"YES\n":"NO\n");

	}




	return 0;
}


int chk(
	double x1,double y1,
	double x2,double y2,
	double x3,double y3,
	double x4,double y4	){
	if(((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))==0) return 1;
	return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)

int main()
{
   FAST();
   int n;
   int sum  =0;
   cin >> n;
   int t = n;
   while(n != 0){
      sum += n % 10;
      n /= 10;
   }
   outl(t  % sum == 0 ? "Yes" : "No") ;
}



Measured memory_bytes: 256
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
	
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		char[] c = sc.next().toCharArray();
		
		c[K-1] = String.valueOf(c[K-1]).toLowerCase().toCharArray()[0];
		System.out.println(String.valueOf(c));
		sc.close();
	}
	
	
	
}

Measured memory_bytes: 23636
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
d = gets.chomp.to_i
c = gets.chomp.split.map(&:to_i)
s = []
d.times do
  s.push gets.chomp.split.map(&:to_i)
end

d.times do |i|
  puts s[i].index(s[i].max) + 1
end




Measured memory_bytes: 14744
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> dp(3);
    for(int i=0;i<n;i++){
        vector<int> new_dp(3);
        vector<int> c(3);
        for(int i=0;i<3;i++){
            cin>>c[i];
        }
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j){
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    cout<<max({dp[0],dp[1],dp[2]});
    return 0;
}


Measured memory_bytes: 3580
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	int s , w ; 
	cin>>s>>w ; 
	if(s<=w){
		cout<<"unsafe\n";
	}
	else{
		cout<<"safe\n";
	}
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

stair = 0

for i in range(N):
    if i != 0:
        if A[i] < A[i-1]:
            stair = stair + A[i-1] - A[i]
            A[i] = A[i-1]
            

print(stair)


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

#define ll long long

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

    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n),d(n);

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

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

    int cnt1=0, cnt2=0;

    while(c != a)
    {
    	cnt1++;
    	next_permutation(c.begin(),c.end());
    }

    while(d != b)
    {
    	cnt2++;
    	next_permutation(d.begin(),d.end());
    }
    cout<<abs(cnt1-cnt2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,c,s,t,a;
int b[35][100010];
vector<P> vec1,vec2;
signed main(){
	cin>>n>>c;
	rep(i,n){
		cin>>s>>t>>a;
		b[a][s-1]++;
		b[a][t]--;
		vec1.push_back({a,s-1});
		vec2.push_back({a,t});
	}
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	for(int i=1;i<=30;i++){
		rep(j,100009){
			if(j)b[i][j]+=b[i][j-1];
		}
	}
	int ans=0;
	rep(i,100010){
		int cnt=0;
		for(int j=1;j<=30;j++)cnt+=(bool)b[j][i];
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 28392
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    double countodd = 0;
    for(ll i=1; i<=t; i++){
        if(i%2 == 1)
            countodd++;
    }
    cout << fixed << setprecision(15) << countodd/t;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n, m; cin >> n >> m;
  vector<vector<int>> ss;
  rep(i, m) {
    int k; cin >> k;
    vector<int> s(k);
    rep(j, k) {cin >> s[j]; s[j]--;}
    ss.push_back(s);
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  int ans = 0;
  for (int i = 0; i < (1<<n); i++) { // i: switch
    bool flag = true;
    for (int j = 0; j < ss.size(); j++) {  // s: 電球jと繋がっているスイッチ
      int cnt = 0;
      for (auto& x : ss[j]) {
        if ((i >> x) & 1 == 1) cnt++;
      }
      if (cnt % 2 != p[j]) flag = false;
    }
    if (flag) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
N, K = map(int, input().split())

dp = [0 for _ in range(K + 1)]
res = 0

for i in range(1, K + 1)[::-1]:
    dp[i] += pow(K // i, N, MOD)
    for j in range(1, K // i):
        dp[i] -= dp[i * (j + 1)]
    res += i * dp[i]
    res %= MOD

print(res)

Measured memory_bytes: 11384
#include <stdio.h>

int main(void){
    int N,M;
    int H[100001];
    int flag[100001] = {};
    
    scanf("%d%d",&N,&M);
    
    for(int i = 1; i <= N; i++){
        scanf("%d",&H[i]);
    }
    
    for(int i = 0; i < M; i++){
        int A,B;
        scanf("%d%d",&A,&B);
        if(H[A] == H[B]){
            flag[A] = flag[B] = 1;
        }
        else if(H[A] > H[B]){
            flag[B] = 1;
        }
        else if(H[B] > H[A]){
            flag[A] = 1;
        }
    }
    
    int cnt = 0;
    for(int i = 1; i <= N; i++){
        if(flag[i] == 0){
            cnt++;
        }
    }
    
    printf("%d\n",cnt);
}

Measured memory_bytes: 2516
#include <iostream>
#include <string>
#include <set>
using namespace std;

char l[11] = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};

int main() {
  set<char> left;
  for (int i=0; i<11; ++i) left.insert(l[i]);

  string in;
  while(cin>>in) {
    if (in == "#") break;
    int prev = (left.find(in[0]) == left.end())?0:1;
    int ans = 0;
    for (int i=0; i<in.length(); ++i) {
      int n = (left.find(in[i]) == left.end())?0:1;
      if (n != prev) ans++;
      prev = n;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int r,d,x;
  cin>>r>>d>>x;
  int arr[10]={0};
  arr[0]=r*x-d;
  for(int i=1;i<10;i++){
    arr[i]=r*arr[i-1]-d;
  }
  for(int i=0;i<10;i++)
    cout<<arr[i]<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

from math import ceil
import heapq

def main():
    n, d, a = map(int, input().split())
    q = []
    for i in range(n):
        x, h = map(int, input().split())
        heapq.heappush(q, (x, 0, ceil(h / a)))
    bomb = 0
    res = 0
    while q:
        x, ty, h = heapq.heappop(q)
        if ty == 0:
            if h > bomb:
                heapq.heappush(q, (x + 2 * d, 1, h - bomb))
                res += h - bomb
                bomb = h
        else:
            bomb -= h
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 35724
function Main(input) {
    var N = parseInt(input[0], 10);
    var a = input.slice(1)
        .map(e => parseInt(e, 10))
        .sort((a, b) => {
            return b - a;
        });

    var alice = 0;
    var bob = 0;

    for (var i = 0; i < N; i++) {
        if (i % 2 === 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    console.log(alice - bob);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class DigitNumber
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string line = System.Console.ReadLine();
                if(line=="" || line==null)
                {
                    return;
                }
                else
                {
                    string[] param = line.Split(' ');
                    System.Console.WriteLine((ulong.Parse(param[0]) + ulong.Parse(param[1])).ToString().Length);

                }
            }
        }
    }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  string A, B, C;
  B=".";
  for (int i=0; i<W-1; i++)
    B+='.';
  cin >> C;
  
  for (int i=0; i<H; i++) {
    if (i != H-1) {
      A=B; 
      B=C;
      cin >> C;
    }
    else {
      A=B;
      B=C;
      C=".";
      for (int k=0; k<W-1; k++)
        C+='.';
    }
    
    char a1, a2, a3;
    char b1, b2, b3;
    char c1, c2, c3;
    a1='.'; a2='.'; a3=A.at(0);
    b1='.'; b2='.'; b3=B.at(0);
    c1='.'; c2='.'; c3=C.at(0);    
    
    int j=0;
    while (j<W) {
      j++;
      if (j != W) {
        a1=a2; a2=a3; a3=A.at(j);
        b1=b2; b2=b3; b3=B.at(j);
        c1=c2; c2=c3; c3=C.at(j);
      }
      else {
        a1=a2; a2=a3; a3='.';
        b1=b2; b2=b3; b3='.';
        c1=c2; c2=c3; c3='.';
      }
      
      if (b2 != '#') {
        int f=0;
        if (a1=='#')
          f+=1;
        if (a2=='#')
          f+=1;
        if (a3=='#')
          f+=1;
        if (b1=='#')
          f+=1;
        if (b3=='#')
          f+=1;
        if (c1=='#')
          f+=1;
        if (c2=='#')
          f+=1;
        if (c3=='#')
          f+=1;
        
        char g;
        string n = "012345678";
        g = n.at(f);
        
        B.at(j-1) = g;
      }
    }
    cout << B << endl;
  }
}
  

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

def gcd(a,b):
    while(a%b!=0):
        a,b=b,a%b
    return b
a=list(sorted(a))
c=gcd(a[0],a[1])
for i in range(2,n):
    c=gcd(a[i],c)
print(c)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s,t; cin>>s>>t;
  int cnt=0;
  for(int i=0;i<s.length();i++)
    if(s[i]!=t[i])
      cnt++;

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

Measured memory_bytes: 3800
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll t=01;
    while(t++)
    {
        ll a;
        cin>>a;
        if(a==0)
        {
            cout<<--t;
            return;
        }
    }
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define f first
#define s second
#define R PP(1,0,0)
#define C PP(0,1,0)
#define S PP(0,0,1)
using namespace std;
typedef pair <int,int> P;
typedef pair <int,P> iP;
int p,q;
string str[2][11];
map<iP,int> M;
iP PP(int a,int b,int c){return iP(a,P(b,c));}

int gcd(int a,int b,int c,int d){
  a=abs(a),b=abs(b),c=abs(c),d=abs(d);
  a= a&&b? __gcd(a,b):max(a,b);
  c= c&&d? __gcd(c,d):max(c,d);
  a= a&&c? __gcd(a,c):max(a,c);
  return max(1,a);
}

void solve(){
  if(M.size()==2&&M.count(PP(1,1,1))) M[R]=M[C]=M[S]=M[PP(1,1,1)]/3;

  map<iP,int> ::iterator i,j;

  for(int k=0;k<3;k++){
  for(i=M.begin();i!=M.end();i++)
    for(j=M.begin();j!=M.end();j++){
      int a=i->f.f, b=i->f.s.f, c=i->f.s.s,d=i->s;
      int x=j->f.f, y=j->f.s.f, z=j->f.s.s,w=j->s;
      
      int T[3][2]={{a,x},{b,y},{c,z}};
      int D,ax,by,cz,dw,l=T[k][0],r=T[k][1];
	D=gcd(l,r,0,0);
	ax=(a*(r/D)-x*(l/D));
	by=(b*(r/D)-y*(l/D));
	cz=(c*(r/D)-z*(l/D));
	dw=(d*(r/D)-w*(l/D));
	D=gcd(ax,by,cz,dw);
	ax/=D,by/=D,cz/=D,dw/=D;

	if(M.count(PP(ax,by,cz))) continue;
	if(ax<0||by<0||cz<0||dw<0)continue;

	i=M.begin();
	M[PP(ax,by,cz)]=dw;
      }
  }
}

void in(){
  M.clear();
  int cnt[3]={},d;
  for(int i=0;i<p;i++)
    for(int j=0,f=1,dot=0;j<str[0][i].size();j++){
      char ch=str[0][i][j];
      if(ch=='.')dot++;
      else if(f)f=0,d=gcd(cnt[0],cnt[1],cnt[2],dot),M[PP(cnt[0]/d,cnt[1]/d,cnt[2]/d)]=dot/d;
      if(ch=='('||ch=='['||ch=='{')cnt[ch/50]++;
      if(ch==')'||ch==']'||ch=='}')cnt[ch/50]--;
    }
}


int cal(int a,int b,int c){
  int d=gcd(a,b,c,0),D;
  a/=d,b/=d,c/=d;
  if(M.count(PP(a,b,c))) return M[PP(a,b,c)]*d;
  int fa=M.count(R),fb=M.count(C),fc=M.count(S);
  int abc=fa+fb+fc;
  if(abc/3) return (M[R]*a+M[C]*b+M[S]*c)*d;
  if(abc/2&&(!a!=!fa||!b!=!fb||!c!=!fc)) return -1;
  if(abc/2) return (M[R]*a+M[C]*b+M[S]*c)*d;
  D=gcd(b,c,0,0);
  if(fa&&M.count(PP(0,b/D,c/D)))return (M[R]*a+M[PP(0,b/D,c/D)]*D)*d;
  D=gcd(a,c,0,0);
  if(fb&&M.count(PP(a/D,0,c/D)))return (M[C]*b+M[PP(a/D,0,c/D)]*D)*d;
  D=gcd(a,b,0,0);
  if(fc&&M.count(PP(a/D,b/D,0)))return (M[S]*c+M[PP(a/D,0,c/D)]*D)*d;
  return -1;
}

void out(){
  int cnt[3]={},e[3]={M.count(R),M.count(C),M.count(S)};
  e[0]= e[0]? M[R]:-1;
  e[1]= e[1]? M[C]:-1;
  e[2]= e[2]? M[S]:-1;
  
  for(int i=0;i<q;i++){
    M.erase(R),M.erase(C),M.erase(S);
    if(e[0]!=-1)M[R]=e[0];
    if(e[1]!=-1)M[C]=e[1];
    if(e[2]!=-1)M[S]=e[2];
    cout <<cal(cnt[0],cnt[1],cnt[2]);
    if(i!=q-1)cout <<" ";
    for(int j=0;j<str[1][i].size();j++){
      char ch=str[1][i][j];
      if(ch=='('||ch=='['||ch=='{')cnt[ch/50]++;
      if(ch==')'||ch==']'||ch=='}')cnt[ch/50]--;
    }
  }
  cout <<endl;
}

int main(){
  while(1){
    cin>>p>>q;
    if(!p&&!q) break;
    for(int i=0;i<p;i++)cin>>str[0][i];
    for(int i=0;i<q;i++)cin>>str[1][i];
    in();
    solve();
    out();
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 100
struct edge{
  int to,cost;
};
struct inp{
  int a,b,c;
};
typedef pair<int,int> P;
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+V,INF);
  d[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    REP(i,G[v].size()){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(){
  int e;
  bool used[1000];

  scanf("%d%d",&V,&e);
  vector<inp> iedge(e);
  REP(i,e){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    --a;--b;
    edge e1 = {b,c}, e2 = {a,c};
    G[a].push_back(e1);
    G[b].push_back(e2);
    inp e3 = {a,b,c};
    iedge[i] = e3;
  }
  REP(i,e) used[i] = false;

  REP(i,V){
    dijkstra(i);
    REP(j,e){
      if(used[j]) continue;
      if(d[iedge[j].a] + iedge[j].c == d[iedge[j].b]) used[j] = true;
    }
  }

  int ans=0;
  REP(i,e) if(!used[i]) ++ans;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		String s=sc.next();
		int size=s.length();
		
		if(s.substring(0,n/2).equals(s.substring(size/2))){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N * 3);
    for (int i = 0; i < N * 3; ++i) cin >> A[i];
    sort(A.begin(), A.end(), greater<long long>());
    long long res = 0;
    for (int i = 1, j = 0; j < N; i += 2, ++j) res += A[i];
    cout << res << endl;
}

Measured memory_bytes: 5480
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();		
		int k = scan.nextInt();
		int ans = (int)Math.ceil((double)(n - 1)/ (k - 1));
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844