akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long H, N;
	cin >> H >> N;
	vector<long long>A(N), B(N);
	long long A_max = 0;
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i) >> B.at(i);
		A_max = max(A_max, A.at(i));
	}
	vector<long long>DP(H + A_max);
	for (long long i = H; i >= 0; i--) {
		DP.at(i) = 1e9;
	}
	DP.at(H) = 0;
	long long const Zero = 0;
	for (long long i = H; i >= 0; i--) {
		for (long long j = 0; j < N; j++) {
			DP.at(max(i - A.at(j), Zero)) = min(DP.at(max(i - A.at(j), Zero)), DP.at(i) + B.at(j));
		}
	}
	cout << DP.at(0) << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int count = 0;
		int ans = 1;
		for(int i=1;i<=n;i++){
			int count1 = 0;
			int tmp = i;
			while(tmp%2==0) {
				tmp = tmp/2;
				count1 = count1+1;
			}
			if(count1>count) {
				count = count1;
				ans = i;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35608
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}

int main(){
    string s;
    string t;
    cin >> s >> t;
    //sは辞書順，tは逆辞書順に並べる．
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    bool can = true;
    can = (s<t);

    if(can) cout<<"Yes"<<endl;
    else  cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int mai = sc.nextInt();	//枚数
		int kin = sc.nextInt();	//金額
		int M = 0;				//諭吉の枚数
		int G = 0;				//一葉の枚数
		int S = 0;				//英世の枚数
		int chek = 0;			//0の時不可能 -1 -1 -1 ::: 1の時MGSそのまま出力

		loop: for(int i = 0; i <= mai; i++) {
			if(i == 0 && mai * 10000 == kin) {	// 10000 * 枚数 = 金額なら即終了
				M = mai;
				chek = 1;
				break loop ;
			}
			if(i == 0 && mai * 5000 == kin) {	// 5000 * 枚数 = 金額なら即終了
				G = mai;
				chek = 1;
				break loop ;
			}
			if(kin >= i * 10000 && kin <= mai * 10000) {	//諭吉カウンター
				M = i;
			}
			for(int j = 0; j <= mai - M; j++) {		//一葉カウンター
				G = j;
				if(M + G == mai && M * 10000 + G * 5000 == kin && kin <= M * 10000 + (mai - M) * 5000) {	//諭吉 + 一葉 = 枚数 かつ 諭吉額 + 一葉額 = 金額なら終了
					chek = 1;
					break loop;
				}
				if(kin - (M * 10000 + G * 5000) == (mai - M - G) * 1000) {	//金額 - 諭吉額 - 一葉額 = 残り枚数 * 英世額 ならSに英世枚数を入れて終了
					S = mai - M - G;
					chek = 1;
					break loop;
				}
			}
		}
		if(chek == 0) {
			M = -1;
			G = -1;
			S = -1;
		}
		System.out.print(M + " " + G + " " + S);
	}
}

Measured memory_bytes: 21972
N = int(input())
X = list(map(int, input().split()))

cur = 1000
for i in range(N - 1):
    if X[i] < X[i + 1]:
        stocks = cur // X[i]
    else:
        stocks = 0

    cur += (X[i + 1] - X[i]) * stocks

# Last
print(cur)


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

