akhauriyash/Code-Regression huggingface dataset:
s = input()
q = int(input())

direction = True
front = ""
back = ""

for i in range(q):
    q_i = input().split()
    if q_i[0] == "1":
        if direction:
            direction = False
        else:
            direction = True

    else:
        if direction:
            if q_i[1] == "1":
                front += q_i[2]
            else:
                back += q_i[2]
        else:
            if q_i[1] == "1":
                back += q_i[2]
            else:
                front += q_i[2]

if direction:
    print(front[::-1] + s + back)
else:
    print(back[::-1] + s[::-1] + front)

Measured memory_bytes: 4408
#include<stdio.h>
#include<string.h>
int main(void){
    char s[4];
    int ans=0;
    scanf("%s",s);
    if(s[0]=='1')
    ++ans;
    if(s[1]=='1')
    ++ans;
    if(s[2]=='1')
    ++ans;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import numpy as np
N = int(input())
A = [input().split() for i in range(2)]
f = np.vectorize(int)
A = f(A)
max_sum = 0
for i in range(N):
    sum = 0
    for j in range(i+1):
        sum += A[0][j]
    for j in range(i, N):
        sum += A[1][j]
    if sum > max_sum:
        max_sum = sum

print(max_sum)

Measured memory_bytes: 13476
<?php
$n = explode(" ",fgets(STDIN));
$a = intval($n[0]);
$b = intval($n[1]);
$c = intval($n[2]);
$ans = 0;
if(($a+$b)>$c-2){
	$ans = $b+$c;
}else{
	$ans = $b*2 + $a + 1;
}
echo $ans;

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

bool my_compare(pair<int, int> a, pair<int, int> b) {
	if (a.first != b.first) {
		return a.first < b.first; 
	}
	else {
		return true;
	}
}
int main() {

	int N = 0;
	int i;
	int temp;
	vector<pair<int,int>> A;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> temp;
		A.push_back(make_pair(temp,i+1));
	}
	sort(A.begin(), A.end(), my_compare);

	for (i = 0; i < N; i++) {
		cout << A[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main(){
   ll n;
   cin>>n;
   vector<ll> v(n);
   for(ll i=0;i<n;i++) cin>>v[i];
   ll sum=0;
   for(ll i=1;i<n;i++){
    if(v[i]<v[i-1]){
        ll d=(v[i-1]-v[i]);
        v[i]+=d;
        sum+=d;
    }
   }
   cout<<sum<<endl;

}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
const int n= 100500;
vector<int> P;

void sieve(int n){
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for(int p=2; p*p<=n; p++){
        if(prime[p]){
            for(int i=p*p; i<=n; i+=p){
                prime[i]=false;
            }
        }
    }

    for(int p=2; p<=n; ++p){
        if(prime[p]) P.push_back(p);
    }
}

int main(){
    int x;
    cin>>x;
    sieve(n);
    int pos=lower_bound(P.begin(), P.end(), x)- P.begin();
    cout<<P[pos]<<"\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}


ll solve(ll H)
{
    if(H==1)
        return 1;
    return 1+2*solve(H/2);
}

int main()
{
    fastio();
    ll h,ans=0;
    cin >> h;
    ans=solve(h);
    cout <<ans << endl;
    
}

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

#define int long long

signed main(void){
    int a,b,c; cin >> a >> b >> c;
    if((a==b && b==c) || (a!=b && b != c && c != a)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e,k,ans;
    cin >> a>>b>>c>>d>>e>>k;
    if(e-a >k){
        cout << ":(";
    }else{
        cout << "Yay!";
    }


    //cout << ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static int[] dat;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int a = 1;
        while (a < 300000) {
            a *= 2;
        }
        dat = new int[2*a];

        for (int i = 0; i < N; i++) {
            int A = sc.nextInt();
            int l = Math.max(A-K,0);
            int r = A+K+1;
            int max = query(l,r,0,0,a);
            update(A, max+1, a);
        }

        System.out.println(dat[0]);
    }

    private static void update(int i, int x, int n) {
        i += n-1;
        dat[i] = x;
        while (i > 0) {
            i = (i-1)/2;
            dat[i] = Math.max(dat[i*2+1], dat[i*2+2]);
        }
    }

    private static int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return dat[k];

        int vl = query(a, b, k*2+1, l, (l+r)/2);
        int vr = query(a, b, k*2+2, (l+r)/2, r);

        return Math.max(vl, vr);
    }
}


Measured memory_bytes: 62592
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = 1;
        int i = 1;

        while(x != 0){
            x = sc.nextInt();
            switch (x) {
                case 0: break;
                default: System.out.println("Case " + i + ": " + x); break;
            }
            i++;
        }
    }
}


Measured memory_bytes: 42532
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n := scanInt(stdin)
	stdin.Scan()
	bs := make([]string, n)
	ss := make([]string, n)
	bs = scanArray(stdin)
	copy(ss, bs)

	bubbleSort(n, bs)
	selectSort(n, ss)
	if reflect.DeepEqual(bs, ss) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}

