akhauriyash/Code-Regression huggingface dataset:
# Aizu Problem 0207: Block

import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def build_grid(W, H, N, blocks):
    grid = [[0 for _ in range(W)] for __ in range(H)]
    for c, d, x, y in blocks:
        x, y = x - 1, y - 1
        if d == 0:
            # horizontal long:
            dx, dy = 4, 2
        else:
            # vertical long:
            dx, dy = 2, 4
        for xi in range(x, x + dx):
            for yi in range(y, y + dy):
                grid[yi][xi] = c
    return grid


def bfs(W, H, grid, xs, ys, xg, yg):
    delta = [[0, 1], [0, -1], [1, 0], [-1, 0]]
    color = grid[ys][xs]
    if color == 0:
        return "NG"
    visited = set()
    queue = [(xs, ys)]
    while len(queue) > 0:
        current = queue.pop(0)
        visited.add(current)
        col, row = current
        for drow, dcol in delta:
            row2, col2 = row + drow, col + dcol
            if 0 <= row2 < H and 0 <= col2 < W and grid[row2][col2] == color:
                # neighboring piece has same color:
                neighbor = (col2, row2)
                if neighbor == (xg, yg):
                    return "OK"
                if neighbor not in queue and neighbor not in visited:
                    queue.append(neighbor)
    return "NG"

    
while True:
    W, H = [int(_) for _ in input().split()]
    if W == H == 0:
        break
    xs, ys = [int(_) - 1 for _ in input().split()]
    xg, yg = [int(_) - 1 for _ in input().split()]
    N = int(input())
    blocks = [[int(_) for _ in input().split()] for __ in range(N)]
    grid = build_grid(W, H, N, blocks)
    print(bfs(W, H, grid, xs, ys, xg, yg))
    
    #for row in grid:
    #    print(''.join([str(r) for r in row]))
    #print(color)