B=[0 for i in range(K+1)]
for i in range(K+1)[::-1]:
    if i==0: continue
    B[i]=pow((K//i),N,MOD)
    t=i*2
    while t<=K:
        B[i]-=B[t]
        t+=i

ans=0
for i in range(K+1):
    ans+=i*B[i]
    ans%=MOD
print(ans)

Measured memory_bytes: 11260
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int N,M;
	cin>>N>>M;
	vpint A;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		A.pb(mp(a,b));
	}
	sort(A.begin(),A.end());
	priority_queue<int,vint,greater<int>> pq;
	int ans=0;
	for(int i=0;i<M;i++){
		if(pq.size()==0)
			pq.push(A[i].second);
		else{
			if(pq.top()<=A[i].first){
				ans++;
				pq=priority_queue<int,vint,greater<int>>();
				i--;
			}
			else
				pq.push(A[i].second);
		}
	}
	if(pq.size())
		ans++;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////


ll N, k, num, sum;
ll a, b;

int main() {
	
	while( cin>>N, N ){
		k = 1;
		
		while( 1 ){
			num = (1LL<<k)-1LL;
			sum = (9*9ll)*num;
			if( N - sum <= 0 ) break;
			N -= sum;
			k++;
		}
		//cout<<"N:"<<N<<endl;
		//cout<<"K:"<<k<<endl;
		N--;
		a = (N/(num*9LL))+1;
		N %= (num*9LL);
		cout<<a;
		
		b = a;
		while( a == b ){
			REP( i, 10 ){
				b = i;
				if( i == a ){
					num = 9LL*((1LL<<(k-1LL))-1LL);
				}
				else{
					num = 1LL<<(k-1LL);
				}
				if( N - num < 0 ) break;
				N -= num;
			}
			cout<<b;
			k--;
		}
		while( k-- ){
			if( ((N&(1LL<<k)) == 0) ^ (a > b) ) cout<<a;
			else{				  cout<<b;}
		}
		puts("");
		//cout<<"a:"<<a<<endl;
		//cout<<"b:"<<b<<endl;
	}
	return 0;
}



Measured memory_bytes: 3032
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, d, a = map(int, input().split())
    XH = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[0])

    que = deque()
    total = 0
    res = 0
    for i in range(n):
        x, h = XH[i]
        while que and que[0][0] < x:
            total -= que[0][1]
            que.popleft()
        h -= total

        if h > 0:
            num = (h + a - 1) // a
            res += num
            damage = num * a
            total += damage
            que.append([x + d * 2, damage])
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 66432
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> a[2];
    fr(i,2){
        a[i].resize(n);
        for(auto&j:a[i]) in>>j;
    }
    int ans{},s;
    fr(i,n){
        s=0;
        fr(j,i+1) s+=a[0][j];
        for(int j=i;j<n;++j) s+=a[1][j];
        ans=max(ans,s);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double r=sc.nextDouble(),S=0,L=0;
		S=r*r*Math.PI;
		L=2*r*Math.PI;
		System.out.println(String.format("%.6f", S)+" "+String.format("%.6f", L));
	}
}


Measured memory_bytes: 28300
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=30000005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
ll n,a[5],b[5],c[5],w[5];
ll f[MAXN],smax;
int main()
{
    n=read(),smax=0;
    for (int i=1;i<=3;i++) a[i]=read(),w[i]=a[i];
    for (int i=1;i<=3;i++) b[i]=read(),c[i]=b[i]-a[i];
    memset(f,0,sizeof f);
    for (int i=1;i<=3;i++)
	    for (int j=w[i];j<=n;j++) f[j]=max(f[j],f[j-w[i]]+c[i]),smax=max(smax,f[j]);
	n=n+smax,smax=0;
    memset(f,0,sizeof f);
	for (int i=1;i<=3;i++) w[i]=b[i],c[i]=a[i]-b[i];
    for (int i=1;i<=3;i++)
	    for (int j=w[i];j<=n;j++) f[j]=max(f[j],f[j-w[i]]+c[i]),smax=max(smax,f[j]);
	n+=smax;
	printf("%lld\n",n);
	return 0;
}


Measured memory_bytes: 234752
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;

    int ans = M * 1900 + (N - M) * 100;
    ans *= 1 << M;

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

Measured memory_bytes: 3460
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int A, B;
	cin >> A >> B;
	if(A > 12){
		cout << B << endl;
	}
	else if(A < 6){
		cout << 0 << endl;
	}
	else{
		cout << B / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
X, Y, Z = map(int, input().split(' '))
first = Y + 2*Z
follower = Y + Z
total = 0
if first < X:
    #total += first
    length = X - first
    num = length // follower + 1
elif first == X:
    num = 1
else:
    num = 0
print(num)

Measured memory_bytes: 3060
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N= int(input())
nine_list = []
for i in range(1,10):
    for j in range(1,10):
        nine_list.append(i*j)
if N in nine_list:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6948
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String s = mylist.get(0);
        Boolean chkflg = false;

        if (s.substring(0, 7).equals("keyence")) {
            chkflg = true;
        } else if (s.substring(0, 1).equals("k") && s.substring(s.length() - 6).equals("eyence")) {
            chkflg = true;
        } else if (s.substring(0, 2).equals("ke") && s.substring(s.length() - 5).equals("yence")) {
            chkflg = true;
        } else if (s.substring(0, 3).equals("key") && s.substring(s.length() - 4).equals("ence")) {
            chkflg = true;
        } else if (s.substring(0, 4).equals("keye") && s.substring(s.length() - 3).equals("nce")) {
            chkflg = true;
        } else if (s.substring(0, 5).equals("keyen") && s.substring(s.length() - 2).equals("ce")) {
            chkflg = true;
        } else if (s.substring(0, 6).equals("keyenc") && s.substring(s.length() - 1).equals("e")) {
            chkflg = true;
        } else if (s.substring(s.length() - 7).equals("keyence")) {
            chkflg = true;
        }
        System.out.println(chkflg ? "YES" : "NO");
    }

}