func bubbleSort(n int, a []string) {
	flag := true
	for flag {
		flag = false
		for j := n - 1; j >= 1; j-- {
			if intCard(a[j]) < intCard(a[j-1]) {
				tmp := a[j-1]
				a[j-1] = a[j]
				a[j] = tmp
				flag = true
			}
		}
	}
	fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	fmt.Println("Stable")
}

func selectSort(n int, a []string) {
	for i := 0; i < n; i++ {
		minj := i
		for j := i; j < n; j++ {
			if intCard(a[j]) < intCard(a[minj]) {
				minj = j
			}
		}

		tmp := a[minj]
		a[minj] = a[i]
		a[i] = tmp
	}
	fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
}

func intCard(s string) int {
	return int([]rune(s)[1] - '0')
}

func scanInt(sc *bufio.Scanner) int {
	t := sc.Text()
	i, err := strconv.Atoi(t)
	if err != nil {
		panic(err)
	}
	return i
}

func scanArray(sc *bufio.Scanner) []string {
	t := sc.Text()
	ss := strings.Split(t, " ")

	return ss
}



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

const int INF = 1e9;

int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> h(N);
    for(auto &e : h) cin >> e;

    vector<int> dp(N+1, INF);
    dp[0] = 0;

    for(int i = 0; i < N; i++) {
        for(int k = 1; k <= K; k++) {
            if(i + k < N) dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]));
        }
    }

    cout << dp[N-1] << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, p, ma = 0, res = 0;
	cin >> n;
	REP(i, n) {
		cin >> p;
		res += p;
		ma = max(ma, p);
	}
	cout << (res - ma/2) << endl;
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include <algorithm>
 
using namespace std;
 
void triangleCal()
{
    int n;
    int side[3];
  
    cin >>n;
    
    while(n--)  //instead of "for"
    {
        cin >>side[0]>>side[1]>>side[2]; 
        
        sort(side, side+3); // sort date by ascending order
        
       if(side[2] * side[2] == side[1] * side[1] + side[0] * side[0]) 
       {
           cout <<"YES"<<endl;
       }
       else
       {
           cout <<"NO"<<endl;
       }
    }
    
    return;
}
   
int main(){
   
    triangleCal();
    return 0;
}

Measured memory_bytes: 1168
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Information Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  int n,i,k;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++)
  	cin>>a[i];
  int ans = 0;
  for (int i = 0; i < n; ++i) 
  {
    if ((k-1) * i + 1 >= n) {
	  ans = i;
	  break;
	}
  }
	cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}