Measured memory_bytes: 8008
#include<stdio.h>
int main(void){
    int a,b,c;
    int temp;
    int i;
    scanf("%d %d %d",&a,&b,&c);
    for(i=0;i<2;i++){
        if(a>b){
            temp=a;
            a=b;
            b=temp;
        }
        if(b>c){
            temp=b;
            b=c;
            c=temp;
        }
        if(a>c){
            temp=a;
            a=c;
            c=temp;
        }
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,d,x,b=0;
    cin>>n>>d>>x;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        for(int j=1;j<=d;j+=a){
            b+=1;
        }
    }
    cout<<b+x<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long N;
    string s;
    cin >> N >> s;

    long R = 0, B = 0;
    for (int n = 0; n < N; n++) {
        if (s[n] == 'R') R++;
        else             B++;
    }

    if (R > B)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stack>
using namespace std;

class P {
public:
	int x, y;
	P() {}
	P(int _x, int _y) : x(_x), y(_y) {}
};

int w, h;
char map[22][22];

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

int main() {
	while (1) {
		cin >> w >> h;
		if (w == 0 && h == 0) break;
		P start;
		for (int i = 0; i < h; i++) {
			cin >> map[i];
			char* at = strchr(map[i], '@');//文字列から文字を検索する
			if (at != NULL) {//@が存在したらスタート地点なので記録
				start.x = at - map[i];
				start.y = i;
			}
		}
		//深さ優先探索
		stack<P> deq;
		int count = 0;
		deq.push(start);//初期位置をpush
		while (!deq.empty()) {
			P current = deq.top();//pop
			deq.pop();
			count++;
			for (int i = 0; i < 4; i++) {
				int nextX = dx[i] + current.x;
				int nextY = dy[i] + current.y;
				if (0 <= nextX && nextX < w && 0 <= nextY && nextY < h
						&& map[nextY][nextX] == '.') {
					deq.push(P(nextX, nextY));//次のノードをpush
					map[nextY][nextX] = '#';//戻らないように埋める
				}
			}

		}
		cout << count << endl;
	}
	return 0;
}

/*	ポイント
		領域の塗りつぶし問題
		再帰による実装の方が一般的かも
		埋めるタイミングが間違ってて詰まってた
		mapはy,xの順の添字で使うと入力が楽
			でもその分参照は注意
		探索の基礎
			push()
			while (!empty) {
				pop()
				if (ゴール判定) {
					break;
				}
				if (次のノードの条件) {
					push()
				}
			}
			※stackで深さ,queueで幅,priority_queueでダイクストラ(コストがpriority)
*/

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
char C[110][110];
int dp[110][110];

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		rep(j, 0, M) cin >> C[i][j];
	}
	rep(i, 0, N) {
		rep(j, 0, M) {
			if(i == 0 && j == 0) continue;
			int v = inf;
			if(i != 0) MIN(v, dp[i - 1][j] + (C[i][j] != C[i - 1][j]));
			if(j != 0) MIN(v, dp[i][j - 1] + (C[i][j] != C[i][j - 1]));
			dp[i][j] = v;
		}
	}
	int res = -1;
	int d = dp[N - 1][M - 1];
	// debug(d);
	if(C[0][0] == '.' && C[N - 1][M - 1] == '.') res = d / 2;
	else if(C[0][0] == '#' && C[N - 1][M - 1] == '#') res = d / 2 + 1;
	else res = (d + 1) / 2;
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define int long long
using namespace std;
int dp[51][2501];
signed main() {
	int N, A;
	cin >> N >> A;
	vector <int>x(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < 51; i++) {
		for (int j = 0; j < 2501; j++) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for (int k = 0; k < N; k++) {
		for (int i = N; i > 0; i--) {
			for (int j = 2500; j >=x[k]; j--) {
				
					dp[i][j] += dp[i - 1][j - x[k]];
				
			}
		}
	}
	for (int i = 1; i < N+1; i++) {
		res += dp[i][i*A];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1280
import math
N = int(input())
A = [0] + list(map(int, input().split( )))
B = [0]*(N+1)
s = 0
for i in reversed(range(1, N+1)):
  ball = 0  
  for j in range(i,N+1,i):
    ball += B[j]
  if ball%2 != A[i]:
    B[i] = 1
    s += 1

print(s)
print(*[i for i, b in enumerate(B) if b == 1], sep=' ')

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

#define INF 1000000
#define MAX_N 50000

int main(){
	int n, m;
	cin >> n >> m;
	
	int c[20];
	for(int i=0;i<m;i++)
		cin >> c[i];
	
	int dp[MAX_N+1];   //dp[i] : i円を支払うための最小枚数

	for(int i=1;i<=MAX_N;i++)   
		dp[i] = INF;            //初期化(dp[0]=0)

	for(int i=0;i<=n;i++){ 		//i円を支払うとき
		for(int j=0;j<m;j++){   	//j番目のコインを使うとき
			if(i+c[j] <= n)
				dp[i+c[j]] = min(dp[i+c[j]], dp[i]+1);	
		}
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 3320
#include <stdio.h>

int main(int argc,char* argv[]){
    unsigned long long ryuka[86]={2,1};
    int i=0;
    int j;
    scanf("%d",&i);
    for(j=2;j<=i;j++){
        ryuka[j]=ryuka[j-1]+ryuka[j-2];
    }
    printf("%llu\n",ryuka[i]);
    return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long x = scanner.nextLong(), k = scanner.nextLong(), d = scanner.nextLong();
			x = Math.abs(x);
			if (k < (x / d)) {
				System.out.println(x - k * d);
			} else {
				k -= x / d;
				if (0 == (k & 1)) {
					System.out.println(x - (x / d) * d);
				} else {
					System.out.println(Math.abs(x - (x / d) * d - d));
				}
			}
		}
	}
}


Measured memory_bytes: 35864
N = int(input())
K = 101
D = []
for _ in range(N):
    x, y, h = map(int, input().split())
    D.append((x,y,h))
D.sort(key=lambda x:x[2], reverse=True)
for i in range(K):
    for j in range(K):
        flg = True
        H = -1
        for x, y, h in D:
            if h == 0:
                if H > abs(x-i) + abs(y-j):
                    flg = False
                    break
                continue
            if H == -1:
                H = abs(x-i) + abs(y-j) + h
                continue
            if H != abs(x-i) + abs(y-j) + h:
                flg = False
                break
        if flg:
            print(i,j,H)
            exit()


Measured memory_bytes: 70260
//けんさんの写経　惰性気味
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n ; cin >> n ;
    vector<long long> a(n*3);
    for (int i = 0 ; i < n * 3 ; i++ ){
        cin >> a[i] ;
    }
    //左から前処理
    vector<long long> s(n*2+1,0); //左のほうからN (~ 2N+1)選べるとき、最大化する
    priority_queue<long long, vector<long long>,greater<long long> > que1;
    for(int i = 0 ; i < n ; i ++){
        s[i+1] = s[i] + a[i];
        que1.push(a[i]);
    }
    for(int i = n  ; i  < n * 2 ; i++ ){
        long long mi = que1.top();
        if(a[i] > mi ){
            s[i+1] = s[i] - mi + a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else s[i+1] = s[i];
    }

    //右側から前処理
    vector<long long> t(n*2+1,0);
    priority_queue<long long> que2;
    for(int i =0 ; i < n ; i ++){
        t[i+1] = t[i] + a[n*3 - 1 - i ];
        que2.push(a[n*3-1-i]);
    }
    for(int i = n ; i < n * 2 ; i++){
        long long ma = que2.top();
        if(a[n*3-1-i] < ma){
            t[i+1] = t[i] - ma + a[n*3-1-i];
            que2.pop();
            que2.push(a[n*3-1-i]);
        }
        else t[i+1] = t[i] ;
    }
    //集計
    long long res = -(1LL<<60);
    for(int i = n ; i <= n * 2 ; i ++){
        res = max(res, s[i] - t[n*3-i]);
    }
    cout << res << endl;
    
}

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
long long i,j,a,b,c,x,y,z,k;
string s;
int main(){
  cin>>a>>b>>c>>k;
  if(abs(a-b)>pow(10,18))return cout<<"Unfair",0;
  if(k&1)cout<<-1*(a-b);
  else cout<<(a-b);
}

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

typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	int x;
	cin >> x;

	if(x >= 400 && x <600) cout << 8;
	else if(x >= 600 && x < 800) cout << 7;
	else if(x >= 800 && x < 1000) cout << 6;
	else if(x >= 1000 && x < 1200) cout << 5;
	else if(x >= 1200 && x < 1400) cout << 4;
	else if(x >= 1400 && x < 1600) cout << 3;
	else if(x >= 1600 && x < 1800) cout << 2;
	else {
		cout << 1;
	}
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



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

int main() {
    long long a;
    long long b;
    cin >> a >> b;
    long long sum = a + b;
    long long difference = a - b;
    long long mult = a * b;
    long long l = max(sum, difference);
    cout << max(l, mult) << endl;
    //~ if (sum > difference && sum > mult) {
        //~ cout << sum << endl;
    //~ }
    //~ else if (difference > sum && difference > mult) {
        //~ cout << difference << endl;
    //~ }
    //~ else {
        //~ cout << mult << endl;
    //~ }
    return 0;
}



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


int main()
{

    ll n, q, a, b, i, x, p1, ii;
    cin>>n>>q;
    vector<ll>adjmat[n+1];
    vector<ll>out(n+1, 0);
    for(i=0; i<n-1; i++){
        cin>>a>>b;
        adjmat[a].push_back(b);
        adjmat[b].push_back(a);
    }
    for(i=1; i<=n; i++){
        out[i]=0;
    }
    for(ii=0; ii<q; ii++){
        cin>>x>>p1;
        out[x]+=p1;
    }

    stack<ll>s;
        ll  m, p, c;
        //memset(vis, -1, sizeof(vis));
        vector<ll>vis(n+2, -1);
        s.push(1);
        vis[1]=1;
        while(!s.empty()){
            m=s.top();
            s.pop();
            c=0;
            for(i=0; i<adjmat[m].size(); i++){
                p = adjmat[m][i];
                if(vis[p]== -1){
                    s.push(p);
                    out[p] += out[m];
                    vis[p] = 1 ;
                }
            }
        }

    for(int i=1; i<=n; i++){
        cout<<out[i]<<" ";
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 19440
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
char a[55][55],b[55][55];
bool check(int m,int bi,int bj){
		rep(i,m)rep(j,m)
		if(a[bi+i][bj+j]!=b[i][j])return false;
		return true;
}
bool solve(int n,int m){
	rep(i,n-m+1)rep(j,n-m+1){
		if(check(m,i,j))return true;
	}
	return false;
}
int main(){
	int n,m;
	cin>>n>>m;
	rep(k,n)cin>>a[k];
	rep(k,m)cin>>b[k];
	if(solve(n,m))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = Integer.parseInt(sc.nextLine());
            if (n > 100 || n < 1) {
                throw new IllegalTestCaseException();
            }
            double[] xs = Stream.of(sc.nextLine().split(" "))
                    .mapToDouble(Double::parseDouble)
                    .toArray();
            double[] ys = Stream.of(sc.nextLine().split(" "))
                    .mapToDouble(Double::parseDouble)
                    .toArray();
            if (n != xs.length || n != ys.length) {
                throw new IllegalTestCaseException();
            }
            double d1 = minkowskiDistance(n, xs, ys, 1);
            double d2 = minkowskiDistance(n, xs, ys, 2);
            double d3 = minkowskiDistance(n, xs, ys, 3);
            double di = minkowskiDistance(n, xs, ys, -1);
            System.out.printf("%.8f\n%.8f\n%.8f\n%.8f\n", d1, d2, d3, di);
        } catch (IllegalTestCaseException
                | NumberFormatException
                | NoSuchElementException e) {
            System.out.println(e);
        }
    }

    /**
     * @param p
     *   if p is -1, it means p is infinity.
     */
    private static double minkowskiDistance(int n, double[] xs, double[] ys, double p) {
        if (p == -1) {
            double max = -1;
            for (int i = 0; i < n; i++) {
                max = Double.max(Math.abs(xs[i] - ys[i]), max);
            }
            return max;
        }
        double summation = 0;
        for (int i = 0; i < n; i++) {
            summation += Math.pow(Math.abs(xs[i] - ys[i]), p);
        }
        summation = Math.pow(summation, 1 / p);
        return summation;
    }

    private static class IllegalTestCaseException extends RuntimeException {
        IllegalTestCaseException() {
            super("Illegal condition.");
        }
    }
}



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

int sum(int a){
    int s = 0;
    while(a > 0){
        s += a%10;
        a /= 10;
    }
    return s;
}

int main(){
    int n;
    cin >> n;
    int ans = 1e9;
    for(int a = 1; a<n; a++){
        int b = n - a;
        ans = min(ans, sum(a)+sum(b));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	long long a,b,n;
	cin >>a>>b>>n;
	long long ans=0;
	long long t;
/*	rep(x,n+1){
		t=floor(a*x/b)-a*floor(x/b);
		ans = max(t,ans);
	}
*/
	t=min(n,b-1);
	ans=floor(a*t/b);
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	a := getInt()
	b := getInt()
	c := getInt()

	ans := 3
	if (a == b) && (b == c) {
		ans = 1
	} else if a == b {
		ans = 2
	} else if b == c {
		ans = 2
	} else if a == c {
		ans = 2
	}
	out(ans)
}


Measured memory_bytes: 640
import sys
import math
import bisect

def solve(m, A):
    #print('m: %d, A: %s' % (m, str(A)))
    n = len(A)
    A.sort()
    min_val = 10 ** 18
    for i in range(n):
        j = (i + 1) % n
        d = abs(A[i] - A[j])
        val = m - min(d, m - d)
        #print('A[%d]: %d, A[%d]: %d, val: %d' % (i, A[i], j, A[j], val))
        min_val = min(min_val, val)
    return min_val

def main():
    m, n = map(int, input().split())
    A = list(map(int, input().split()))
    print(solve(m, A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 26444
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

int main() {
	int n;
	rd(n);
	if (n - (n & -n) == 0) return prints("No"), 0;
	prints("Yes");
	print(1, 2);
	for (int i = 2; i < n - !(n & 1); i += 2)
		print(i, i + 1), print(i + 1, n + 1), print(n + 1, i + n), print(i + n, i + 1 + n);
	if (!(n & 1)) {
		int x = n & -n, y = n - x;
		print(n, x + 1), print(n * 2, y + n);
	}
	return 0;
}


Measured memory_bytes: 5576
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	ll N;
	cin >> N;

	vl A(N + 1), B(N);

	rep(i, N + 1) {
		cin >> A[i];
	}
	rep(i, N) {
		cin >> B[i];
	}

	ll sum = 0;
	ll d;
	rep(i, N) {
		if (A[i] >= B[i]) {
			sum += B[i];
		}
		else {
			sum += A[i];
			d = B[i] - A[i];

			if (A[i+1] >= d) {
				sum += d;
				A[i + 1] -= d;
			}
			else {
				sum += A[i + 1];
				A[i + 1] = 0;
			}
		}
	}

	cout << sum << endl;


	return 0;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s, t;
	cin >> s >> t;
	FOR (i, 0, sz(s) - 1)
	    if (s[i] != t[i]) {cout << "No"; return 0;}
	    
	cout << "Yes";
}








Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
 
const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
int h, w, k;
string grid[M];
int dir[] = {-1,1,0,0};
int dic[] = {0,0,-1,1};
int dis[M], directions[M];
 
bool valid(int r, int c)
{
    return r >= 0 && r < h && c >= 0 && c < w && grid[r][c] != '@';
}
 
 
int main()
{
    int x1, x2, y1, y2;
    scanf("%d %d %d ", &h, &w, &k);
    scanf("%d %d %d %d ", &x1, &y1, &x2, &y2);
 
    for(int i = 0 ; i< h ;i++)
    {
        string s;
        getline(cin, s);
        grid[i] = s;
    }
    x1--; y1--; x2--; y2--;
    memset(dis, -1, sizeof dis);
    dis[x1*w + y1] = 0;
    directions[x1*w+y1] = 15;
    queue<pair<int, int> > q;
    q.push({x1, y1});
    while(!q.empty())
    {
        int ur = q.front().first, uc = q.front().second;
        // cout<<ur<<" "<<uc<<endl;
        q.pop();
        if(ur == x2 && uc == y2)
            break;
        for(int i = 0 ; i< 4 ; i++)
        {
            int steps = 1, vr, vc;
            while(steps <=k)
            {
                vr = ur + (dir[i] * steps);
                vc = uc + (dic[i] * steps);
                if(valid(vr, vc))
                {
                    if(!((directions[vr*w+vc]>>i) & 1))
                    {
                        if(!directions[vr*w+vc])
                        {
                            dis[vr*w+vc] = dis[ur*w+uc] + 1;
                            q.push({vr, vc});
                        }
                        directions[vr*w+vc] |= (1 << i);
                    }
                    else if(dis[vr*w + vc] ==dis[ur*w+uc] + 1 )
                    {
                        steps++;
                        continue;
                    }
                    else
                        break;
                    
                }
                else
                    break;
                steps++;
            }
        }
    }
    printf("%d", dis[x2*w+y2]);
    return 0;
}

Measured memory_bytes: 43292
#include<cstdio>
#include<algorithm>
#define ll long long
#define rg register
struct ios{
	template<typename TP>
	inline ios operator >> (TP &x)
	{
		TP f=1;x=0;rg char c=getchar();
		for(;c>'9' || c<'0';c=getchar()) if(c=='-') f=-1;
		for(;c>='0' && c<='9';c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
		x*=f;
		return *this;
	}
	template<typename TP>
	inline ios operator << (TP x)
	{
		int top=0,s[66];
		if(x<0) x=-x,putchar('-');
		if(!x) putchar ('0');
		while(x) s[++top]=x%10+'0',x/=10;
		while(top) putchar(s[top--]);
		return *this;
	}
	inline ios operator << (char s)
	{
		putchar(s);
		return *this;
	}
}io;
int n,ans; 
int main()
{
	io>>n;
	io<<(n-1)/2;
	return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=a[0]
del a[0]

num=0
n-=2

while n>0:
  if n==1:
    ans+=a[num]
    n-=1
    
  else:
    ans+=a[num]*2
    n-=2
    num+=1
    
print(ans)

Measured memory_bytes: 31596
#include <bits/stdc++.h>
using namespace std;
bool dp[80][80][80*(80+80)];
int A[80][80];
int B[80][80];
int main(void){
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            cin >> A[i][j];
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            cin >> B[i][j];
    
    dp[0][0][abs(A[0][0]-B[0][0])] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < 80*(80+80); k++) {
                if (dp[i][j][k]) {
                    if (i+1 < H) {
                        dp[i+1][j][k+abs(A[i+1][j]-B[i+1][j])]=1;
                        dp[i+1][j][abs(k-abs(A[i+1][j]-B[i+1][j]))]=1;
                    }
                    if (j+1 < W) {
                        dp[i][j+1][k+abs(A[i][j+1]-B[i][j+1])]=1;
                        dp[i][j+1][abs(k-abs(A[i][j+1]-B[i][j+1]))]=1;
                    }
                }
            }
        }
    }
    
    int ans;
    for (int i = 0; i < 80*(80+80); i++)
        if (dp[H-1][W-1][i]) {
            ans = i;
            break;
        }
    cout << ans << endl;
}

Measured memory_bytes: 79488
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int n;
int a,b;
char s[100005];


int main(void){
    int yes=0;
    int bb=0;
    scanf("%d %d %d",&n,&a,&b);
    scanf("%s",s);
    int sum=a+b;

    for(int i=0;s[i]!='\0';i++){
        if(s[i]=='c'){printf("No\n");}
        else if(s[i]=='a'&&sum>yes){printf("Yes\n");yes++;}
        else if(s[i]=='b'&&sum>yes&&b>bb){printf("Yes\n");yes++;bb++;}
        else{printf("No\n");}
    }
}

Measured memory_bytes: 640
"""
problem statment url: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C
"""
 
from __future__ import division
from sys import stdin, maxint

def knapsack(N, W, infos):
    dp = [0] * (W + 1)
    for i in range(N):
    	for j in range(infos[i][1], W + 1):
    		dp[j] = max(dp[j], dp[j - infos[i][1]] + infos[i][0])
    return dp[W]
 
if __name__ == '__main__':
    N, W = map(int, stdin.readline().strip().split())
    infos = []
    for _ in range(N):
        v, w = map(int, stdin.readline().strip().split())
        infos.append((v, w))
    print(knapsack(N, W, infos))

Measured memory_bytes: 7052
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
main()
{
	fast();
	int t=1;
	//cin>>t;
	while(t--)
	{
		string s,t;
		cin>>s>>t;
		int cnt=0;
		for(int i=0;i<s.length();i++)
		{
			if(s[i]!=t[i])
			cnt++;
		}
		cout<<cnt<<endl;
	}
	
}




Measured memory_bytes: 3796
import sys
readline = sys.stdin.readline

D = {
	"N": (0, 1),
	"E": (1, 0),
	"S": (0, -1),
	"W": (-1, 0),
}

while True:
	n = int(readline())
	if n == 0: break
	gems = {tuple(int(x) for x in readline().split()) for i in xrange(n)}
	x = 10
	y = 10
	try:
		gems.remove((x, y))
	except KeyError:
		pass
	for i in xrange(int(readline())):
		c, cnt = readline().split()
		dx, dy = D[c]
		for j in xrange(int(cnt)):
			x += dx
			y += dy
			try:
				gems.remove((x, y))
			except KeyError:
				pass
	print "No" if gems else "Yes"

Measured memory_bytes: 4304
N, K= [int(x) for x in input().split()]
t = [[] for i in range(N)]
for i in range(K):
  q,ans = input().split()
  t[int(q)-1].append(ans)

wa = 0
ac = 0
for i in t:
  w_tmp = 0
  for j in i:
    if j == "WA":
      w_tmp += 1
    elif j== "AC":
      ac += 1
      wa += w_tmp
      break
print(ac,wa)

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int zero = n / k;
    int half = k % 2 == 0 ? (n + k / 2) / k : 0;
    cout << (long long) zero * zero * zero + (long long) half * half * half << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
int h, w;
vector<vector<int>> dp(100,vector<int>(100,INF));
string s[100];

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

int dfs(int i, int j) {
  if(dp[i][j] != INF) return dp[i][j];
  int res = INF;
  rep(k,2) {
    int nx = i + dx[k], ny = j + dy[k];
    if(nx < h && ny < w) {
      if(s[i][j] == s[nx][ny]) res = min(dfs(nx,ny),res);
      else res = min(dfs(nx,ny)+1,res);
    }
  }
  return dp[i][j] = res; 
}

int main(){
  cin >> h >> w;
  rep(i,h) cin >> s[i];
  if(s[h-1][w-1] == '#') dp[h-1][w-1] = 1;
  else dp[h-1][w-1] = 0;
  int ans = dfs(0,0);
  if(s[0][0] == '#') ans++;
  cout << ans / 2 << endl;
  return 0;
}


Measured memory_bytes: 384
# encoding:utf-8

import copy
import numpy as np
import random

N = int(input())
n = N
C = []
S = []
F = []
for i in range(n-1):
    c,s,f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

answer = []
for i in range(n-1):
    to_goal = C[i] + S[i]
    for j in range(i+1,n-1):
        if to_goal >= S[j]:
            if to_goal % F[j] == 0:
                to_goal += C[j]
            else:
                to_goal = ((to_goal//F[j])+1)*F[j]+C[j]
        elif to_goal < S[j]:
            to_goal = S[j]+C[j]

    answer.append(to_goal)


answer.append(0)
for i in range(len(answer)):
    print(answer[i])


Measured memory_bytes: 13520
// https://atcoder.jp/contests/abc149/tasks/abc149_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll A, B, K;
  cin >> A >> B >> K;

  ll a_res = max(A - K, 0ll);
  ll b_res = max(0ll, B - max(0ll, K - (A - a_res)));

  cout << a_res << " " << b_res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,h,ar,area;
    scanf("%d %d %d",&a,&b,&h);
    if(h%2==0)
    {
        ar = (a+b)*h;
        area = ar / 2;

       printf("%d",area);
    }
    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <functional>

int main()
{
    int w;
    std::cin >> w;
    std::vector<int> v(w);
    for(int i = 0; i < w; ++i){
        v[i] = i+1;
    }
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        int a, b;
        char c;
        std::cin >> a >> c >>  b;
        std::swap(v[a-1], v[b-1]);
    }
    for(int i = 0; i < w; ++i){
        std::cout << v[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3000
#include <stdio.h>
#include <vector>
 
using namespace std;
 
struct Node{
    Node(){
        brother = parent = -1;
        height = depth = num_of_children = 0;
    }
    int parent,brother,depth,num_of_children,height;
    vector<int> children;
};
 
void calcDepth(Node nodes[],int root_id){
    for(int i = 0;i < nodes[root_id].num_of_children;i++){
        nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
        calcDepth(nodes,nodes[root_id].children[i]);
    }
}
 
void calcHeight(Node nodes[],int height,int parent){
    nodes[parent].height = max(nodes[parent].height,height+1);
    if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}
 
int main(){
    int n,id,left_id,right_id,root_id;
    scanf("%d",&n);
    Node nodes[n];
 
    for(int i = 0; i < n; i++){
        scanf("%d %d %d",&id,&left_id,&right_id);
        if(left_id != -1){
            nodes[id].children.push_back(left_id);
            nodes[id].num_of_children++;
            nodes[left_id].parent = id;
        }
        if(right_id != -1){
            nodes[id].children.push_back(right_id);
            nodes[id].num_of_children++;
            nodes[right_id].parent = id;
        }
        if(left_id != -1 && right_id != -1){
            nodes[left_id].brother = right_id;
            nodes[right_id].brother = left_id;
        }
    }
 
    for(root_id = 0; root_id < n; root_id++){
        if(nodes[root_id].parent == -1) break;
    }
 
    if(n > 1){
        calcDepth(nodes,root_id);
 
        for(int i = 0; i < n; i++){
            if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
        }
    }
 
    for(int i = 0; i < n; i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
                ,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
        if(nodes[i].parent == -1){
            printf(" root\n");
        }else if(nodes[i].num_of_children == 0){
            printf(" leaf\n");
        }else{
            printf(" internal node\n");
        }
 
    }
}


Measured memory_bytes: 2788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll K;

    cin >> K;

    string S;
    ll l;

    cin >> S;
    l = S.length();

    if(l <= K){
        cout << S << endl;
    }else{
        for(ll i = 0; i < K; i++){
            cout << S[i];
        }
        cout << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int rui(int a, int b) {
    if(b == 0) {
        return 1;
    }
    return rui(a, b - 1) * a;
}
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    if(A + K - 1 >= B - K + 1) {
        rep(i, A, B + 1) { cout << i << endl; }
    } else {
        rep(i, A, A + K) { cout << i << endl; }
        rep(i, B - K + 1, B + 1) { cout << i << endl; }
    }
}

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

using namespace std;

int main(){
  int n,a,b;
  cin >> n;
  if ( n == 1) cout << "Hello World" << endl;
 else if (n == 2){
    cin >> a;
    cin >> b;
    cout << a+b << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  string s;
  cin >> s;
  int ans = 1e9;
  int n = s.size();
  rep(i,n-2) {
    int a = s.at(i) - '0';
    int b = s.at(i+1) - '0';
    int c = s.at(i+2) - '0';
    int x = a*100 + b*10 + c;
    ans = min(ans, abs(x-753));
  }
  cout << ans;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	c0 := 0
	c1 := 0
	for _, v := range s {
		if v == '0' {
			c0++
		} else {
			c1++
		}
	}

	if c1 > c0 {
		fmt.Println(c0 * 2)
	} else {
		fmt.Println(c1 * 2)
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846


//見ながら
int main() {

  double a, b, x;
  cin >> a >> b >> x;
  double s = x / a;
  double rad;
  if(s >= a * b / 2){
    double h = (a * b - s) * 2 / a;
    rad = atan2(h, a);
  }else{
    double w = s * 2 / b;
    rad = atan2(b, w);
  }
  double PI = acos(-1);
  double deg = rad / (2 * PI) * 360;
  printf("%.10f\n", deg);
  return 0;

}



Measured memory_bytes: 256
s=input()

def isg(s):
        if len(s)%2!=0:
                return False
        s1=s[:len(s)//2]
        s2=s[len(s)//2:]
        return s1==s2

while len(s) != 0:
        s=s[:-1]
        if isg(s):
                print(len(s))
                exit()

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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = n / x;
  if (n % x != 0) ans++;
  cout << ans * t << endl;
  return 0;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int L = sc.nextInt();
    List<String> slist = new ArrayList<>();
    
		// 文字列の入力
    for(int i=0; i<N; i++){
      slist.add(sc.next());
    }
    List<String> subList = slist.subList(1, slist.size());
    Collections.sort(slist);
    StringBuffer sb = new StringBuffer(L * N);
    for(String s: slist){
     sb.append(s);
    }
    System.out.println(sb);
	}
}


Measured memory_bytes: 10004
#include <algorithm>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<long> a(n);
  for (auto &v : a)
    std::cin >> v;
  int q;
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    long k;
    std::cin >> k;
    auto r = std::equal_range(a.begin(), a.end(), k);
    std::cout << r.first - a.begin() << " " << r.second - a.begin()
              << std::endl;
  }
}



Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<deque>
using namespace std;
int main() {

	int x;
	cin >> x;
	int i;
	for (i = 0; i <= x; i++) {

		if (((i * (i - 1)) / 2 < x) && (x <= (i * (i + 1)) / 2)) {
			cout << i << endl;
			return 0;
		}

	}
	return 0;

}

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
#define ll long long
#define int long long

pair<int,int> ans[100010];
int ans2[100010];
int p;

signed main(){
    int n,k;cin>>n>>k;
    ll now=(3*n+1)/2;
    if(n%2){
        for(int i=1;i<=n;i++){
            int tmp=i%2==0?(n+1)/2+i/2:(i+1)/2;
            ans[p++]={tmp,now+i-tmp};
        }
    }
    else{
        for(int i=1;i<n;i++){
            int tmp=i%2==0?n/2+1+i/2:(i+1)/2;
            ans[p++]={tmp,(now+1+i/2*2)-tmp};
        }
        ans[p++]={n/2+1,2*n};
    }

    // for(int i=0;i<n;i++){
    //         cout<<ans[i].first<<" "<<ans[i].second<<" "<<ans[i].first+ans[i].second<<endl;
    //     }

    for(int i=0;i<n;i++)ans2[i]=k+n*2+i,ans[i].first+=k-1,ans[i].second+=k-1;
    for(int i=0;i<n;i++){
        if(ans[i].first+ans[i].second>ans2[i]){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i].first<<" "<<ans[i].second<<" "<<ans2[i]<<endl;
    }
}

Measured memory_bytes: 4608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		if (n == 0) {
			System.out.println(0);
			return;
		}

		List<Integer> list = new ArrayList<>();
		while (n != 1) {
			if (n < 0) {
				list.add(-n % 2);
				n = (-n + 1) / 2;
			} else {
				list.add(n % 2);
				n = -(n / 2);
			}
		}
		System.out.print(1);
		Collections.reverse(list);
		for (int i : list) {
			System.out.print(i);
		}
		System.out.println();
	}
}


Measured memory_bytes: 23124
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    a, b, c, d, e, f = ns()
    max_cncnt, ans_sum, ans_sugar = -1, 0, 0

    sugar_cand = []
    sugar_dp = [False for _ in range(f + 1)]
    sugar_dp[0] = True
    for i in range(f + 1):
        if sugar_dp[i]:
            if i + c <= f:
                sugar_dp[i + c] = True
            if i + d <= f:
                sugar_dp[i + d] = True
            sugar_cand.append(i)

    for i in range(f // (100 * a) + 1):
        for j in range(f // (100 * b) + 1):
            water = 100 * (a * i + b * j)
            if water == 0:
                continue
            if water > f:
                break
            sugar_lim = min(water * e // 100, f - water)
            sugar_idx = bisect.bisect_right(sugar_cand, sugar_lim)
            sugar = 0 if sugar_idx == 0 else sugar_cand[sugar_idx - 1]
            if max_cncnt < sugar / (water + sugar):
                ans_sum = water + sugar
                ans_sugar = sugar
                max_cncnt = ans_sugar / ans_sum

    print(ans_sum, ans_sugar)


if __name__ == '__main__':
    main()


Measured memory_bytes: 85260