Measured memory_bytes: 21332
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=500010,inf=1e9;
int n,ans,cnt;
int f[maxn][3],a[maxn],pos[maxn],suml[maxn],sumr[maxn];
char s[maxn];
void read(int &k)
{
	int f=1;k=0;char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
	k*=f;
}
int main()
{
	read(n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)a[i]=s[i]-'0';
	pos[0]=0;
	for(int i=1;i<=n;i++)
	if(a[i]==0)pos[++cnt]=i,suml[cnt]=i-pos[cnt-1]-1;
	pos[cnt+1]=n+1;for(int i=cnt;i;i--)sumr[i]=pos[i+1]-pos[i]-1;
	for(int i=1;i<=cnt;i++)
	{
		f[i][0]=max(f[i-1][0],max(f[i-1][1],f[i-1][2]));
		if(suml[i]>0&&sumr[i]>0)f[i][1]=max(f[i-1][0]+suml[i],f[i-1][1]+suml[i]-1);else f[i][1]=-inf;
		if(suml[i]>0&&sumr[i]>0)f[i][2]=f[i-1][0]+sumr[i];else f[i][2]=-inf;//,printf("%d %d\n",i,f[i-1][2]+sumr[i-1]-2);else f[i][2]=-inf;
		if(suml[i]>1)f[i][2]=max(f[i][2],max(f[i-1][2]-1,f[i-1][1])+sumr[i]);
		ans=max(ans,max(f[i][0],max(f[i][1],f[i][2])));
//		printf("%d %d %d %d\n",i,f[i][0],f[i][1],f[i][2]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 14464
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, K = map(int, input().split())
P = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

E = [0]
tot = 0
for p in P:
    tot += (p + 1) / 2
    E.append(tot)


m = 0
for i in range(N - (K - 1)):
    _ = E[i + K] - E[i]
    if _ > m:
        m = _

print(m)

Measured memory_bytes: 31732
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

//-----Template---------
int counter[26];
string s;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>> s;
    bool C=false;
    bool A=false;
    for (int i = 0; i < s.length(); ++i) {
        if(s[i]=='C'){
            C=true;
        }
        if(s[i]=='F' && C){
            A=true;
        }
    }
    if(A){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

A,B,N = MI()
if N<B:
    print(int(A*N/B))
else:
    print(int(A*(B-1)/B))


Measured memory_bytes: 71216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   int n, k;
   string s;
   cin >> n >> s >>k;
   rep(i, n){
       if(s[i]!=s[k-1]) s[i] = '*';
   }
   cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0
    for a in A:
        ans += a//2
    prev = 0
    for a in A:
        new = a%2
        if prev == 1:
            if new == 1:
                ans += 1
            elif a>0:
                prev = 1
            else:
                prev = 0
        prev = prev^new
    return ans
print(solve())

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

using namespace std;

int main() {
  string S;
  cin >> S;

  vector<string> M = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  for (int i = 0; i < 7; i++) {
    if (M[i] == S) {
      cout << 7 - i;
      break;
    }
  }

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> exist(9, 0);
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        int b = a / 400;
        if(a >= 3200) exist[8]++;
        else exist[b]++;
    }

    int ans = 0;
    for (int i = 0; i < 8; i++)
    {
        if(exist[i] > 0) ans++;
    }

    if(ans == 0) cout << "1 " << exist[8] << endl;
    else cout << ans << " " << ans + exist[8] << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = INT_MAX, x[n], one = INT_MAX;
    rep(i, n) {
        cin >> x[i];
        one = min(one, abs(x[i]));
    }
    if (k == 1) ans = one;
    else {
        rep(i, n - k + 1) {
            int num = x[k+i-1] - x[i];
            num += min(abs(x[k+i-1]), abs(x[i]));
            ans = min(ans, num);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
	int n, T;
	cin >> n >> T;
	int t[n];
	for(int i=0; i<n; i++) cin >> t[i];
	
	long long ans=0;
	for(int i=0; i<n-1; i++){
		if(t[i+1]-t[i] < T) ans+=t[i+1]-t[i];
		else ans += T;
	}
	ans += T;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, x, t;
  cin >> n >> x >> t;
  if (n % x != 0) {
    cout << (n / x + 1) * t << endl;
  } else {
    cout << (n / x) * t << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second
#define MOD 998244353LL

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

vector<ll> fact;

tuple<ll, ll, ll> exgcd(ll a, ll b) {
    if (b == 0)
        return make_tuple(a, 1, 0);
    ll g, x, y;
    tie(g, x, y) = exgcd(b, a%b);
    return make_tuple(g, y, x-(a/b)*y);
}

ll moddiv(ll a, ll b)
{
    ll bb;
    tie(ignore,bb,ignore)=exgcd(b,MOD);
    if(bb<0) b+=MOD;
    return (a*bb)%MOD;
}

ll C(int a, int b)
{
    ll ret=fact[a];
    ret=moddiv(ret,fact[a-b]);
    ret=moddiv(ret,fact[b]);
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n,m,k;
    cin>>n>>m>>k;
    fact.resize(n);
    fact[0]=1;
    for(int i=1; i<n; i++) fact[i]=(fact[i-1]*i)%MOD;
    ll answer=1;
    vector<ll> v(n);
    v[0]=1;
    for(int i=1; i<n; i++) v[i]=(v[i-1]*(m-1))%MOD;
    for(int i=0; i<n; i++){
        answer=(answer*m)%MOD;
    }
    for(int i=n-1; i>k; i--){
        ll now=(((C(n-1,n-1-i)*m)%MOD)*v[n-i-1])%MOD;
        answer=(answer+MOD-now)%MOD;
    }
    cout<<answer;

    return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
bool touch[200001];
signed main() {
  int N, M; cin >> N >> M;
  vector<int> ord;
  memset(touch, -1, sizeof(touch));
  REP(i,M) {
    int k; cin >> k;
    touch[k] = false;
    ord.push_back(k);
  }
  set<int> S;
  reverse(ord.begin(), ord.end());
  for(int k : ord) {
    if(!S.count(k)) {
      cout << k << endl;
      S.insert(k);
    }
  }
  // cout << "-" << endl;
  for(int i = 1; i <= N; ++i) {
    if(touch[i]) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 8576
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

using namespace std;

void solve()
{
    string s;
    cin >> s;
    s[1] = 'B' + 'R' - s[1];
    cout << s << endl;
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  
  // read N
  long long int N, tmp;
  scanf("%lld", &N);
  
  // read L
  std::vector<long long int> L;
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    L.push_back(tmp);
  }
  std::sort(L.begin(), L.end(), std::less<long long int>());
  
  /*std::cerr << "L" << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr <<L[i] << " ";
  }std::cerr << std::endl;*/
  
  // count L
  std::vector<long long int> n(1001), S(1001);
  
  for(long long int i = 0; i < N; i++){
    n[L[i]]++;
  }
  for(long long int i = 1; i < 1001; i++){
    S[i] = S[i-1] + n[i];
  }
  
  /*std::cerr << "n:" << std::endl;
  for(long long int i = 0; i < 10; i++){
    std::cerr << n[i] <<" ";
  }std::cerr << std::endl;
  std::cerr << "S:" << std::endl;
  for(long long int i = 0; i < 10; i++){
    std::cerr << S[i] << " ";
  }std::cerr << std::endl;*/
  
  // solve problem
  long long int m, M, ans = 0;
  for(long long int i = 0; i < N; i++){
    for(long long int j = i+1; j < N; j++){
      //m = std::min(std::abs(L[i]-L[j]), (long long int)1000);
      M = std::min(L[i]+L[j]-1, (long long int)1000);
      //ans += S[M] - S[m];
      //ans += S[M] - S[L[j]];
      ans += S[M] - j-1;
      //std::cerr << i << " "  << L[i] << " " << j << " " << L[j] << " "  << ans << std::endl;
    }
  }
    
  std::cerr << "Answer" << std::endl;
  std::cout << ans << std::endl;

  return 0;
}


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

int main(void){
    set<string> W;
    int N;
    cin>>N;
    string S1,S2;

    for(int i=0;i<N;i++){
        cin>>S2;
        if(W.count(S2)==1){
            cout<<"No"<<endl;
            return 0;
        }else{
            if(i >= 1 && S2[0]!=S1[S1.size()-1]){
                cout<<"No"<<endl;
                return 0;
            }else{
                W.insert(S2);
                S1=S2;  
            }
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=3005;
const int mod=1e9+7;
int n,q,cnt,val[N],dp[N];

namespace utils{
	template <class T> inline void apx(T &x,const T y){
		x<y?x=y:0;
	}
	template <class T> inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=fgetc(fd));
		while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

template <class T>
inline int fpow(int x,T t){
	int ans=1;
	for(; t; x=(lint)x*x%mod,t>>=1){
		if(t&1) ans=(lint)ans*x%mod;
	}
	return ans;
}

void get_val(){
	static int buk[N];
	bool flag=0;
	for(int i=1; i*i<=n; ++i){
		if(n%i) continue;
		val[++cnt]=i;
		if(i*i==n) flag=1;
		else buk[cnt]=n/i;
	}
	for(int i=cnt-flag; i; --i){
		val[++cnt]=buk[i];
	}
}

void get_dp(){
	for(int i=1; i<=cnt; ++i){
		int res=fpow(q,(val[i]+1)>>1);
		for(int j=1; j<i; ++j){
			if(val[i]%val[j]==0) res=(res-dp[j])%mod;
		}
		dp[i]=(res+mod)%mod;
	}
}

int main(){
	n=nxi(),q=nxi();
	get_val();
	get_dp();
	int ans=0;
	for(int i=1; i<=cnt; ++i){
		int wgt=val[i]&1?val[i]:val[i]>>1;
		ans=(ans+(lint)wgt*dp[i])%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < 3; ++i) cnt += (s.at(i) == t.at(i));
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	if sc.Scan() {
		tmp := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(tmp[0])
		b, _ := strconv.Atoi(tmp[1])

		fmt.Printf("%d %d %f\n", a/b, a%b, float64(a)/float64(b))
	}
}



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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n,ma,mb;cin>>n>>ma>>mb;
  int dp[42][410][410]={};
  for(int i=0;i<42;i++)
    for(int j=0;j<410;j++)
      for(int k=0;k<410;k++)
	dp[i][j][k]=INF;
  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    int a,b,c;cin>>a>>b>>c;
    for(int j=0;j<400;j++){
      for(int k=0;k<400;k++){
	if(dp[i][j][k] != INF){
	  dp[i+1][j+a][k+b]
	    =min(dp[i+1][j+a][k+b],dp[i][j][k]+c);
	}
	dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
      }
    }
  }
  int a=ma,b=mb;
  int ans=INF;
  while(a<=400&&b<=400){
    ans=min(ans,dp[n][a][b]);
    a+=ma;
    b+=mb;
  }
  if(ans!=INF)
    cout<<ans<<endl;
  else
    cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 27904
#include <iostream>

using namespace std;

int main(){
	double w;

	while(cin >> w){

		if(w == 0) break;

		if(48.00 >= w){
			cout << "light fly" << endl;
		}else if(w > 48.00 && w <= 51.00){
			cout << "fly" << endl;
		}else if(w > 51.00 && w <= 54.00){
			cout << "bantam" << endl;
		}else if(w > 54.00 && w <= 57.00){
			cout << "feather" << endl;
		}else if(w > 57.00 && w <= 60.00){
			cout << "light" << endl;
		}else if(w > 60.00 && w <= 64.00){
			cout << "light welter" << endl;
		}else if(w > 64.00 && w <= 69.00){
			cout << "welter" << endl;
		}else if(w > 69.00 && w <= 75.00){
			cout << "light middle" << endl;
		}else if(w > 75.00 && w <= 81.00){
			cout << "middle" << endl;
		}else if(w > 81.00 && w <= 91.00){
			cout << "light heavy" << endl;
		}
		else{
			cout << "heavy" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
{- A
f :: [Char] -> String
f (x:y:ys)
    | x == y = "Bad"
    | ys == [] ="Good"
    | otherwise = f (y:ys)

main = getLine >>= putStrLn . f
-}

del :: Int -> Int -> Int -> Int
del d x y
    | d == abs x = y
    | d == abs y = x
    | otherwise = x + y

f :: [Int] -> String
f (n:l:xs) = do
    let x = [l+i-1 | i <- [1..n] ]
    let d = minimum $ map abs x
    show $ foldr1 (del d) x

main = getLine >>= putStrLn . f . map read . words

Measured memory_bytes: 508
#ifdef DEBUG
#include "redirect.h"
#endif

#include<bits/stdc++.h>
#define N 200050
#define p 998244353
using namespace std;
long long inv[N],C[N];

int main(int argc, char *argv[]) {
#ifdef DEBUG
    init(argc, argv);
#endif
    register int n,m,k,i;
    long long x,ans=0;
    scanf("%d %d %d",&n,&m,&k);
    if (m==1) {
        if (k>=n-1) puts("1"); else puts("0"); return 0;
    }
    inv[1]=1;
    for (i=2; i<=max(n,m); ++i) inv[i] = (-(p/i))*inv[p%i]%p;
    for (C[0]=i=1;i<=k;i++) C[i]=((C[i-1]*(n-i)%p)*inv[i])%p;

    x=m%p;
    for (i=1;i<=n-1;i++) x=x*(m-1)%p;

    for (i=0;i<=k;i++) {
        ans=(ans+C[i]*x%p)%p;
        x=x*inv[m-1]%p;
    }

    printf("%lld",(ans+p)%p);
    return 0;
}


Measured memory_bytes: 6708
N = int(input())
A = list(map(int,input().split()))
flag = 0
for i in range(N):
    if A[i]!=0:
        flag = 1
        break
if flag==0:
    print(0)
else:
    pmax = 0
    mmin = 0
    indp = -1
    indm = -1
    for i in range(N):
        if A[i]>0:
            if A[i]>pmax:
                pmax = A[i]
                indp = i
        elif A[i]<0:
            if A[i]<mmin:
                mmin = A[i]
                indm = i
    if pmax>=abs(mmin):
        print(2*N-2)
        for i in range(N):
            if i!=indp:
                print(indp+1,i+1)
        for i in range(N-1):
            print(i+1,i+2)
    else:
        print(2*N-2)
        for i in range(N):
            if i!=indm:
                print(indm+1,i+1)
        for i in range(N-1,0,-1):
            print(i+1,i)

Measured memory_bytes: 62620
open Batteries
(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)
let k = read_int()
let s = read_line()
let ex_s = s |> explode
let _ = (if String.length s <= k then s else
  (String.init k (fun a -> List.nth ex_s a) ^ "...")
) |> print_endline

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin>>n>>a>>b;
	hrp(i, a, b) if (!(i%n)) { cout<<"OK"<<endl; return 0;}
	cout<<"NG"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

int main(){
  int k, x, min, max;
  
  cin >> k >> x;
  
  min = x - (k-1);
  max = x + k;
  
  for(int i = min; i < max; i++){
    if(i == max - 1){
      cout << i << endl;
    }else{
      cout << i << " ";
    }
  }
}

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

int main()
{
  std::string s;
  std::cin >> s;
  auto len = s.length() / 2;
  for (auto i = len - 1; i > 0; --i)
  {
    if (s.substr(0, i) == s.substr(i, i))
    {
      std::cout << i * 2 << std::endl;
      return 0;
    }
  }
}

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

typedef long long ll;
typedef vector <ll> vi;

vi pedra;
vi memo;

long long dp(int n, int k){
    // condição de parada
    if (n <= 0) return 0;
    if (memo[n] != -1) return memo[n];
    memo[n] = dp(n-1, k) + abs(pedra[n]-pedra[n-1]);
    for (int i = 1; i <= k; i++){
        if (n - i >= 0){
            memo[n] = min(memo[n], dp(n-i, k) + abs(pedra[n]-pedra[n-i]));
        }
    }
    return memo[n];
}

int main(){
    int n, k;
    cin >> n >> k;
    pedra.assign(n, 0);
    memo.assign(n, -1);
    for (int i = 0; i < n; i++){
        int aux;
        scanf("%d", &aux);
        pedra[i] = aux;
    }
    printf("%lld\n", dp(n-1, k));
    // for (int i = 0; i < n; i++) printf("%lld ", pedra[i]);
}


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

int main()
{
    int N, M, tmp;
    cin >> N >> M;

    vector<int> load(N);

    for (int i = 0; i < 2 * M; i++){
        cin >> tmp;
        load.at(tmp - 1)++;
    }

    for (int i = 0;i<N;i++)
        cout << load.at(i) << endl;
}

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

int main()
 {
 	long long int n,p=1,i,c=0;
 	cin>>n;
 	long long int a[n];
 	for(i=0;i<n;i++)
 		cin>>a[i];
 	for(i=0;i<n;i++)
 		{
 			if(a[i]==0)
 			c++;
		 }
	if(c>0)
	{
		cout<<"0"<<endl;
		return 0;
	}
		
	
	
	for(i=0;i<n;i++)
		{
			if(a[i]<=1000000000000000000/p)
				p=p*a[i];
			else
			{
				cout<<"-1"<<endl;
				return 0;
			}
				
				
		}
		cout<<p<<endl;

 	return 0;
}
 	
 					

Measured memory_bytes: 4396
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
int f[303][1<<5|3][303],n,c,l[403],bh[403],a[403];bool vis[403];double res;
inline void add(int &x,int y){x+=y;}
void dfs(int dep){
	if(dep>n){
		rep(i,0,c-1)rep(j,0,n-1)if(j)bh[i*n+j]=j;//a[j+1]-2;//[0..n-2]
		memset(f,0,sizeof(f));f[0][0][l[1]*n]=1;
		rep(i,0,c*n-1)rep(s,0,(1<<n-1)-1)rep(j,i,c*n)if(f[i][s][j]){
			add(f[i+1][s][j],f[i][s][j]);
			if(bh[i]&&!(s>>(a[bh[i]+1]-2)&1))
				add(f[i+1][s|1<<(a[bh[i]+1]-2)][max(j,min(c*n,i+l[a[bh[i]+1]]*n))],f[i][s][j]);
		}
		double now=f[c*n][(1<<n-1)-1][c*n];rep(i,1,n-1)now/=c;
		rep(i,1,n-1)now/=i;res+=now;
		return;
	}
	if(dep==1){a[dep]=1;vis[1]=1;dfs(dep+1);return;}
	rep(i,1,n)if(!vis[i]){
		vis[i]=1;a[dep]=i;
		dfs(dep+1);vis[i]=0;
	}
}
int main() {
	read(n);read(c);rep(i,1,n)read(l[i]);
	
	sort(l+1,l+n+1);reverse(l+1,l+n+1);
	dfs(1);printf("%.15lf",res);
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	cout<<(s=="ARC"?"ABC":"ARC")<<endl;
}


Measured memory_bytes: 3504
import sys
sys.setrecursionlimit(200000)
from collections import deque
from bisect import bisect_left

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


INF = 10 ** 10
done = [False] * N
done[0] = True
lisdp = [INF] * N
lisdp[0] = A[0]
change = [[-1, INF] for i in range(N)] #index, original
change[0] = [0, INF]
lisl = [0] * N
lisl[0] = 1

def dfs(v):
	for nv in adj[v]:
		if done[nv]:
			continue
		done[nv] = True
		ind = bisect_left(lisdp, A[nv])
		ori = lisdp[ind]
		change[nv] = [ind, ori]
		if ori == INF:
			lisl[nv] = lisl[v] + 1
		else:
			lisl[nv] = lisl[v]
		lisdp[ind] = A[nv]
		dfs(nv)
	lisdp[change[v][0]] = change[v][1]

dfs(0)
for i in range(N):
	print(lisl[i])	

Measured memory_bytes: 238720
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x) cin >> x
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    cin >> N;

    vll d(N);
    rep(i, N) in(d[i]);

    ll ans = 0;

    rep(i, N)
    {
        reps(j, i + 1, N)
        {
            ans += d[i] * d[j];
        }
    }

    outl(ans);

    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//
uint64_t dp[101010][13]; // mod13

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    string s; cin >> s;
    int n = s.length();

    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        int c;
        if (s[i] == '?') c = -1;
        else c = s[i] - '0';

        for (int j = 0; j < 10; j++) {
            if (c != -1 && c != j) continue;
            for (int ki = 0; ki < 13; ki++) {
                dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
            }
        }

        for (int j = 0; j < 13; j++){
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[n][5] << endl;
    return 0;    return 0;
}


Measured memory_bytes: 10752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		long[]L = new long[N + 1];
		L[0] = 2;
		L[1] = 1;
		for(int i = 2; i <= N; i++) {
			L[i] = L[i - 1] + L[i - 2];
		}
		System.out.println(L[N]);
	}
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair


int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

int main(){

  int w, a, b;
  scanf("%d %d %d", &w, &a, &b);
  if(a > b) swap(a, b);

  printf("%d\n", max(b - a - w, 0));
   
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MD 1000000007
using namespace std;
char k[10010];
typedef long long ll;
int d;
ll dp[10010][110][2];
void ds(int dg) {
	for(int j=0;j<d;j++) {
		for(int i=0;i<10;i++) {
			dp[dg+1][(j+i)%d][0] += dp[dg][j][0];
			dp[dg+1][(j+i)%d][0] %= MD;
		}
		int dv = k[dg]-'0';
		for(int i=0;i<=dv;i++) {
			dp[dg+1][(j+i)%d][i==dv] += dp[dg][j][1];
			dp[dg+1][(j+i)%d][i==dv] %= MD;
		}
	}
}
int main() {
	scanf("%s ",k);
	scanf("%d ",&d);
	int l = strlen(k);
	memset(dp,0,sizeof(dp));
	dp[0][0][1] = 1;
	for(int i=0;i<l;i++) {
		ds(i);
	}
	int val = -1;
	for(int i=0;i<2;i++) {
		val += dp[l][0][i];
	}
		//printf("%d\n",dp[l][0][1]);
	val += MD;
	printf("%d\n",val%MD);
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int a, b;
    cin >> a >> b;
    if (a >= 10 || b >= 10){
        cout << "-1" << endl;
    }else {
        cout << a*b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define fori(x, y) for(int i = x; i<y; i++)
#define get getchar_unlocked
typedef long long ll;
using namespace std;
inline int scan(){  //this scans an int type!!! not a long long!!!! 
    int n=0,s=1;
    char p=get();
    if(p=='-')  s=-1;
    while((p<'0'||p>'9')&&p!=EOF&&p!='-') p=get();
    if(p=='-') s=-1,p=get();
    while(p>='0'&&p<='9') { n = (n<< 3) + (n<< 1) + (p - '0'); p=get();}
    return n*s;
}
int main() { 
	int A, B, C;
	A = scan();
	B = scan();
	if(A>B) swap (A, B);
	C =scan();
	if(B>C) swap (B,C);
	printf("%d\n", A*B/2);
	
	return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];

void solve() {
  string s; cin >> s;
  int n = s.size();
  int cnt =0;
  for (int i=0; i<n; i++) {
    if(s[i] == '1') cnt++;
  }
  cout << cnt << endl;
}


int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] lines = Console.ReadLine().Split(' ');
        int[] cookie = new int[3];
        cookie[0] = int.Parse(lines[0]);
        cookie[1] = int.Parse(lines[1]);
        cookie[2] = cookie[0] + cookie[1];

        bool isPossible = false;
        for(int i=0; i<3; i++){
            if(cookie[i] % 3 == 0){
                isPossible = true;
                break;
            }
        }
        if(isPossible){
            Console.WriteLine("Possible");
        }else{
            Console.WriteLine("Impossible");
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		int sum = 0;
		for (int i = 0; i < m; i++) {
			sum += scan.nextInt();
		}
		
		if (sum <= n) {
			System.out.println(n - sum);
		} else {
			System.out.println("-1");
		}

	}

}


Measured memory_bytes: 46204