int main(){
    int n=in(),m=in();
    ll mod=1000000007;
    vector<int>a(n+1),b(m+1);
    a[n]=0;b[m]=0;
    rep(i,n)a[i]=in();sort(All(a),greater<int>());
    rep(i,m)b[i]=in();sort(All(b),greater<int>());
    int p=0,q=0;
    ll ans=1;
    rep3(k,n*m,1){
        if(a[p]>k||b[q]>k)ans=0;
        else if(a[p]==k&b[q]<k){
            ans*=q;
            p++;
        }else if(a[p]<k&b[q]==k){
            ans*=p;
            q++;
        }else if(a[p]<k&b[q]<k) ans*=p*q-n*m+k;
        else{
            p++;
            q++;
        }
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

map<ll, ll> factorize2(ll n) {
    map<ll, ll> res;
    for (ll i = 2; (i * i) <= n; i++) {
        if (n % i) continue;
        res[i] = 0;
        while((n % i) == 0) {
            n /= i;
            res[i]++;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> fac;
    rep(i, n) {
        auto tmp = factorize2(a[i]);
        for(auto x : tmp) {
            fac[x.first] = max(fac[x.first], x.second);
        }
    }
    mint f = 1;
    for(auto x : fac) {
        rep(i, x.second) {
            f *= x.first;
        }
    }
    mint ans = 0;
    rep(i, n) ans += f / a[i];
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 1024
use strict;
use warnings;
use 5.010;

use Data::Dumper;


my $n   = <STDIN>;

my $line    = <STDIN>;
chomp($line);
my $b   = [split(/ /, $line)];

my $total   = $b->[0];

for (my $i = 1 ; $i < scalar @$b ; $i++) {
    my $b0  = $b->[$i-1];
    my $b1  = $b->[$i];

    # 小さい方を採用
    $total  += ($b0 > $b1) ? $b1 : $b0;
}

$total  += $b->[-1];


say $total;


Measured memory_bytes: 1920
#!/bin/bash
# 標準入力に対して目的の数列を求めるプログラム
# ルールにしたがって次の項を生成(多分ここもif文で生成する)
# 生成した項をこれまで生成した項(配列)と比較forとif文でかけそうやな
# 一致するものがなければ、その項を配列に追加する

#初項の入力と配列の生成
read S
array=($S)
COUNT=1
FIN=0

while :
do
 if [ $(( $S % 2 )) = 1 ]; then
  S=$(( 3 * $S + 1  ))
  COUNT=$(($COUNT + 1))
 else
  S=$(( $S / 2 ))
  COUNT=$((COUNT + 1))
 fi

# 新たに追加された要素(末尾の要素)がすでに配列の中身と同じなら、その数字を出力してbreak
# 新たに追加された要素と同じものがなければ、$Sを再利用して再度実行

 for i in ${array[@]}
 do
 if [ $S -eq $i ]; then
 FIN=1
 break
 fi
 done
 
 array=("${array[@]}" $S)

 if [ $FIN = 1 ]; then
 echo $COUNT
 break
 fi

done


Measured memory_bytes: 504
H,W,N = map(int,input().split())

from collections import defaultdict
L = defaultdict(int)

#黒く塗りつぶしたマスとその周りだけ探索すればよい
for i in range(N):
    a,b = map(int,input().split())
    for p in [-1,0,1]:
        for q in [-1,0,1]:
            if a+p < 2 or b+q < 2 or a+p >H-1 or b+q >W-1:
                continue
            L[(a+p-1,b+q-1)] += 1
            
ans = [0]*10
for v in L.values():
    ans[v] += 1
ans[0] = (H-2)*(W-2) - sum(ans)

for i in range(10):
    print(ans[i])


Measured memory_bytes: 181536
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#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 pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(void) {
	int r, g, b;
	cin>>r>>g>>b;
	int n = 100 * r + 10 * g + b;
	if(n % 4 == 0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}



Measured memory_bytes: 256
N,K,Q = [int(x) for x in input().split()]
# 最終的に減点されるポイント
hiku = [Q for _ in range(N)]
for i in range(Q):
    Ai = int(input())
    hiku[Ai-1] -= 1
for x in hiku:
    x = K-x 
    if x > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 6604
let css = Array.init 3 @@ fun _ -> Array.init 3 @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
let a_s = Array.make 3 0 in
let bs = Array.make 3 0 in
bs.(0) <- css.(0).(0);
bs.(1) <- css.(0).(1);
bs.(2) <- css.(0).(2);
a_s.(1) <- css.(1).(0) - bs.(0);
a_s.(2) <- css.(2).(0) - bs.(0);
for i = 0 to 2 do
  for j = 0 to 2 do
    if css.(i).(j) <> a_s.(i) + bs.(j) then begin print_endline "No"; exit 0 end
  done
done;
print_endline "Yes"

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n){
    cin>>x[i];
    y[i]=x[i];
  }
  sort(ALL(x));

  int t1=x[n/2];
  int t2=x[n/2-1];
  rep(i,n){
    if(y[i]<t1){
      cout<<t1<<endl;
    }else{
      cout<<t2<<endl;
    }
  }


  return 0;

}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a[N],Ha[N],hs,k,f[N];
struct BIT{
	int n,c[N];
	void set(LL _n){
		n=_n;
		memset(c,0,sizeof c);
	}
	void add(int x,int d){
		for (;x<=n;x+=x&-x)
			c[x]+=d;
	}
	int ask(int x){
		int ans=0;
		for (;x;x-=x&-x)
			ans+=c[x];
		return ans;
	}
}T;
bool check(int k){
	for (int i=1;i<=n;i++)
		f[i]=f[i-1]+(a[i]>=k?1:-1);
	T.set(n*2+1);
	LL ans=0;
	for (int i=0;i<=n;i++){
		ans+=T.ask(f[i]+n+1);
		T.add(f[i]+n+1,1);
	}
	return ans>=1LL*n*(n+1)/4;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),Ha[i]=a[i];
	sort(Ha+1,Ha+n+1);
	hs=unique(Ha+1,Ha+n+1)-Ha-1;
	for (int i=1;i<=n;i++)
		a[i]=lower_bound(Ha+1,Ha+hs+1,a[i])-Ha;
	int L=1,R=hs,mid,ans=L;
	while (L<=R){
		mid=(L+R)>>1;
		if (check(mid))
			L=mid+1,ans=mid;
		else
			R=mid-1;
	}
	printf("%d",Ha[ans]);
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int sum = a + b;
  if (sum % 2 == 1) {
    cout << (sum + 1) / 2 << endl;
  }else{
    cout << sum / 2 << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  if (k == 0) {
    return !printf("%lld\n", n * n);
  }
  FOR(i, k + 1, n + 1) {
    // ll hoge = ans;
    ans += n / i * (i - k) + max((ll)0, n % i - k + 1);
    // cout << i << " " << ans - hoge << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* ex3_4 
　　　　　sachiyan*/

#include <stdio.h>
int main(void){
    int N; //入力Nの定義
    int i,j; //while内変数の定義
    scanf("%d", &N); //Nの読み取り
    i = 1;
    while(i <= 9){ //二重のループを０－９までで回して九九の解をすべてしらべる
        j = 1;
        while(j <= 9){
            if(i*j == N){ //九九を総当たりで探し、Nと等しければ
                printf("Yes"); //Yesを出力しendの行まで飛ぶ
                goto end; //endの行まで飛ぶ
            }
            j++;
        }
        i++;
    }
    if(i == 10 && j == 10){ //九九全てに当てはまらないとき
        printf("No"); //Noを出力
    }
    end:
        printf("\n"); //改行を出力
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll s,w;
  cin >> s>>w;
  if(s>w){
    cout << "safe" << endl;
    return 0;
  }
  cout << "unsafe" << endl;
  return 0;
}


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

int main()
{
	//??°???????????????
	int num1,test1[200][3],test2[200][3],num5[200],m,k,c,z,q,w;

	cin>>num1;
	for(int i=0;i<num1;i++){
		for(int l=0;l<3;l++){
			cin>>test1[i][l];
		}
	}
	for(int g=0;g<num1;g++){
	    for(int d=0;d<3;d++){
					test2[g][d]=test1[g][d];
		}
	}
	for(int g=0;g<num1-1;g++){
		for(int h=g+1;h<num1;h++){
			if(test2[g][0]==test2[h][0]){
				m=g;
				k=h;
				test1[m][0]=0;
				test1[k][0]=0;
			}
			if(test2[g][1]==test2[h][1]){
				c=g;
				z=h;
				test1[c][1]=0;
				test1[z][1]=0;
			}
			if(test2[g][2]==test2[h][2]){
				q=g;
				w=h;
				test1[q][2]=0;
				test1[w][2]=0;
			}
		}
	}
	for(int s=0;s<num1;s++){
		num5[s]=test1[s][0]+test1[s][1]+test1[s][2];
		cout<<num5[s];
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N,K;
  cin>>N>>K;
  vector<ll> H(N);
  REP(i,N){
    cin>>H[i];
  }
  if(K>=N){
    cout<<0<<endl;
  }else{
    ll ans=0;
    sort(ALL(H));
    REP(i,N-K){
      ans+=H[i];
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 4756
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
string tostring(int a){
	string s="";
	while(a){
		s+=(char)('0'+a%10);
		a/=10;
	}
	reverse(all(s));
	return s;
}
int main(){
	string s;int n;
	while(cin>>s>>n,n){
		while(s.size()!=n)s="0"+s;
		map<string,int>m;
		m[s]=1;
		int co=1;
		while(1){
			sort(all(s));
			int a=atoi(&s[0]);
			reverse(all(s));
			int b=a-atoi(&s[0]);
			b=abs(b);
			s=tostring(b);
			while(s.size()!=n)s="0"+s;
			if(m[s])break;
			co++;m[s]=co;
		}
		cout<<m[s]-1<<" "<<atoi(&s[0])<<" "<<co-m[s]+1<<endl;
	}
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int num;
double Search(vector<vector<vector<double>>> &dp, int a, int b, int c) {
	if (dp[a][b][c] >= 0.0)
		return dp[a][b][c];
	double x = (double)num;
	if (a)
		x += (double)a * Search(dp, a - 1, b, c);
	if (b)
		x += (double)b * Search(dp, a + 1, b - 1, c);
	if (c)
		x += (double)c * Search(dp, a, b + 1, c - 1);
	return dp[a][b][c] = x / (double)(a + b + c);
}

int main(void) {
	int i, k;
	double ans;
	vector<int> a(4, 0);
	cin >> num;
	rep(i, num) {
		cin >> k;
		a[k]++;
	}
	vector<vector<vector<double>>> dp(num + 1, vector<vector<double>>(num + 1, vector<double>(num + 1, -1.0)));
	dp[0][0][0] = 0.0;
	ans = Search(dp, a[1], a[2], a[3]);
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 219956
#include <iostream>

using namespace std;

int main()
{
     int a,n;
     cin>>n;
     int sum=0;
     int u=n;
     while(n)
     {
         a=n%10;
         n=n/10;
         sum=sum+a;
     }

     if(u%sum==0)
        cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;

    return 0;
}


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

using namespace std;
typedef long long LL;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> x(M), y(M);
  rep(i,M) cin >> x[i] >> y[i];
  vector<bool> ans(N+1);
  vector<int> num(N+1);
  rep(i,N) num[i+1]=1;
  ans[1]=true;
  rep(i,M){
    if(ans[x[i]]){
      ans[y[i]]=true;
      if(num[x[i]]==1) ans[x[i]]=false;
    }
    num[x[i]]--;
    num[y[i]]++;
  }
  int s=0;
  rep(i,N) s+=ans[i+1];
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int MAX_N = 1000 + 10;
struct S
{
    int id, time;
    char str[3];
};
int n;
S s[MAX_N];
int in_time;

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

        int y, m, h, mm, id, max_id = 0;
        char str[3];
        for(int i = 0; i < n; i++)
        {
            scanf("%d/%d %d:%d %s %d", &y, &m, &h, &mm, str, &id);
            s[i].id = id, s[i].time = h * 60 + mm, strcpy(s[i].str, str);
            max_id = max(max_id, id);
        }
        bool is_at1, is_at2;
        is_at1 = is_at2 = false;
        int in_time, out_time, during_time, _beg_time, temp_time, max_time;
        max_time = temp_time = 0;
        in_time = out_time = during_time = _beg_time =  -1;
        for(int j = 1; j <= max_id; j++)
        {
            for(int i = 0; i < n; i++)
            {
                if(s[i].id == 0)
                {
                    if(s[i].str[0] == 'I')
                    {
                        is_at1 = true;
                        if(is_at2 == true)
                        {
                            _beg_time = s[i].time;
                            //in_time = s[i].time;
                        }
                        /*else
                            in_time = s[i].time;*/
                    }
                    else
                    {
                        is_at1 = false;
                        if(is_at2 == true)
                        {
                            if(_beg_time != -1)
                            {
                                temp_time += s[i].time - _beg_time;
                                _beg_time = -1;
                            }
                        }
                    }
                }
                else
                {
                    if(s[i].id == j)
                    {
                        if(s[i].str[0] == 'I')
                        {
                             is_at2 = true;
                            if(is_at1 == true)
                            {
                                _beg_time = s[i].time;
                            }
                        }
                        else
                        {
                            is_at2 = false;
                            if(_beg_time != -1)
                            {
                                temp_time += s[i].time - _beg_time;
                                 _beg_time = -1;
                            }
                        }
                    }
                }
           }
           max_time = max(max_time, temp_time);
           _beg_time = -1;
           temp_time = 0;
        }
    printf("%d\n", max_time);
    }
    return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstring>
using namespace std;
int n,m;
char d[110][110];
int main() {
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%s",d[i]);
	for (int i=1;i<=m+2;i++)
		printf("#");
	printf("\n");
	for (int i=1;i<=n;i++) {
		printf("#");
		for (int j=0;j<m;j++)
			printf("%c",d[i][j]);
		printf("#\n");
	}
	for (int i=1;i<=m+2;i++)
		printf("#");	
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
local mmi = math.min
local n, a, b = io.read("*n", "*n", "*n", "*l")
local str = io.read()
local prv = nil
local sum = 0
for v in str:gmatch("%d+") do
  local nxt = tonumber(v)
  if prv ~= nil then
    sum = sum + mmi((nxt - prv) * a, b)
  end
  prv = nxt
end
print(sum)


Measured memory_bytes: 4260
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


const LL mod = 1e9 + 7;
int c[2005][2005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  int n;
  scanf("%d", &n);
  LL ans = 0;
  c[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < n; j++) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
  }
  for (int i = 1; 3 * i <= n; i++) {
    int s = n - i * 3;
    ans += c[i - 1 + s][i - 1];
  }
  cout << (ans % mod + mod) % mod << endl;
 
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 19192
<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));

for($i = 0; $i < $n; $i++) {
    $work = explode(' ', trim(fgets(STDIN)));
    $a[] = $work;
}

for($i = 0; $i < $m; $i++) {
    $work = trim(fgets(STDIN));
    $b[] = $work;
}

for ($i = 0; $i < $n; $i++) {
    $sum = 0;
    for ($j = 0; $j < $m; $j++) {
        $sum += ((int)$a[$i][$j] * (int)$b[$j]);
    }
    echo $sum .PHP_EOL;
}

Measured memory_bytes: 10964
n,m = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors
ans = 1
lst = make_divisors(m)
lst.sort()
for d in lst:
    if m>=d*n:
        ans = d
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define N 100

int zettaiti( int a, int b ){
  int ans = ( a > b ) ? a - b : b - a ;
  return ans;
}

int main( void ){
  int i, y, x;
  int n, a, b, c, d, max;
  int ax, ay;
  int bx, by;
  int cx, cy;
  int dx, dy;
  int min = 5 * N;

  scanf( "%d%d%d%d%d", &n, &a, &b, &c, &d );

  // printf( "%d, %d, %d, %d, %d\n", n, a, b, c, d );
  max = ( a   > b ) ? a   : b;
  max = ( max > c ) ? max : c;
  max = ( max > d ) ? max : d;

  // テ・ツ崢ウテ・ツスツ「テヲツアツコテ・ツョツ?
  for( i = n - 1; i >= 0; i-- ){
    int count   = 0;
    int endFlag = 0;

    // テ・ツ債佚」ツ?ェテ」ツつ凝ゥツ?催ァツスツョ
    for( y = 0; ; y++ ){
      for( x = 0; x <= i; x++ ){
        count++;
        if( count == a ){
          ax = x;
          ay = y;
        }else if( count == b ){
          bx = x;
          by = y;
        }else if( count == c ){
          cx = x;
          cy = y;
        }else if( count == d ){
          dx = x;
          dy = y;
        }

        if( count >= max ){
          break;
        }
      }

      if( count >= max ){ // テ、ツクツ?」ツ?、テ」ツ?ョテ・ツ崢ウテ・ツスツ「テ」ツつ津ィツヲツ凝ァツオツづ」ツつ湘」ツ?」テ」ツ?淌ヲツ卍?
        int preMin =
          zettaiti( ax, bx ) +
          zettaiti( ay, by ) +
          zettaiti( cx, dx ) +
          zettaiti( cy, dy );
        if( min > preMin ){
          min = preMin;
        }
        break;
      }
    }
  }

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

  return( 0 );
}

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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    int a = 0;
    for (int i = A; i <= B; i ++ ){
        if (i % K == 0){
            a = 1;
        }
    }
    if (a == 1)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;
  int N = len(S);
  map<char, int> m;
  rep(i, N) {
    m[S[i]]++;
  }

  int A = m['a'], B = m['b'], C = m['c'];
  if (max({A, B, C}) - min({A, B, C}) <= 1)
    cout << "YES\n";
  else
    cout << "NO\n";
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
#define zahyoutype long
 
typedef struct Point{zahyoutype x,y;}P;
typedef struct line{P p1,p2;}L;
int sgn(zahyoutype x){return x<0?-1:x>0;}
 
//opとoqの内積と外積
zahyoutype innerproduct(P p,P q,P o){return (p.x-o.x)*(q.x-o.x)+(p.y-o.y)*(q.y-o.y);}
zahyoutype crossproduct(P p,P q,P o){return (p.x-o.x)*(q.y-o.y)-(p.y-o.y)*(q.x-o.x);}
 
int iscrossSS(L s,L t){
	//点(p,q)が直線f(x,y)=ax+by+c=0のどっち側にあるかは外積を見ればよい
	zahyoutype t1=crossproduct(t.p1,s.p2,s.p1);
	zahyoutype t2=crossproduct(t.p2,s.p2,s.p1);
	zahyoutype t3=crossproduct(s.p1,t.p2,t.p1);
	zahyoutype t4=crossproduct(s.p2,t.p2,t.p1);
	//同一直線上にない
	if(t1 || t2)return sgn(t1)!=sgn(t2) && sgn(t3)!=sgn(t4);
	//if(t1 || t2)return sgn(t1)*sgn(t2)==-1 && sgn(t3)*sgn(t4)==-1;//端点を含まない
	//同一直線上にある
	//内積をみる
	zahyoutype c1=innerproduct(s.p2,s.p2,s.p1);
	zahyoutype c2=innerproduct(t.p1,s.p2,s.p1);
	zahyoutype c3=innerproduct(t.p2,s.p2,s.p1);
	return 0<=c2&&c2<=c1 || 0<=c3&&c3<=c1 || c2<=0&&c1<=c3 || c3<=0&&c1<=c2;
	//return 0<c2&&c2<c1 || 0<c3&&c3<c1 || c2<=0&&c1<=c3 || c3<=0&&c1<=c2;//端点を含まない
}
 
double seglen(L s){return hypot(s.p2.x-s.p1.x,s.p2.y-s.p1.y);}
double distPP(P p,P q){return hypot(p.x-q.x,p.y-q.y);}
double distPL(P p,L s){return fabs(crossproduct(p,s.p2,s.p1)/seglen(s));}
double distPS(P p,L s){
	zahyoutype c =innerproduct(   p,s.p2,s.p1);
	zahyoutype ss=innerproduct(s.p2,s.p2,s.p1);
	if(c<=0)return distPP(p,s.p1);
	if(c<=ss)return distPL(p,s);
	return distPP(p,s.p2);
}
 
void readpoint(P*p){zahyoutype x=1;scanf(x/2?"%lf%lf":"%ld%ld",&p->x,&p->y);}
void printpoint(P p){zahyoutype x=1;printf(x/2?"%.f %.f\n":"%ld %ld\n",p.x,p.y);}
 
P p[110];
L s[110];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		readpoint(p+i);
		s[i].p2=p[i];
		s[(i+1)%n].p1=p[i];
	}
	int q;
	scanf("%d",&q);
	while(q--){
		L t;
		readpoint(&t.p1);
		{
			int flag=0;
			for(int i=0;i<n;i++)if(distPS(t.p1,s[i])==0)flag=1;
			if(flag){
				puts("1");
				continue;
			}
		}
		{
			int flag=1;
			while(flag){
				t.p2.x=rand()%1000+10000;
				t.p2.y=rand()%1000+10000;
				if(seglen(t)==0)continue;
				flag=0;
				for(int i=0;i<n;i++)if(distPS(p[i],t)==0)flag=1;
			}
		}
		 
		int flag2=0;
		for(int i=0;i<n;i++)if(iscrossSS(t,s[i]))flag2^=1;
		puts(flag2?"2":"0");
	}
}


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

using namespace std;

int main(){
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;

    long long int c2,d2;
    c2=c;
    d2=d;
    long long int r =  d2%c2;
    while(r!=0){
    d2 = c2;
    c2 = r;
    r = d2 % c2;
    }
    long long int lcm=c*d/c2;

    cout<<b-a+1-(b/c+b/d-b/lcm)+((a-1)/c+(a-1)/d-(a-1)/lcm)<<endl;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int k, n;
  string s;
  cin >> k >> s;
  n = s.size();
  combination c(n+k);
  mint ans = 0;
  for (int i = 0; i <= k; ++i) {
    mint now = mint(26).pow(k-i);
    now *= mint(25).pow(i);
    now *= c(i+n-1,n-1);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35560
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< pair<cat, int> > D(N);
	for(int i = 0; i < N; i++) {
		cin >> D[i].ff;
		D[i].ss = i;
	}
	sort(begin(D), end(D));
	map<cat, int> M;
	for(int i = 0; i < N; i++) M[D[i].ff] = i;
	vector<int> sz(N, 1);
	vector< pair<int, int> > E;
	for(int i = N-1; i > 0; i--) {
		if(2*sz[i] >= N) {
			cout << "-1\n";
			return 0;
		}
		cat D_up = D[i].ff + sz[i] - (N-sz[i]);
		auto it = M.find(D_up);
		if(it == M.end()) {
			cout << "-1\n";
			return 0;
		}
		sz[it->ss] += sz[i];
		E.push_back({D[i].ss, D[it->ss].ss});
	}
	if(sz[0] != N || (int)E.size() != N-1) {
		cout << "-1\n";
		return 0;
	}
	vector< vector<int> > G(N);
	for(int i = 0; i < N-1; i++) {
		G[E[i].ff].push_back(E[i].ss);
		G[E[i].ss].push_back(E[i].ff);
	}
	vector<int> dep(N, -1);
	dep[D[0].ss] = 0;
	queue<int> q;
	q.push(D[0].ss);
	while(!q.empty()) {
		ALL_THE(G[q.front()], it) if(dep[*it] == -1) {
			dep[*it] = dep[q.front()] + 1;
			q.push(*it);
		}
		q.pop();
	}
	cat depsum = 0;
	for(int i = 0; i < N; i++) {
		if(dep[i] == -1) {
			cout << "-1\n";
			return 0;
		}
		depsum += dep[i];
	}
	if(depsum != D[0].ff) {
		cout << "-1\n";
		return 0;
	}
	for(int i = 0; i < (int)E.size(); i++) cout << E[i].ff+1 << " " << E[i].ss+1 << "\n";
	return 0;
}

// look at my code
// my code is amazing


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reverse_rep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    
    ll added = 0;
    ll ans = 0;

    reverse_rep(i, N) {
        ll tmp = B[i] - (A[i] + added) % B[i];
        if (tmp == B[i]) continue;
        added += tmp;
        ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  double r;
  cin >> r;
  cout << 6.28318530717958623200*r << endl;
  return 0;
}


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

int main()
{
	int a;

	cin >> a;

	if (a < 1200)
	{
		cout << "ABC";
	}
	else if (a < 2800)
	{
		cout << "ARC";
	}
	else
	{
		cout << "AGC";
	}

	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <set>

using namespace std;
 
int main () {
  int a;
  string b;
  set <string> s;
  cin>>a;
  for(int i=1;i<=a;i++)
  {cin>>b; s.insert(b);}
  cout<<s.size();
    
  
  
}

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

typedef long long ll;

const int MAXN = 100 * 1000 + 10;

int main()
{
    string s;
    cin>>s;
    int i=1;
    while(i<s.size()){
        if(s[i]=='T' && s[i-1]=='S'){
            s.erase(i-1,2);
            //cout<<s<<endl;
            if(i<2){
                continue;
            }
            i--;
            continue;
        }
        i++;
    }
    cout<<s.size();
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
int a,s,d[1001],f[1001],g[1001][1001],h,i,j,z,x;
int main(void)
{
	x=1;
	while(1){
		scanf("%d",&a);
		if(a==0)	break;
		scanf("%d",&s);
		for(i=0;i<s;i++)
			scanf("%d,%d",&d[i],&f[i]);
		for(i=0;i<=s;i++){
			for(j=0;j<=a;j++)
				g[i][j]=-1;
		}
		g[0][0]=0;
		for(i=0;i<s;i++){
			for(j=0;j<=a;j++){
				if(g[i][j]!=-1){
					if(g[i][j]>g[i+1][j])
						g[i+1][j]=g[i][j];
					if(j+f[i]<=a){
						if(g[i][j]+d[i]>g[i+1][j+f[i]])
							g[i+1][j+f[i]]=g[i][j]+d[i];
					}
				}
			}
		}
		h=0;
		z=0;
		for(i=0;i<=a;i++){
			if(h<g[s][i]){
				h=g[s][i];
				z=i;
			}
		}
		printf("Case %d:\n",x);
		printf("%d\n%d\n",h,z);
		x++;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }
    int ans = 10001;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += w[i];
    }
    for (int i = 0; i < n; i++) {
        int t = 0;
        for (int j = 0; j < i; j++) {
            t += w[j];
        }
        ans = min(ans,abs(abs(sum-t)-t));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256