akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/abc175/tasks/abc175_d
# ダブリングで解く
# K>ループ長の場合、累積の最後の値が負ならmaxを取ればいいし、正ならば 累積の最後の値*周数をかけてから計算
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations, accumulate
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N, K = ints()
P = mina(*ints())
C = ints()

next = [[-1] * N for _ in range(32)]  # next[k][i] ノードiから2^k回移動するときのノード
score = [[0] * N for _ in range(32)]  # score[k][i] ノードiから2^k回移動するときに加算されるスコア
# nextの構築
next[0] = P
for k in range(31):
    for i in range(N):
        next[k + 1][i] = next[k][next[k][i]]
# scoreの構築
for i in range(N):
    score[0][i] = C[P[i]]
for k in range(31):
    for i in range(N):
        score[k + 1][i] = score[k][i] + score[k][next[k][i]]


# これじゃ道中がわからない...
# 一点しか求まらない
def get_score(i, k):  # 途中の1点のscoreを算出
    now = i
    ret = 0
    for j in range(k.bit_length()):
        if (k >> j) & 1:
            ret += score[j][now]
            now = next[j][now]
    return ret, now


# 各ノードからK回移動したときのscoreを計算する
ans = -10**10
for i in range(N):
    # print(i, 'について')
    if K <= N:
        # 素直に最初からK回シミュレーションする
        tmp = 0
        now = i
        for _ in range(K):
            tmp += score[0][now]
            now = next[0][now]
            ans = max(tmp, ans)
            # print(tmp)
    else:
        # 最初からN回シミュレーション + K-NからN回シミュレーション
        tmp = 0
        now = i
        for j in range(N):
            tmp += score[0][now]
            now = next[0][now]
            ans = max(tmp, ans)
            # print(tmp)

        tmp, now = get_score(i, K - N)
        for j in range(N):
            tmp += score[0][now]
            now = next[0][now]
            ans = max(tmp, ans)
            # print(tmp)


print(ans)


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

using namespace std;

const int M = 100007;
long long D[M];

int main() {
  for (int i = 1; i < M; i++) D[i] = 1e18;
  int N, W, w, v;
  scanf("%d%d", &N, &W);
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", &w, &v);
    for (int j = 1000 * i; j >= v; j--) {
      D[j] = min(D[j], D[j - v] + w);
    }
  }
  long long r;
  for (int i = 0; i < M; i++) {
    if (D[i] <= W) {
      r = i;
    }
  }
  printf("%lld", r);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int H, W, D, A;
int Q, L, R;
int px[90001], py[90001];
int d[90001];

int main(void) {
    cin >> H >> W >> D;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> A;
            px[A] = i, py[A] = j;
        }
    }

    for (int i = D + 1; i <= H * W; ++i) {
        d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
    }

    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        cin >> L >> R;
        cout << d[R] - d[L] << endl;
    }
    return 0;
}

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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
char festival[500];
char curr;
int init()
{
int i;
i=0;
	while(curr != 10)
	{
		scanf("%c",&curr);
		festival[i]=curr;
		i++;
	}
return i;
}

int output(int i)
{
int j;
for(j=0;j<i-9;j++)
	printf("%c",festival[j]);
return 0;
}

int main(int argc, char *argv[]) 
{
int i;
i = init();
output(i);
return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N = int(input())
if N == 1:
    print("Hello World")
    exit()
else:
    A = int(input())
    B = int(input())
    print(A+B)


Measured memory_bytes: 38512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll K,ans=1,P=7;
  cin>>K;
  
  REP(i,100000000){
    if(P%K==0){
      co(ans);
      return 0;
    }
    ans++;
    P=(P*10+7)%K;
  }
  co(-1);
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
void fast(){
cin.tie(0);
cin.sync_with_stdio(0);
}
int main()
{
    fast();
 int n;
 cin>>n;
 vector<string>v;
 for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(i !=0){string ss=v[v.size()-1];
    if(s[0] != ss[ss.size()-1])
        {cout<<"No"; return  0;}}
    for(int i=0;i<v.size();i++)
    {
        if(v[i]==s)
            {cout<<"No"; return 0;}
    }
    v.push_back(s);
 }
 cout<<"Yes";
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5)

