akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

bool eq(vi P, vi Q) {
	rep(i, P.size()) {
		if (P[i] != Q[i]) {
			return false;
		}
	}
	return true;
}

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

	vi P(N);
	rep(i, N) {
		cin >> P[i];
	}
	vi Q(N);
	rep(i, N) {
		cin >> Q[i];
	}

	vi per(N);
	rep(i, N) {
		per[i] = i+1;
	}

	ll p, q;
	for (int i = 0; true; i++) {
		if (eq(per, P)) {
			p = i;
		}
		if (eq(per, Q)) {
			q = i;
		}

		if (!next_permutation(all(per))) {
			break;
		}
	} 

	cout << abs(p - q) << endl;

	return 0;
}


Measured memory_bytes: 256
<?php
$K =(int)fgets(STDIN);
$ans = 0;
for ($a = 1; $a <= $K; $a++) {
    for ($b = 1; $b <= $K; $b++) {
        for ($c = 1; $c <= $K; $c++) {
            $ans += gcd($a, gcd($b, $c));
        }
    }
}

echo $ans;

function gcd($m, $n){
    if($n > $m) list($m, $n) = [$n, $m];

    while($n !== 0) {
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}

Measured memory_bytes: 16184
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, dp[100000][2];
vector<int> adj[100000];
int calc(int u, int p, int pb) {
	if (dp[u][pb] != -1) return dp[u][pb];
	int b = 1, w = 1;
	for (auto v : adj[u]) {
		if (v == p) continue;
		b = ((long long)b * calc(v, u, 1)) % MOD;
		w = ((long long)w * calc(v, u, 0)) % MOD;
	}
	int res = w;
	if (pb == 0) res = (res + b) % MOD;
	return dp[u][pb] = res;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	memset(dp, -1, sizeof(dp));
	int ans = calc(0, -1, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 13440
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    ll n;
                    cin>>n;
                    if(n%2 == 0){
                        cout<<"-1";
                        return ;
                    }
                    ll k = 7;
                    ll cnt = 1;
                    while(true){
                        if(k%n == 0){
                            cout<<cnt;
                            break;
                        }
                        if(cnt > n){
                            cout<<"-1";
                            break;
                        }
                        k = (k%n)*10 +7;
                        // cout<<k<<"\n";
                        ++cnt;
                    }
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl;
        return 0;
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)
    d=1;
    cout<<((a-b)/(b-c)+d)*2+1<<endl;
}

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

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

    vector<int> v(4);
    v[0] = n/1000;
    v[1] = n%1000/100;
    v[2] = n%1000%100/10;
    v[3] = n%1000%100%10;

    for(int i=0;i<(1<<3);i++){
        bitset<3> op(i);
        int ans = v[0];
        for(int j=0;j<3;j++){
            if(op.test(j)){
                ans += v[j+1];
            }
            else {
                ans -= v[j+1];
            }
        }
        if(ans == 7){
            string Ans;
            Ans += to_string(v[0]);
            for(int j=0;j<3;j++){
                
                if(op.test(j)){
                    Ans += "+";
                }
                else {
                    Ans += "-";
                }
                Ans += to_string(v[j+1]);
            }
            Ans += "=7";
            cout << Ans;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
    
using namespace std;
    
int main()
{
    int a, b;
    cin >> a >> b;
        
    if(a < b){
        cout << "a < b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
n=int(input())
a=list(map(int,input().split()))
l=[]
for i,x in enumerate(a):
    l.append([x,i])
l.sort(reverse=True)
cnt=1
dp=[[0]*(n+1) for _ in range(n+1)]
for i,j in l:
    for x in range(cnt+1):
        if x==0:
            dp[x][cnt-x]=dp[x][cnt-x-1]+i*(n-1-(cnt-x-1)-j)
        elif x==cnt:
            dp[x][cnt-x]=dp[x-1][cnt-x]+i*(j-x+1)
        else:
            dp[x][cnt-x]=max(dp[x-1][cnt-x]+i*(j-x+1),dp[x][cnt-x-1]+i*(n-1-(cnt-x-1)-j))
    cnt+=1
ans=0
for i in range(n+1):
    ans=max(ans,dp[i][n-i])
print(ans)

Measured memory_bytes: 124728
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
s = Set.new
k.times do
  d = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  s += Set.new(a)
end

puts n - s.size


Measured memory_bytes: 14868
#include<bits/stdc++.h>
using namespace std;
int n,a[100001];
long long ans;

int main()
{
	cin>>n;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=0;i<n;i++)
    {
        ans+=a[i]/2;
        a[i]%=2;
        if(a[i]&&a[i+1])
            ans++,a[i]--,a[i+1]--;
	}
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#prag\
ma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define N 100005
using namespace std;
int n,m,a[N],fa[N],id[N],tmp[N];
bool visited[N];
int Find(int x)
{
	if(fa[x]!=x) fa[x]=Find(fa[x]);
	return fa[x]; 
}
bool cmp(int x,int y)
{
	return a[x]<a[y];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		fa[i]=i;
	}
	for(int i=1;i<=m;++i)
	{
		int u,v; scanf("%d%d",&u,&v); ++u; ++v;
		int fu=Find(u),fv=Find(v); fa[fv]=fu;
	}
	if(m==n-1)
	{
		printf("0\n");
		return 0;
	}
	for(int i=1;i<=n;++i) if(fa[i]==i) id[i]=i;
	for(int i=1;i<=n;++i) if(a[i]<a[id[Find(i)]]) id[fa[i]]=i;
	int cnt=0;
	ll ans=0;
	for(int i=1;i<=n;++i) if(fa[i]==i) visited[id[i]]=true,ans+=a[id[i]],++cnt;
	for(int i=1;i<=n;++i) tmp[i]=i;
	sort(tmp+1,tmp+n+1,cmp);
	for(int i=1;i<=n && cnt<2*(n-m-1);++i) if(!visited[tmp[i]]) ans+=a[tmp[i]],++cnt;
	if(cnt<2*(n-m-1)) printf("Impossible\n"); else printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

string S,T;
int ans;

int main(){
    cin>>S>>T;
    rep(i,3)if(S[i]==T[i])ans++;
    out(ans);

    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

template <class T>
T digitSum(T num) {
    T sum = 0;
    while (num != 0) {
        sum += num%10;
        num /= 10;
    }
    return sum;
}


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

    // input
    int N, A, B;
    cin >> N >> A >> B;
    
    // calculation
    ll sum = 0, digsum;
    REPN(i, N) {
        digsum = digitSum(i);
        if (A <= digsum && digsum <= B) {
            sum += i;
        }
    }
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
lis = []
rem = 0
for i in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        rem = i
    lis.append((x,y,h))
flag = 1
for i in range(101):
    for j in range(101):
        flag = 1
        H = lis[rem][2]+abs(lis[rem][0]-i)+abs(lis[rem][1]-j)
        for k in range(N):
            if lis[k][2] != max(H-abs(lis[k][0]-i)-abs(lis[k][1]-j),0):
                flag = 0
                break
        if flag == 1:
            break
    if flag == 1:
        break
print(str(i)+" "+str(j)+" "+str(H))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define debug(a) cout << a << endl
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn=100005;

//=================================================
int a[maxn][4];
int dp[maxn][4];
int n,k;
void init() {
    for(int i=0;i<=n;i++) {
        for(int j=0;j<4;j++) {
            a[i][j]=0;
            dp[i][j]=0;
        }
    }
}
int main()
{
    IO;
    cin>>n;
    init();
    for(int i=1;i<=n;i++) {
        for(int j=1;j<4;j++) {
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<4;j++) {
            for(int k=1;k<4;k++) {
                if(j!=k)
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int a,b; cin >> a >> b;
    int ans = 1;
    int ans1 = 0;
    while(ans < b){
        ans += a-1;
        ans1++;
    }
    cout << ans1;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int so[100100];
int ev[100100];
int ae,ao;
int anse,anso;
int sume,sumo;
int od[100100];
int main()
{
	int n;
	cin>>n;
	for(int i = 0;i < n; i++)
	{
		scanf("%d",&so[i]);
	}
	int even=n/2;
	int odd=n-even;
	for(int i = 0; i < n; i++)
	{
		if(i%2)
			ev[so[i]]++;
		else
			od[so[i]]++;
	}
	for(int i = 0; i < 100100; i++)
	{
		if(anse<=ev[i])
		{
			ae=anse;
			anse=ev[i];
			sume=i;
		}
		else if(ae<ev[i])
			ae=ev[i];
		if(anso<=od[i])
		{
			ao=anso;
			anso=od[i];
			sumo=i;
		}
		else if(ao<od[i])
		{
			ao=od[i];
		}
	}
	if(sumo!=sume)
	{
		cout<<n-anse-anso;
		return 0;
	}
	else
	{
		cout<<min(n-anse-ao,n-anso-ae);
	}
	return 0;
}

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

int main(){
    
    string s;
    int a = 0;
    
    cin >> s;
    for(int i = 0;i < 4;++i)
        if(s[i] == '+') a++;
        else a--;
        
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import bisect
n = int(input())
a = sorted(map(int, input().split()))
if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit()

p = bisect.bisect_left(a, 0)
p = min(max(1, p), n - 1)
print(sum(a[p:]) - sum(a[:p]))
b = a[p - 1]
for i in range(p, n - 1):
    print(b, a[i])
    b -= a[i]
c = a[n - 1]
for i in range(p - 1):
    print(c, a[i])
    c -= a[i]
print(c, b)


Measured memory_bytes: 14092
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("869121");
            //2511445
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        checked {
            List<string> InputList = GetInputList();

            int N = int.Parse(InputList[0]);

            const long Hou = 1000000000 + 7;

            long Answer = DeriveModPow(10, N, Hou);
            Answer -= 2 * DeriveModPow(9, N, Hou);
            Answer %= Hou;
            if (Answer < 0) Answer += Hou;

            Answer += DeriveModPow(8, N, Hou);
            Answer %= Hou;

            Console.WriteLine(Answer);
        }
    }

    //繰り返し2乗法で、(NのP乗) Mod Mを求める
    static long DeriveModPow(long pN, long pP, long pM)
    {
        checked {
            long CurrJyousuu = pN % pM;
            long CurrShisuu = 1;
            long WillReturn = 1;

            while (true) {
                //対象ビットが立っている場合
                if ((pP & CurrShisuu) > 0) {
                    WillReturn = (WillReturn * CurrJyousuu) % pM;
                }

                CurrShisuu *= 2;
                if (CurrShisuu > pP) return WillReturn;
                CurrJyousuu = (CurrJyousuu * CurrJyousuu) % pM;
            }
        }
    }
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n, k, q; cin >> n >> k >> q;
    vll s(n, 0);
    ll in;
    rep(i, q){
        cin >> in;
        s[in-1]++;
    }

    rep(i, n){
        cout << (s[i]>q-k? "Yes" : "No") << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template<typename T = int, class F = std::plus<T>, class F_INV = std::minus<T>, const T E = 0>
struct BinaryIndexedTree {
    const F op = F(); const F_INV op_inv = F_INV();
    int n; vector<T> dat;
    void build(const vector<T>& v) {
        n = v.size(); dat.assign(n, E); for (int i = 0; i < n; ++i) add(i, v[i]);
    }
    void add(int k, T v) { for (int i = k; i < n; i |= i + 1) dat[i] = op(dat[i], v); }
    T query(int a, int b) const {
        T ret = E; if (a == b) return ret;
        for (int i = b - 1; i >= 0; i = (i & (i + 1)) - 1) ret = op(ret, dat[i]);
        return op_inv(ret, query(0, a));
    }
};

struct RangeAddRangeSumQuery {
    int n;
    BinaryIndexedTree<ll> bit0, bit1;
    void build(int n_) {
        n = n_;
        bit0.build(vector<ll>(n + 1));
        bit1.build(vector<ll>(n + 1));
    }
    void range_add(int l, int r, ll x) {
        bit0.add(l, -x * l);
        bit1.add(l, x);
        bit0.add(r, x * r);
        bit1.add(r, -x);
    }
    ll range_sum(int l, int r) {
        return bit0.query(l, r) + r * bit1.query(0, r) - l * bit1.query(0, l);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }

    ll t = 0;
    rep(i, 1, N) t += (A[i] - A[i - 1] + M) % M;

    RangeAddRangeSumQuery rars;
    rars.build(M);
    rep(i, 1, N) {
        if (A[i - 1] == A[i]) continue;
        else if (A[i - 1] < A[i]) {
            rars.range_add(A[i - 1] + 2, A[i] + 1, 1LL);
            rars.range_add(A[i] + 1, A[i] + 2, (ll)-(A[i] - A[i - 1] - 1));
        }
        else {
            ll add = (ll)(A[i] - A[i - 1] + M - 1) % M;
            rars.range_add(A[i - 1] + 2, M, 1LL);
            rars.range_add(0, A[i] + 1, 1LL);
            rars.range_add(0, 1, (ll)M - (A[i - 1] + 2));
            rars.range_add(A[i] + 1, A[i] + 2, -add);
        }
    }

    ll ans = INT64_MAX;
    rep(i, M) {
        ans = min(ans, t - rars.range_sum(0, i + 1));
    }
    write(ans);
}

Measured memory_bytes: 3056
// AtCoder Regular Contest 078
// E - Awkward Response

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


bool query(ll n) {
    char c;
    cout << "? " << n << endl;
    cin >> c;
    return c == 'Y';
}

int main() {

    int d;
    ll n, l, r, m;

    for (d = 1, n = 1; d < 11 && query(n); d++, n *= 10) {}
    if (d == 11) {
        for (d = 1, n = 1; d < 11 && !query(n * 10 - 1); d++, n *= 10) {}
        cout << "! " << n << endl;
        return 0;
    }

    l = n / 10;
    r = n;
    m = (l + r + 1) / 2;
    while (r - l > 1) {
        if (query(m * 10)) {
            r = m;
        } else {
            l = m;
        }
        m = (l + r + 1) / 2;
    }

    cout << "! " << m << endl;

    return 0;

}





Measured memory_bytes: 648
# -*- coding: utf-8 -*-

def input_multiple_number_as_list():
    return list(map(int, input().split()))
N = int(input())
list_A = input_multiple_number_as_list()

#list_A.sort()
cntlist = [0]*(N+1)

for k in range(N):
    cntlist[list_A[k]]+=1

totalcomb = 0

for k in cntlist:
    totalcomb += (k*(k-1)//2)
for k in list_A:
    print(totalcomb-((cntlist[k])*(cntlist[k]-1)//2)+((cntlist[k]-1)*(cntlist[k]-2)//2))



Measured memory_bytes: 24996
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

int main(){
  string S;
  cin >> S;
  int N = S.length();
  vector<int> A(N);
  
  int cnt = 0;
  
  for (int j = 0; j < 2; j++){
	int cnt = 0;
    for (int i = 0; i < N; i++){
      if (S[i] == 'R') cnt++;
      else {
        A[i] += cnt/2; //切り下げ
      	A[i-1] += (cnt+1)/2; //切り上げ
      	cnt = 0; //初期化
      }
    }
    reverse(S.begin(), S.end());
    reverse(A.begin(), A.end());
    
    for (int i = 0; i < N; i++){
      if (S[i] == 'L') S[i] = 'R';
      else S[i] = 'L';
    }
  }
    
  for (int i = 0; i < N; i++){
    printf("%d%c", A[i], i == N-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n;
	cin>>n;
	ll ans = sqrt(n);
	cout<<ans*ans<<endl;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3696
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int sum = 0;
	int n,t[101];
	cin >> n;
	REP(i, n){
		cin >> t[i];
		sum += t[i];
	}
	int m,p,x;
	cin >> m;
	REP(i, m){
		cin >> p >> x;
		p--;
		cout << sum - t[p] + x << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  long h,w;
  long buf;
  scanf("%ld %ld",&h,&w);
  if(w==1 || h==1)buf=1;
  else if(w%2==0)buf=w/2*h;
  else if(h%2==0)buf=h/2*w;
  else buf=h/2.0*w+0.5;
  printf("%ld",buf);
  return 0;
}

Measured memory_bytes: 128
s=input()
k=int(input())
a2n = lambda c: ord(c) - ord('a') + 1
n2a = lambda c: chr(c+64).lower()
ls=list(s)
i=0
while k>0 and i<len(ls):
  a=(1-a2n(ls[i]))%26
  if k>=a:
    ls[i]='a'
    k-=a
  i+=1
if k>0:
  ls[-1]=n2a(a2n(ls[-1])+k%26)
print(''.join(ls))

Measured memory_bytes: 49648
#include <stdio.h>

int main(void) 
{
	int a[101][101] = { 0 };
	int b[101] = { 0 };
	int d[101] = { 0 };
	int i, j, r, c;
	int x;
	int e = 0;

	scanf("%d %d", &r, &c);

	for (j = 0; j < r; j++) {
		for (i = 0; i < c; i++) {
			scanf("%d", &x);
			a[j][i] = x;
		}
	}

	for (j = 0; j < r; j++){
		for (i = 0; i < c; i++) {
			b[i] += a[j][i];
		}
	}

	for (j = 0; j < r; j++){
		for (i = 0; i < c; i++){
			d[j] += a[j][i];
		}
	}

	for (j = 0; j < r; j++) {
		for (i = 0; i < c; i++) {
			printf("%d ", a[j][i]);
		}
		printf("%d\n", d[j]);
	}
	for (i = 0; i < c; i++) {
		printf("%d ", b[i]);
		e += b[i];
	}
	printf("%d\n", e);

	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int T,t[30],N,m[101];
int dp[101][30];
int main(){
	while(true){
		cin>>T;
		if(T==0) break;
		rep(i,T) cin>>t[i];
		cin>>N;
		rep(i,101) m[i]=25;
		rep(i,N){
			int x,y;
			cin>>x>>y;
			chmin(m[x-1],y);
		}
		rep(i,101) rep(j,T) dp[i][j]=1e9;
		dp[0][0]=0;
		rep(i,100) rep(j,T){
			if(t[(j+1)%T]<=m[i+1]) chmin(dp[i+1][(j+1)%T],dp[i][j]);
			chmin(dp[i+1][0],dp[i][j]+1);
		}
		int ans=1e9;
		rep(j,T) chmin(ans,dp[100][j]);
		cout<<ans<<endl;
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> a(3*N);
    for(int i=0;i<3*N;i++){
        cin >>a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    long long c=0;
    for(int i=1;i<2*N;i+=2){//各メンバー強さの大きい順で並べたとき、最初を0番目としたときに初めからNまで数えて奇数番目のメンバーのみ取っていくとチームの強さの和としては最大となる
        c+=a.at(i);
    }
    cout << c <<endl;
    return 0;
}

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

int main() {
  string op;
  int A,B;
  cin >> A >> op >> B;
  int result;
  
  if (op == "+"){
    result = A + B;
  }
  else if(op == "-"){
    result = A - B;
  }
  
  cout << result <<endl;
}



Measured memory_bytes: 3624
#include<set> 
#include<map> 
#include<vector>
#include<algorithm> // sort,reverse,min,lower_bound

#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=a;i<(n);i++)
typedef long int li;

struct graph{
  int order;
  int comp;
  vector<vector<int>> adj;
  vector<int> uf;

  graph(int n,int m,int origin=1);
  void print_uf();
  int find(int a);
  int c_size(int a){ return -uf[find(a)]; };
  void merge(int u,int v);
  void merge();
};


// print_item
template<typename T>
void print_item(T x) {cout << x;}
void print(int x) {cout << x;}

// 汎用
void print(auto& vec,string str="");
// pair 型の print (map 含む)
template<typename F,typename S>
void print(pair<F,S> x);


int main(){
  if(df) printf("*debug mode*\n");
  int n,m; cin >>n >>m;
  int flag=2*m-n+2;
  vector<pair<li,int>> vec(n); li ans=0;
  rep(i,n){
    int a; cin >>a;
    vec.at(i)={a,i};
    ans+=a;
  }
  sort(vec.begin(),vec.end());
  graph g(n,m,0);
  if(flag<0){
    printf("Impossible\n");
    return 0;
  }
  g.merge();
  if(g.comp==1){
    printf("0\n");
    return 0;
  }
  if(df){
    g.print_uf();
    if(df)printf("flag:%d\n",flag);
  }
  int cnt,i;cnt=i=0;
  while(cnt<flag){
    auto x=vec.at(n-i-1);
    if(df)print(x);
    if(g.c_size(x.second)>1){
      ans-=x.first;
      g.uf[g.find(x.second)]++;
      if(df)printf("->%d\n",g.uf[g.find(x.second)]);
      cnt++;
    }
    i++;
  }
  printf("%ld\n",ans);
}

void print(auto& vec,string str){
  if(str!="") cout << str << ":";
  for(auto x: vec) {print(x); cout << " ";}
  cout << endl;
}

// pair 型の print (map 含む)
template<typename F,typename S>
void print(pair<F,S> x) {
  printf("(");
  print_item(x.first);
  printf(",");
  print(x.second);
  printf(")");
}

graph::graph(int n,int m,int origin){
  order=comp=n;
  adj.resize(n);
  uf.resize(n,-1);
  
  rep(i,m){
    int u,v;cin >>u >>v; u-=origin; v-=origin;
    adj.at(u).push_back(v);
    adj.at(v).push_back(u);
  }
}

// union_find
int graph::find(int a){
  if(uf[a]<0)return a;
  if(uf[uf[a]]<0)return uf[a];
  return uf[a]=find(uf[a]);
}

void graph::merge(int u,int v){
  u=find(u); v=find(v);
  if(u==v)return;
  comp--;
  if(uf[u]>uf[v])swap(u,v);
  uf[u]+=uf[v];
  uf[v]=u;
}
void graph::merge(){
  rep(u,order){
    for(int v:adj.at(u)) merge(u,v);
  }
}
void graph::print_uf(){
  rep(i,order){
    printf("%2d(%d) ",i,find(i));
    for(int v:adj.at(i)) cout << v << " ";
    if(i==find(i))printf("\t[%d]",c_size(i));
    printf("\n");
  }
  printf("cnt comp:%d\n",comp);
}

/// confirm df==0 ///


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const LL mod = 1e9+7;

LL modinv(LL x){
	LL m=mod, u=1, v=0;
	while(m){
		LL t=x/m;
		x-=t*m; swap(x,m);
		u-=t*v; swap(u,v);
	}
	u%=mod;
	if(u<0) u+=mod;
	return u;
}

int main(){
	int N;
	cin >> N;
	vector<LL> A(N);
	rep(i,N) cin >> A[i];
	LL sum=0;
	rep(i,N) (sum+=A[i])%=mod;
	LL ans=0;
	rep(i,N){
		ans+=(sum-A[i])*A[i]%mod;
		ans%=mod;
	}
	ans*=modinv(2);
	ans%=mod;
	while(ans<0) ans+=mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4844
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
//	   cin>>t;
      

	      while(t--)
{
	/*
	9
G W W G P W P G G*/
ll n;
cin>>n;

string s[n];
map<string ,ll > M;
fo(i,n)
{
	cin>>s[i];
M[s[i]]++;
  }  
  ll ans=0;
  fo(i,n)
  {
  	if(M[s[i]]>=1)
  	ans+=1;
  	M[s[i]]=0;
  }
  if(ans==3)
  cout<<"Three";
  else
  cout<<"Four";
ee;




}
return 0;
}















Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint cnt[100005];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = k; i >= 1; i--){
		llint num = k / i;
		cnt[i] = modpow(num, n);
		for(int j = 2*i; j <= k; j+=i){
			cnt[i] += mod - cnt[j];
			if(cnt[i] >= mod) cnt[i] -= mod;
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= k; i++){
		ans += i * cnt[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

int main()
{

        int n;
        cin >> n;
        long long sum = 0;
        int minv = 0;
        int maxv = 0;
        for (int i = 0; i < n; ++i) {
                int tmp;
                cin >> tmp;
                if (i == 0) {
                        minv = tmp;
                        maxv = tmp;
                }
                else {
                        minv = std::min(minv, tmp);
                        maxv = std::max(maxv, tmp);
                }
                sum += tmp;
        }
        cout << minv << " " << maxv << " " << sum << endl;


}



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


using namespace std;

typedef long long ll;




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


  int n;
  cin>>n;
  ll arr[n];
  char tmp[n];
  ll money=1000;
    ll stock=0;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  vector<ll>low,high;
  for(int i=0;i<n-1;i++)
  {
      if(arr[i]<arr[i+1] && (i==0 || arr[i-1]>=arr[i]))
      {
          tmp[i]='B';
      }


  }

  for(int i=1;i<n;i++)
  {
      if(arr[i]>=arr[i-1] && (i==n-1 || arr[i+1]<arr[i]))
      {
          tmp[i]='S';
      }


  }
  for(int i=0;i<n;i++)
  {
     if(tmp[i]=='B')
     {
         ll x = money/arr[i];
         money = money - x*arr[i];
         stock+=x;
     }
     else if(tmp[i]=='S')
     {
         money+=stock*arr[i];
         stock=0;
     }

  }
  cout<<money<<endl;

}


Measured memory_bytes: 3628
import java.util.Scanner;

class Main{
        public static void main(String[] args){
                Scanner scanner=new Scanner(System.in);
                int i=scanner.nextInt()-scanner.nextInt();
                if(i<0){
                        System.out.println(0);
                }else{
                        System.out.println(i);
                }
        }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner S = new Scanner(System.in);
		int N = S.nextInt();
		int M = S.nextInt();
		int[] A = new int[N];
		int[] A_num = new int[N];
		int[] B = new int[M];
		int answer = 0;
		
		for(int i = 0;i < N;i++){
			A[i] = S.nextInt();
		}
		
		for(int i = 0;i < M;i++){
			B[i] = S.nextInt();
		}
		
		for(int j = 0;j < M;j++){
			int s = B[j];
			for(int i = 0;i < N;i++){
				if(s >= A[i]){
					A_num[i]++;
					break;
				}
			}
		}
		
		int max = A_num[0];
		for(int i = 0;i < N;i++){
			if(max <= A_num[i]){
				max = A_num[i];
				answer = i + 1;
			}
		}
		
		/*
		for(int i = 0;i < N;i++){
			System.out.print(" "+A_num[i]);
		}
		
		System.out.println();
		*/
		
		System.out.println(answer);
		
	}

}

Measured memory_bytes: 25144
#C
n = int(input())
x = list(map(int, input().split()))
s = sum(x)
s = s / n
if s * 10 % 10 >= 5:
    s = int(s) + 1
else:
    s = int(s)

ans = 0
for i in x:
    ans += (i - s)** 2
print(ans)

Measured memory_bytes: 3060
a,b,c,d = map(int,input().split(' '))
count = 0
while(a > 0 and c > 0):
    count += 1
    if(count % 2 == 1):
        c -= b
    else:
        a -= d
if(a <= 0):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9172
#include <stdio.h>
#include <string.h>

int main(void) {
	char buff[200];
	int i, n, count, ismatch;
	count = 0;
	while(scanf("%s\n", buff)==1) {
		n = strlen(buff);
		ismatch = 1;
		for(i=0;i<n/2;i++){
			if(buff[i] != buff[n-i-1]){
				ismatch = 0;
				break;
			}
		}
		
		if(ismatch) {
			count ++;
		}
	}
	
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 544
#include<iostream>
#include<string>

using namespace std;

int main(){
    int N,M,*wcount,wacount=0,acount=0,*check,p;
    string S;
    cin >> N >> M;
    check = new int[N];
    wcount = new int[N];
    for(int i=0;i<N;i++){
        check[i] = 0;
        wcount[i] = 0;
    }
    for(int i=0;i<M;i++){
        cin >> p >> S;
        if(S == "WA"){
            if(check[p-1] == 0){
                wcount[p-1]++;
            }
        }else{
            check[p-1] = 1; 
        }
    }
    for(int i=0;i<N;i++){
        acount += check[i];
        if(check[i] == 1) wacount += wcount[i];
    }
    cout << acount << ' ' << wacount;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char c=getchar();
    int p=1;
    x=0;
    while(!isdigit(c)){
        if(c=='-')p=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<1)+(x<<3)+(c^'0');
        c=getchar();
    }
    x*=p;
}
const int maxn=100050;
struct edge{
    int to,next;
}e[maxn<<1];
map<int,int>ma;
int head[maxn],n,m,ans,p[maxn],tot,cnt,vec[maxn];
bool vis[maxn];
inline void add(int u,int v){
    e[++cnt].to=v;
    e[cnt].next=head[u];
    head[u]=cnt;
}
inline void dfs(int rt){
    vis[rt]=1;vec[++tot]=rt;ma[p[rt]]=1;
    for(register int i=head[rt];i;i=e[i].next){
        if(!vis[e[i].to]){
            dfs(e[i].to);
        }
    }
}
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(n);read(m);
    for(register int i=1;i<=n;++i){
        read(p[i]);
    }
    for(register int i=1;i<=m;++i){
        int x,y;
        read(x);read(y);
        add(x,y);
        add(y,x);
    }
    for(register int i=1;i<=n;++i){
        if(!vis[i]){
            tot=0;
            ma.clear();
            dfs(i);
            for(register int i=1;i<=tot;++i){
                if(ma[vec[i]])ans++;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 8704
"use strict";

var main = function main(input) {
  var args = input.split('\n');
  var H = parseInt(args[0].split(' ')[0], 10);
  var W = parseInt(args[0].split(' ')[1], 10);
  var S = [];

  for (var i = 0; i < H; i++) {
    S.push(args[i + 1]);
  }

  var result = Array.from(new Array(H), function () {
    return new Array(W).fill(0);
  });

  for (var _i = 0; _i < S.length; _i++) {
    var line = S[_i];

    for (var j = 0; j < line.length; j++) {
      if (line.charAt(j) == '#') {
        result[_i][j] = '#'; // 上に波及、一番上の時(i == 0)はやらない

        if (_i != 0) {
          var up = S[_i - 1]; // 左に波及、一番左の時(j == 0)はやらない

          if (j != 0) {
            if (up.charAt(j - 1) != '#') {
              result[_i - 1][j - 1]++;
            }
          } // 右に波及、一番右の時(j == W - 1)はやらない


          if (j != W - 1) {
            if (up.charAt(j + 1) != '#') {
              result[_i - 1][j + 1]++;
            }
          } // 真ん中に波及


          if (up.charAt(j) != '#') {
            result[_i - 1][j]++;
          }
        } // 下に波及、一番下の時(i == H - 1)はやらない


        if (_i != H - 1) {
          var down = S[_i + 1]; // 左に波及、一番左の時(j == 0)はやらない

          if (j != 0) {
            if (down.charAt(j - 1) != '#') {
              result[_i + 1][j - 1]++;
            }
          } // 右に波及、一番右の時(j == W - 1)はやらない


          if (j != W - 1) {
            if (down.charAt(j + 1) != '#') {
              result[_i + 1][j + 1]++;
            }
          } // 真ん中に波及


          if (down.charAt(j) != '#') {
            result[_i + 1][j]++;
          }
        } // 左右に波及
        // 左に波及、一番左の時(j == 0)はやらない


        if (j != 0) {
          if (line.charAt(j - 1) != '#') {
            result[_i][j - 1]++;
          }
        } // 右に波及、一番右の時(j == W - 1)はやらない


        if (j != W - 1) {
          if (line.charAt(j + 1) != '#') {
            result[_i][j + 1]++;
          }
        }
      }
    }
  }

  result.forEach(function (elem) {
    return console.log(elem.join(''));
  });
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 7500
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();

    for (int i = 0; i < k; i++) {
      if (b>=c) {
        c*=2;
      } else if (a>=b) {
        b*=2;
      }
      if(a<b && b<c) {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");

  }

}


Measured memory_bytes: 35800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int n, m;
map<int, pii> mp;
int d[50][50];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int dd[50][50]; fill_n(*dd, 50 * 50, inf);
    rep(i, m) { int a, b; cin >> a >> b; a--; b--; dd[a][b] = 1; dd[b][a] = 1; mp[i] = {a, b}; }
    int ans = 0;
    rep(l, m) {
        dd[mp[l].F][mp[l].S] = inf;
        dd[mp[l].S][mp[l].F] = inf;
        rep(i, n) rep(j, n) d[i][j] = dd[i][j];
        // cout << endl; rep(i, n) { rep(j, n) cout << d[i][j] << " "; cout << endl; }
        rep(k, n) rep(i, n) rep(j, n) {
            if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
        }
        rep3(i, 1, n) if (d[0][i] == inf) { ans++; break; }
        // cout << endl; rep(i, n) { rep(j, n) cout << d[i][j] << " "; cout << endl; }
        dd[mp[l].F][mp[l].S] = 1;
        dd[mp[l].S][mp[l].F] = 1;
    }
    out(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll n, k;
    std::cin >> n >> k;
    if(n == k){
        std::cout << 0 << std::endl;
        return 0;
    }

    if(n < k){
        std::cout << std::min(k - n, n) << std::endl;
    }else{
        ll cnt = n / k;
        std::cout << std::min(std::abs(n - cnt * k), std::abs(n - (cnt + 1) * k)) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
	int num;
	struct node *next;
};

struct person{
	int label;
	struct node *friend;
	struct node *block;
};

void reg_friend(int m, struct person *p){
	int a, b;
	struct node *tmp;
	int i;

	for(i=0; i<m; i++){
		scanf("%d %d", &a, &b);
		a--;
		b--;
		tmp = (struct node *)malloc(sizeof(struct node));
		tmp->num = b;
		tmp->next = p[a].friend;
		p[a].friend = tmp;
		tmp = (struct node *)malloc(sizeof(struct node));
		tmp->num = a;
		tmp->next = p[b].friend;
		p[b].friend = tmp;
	}
}

void reg_block(int k, struct person *p){
	int a, b;
	struct node *tmp;
	int i;

	for(i=0; i<k; i++){
		scanf("%d %d", &a, &b);
		a--;
		b--;
		tmp = (struct node *)malloc(sizeof(struct node));
		tmp->num = b;
		tmp->next = p[a].block;
		p[a].block = tmp;
		tmp = (struct node *)malloc(sizeof(struct node));
		tmp->num = a;
		tmp->next = p[b].block;
		p[b].block = tmp;
	}
}

int dfs(struct person p[], int i, int label){
	struct node *head = NULL;
	struct node *tmp, *b, *c;
	int cnt = 1;

	p[i].label = label;
	tmp = (struct node *)malloc(sizeof(struct node));
	tmp->num = i;
	tmp->next = head;
	head = tmp;
	while(head != NULL){
		b = head;
		head = head->next;
		for(c=p[b->num].friend; c!=NULL; c=c->next){
			if(p[c->num].label == -1){
				p[c->num].label = label;
				tmp = (struct node *)malloc(sizeof(struct node));
				tmp->num = c->num;
				tmp->next = head;
				head = tmp;
				cnt++;
			}
		}
	}

	return cnt;
}

int main(){
	int n, m, k;
	struct person *p;
	struct node *q;
	int i;
	int *size;
	int cnt, now_label = 0;

	scanf("%d %d %d", &n, &m, &k);

	p = (struct person *)malloc(sizeof(struct person) * n);
	size = (int *)malloc(sizeof(int) * n);
	for(i=0; i<n; i++){
		p[i].label = -1;
		p[i].friend = NULL;
		p[i].block = NULL;
	}

	reg_friend(m, p);
	reg_block(k, p);

	for(i=0; i<n; i++){
		if(i != 0){
			printf(" ");
		}

		if(p[i].label != -1){
			cnt = size[p[i].label];
			for(q=p[i].friend; q!=NULL; q=q->next){
				cnt--;
			}
			for(q=p[i].block; q!=NULL; q=q->next){
				if(p[q->num].label == p[i].label){
					cnt--;
				}
			}
			cnt--;
			printf("%d", cnt);
			continue;
		}

		size[now_label] = dfs(p, i, now_label);
		cnt = size[now_label];
		now_label++;
		for(q=p[i].friend; q!=NULL; q=q->next){
			cnt--;
		}
		for(q=p[i].block; q!=NULL; q=q->next){
			if(p[q->num].label == p[i].label){
				cnt--;
			}
		}
		cnt--;
		printf("%d", cnt);
	}

	return 0;
}


Measured memory_bytes: 18816
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const double PI = acos(-1);


int main (){
    int n;
    string s, t, ans;
    cin >> n >> s >> t;

    for (int i=0; i<n; i++){
        ans+=s[i];
        ans+=t[i];
    }

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	h := make([]int, n)
	for i:=range h {
		fmt.Scan(&h[i])
	}
	g := make([]int, n-1)
	if n == 1 {
		fmt.Println(h[0])
		return
	}

	for i:=1;i<n;i++ {
		if h[i-1] <= h[i] {
			g[i-1] = 1
		} else {
			g[i-1] = -1
		}
	}
	var ans int
	if g[0] == -1 {
		ans = h[0]
	} else {
		ans = 0
	}
	for i:=1;i<n-1;i++ {
		if g[i-1] == -1 && g[i] == 1 {
			ans -=  h[i]
		} else if g[i-1] == 1 && g[i] == -1 {
			ans += h[i]
		}
		if g[i] == 1 && i == n-2 {
			ans += h[n-1]
		}
	}

	fmt.Println(ans)
}

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

int main()
{
	int n; cin >> n;
	long long ans = 0;
	vector<long long>a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i = n - 1; i >= 0; i--) {
		if ((a[i]+ans)%b[i])ans += ((a[i]+ans) / b[i] + 1)*b[i] - a[i]-ans;
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <vector>

class Search {
	int a,b;
	//int n;
	std::vector<std::vector<bool>> searched_point;

public:
	int count;
	void set_searched_point(int n_a, int n_b);
	void prohibit(int n);
	bool pass_search(int x,int y);

};

void Search::set_searched_point(int n_a, int n_b) {

	a = n_a;
	b = n_b;
	count = 0;

	searched_point.resize(a + 1);

	for (int i = 0; i < a + 1; ++i) {
		searched_point[i].resize(b + 1);
	}

	for (int i = 0; i < a + 1; ++i){
		for (int j = 0; j < b+1; ++j){
			searched_point[i][j] = false;
		}
	}

	return;
}

void Search::prohibit(int n) {

	int p_x, p_y;//prohibit point

	for (int i = 0; i < n; ++i){
		std::cin >> p_x >> p_y;
		searched_point[p_x][p_y] = true;
	}

	return;
}

bool Search::pass_search(int x,int y) {

	if (searched_point[x][y] == true) {
		return true;
	}
	else if (x == a && y == b) {
		++count;
		return true;
	}
	else if (x == a) {
		pass_search(x, y + 1);
	}
	else if (y == b) {
		pass_search(x + 1, y);
	}
	else {
		pass_search(x + 1, y);
		pass_search(x, y + 1);
	}

}

int main() {

	int a,b;
	int n;
	Search se;

	while (true){

		std::cin >> a >> b;

		if (a == 0 && b == 0){
			break;
		}
		else {
			se.set_searched_point(a, b);
		}

		std::cin >> n;

		se.prohibit(n);
		se.pass_search(1, 1);

		std::cout << se.count << std::endl;
	}

	return 0;
}

Measured memory_bytes: 2988
#include "bits/stdc++.h"
using namespace std;

struct node {
    int time, point, kind;
    bool operator<(const node &p) const {
        return time < p.time;
    }
};

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<node> v;
    for (int i = 0; i < n; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        v.push_back({ s - x, x, 1 });
        v.push_back({ t - x, x, 0 });
    }
    sort(v.rbegin(), v.rend());
    multiset<int> sp;
    for(int i = 0; i < q; i++) {
        int d;
        cin >> d;
        while (!v.empty() && v.back().time <= d) {
            if (v.back().kind) sp.insert(v.back().point);
            else sp.erase(sp.find(v.back().point));
            v.pop_back();
        }
        cout << (sp.empty() ? -1 : *sp.begin()) << '\n';
    }
}

Measured memory_bytes: 16748