N = int(input())

C = [-1] * N  # Colors
E = [[] for _ in range(N)]  # Edges
swap = {0: 1, 1: 0}


def coloring(v, c):
    C[v] = c
    for e in E[v]:
        if C[e[0]] == -1:
            coloring(e[0], c if e[1] % 2 == 0 else swap[c])


for i in range(N - 1):
    u, v, w = map(int, input().split())
    E[u - 1].append((v - 1, w))
    E[v - 1].append((u - 1, w))

coloring(0, 0)

for c in C:
    print(c)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 017_agc_b / Link: https://agc017.contest.atcoder.jp/tasks/agc017_b?lang=en  ----- */
/* ------問題------

N 個のマスが一列に並んでいます． 一番左のマスには整数 A が，一番右のマスには整数 B が書かれており，他のマスには何も書かれていません．
青橋君は，何も書かれていないマスに整数を書き込み，次の条件を満たすようにしたいです：
どの隣接する 2 マスについても，書かれている整数の差は C 以上 D 以下である．
青橋君は，この条件を満たす限り，いくらでも大きい整数や小さい整数を書き込むことができます． 青橋君が条件を満たすように整数を書き込むことができるかを判定してください．

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, A, B, C, D;

LL ans = 0LL;

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

	cin >> N >> A >> B >> C >> D;
	if (A > B)swap(A, B);
	if (C > D)swap(C, D);
	FOR(i, 0, N - 1) {
		{
			LL up = i*D - (N - i - 1)*C + A;
			LL down = i*C - (N - i - 1)*D + A;
			if (down <= B&&B <= up)ans = 1;
		}
		{
			LL up = -(i*D - (N - i - 1)*C) + A;
			LL down = -(i*C - (N - i - 1)*D) + A;
			if (down <= B&&B <= up)ans = 1;
		}
	}

	cout <<(ans?"YES":"NO") << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#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
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a;cin>>a;
  cout<<(a-1)*(a)/2;
}


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

char s[100010];
int a[100010], p[100010];

int main(){
	int n; scanf("%d%s", &n, s);
	for (int i = 0; i < n; i++){
		p[i] = s[i] == 'x';
	}
	p[n] = p[0];
	for (a[0] = 0; a[0] < 2; a[0]++){
		for (a[1] = 0; a[1] < 2; a[1]++){
			for (int i = 2; i <= n + 1; i++){
				a[i] = a[i - 2] ^ (p[i - 1] ^ a[i - 1]);
			}
			if (a[n] == a[0] && a[n + 1] == a[1]){
				for (int i = 0; i < n; i++){
					printf(a[i] ? "W" : "S");
				}
				printf("\n");
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
}

Measured memory_bytes: 256
from inspect import currentframe


def debug_print(s):
    # print(s)
    return


def debug_key(*args):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    debug_print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))


def solve(H, stone):
    debug_print("\n-----solve-----")
    debug_key(stone)

    ans = -1
    tmp = 1
    while tmp:
        ans += tmp
        tmp = 0
        erase = [set() for _ in range(5)]
        for i in range(H):
            for j in range(1, 4):
                if stone[i][j - 1] == stone[i][j] == stone[i][j + 1]:
                    for k in range(j - 1, j + 2):
                        erase[k].add(i)
        stone2 = list(map(list, zip(*stone)))
        for j in range(5):
            for i in sorted(erase[j], reverse=True):
                tmp += stone[i][j]
                del stone2[j][i]
            stone2[j] = [0] * len(erase[j]) + stone2[j]
        stone = list(map(list, zip(*stone2)))
    print(ans)

    return


if __name__ == '__main__':

    while True:
        H_input = int(input())
        if H_input == 0:
            break
        stone_input = [list(map(int, input().split())) for _ in range(H_input)]
        solve(H_input, stone_input)




Measured memory_bytes: 7516
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 200020
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = 2.0 * acos(0.0);
const int BLOCK = 333;

int dp[MAXN], peso[MAXN], N, K;

int solve(int i)
{
	if(dp[i] != -1) return dp[i];
	if(i == N) return dp[i] = 0;

	dp[i] = INF;

	for(int j = 1; j <= K && i + j <= N; j++)
		dp[i] = min(dp[i], abs(peso[i] - peso[i + j]) + solve(i + j));

	return dp[i];
}

int main(int argc, char const *argv[])
{
	optimize;
	
	memset(dp, -1, sizeof dp);

	cin >> N >> K;

	for(int i = 1; i <= N; i++)
		cin >> peso[i];

	cout << solve(1) << endl;

	return 0;
}

Measured memory_bytes: 12524
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n,q;
  cin>>n>>q;
  vector<int>v[n];// n sonkhok vector/array v ache//v[0] te element...v[1]..e..onk elements
  while(q--){
    int a,b,c;//a = query type//b=position
    cin>>a>>b;
    if(!a){//a=0=push_back
      cin>>c;
      v[b].push_back(c);//just end e add hoche b no vector er
    }
    else if(a==1){
      r(i,(int)v[b].size()){//printing element 0 to b
        if(i)
            cout<<' ';
            cout<<v[b][i];//b no vector e jotogulo element ache sob
      }
      cout<<endl;
    }
    else

        v[b].clear();
  }


  return 0;
}



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

vector<bool> ok;
bool comp(P a, P b) {
  return a.second > b.second;
}
int main(){
  int N;
  cin >> N;
  vector<P> red(N),blue(N);
  ok.resize(N,false);
  rep(i,N) {
    int a,b;
    cin >> a >> b;
    red[i] = make_pair(a,b);
  }
  sort(red.begin(),red.end(),comp);
  rep(i,N) {
    int c,d;
    cin >> c >> d;
    blue[i] = make_pair(c,d);
  }
  sort(blue.begin(),blue.end());
  int res = 0;
  rep(i,N) {
    int a = red[i].first, b = red[i].second;
    rep(j,N) {
      int c = blue[j].first, d = blue[j].second;
      if(!ok[j] && a < c && b < d) {
        ok[j] = true;
        res++;
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in xrange(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                peaks.append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            else:
                peaks.append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        else:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print(max(peaks))

N,L = map(int,raw_input().strip().split())
ices = []
while True:
    ice = int(raw_input().strip())
    ices.append(ice)
    if len(ices) == N:
        break

orderN(N,L,ices)

Measured memory_bytes: 12512
number_4 = []
number_7 = []

for i in range(101):
    if i % 4 == 0:
        number_4.append(i)
    if i % 7 == 0:
        number_7.append(i)

n = int(input())

found = False
for i in range(len(number_4)):
    if found:
        break
    if n < 4:
        break
    for j in range(len(number_7)):
        if number_4[i] + number_7[j] == n:
            found = True
            break

if found:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int ans=(a+b)/2;
    
 	if(a%2!=b%2){
    		System.out.println("IMPOSSIBLE");
    	}else{

    	System.out.println(ans);
    }
    }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;
int c[20],a[20][20],val[20],inf = 1000000000;
int main(){
    int i,j,k,m,n,x;
    cin >> n >> m >> x;
    for(i=0;i<n;i++){
        cin >> c[i];
        for(j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int ans = inf;
    for(i=0;i<(1<<n);i++){
        int cost = 0;
        for(j=0;j<m;j++) val[j] = 0;
        for(j=0;j<n;j++){
            if(i & (1<<j)){
                cost += c[j];
                for(k=0;k<m;k++){
                    val[k] += a[j][k];
                }
            }
        }
        bool flag = true;
        for(j=0;j<m;j++){
            if(val[j]<x) flag = false;
        }
        if(flag){
            ans = min(ans,cost);
        }
    }
    if(ans==inf) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int Q=stdIn.nextInt();
		int A[]=new int[N];
		boolean key[]=new boolean[N];
		int a[][]=new int[Q][4];
		boolean fin=true;
		int now=N-1,cout=0;
		long max=0;
		for(int i=0;i<Q;i++){
			a[i][0]=stdIn.nextInt()-1;
			a[i][1]=stdIn.nextInt()-1;
			a[i][2]=stdIn.nextInt();
			a[i][3]=stdIn.nextInt();
		}
		A[0]=0;A[N-1]=-1;
		while(fin){
			for(int i=0;i<N;i++){
				if(i==N-1){
					if(key[i])
						A[i]++;
					else{
						key[i]=true;
						A[i]=A[i-1];
					}
					if(A[i]==M-1){
						key[i]=false;
						if(now==i)
							now--;
					}
				}
				else
					if(i==now){
						if(key[i])
							A[i]++;
						else{
							key[i]=true;
							if(i!=0)
								A[i]=A[i-1];
						}
						if(A[i]==M-1){
							if(i==0){
								fin=false;
								break;
							}
							key[i]=false;
							now--;
						}
						else
							now++;
					}
			}
			long sum=0;
			for(int i=0;i<Q;i++){
				if(A[a[i][1]]-A[a[i][0]]==a[i][2])
					sum+=a[i][3];
			}
			if(sum>max)
				max=sum;
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 38676
#include<stdio.h>
int main(void){
    int H, W, i, j;
    char mark[] = {'#', '.'};
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0){return 0;}
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                printf("%c", mark[(i + j) % 2]);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
  int N;
  double D;
  cin >> D >> N;
  double a = pow(100.0, D);
  int ans;
  if (N <= 99)
    ans = a * N;
  else if (N = 100)
    ans = 101 * a;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int a, b, c;
	cin >> a >> b >> c;
	int extra = (a - b);
	c -= extra;
	c = max(c, 0LL);
	cout << c;
	return 0;
}

Measured memory_bytes: 256
def selectionSort(a, n)
  count = 0
  for i in 0..n-1
    minj = i
    for j in i..n-1
      minj = j if a[j] < a[minj]
    end
    if i != minj then
      a[i], a[minj] = a[minj], a[i]
      count+=1
    end
  end
  puts a.join(" ")
  puts count
end

n = gets.to_i
a = gets.split.map(&:to_i)
selectionSort(a, n)

Measured memory_bytes: 8664
#include<stdio.h>
#define M 100000

int main(void){
  int i,j;
  int n,ans;
  int num[M];

  num[0]=0;
  for(i=1;i<M;i++)
    num[i]=1;
  for(i=1;i<M;i++)
    if(num[i]==1)
      for(j=i+i+1;j<M;j+=i+1)
        num[j]=0;

  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;

    ans=0;
    for(i=1;i<n/2;i++)
      if(num[i] && num[n-i-2])
        ans++;

    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    string S;
    cin >> S;
    
    size_t size = S.size();
    
    //01をいっぱい作る
    string trueans = "01";
    for(int i=0;i<size;i++){
        trueans = trueans+"01";
    }
    int ans = 0;
    if(S[0]=='0'){
        for(int i=0;i<size;i++){
            if(S[i]!=trueans[i]){
                ans++;
            }
        }
    }else{
        for(int i=0;i<size;i++){
            if(S[i]!=trueans[i+1]){
                ans++;
            }
        }
    }
        cout << ans << endl;
        return 0;
    }


Measured memory_bytes: 1472
#include<iostream>
using namespace std;
using ll = long long;

int digit(ll x) {
  int res=1;
  while(x/10!=0) {
    res++;
    x/=10;
  }
  return res;
}

int main() {
  ll N;
  int ans=10;
  cin>>N;
  for (ll i=1;i*i<=N;i++) {
    if (N%i == 0) {
      ans = min(ans, digit(N/i));
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
  string s;
  cin >> s;
  int64_t a=0, count=0, n = s.size();
  for(int i = 0; i<n; i++){
    count += ctoi(s.at(i));
  }
  string ans;
  if(count == 0){
    ans = "Yes";
    cout << ans << endl;
    return 0;
  }else if(count % 9 ==0){
    ans = "Yes";
  }else{
    ans = "No";
  }
  cout << ans << endl;
}

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

using namespace std;


int main() {

  int n;
  vector<int> data;
  int key;

  vector<int> next;
  int l,h,m;
  int count;

  int temp;


  while(cin >> n) {

    if(n==0) break;

    data.clear();

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

      int tmp;

      cin >> tmp;

      data.push_back(tmp);

    }

    //for(int i=0;i<n;i++) cout << data[i] << " ";

    cin >> key;

    count=0;

    l=0;

    h=n-1;

    while(l<=h) {

      count++;

      m=(l+h)/2;

      if(key==data[m]) break;

      else if(key<data[m]) h=m-1;

      else l=m+1;

    }

    cout << count << endl;

  }

  return 0;

}

      

      

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

int main() {
    int N, M, a, b;
    int c[50] = {};
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        c[a-1]++;
        c[b-1]++;
    }
    for (int i = 0; i < N; i++) {
        cout << c[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<array>
#include<algorithm>

int main(){

    size_t n;
    std::cin >> n;

    std::array<std::array<std::array<size_t, 10>, 3>, 4> ar = {};

    for(size_t i = 0; i < n; i++){
        size_t b, f, r;
        int v;
        std::cin >> b >> f >> r >> v;

        ar[b - 1][f - 1][r - 1] += v;
    }

    for(size_t i = 0; i < ar.size(); i++){
        for(size_t j = 0; j < ar[i].size(); j++){
            for(size_t k = 0; k < ar[i][j].size(); k++){
                std::cout << ' ' << ar[i][j][k];
            }std::cout << std::endl;
        }

        if(i + 1 != ar.size()){
            for(size_t j = 0; j < 20; j++){
                std::cout << '#';
            }std::cout << std::endl;    
        }
    }

    return 0;
}



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

using namespace std;

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

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

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

const ll MAX = 15000;

ll A[100][100];
ll B[100][100];

bool dp[85][85][MAX];

int main() {
    ll H, W;
    cin >> H >> W;
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
        }
    }
    REP(i, H) {
        REP(j, W) {
            cin >> B[i][j];
        }
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0][abs(A[0][0] - B[0][0])] = true;
    REP(i, H) {
        REP(j, W) {
            ll d = abs(A[i][j] - B[i][j]);
            REP(n, MAX) {
                if (i > 0 && dp[i - 1][j][n]) {
                    //! 上
                    if (abs(n - d) < MAX)
                        dp[i][j][abs(n - d)] = true;
                    if (n + d < MAX)
                        dp[i][j][n + d] = true;
                }
                if (j > 0 && dp[i][j - 1][n]) {
                    //! 左
                    if (abs(n - d) < MAX)
                        dp[i][j][abs(n - d)] = true;
                    if (n + d < MAX)
                        dp[i][j][n + d] = true;
                }
            }
        }
    }

    REP(i, MAX) {
        if (dp[H - 1][W - 1][i]) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 106240
x1, y1, x2, y2 = map(int, input().split())

dx = x2-x1
dy = y2-y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#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;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

using ll = long long;

bool leftestleqt(ll n,ll S,int t){	//t+1,t+1,...
	ll num = 9;
	rep(i,t) num *= 10;
	t++;
	while(n){
		if(n>num){
			n-=num;
			S-=num*t;
			num*=10;
			t++;
		}else{
			S-=n*t;
			n=0;
		}
	}
	if(S<0) return 1;
	return 0;
}
bool ok(ll S){
	for(ll t = 1,num=9;;t++,num*=10){
		if(S>t*num){
			S-=t*num;
		}else{
			if(S%t==0) return 1;
			return 0;
		}
	}
}
mint ten(ll x){
	mint r = 1;
	mint t = 10;
	while(x){
		if(x&1) r*=t;
		t*=t;
		x>>=1;
	}
	return r;
}
int main(){
	ll S;
	cin>>S;
	mint ans = 0;
	for(ll n=1;;n++){
		if(leftestleqt(n,S,6)) break;
		if(S%n==0){
			ans += (ten(S/n-1)*9 - n+1);
		}else{
			ans += 1;
		}
	}
	ll pre = 0;
	for(ll l=1;l<1000000;l++){
		if(ok(pre+S)) ans += 1;
		pre += to_string(l).size();
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
d = 120000
j = -1
for i in range(N):
	temp = T-H[i]*0.006
	if abs(A-temp) < d :
		j = i
		d = abs(A-temp)

print(j+1)

Measured memory_bytes: 3064
from sys import stdin

def main():
    n = int(input())
    A = [int(x) for x in stdin.readline().rstrip().split()]

    m = 10 ** 9 + 7
    s = 0
    b_sum = sum(A)
    for i in range(len(A)-1):
        b_sum = b_sum -A[i]
        rest = b_sum % m
        ans = A[i] * rest % m
        s += ans

    s = s % m
    print(s)
    
if __name__ == "__main__":
    main()

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

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

  string P_str = "";
  for (int i = 0; i < N; i++){
    int p;
    cin >> p;
    P_str += to_string(p);
  }
  string Q_str = "";
  for (int i = 0; i < N; i++){
    int q;
    cin >> q;
    Q_str += to_string(q);
  }

  vector<int> v;
  for (int i = 1; i <= N; i++){
    v.emplace_back(i);
  }

  int cnt = 0;
  int p_cnt = 0;
  int q_cnt = 0;
  do {
    cnt++;

    string chk_str = "";
    for (int num: v) {
      chk_str += to_string(num);
    }

    if (chk_str == P_str) {
      p_cnt = cnt;
    }
    if (chk_str == Q_str) {
      q_cnt = cnt;
    }

    if ( 0 < p_cnt && 0 < q_cnt ) {
      break;
    }

  } while (next_permutation(v.begin(), v.end()));

  cout << abs(p_cnt - q_cnt) << endl;
}


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

int main() {
  long H, W;
  cin >> H >> W;
  
  if((H == 1) || (W == 1)) cout << 1 << endl;
  else {
    if(H % 2 == 0) cout << H * W / 2 << endl;
    else cout << (H - 1) * W / 2 + (W + 1) / 2 << endl;
  }
  
}

Measured memory_bytes: 256
<?php
// D
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
for ($i = 0; $i < $n; $i++) {
    if (isset($cnt[$a[$i]])) {
        $cnt[$a[$i]]++;
    } else {
        $cnt[$a[$i]] = 1;
    }
}
$kumi_sum = 0;
foreach ($cnt as $i => $v) {
    $kumi_sum += $v * ($v - 1) / 2;
}
for ($i = 0; $i < $n; $i++) {
    $ans[] = $kumi_sum - ($cnt[$a[$i]] - 1);
}
echo implode(PHP_EOL, $ans);

Measured memory_bytes: 36840
n,m = map(int, input().split())
x = [int(y) for y in input().split()]
x.sort()
if n >= m:
    print('0')
else:
    y = []
    for i in range(m-1):
        y.append(x[i+1]-x[i])

    y.sort()

    ans = sum(y)

    for i in range(n-1):
        ans -= y[-(i+1)]


    print(ans)



Measured memory_bytes: 13960
#include <iostream>
using namespace std;
int main(){
int n;
int m;
int c;
int d;
while(cin >>n){
cin >>m;
if(n==0){break;}
int a[n];
int b[m];
c=0;
while(c<n){
cin >>a[c];
c=c+1;}
c=0;
while(c<m){
cin >>b[c];
c=c+1;}
d=0;
c=0;
while(c<m){
d=d+b[c];
if(d>=n-1){break;}
d=d+a[d];
if(d>=n-1){break;}
c=c+1;}
cout <<c+1<<endl;}}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
   int n;
    string s;
    cin >> n >> s;
    
    int ans = 0;
    
    for(int i = 1; i < n; i++) {
        int count = 0;
        
        for(char c = 'a'; c <= 'z'; c++){
            bool left = false;
            bool right = false;
            
            for(int j = 0; j < i; j++) {
            if(s[j] == c){
            left = true;
            }
        }
        
        for(int j = i; j < n; j++) {
        if(s[j] == c){
            right = true;
        }
        }
        
        if(left && right) {
            count++;
        }
    
     ans = max(ans,count);
    
}
    }
    cout << ans;
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int,input().split()))
A.append(2)
mi = 2
mx = 2
for i in range(N-1,-1,-1):
    # A[i]人に分けた結果 mi ~ mx人が残った
    mi = (mi + A[i] - 1) // A[i] * A[i]
    mx = mx // A[i] * A[i]
    if mi > mx:
        print(-1)
        exit(0)
    mx += A[i] - 1
print(mi,mx)


Measured memory_bytes: 63984
#include<iostream>
using namespace std;
int main(int argc, char* argv[])
{
    int a, b, c = 0;
    bool IsPoor = 0;
    cin >> a >> b >> c;
    if (a == b) {
        if (b == c) {
            IsPoor = 0;
        }
        else {
            IsPoor = 1;
        }
    }
    else if (b == c) {
        IsPoor = 1;
    }
    else if (a == c) {
        IsPoor = 1;
    }
    if (IsPoor) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a[200][3],n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<n-1;j++){
            bool f=false;
            for(int k=j+1;k<n;k++){
                if(a[j][i]==a[k][i]){
                    f=true;
                    a[k][i]=0;
                }
            }
            if(f)a[j][i]=0;
        }
    }
    for(int i=0;i<n;i++){
        int p=0;
        for(int j=0;j<3;j++){
            p+=a[i][j];
        }
        cout<<p<<endl;
    }

    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

double f(double a){
    return a * acos(-1) / 180;
}
int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    complex<double> hd = polar(a, f(30 * h + 0.5 * m));
    complex<double> md = polar(b, f(6 * m));
    cout << fixed << setprecision(10) << abs(hd - md) << endl;
}



Measured memory_bytes: 4096
# Your code here!
a,b,c,d=gets.split
a=a.to_i
b=b.to_i
c=c.to_i
d=d.to_i


ss=[8*a,4*b,2*c,d].min
tt=[8*a,4*b,2*c,d].sort[1]

e=gets.to_i


if ss==8*a
    puts  4*a*e
elsif ss==4*b
 puts 2*b*e
 
 elsif ss==2*c
  puts e*c
  
  
 else
 
 
puts (e/2)*ss+(e%2)*(tt/2)
     
     
     
     
end    
     

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int O = 1e6 + 5;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}

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

using namespace std;

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (1) {
    if (cur==nil) {
      break;
    }
    if (isf++>0) {
      printf(" ");
    }
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node *listSearch(int key) {
  Node *cur = nil->next;
  while (cur!=nil && cur->key!=key) {
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t) {
  if (t==nil) {
    return;
  }
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

int main() {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for (i=0; i<n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key);
    } else if (com[0] == 'd') {
      if (strlen(com)>6) {
        if (com[6] == 'F') {
          deleteFirst();
        } else if (com[6] == 'L') {
          deleteLast();
        }
      } else {
        deleteKey(key);
      }
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 33928
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1e9+7
using namespace std;
typedef long long ll;
 
int main(){
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<ll> a(X),b(Y),c(Z);
 
    rep(i,X)cin>>a[i];sort(a.begin(),a.end(),greater<ll>());
    rep(i,Y)cin>>b[i];sort(b.begin(),b.end(),greater<ll>());
    rep(i,Z)cin>>c[i];sort(c.begin(),c.end(),greater<ll>());
 
    vector <ll> vec;
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            for(int k =0;k<Z;k++){
                if((i+1)*(j+1)*(k+1)<=K)vec.push_back(a[i]+b[j]+c[k]);
                else break;
            }
        }
    }
    sort(vec.begin(),vec.end(),greater<ll>());
    for(int i=0;i<K;i++){
        cout<<vec[i]<<endl;
    }
}

Measured memory_bytes: 1404
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: i64);
    let mut tot: i64 = 0;
    for a in 1..=n {
        tot += (n - 1) / a;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int popcount(ll x) {
  int res = 0;
  while (x > 0) {
    res++;
    x &= x - 1;
  }
  return res;
}

ll powi(ll x, ll y) {
  ll res = 1;
  while (y--) {
    res *= x;
  }
  return res;
}

int main() {
  int N; cin >> N;
  vector<vector<int>> G(N);
  rep(i, N - 1) {
    int u, v; cin >> u >> v; u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  vector<int> par(N, -1);
  vector<int> dep(N);
  auto dfs = [&](auto dfs, int u, int p) -> void {
    for (int v : G[u]) if (v != p) {
      par[v] = u;
      dep[v] = dep[u] + 1;
      dfs(dfs, v, u);
    }
  };
  dfs(dfs, 0, -1);
  int M; cin >> M;
  vector<int> U(M), V(M);
  rep(i, M) cin >> U[i] >> V[i], U[i]--, V[i]--;
  vector<ll> mask(M);
  rep(i, M) {
    int x = U[i];
    int y = V[i];
    while (x != y) {
      if (dep[x] > dep[y]) swap(x, y);
      mask[i] |= 1LL << y;
      y = par[y];
    }
  }
  ll ans = 0;
  rep(i, 1 << M) {
    ll m = 0;
    rep(j, M) if (i >> j & 1) m |= mask[j];
    ans += powi(-1, popcount(i)) * powi(2, N - 1 - popcount(m));
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  for(int i=0;i<S.size();i++){
    int j=0;
    while(j<N){
      if(S[i]=='Z') S[i]='A';
      else S[i] += 1;
      j++;
    }
  }

  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
static const int MOD = 10000007;
static const int MAX = 1005;
int N, M[MAX];
int A[MAX][MAX], T[MAX], step[MAX];

int summ(int n) {
  return n*(n+1)/2;
}

int match() {
  int ch[N];
  int cnt = 0;
  REP(i,1,N+1) ch[i] = 0;

  REP(i, 1, N+1) {
    if (ch[i] == 1 || ch[T[i]] == 1) continue;
    if (i == T[T[i]]) { // if match
      if (step[i] >= N-1) {
        ch[i] = ch[T[i]] = 1;
        continue;
      } else {
        int teki = T[i];
        step[i]++; step[teki]++;
        ch[i] = ch[teki] = 1;
        if (step[i] < N - 1) {
          // cout << "mada" << i ;
          T[i] = A[i][step[i]];
        } else {
          // cout << "tsuita" << i ;
          T[i] = 0;
        }
        if (step[teki] < N-1) {
          // cout << "mada" << teki;
          T[teki] = A[teki][step[teki]];
        }
        if (step[teki] >= N-1) {
          // cout << "tsuita" << teki;
          T[teki] = 0;
        }
        // cout << endl;
        cnt = 1;
      }
    }
  }

  return cnt;
}


int check() {
  int cnt = 0;
  REP(i, 1, N+1) {
    if (step[i] >= N-1) continue;
    cnt = 1;
  }
  return cnt;
}


int realMatch() {
  int count = 0, cnt = 1;
  while (cnt) {
    cnt = match();
    count++;
    // rep(i,N) {
    //   cout << T[i+1] << " ";
    // }
    // cout << endl;
  }
  if (check()) {
    return -1;
  } else {
    return count-1;
  }
}

int main() {
  cin >> N;
  rep(i,N) {
    step[i+1] = 0;
    rep(j, N-1) {
      A[i+1][j] = 0;
    }
  }
  rep(i,N) rep(j,N-1) {
    cin >> A[i+1][j];
  }

  T[0] = 0;
  rep(i, N) T[i+1] = A[i+1][0];

  cout << realMatch() << endl;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

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

    std::vector<int> a(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[2 * i];
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int p=0;
    for(int i=0;i<4;i++)
    {
       if(s[i]==s[i+1])
       {
       	cout<<"Bad";
       	p=1;
       	break;
	   }
	   else
	    p++;
   }
       
      if(p!=1)
      cout<<"Good";
return 0;
 
 
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    cin >> A;
    cout << (accumulate(ALL(A), 0) >= H ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
D,N = map(int,input().split())

if D == 0:
  if N != 100:
    print(N*1)
  else:
    print(101)
elif D == 1:
  if N != 100:
    print(N*100)
  else:
    print(101*100)
else:
  if N != 100:
    print(N*10000)
  else:
    print(101*10000)

Measured memory_bytes: 3060