akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


using ll = long long;
using pll = pair<ll, ll>;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        ll X, Y, Z; cin >> X >> Y >> Z;
        ll N = X + Y + Z;
        vector<tuple<ll, ll, ll>> coin(N);
        rep(i, N) {
            auto &c = coin[i];
            cin >> get<0>(c) >> get<1>(c) >> get<2>(c);
        }
        sort(all(coin), [] (tuple<ll, ll, ll> &a, tuple<ll, ll, ll> &b) {
                return get<0>(a) - get<1>(a) < get<0>(b) - get<1>(b);
            });

        priority_queue<pll> que_l, que_r;

        vector<ll> sum_l(N), sum_r(N);

        rep(i, Y + Z) {
            if(i > 0) sum_l[i] = sum_l[i - 1];
            sum_l[i] += get<1>(coin[i]);      
            ll diff = get<2>(coin[i]) - get<1>(coin[i]);
            que_l.push(make_pair(diff, i));
            if(que_l.size() > Y) {
                pll now = que_l.top(); que_l.pop();
                sum_l[i] -= get<1>(coin[now.second]);
                sum_l[i] += get<2>(coin[now.second]);
            }
        }
        reverse(all(coin));
        rep(i, X + Z) {
            if(i > 0) sum_r[i] = sum_r[i - 1];
            sum_r[i] += get<0>(coin[i]);      
            ll diff = get<2>(coin[i]) - get<0>(coin[i]);
            que_r.push(make_pair(diff, i));
            if(que_r.size() > X) {
                pll now = que_r.top(); que_r.pop();
                sum_r[i] -= get<0>(coin[now.second]);
                sum_r[i] += get<2>(coin[now.second]);
            }
        }

        ll ans = -INF;
        repeat(k, Y - 1, Y + Z) {
            set_max(ans, sum_l[k] + sum_r[N - (k + 1) - 1]);
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 6644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <set>


using namespace std;

using PV = pair<int, vector<int>>;

using PII = pair<int, int>;

void show(vector<int> &v) {
	for (auto x: v) {
		printf("%d ", x);
	}
	printf("\n");
}

PV calc(vector<int> v) {
	int maxi = 0;
	vector<int> nums;
	for (int i = 0; i < v.size(); i++) {
		if (v[i] > maxi) {
			maxi = v[i];
			nums = {i};
		} else if (v[i] == maxi) {
			nums.emplace_back(i);
		}
	}

	// printf("maxi %d: nums ", maxi);
	// for (auto x: nums) {
	// 	printf("%d ", x);
	// }
	// printf("\n");
	return PV(maxi, nums);
}

int main() {
	int h, w, m;
	cin >> h >> w >> m;

	set<PII> bombs;
	vector<int> bomb_row(h, 0), bomb_col(w, 0);
	int row, col;
	for (int i = 0; i < m; i++) {
		cin >> row >> col;
		row--;
		col--;
		bombs.emplace(row, col);
		bomb_row[row]++;
		bomb_col[col]++;
	}

	// show(bomb_row);
	// show(bomb_col);

	auto ret_r = calc(bomb_row);
	auto ret_c = calc(bomb_col);

	int ans = ret_r.first + ret_c.first - 1;
	for (auto r: ret_r.second) {
		for (auto c: ret_c.second) {
			if (bombs.count(make_pair(r, c)) == 0) {
				ans++;
				cout << ans << endl;
				return 0;
			}
		}
	}

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


Measured memory_bytes: 24756
#include <stdio.h>

#define N 100000

int main() {
	static char s[N + 1];
	int n, i, k;

	scanf("%d%s", &n, s);
	k = 1;
	for (i = 0; i < n - 1; i++)
		if (s[i] != s[i + 1])
			k++;
	printf("%d\n", k);
	return 0;
}


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

int main() {
    int A, B, C;

    cin >> A >> B >> C;

    if (A > 1 && B > 1 && C > 1 && A * B * C == 175) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
A, B, C, D = ri_()
print(max(0, min(B, D) - max(A, C)))

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


int main(){
	char numbers[3000];
	char x;
	char one[5] = {'.',',','!','?', ' '};
	char two[3] = {'a','b','c'};
	char three[3] = {'d','e','f'};
	char four[3] = {'g','h','i'};
	char five[3] = {'j','k','l'};
	char six[3] = {'m','n','o'};
	char seven[4] = {'p','q','r','s'};
	char eight[3] = {'t', 'u', 'v'};
	char nine[4] = {'w','x','y','z'};
	int n, rem_n, i=0, j=0;
	int counter = 0;
	int cases;
	scanf("%d\n", &cases);

	fgets(numbers, sizeof(numbers), stdin);
	//printf("%s", numbers);
	while(1){
		x = numbers[i++];

		while(x != '\0'){
			n = atoi(&x);
			rem_n = n;
			if(n != 0){
				while(x != '\n'){
					if(n == rem_n){
						counter++;
						//printf("counter+:%d\n",counter);
					}
					else if(x == '0'){
						switch(rem_n){
							case 1: printf("%c", one[(counter-1)%5]);
									break;
							case 2: printf("%c", two[(counter-1)%3]);
									break;
							case 3: printf("%c", three[(counter-1)%3]);
									break;
							case 4: printf("%c", four[(counter-1)%3]);
									break;
							case 5: printf("%c", five[(counter-1)%3]);
									break;
							case 6: printf("%c", six[(counter-1)%3]);
									break;
							case 7: printf("%c", seven[(counter-1)%4]);
									break;
							case 8: printf("%c", eight[(counter-1)%3]);
									break;
							case 9: printf("%c", nine[(counter-1)%4]);
									break;
						}
						counter = 0;
						x = numbers[i++];
						break;
					}
					else{
						counter = 1;					
						break;
					}
					x = numbers[i++];
					n = atoi(&x);					
				}
			}				
			else{
				x = numbers[i++];
			}
		}
		newline:
		printf("\n");
		if(++j >= cases)
			break;
		fgets(numbers, sizeof(numbers), stdin);
		i = 0;
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int p = scan.nextInt();
		int q = scan.nextInt();
		int r = scan.nextInt();

		int[] a = {p, q, r};
		Arrays.sort(a);

		System.out.println(a[0] + a[1]);
	}
}


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

int main()
{
  int n;
  int a, b, c;

  cin >> n;
  if (n == 2){
    cin >> a >> b;
    if (a > b){
      int c = a;
      a = b;
      b = c;
    }
    for (int i = 1; i <= a; i++){
      if (a % i == 0 && b % i == 0){
        cout << i << "\n";
      }
    }
    return 0;
  }

  cin >> a >> b >> c;
  if (c < b){
    int d = c;
    c = b;
    b = d;
  }
  if (b < a){
    int d = a;
    a = b;
    b = d;
  }
  if (c < b){
    int d = c;
    c = b;
    b = d;
  }
  for (int i = 1; i <= a; i++){
    if (a % i == 0 && b % i == 0 && c % i == 0){
      cout << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	string s;
	cin >> s;
	string str[101];
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		string t;
		cin >> t;
		t+=t;
		str[i]=t;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(str[i].find(s)!=string::npos)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

// {y, x}
set<pair<int, int>> obs;
vector<int> acc_h;
vector<int> acc_w;

// {cnt, h}
vector<pair<int, int>> acc_cnt_h;
// {cnt, w}
vector<pair<int, int>> acc_cnt_w;

int main(void) {
    int H, W, M;
    cin >> H >> W >> M;

    acc_h.resize(H);
    acc_w.resize(W);
    for (int i = 0; i < M; i++) {
        int h, w;
        cin >> h >> w;
        h--;
        w--;
        obs.insert(make_pair(h, w));
        acc_h[h]++;
        acc_w[w]++;
    }

    for (int i = 0; i < H; i++) {
        acc_cnt_h.push_back(make_pair(acc_h[i], i));
    }
    sort(acc_cnt_h.begin(), acc_cnt_h.end());
    reverse(acc_cnt_h.begin(), acc_cnt_h.end());

    for (int i = 0; i < W; i++) {
        acc_cnt_w.push_back(make_pair(acc_w[i], i));
    }
    sort(acc_cnt_w.begin(), acc_cnt_w.end());
    reverse(acc_cnt_w.begin(), acc_cnt_w.end());

#ifdef DEBUG
    printf("acc_cnt_h: \n");
    for (int i = 0; i < H; i++) {
        cout << acc_cnt_h[i].first << " " << acc_cnt_h[i].second << endl;
    }
    printf("acc_cnt_w: \n");
    for (int i = 0; i < W; i++) {
        cout << acc_cnt_w[i].first << " " << acc_cnt_w[i].second << endl;
    }
#endif

    int max_cnt_h = acc_cnt_h[0].first;
    int max_cnt_w = acc_cnt_w[0].first;

    vector<int> max_hs;
    vector<int> max_ws;
    for (auto p : acc_cnt_h) {
        if (p.first != max_cnt_h) {
            break;
        }
        max_hs.push_back(p.second);
    }
    for (auto p : acc_cnt_w) {
        if (p.first != max_cnt_w) {
            break;
        }
        max_ws.push_back(p.second);
    }

    int ans = max_cnt_h + max_cnt_w - 1;
    for (auto h : max_hs) {
        for (auto w : max_ws) {
#ifdef DEBUG
            printf("calc for: h=%d, w=%d\n", h, w);
#endif
            if (obs.find(make_pair(h, w)) == obs.end()) {
                ans = max_cnt_h + max_cnt_w;
                goto end;
            }
        }
    }

end:
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 28820
h,w,m=map(int,input().split())
B=[[] for i in range(h)]
H=[0]*h
W=[0]*w
for i in range(m):
    p,q=map(int,input().split())
    B[p-1].append(q-1)
    H[p-1]+=1
    W[q-1]+=1
mH=max(H)
mW=max(W)
CH=[]
for i in range(h):
    if H[i]==mH:
        CH.append(i)
CW=[]
for i in range(w):
    if W[i]==mW:
        CW.append(i)
CW=set(CW)
flag=0
if len(CH)*len(CW)>m:
    flag=1
else:
    for ch in CH:
        b=set(B[ch])
        if CW<=b:
            continue
        else:
            flag=1
            break
if flag:
    print(mH+mW)
else:
    print(mH+mW-1)

Measured memory_bytes: 168304
#include "bits/stdc++.h"

using namespace std;

const long long MOD = 1000000007;

void Main() {
    long long N;
    cin >> N;
    vector<long long> A(N, 0LL);
    long long total = 0LL;
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
        total += A[i];
        total %= MOD;
    }

    vector<long long> accum(N, 0LL);
    accum[0] = A[0];
    for (long long i = 1; i < N; ++i) {
        accum[i] = accum[i - 1] + A[i];
    }

    long long ans = 0LL;
    for (long long i = 0; i < N - 1; ++i) {
        long long temp = (A[i] * ((total - accum[i]) % MOD)) % MOD;
        ans += temp;
        ans %= MOD;
    }
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
 
  int r, b, g;
  cin >> r >> b >> g;

  int sum = r * 100 + b * 10 + g;

  if (sum % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}

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

#define INF (1<<30)

int dfs(int a, int b, int c, int i);

int N,A,B,C;
int l[9];

int main(){
	cin>>N>>A>>B>>C;
	for(int i=0;i<N;i++)cin>>l[i];

	int ans=dfs(0,0,0,0);

	cout<<ans<<endl;

	return 0;
}


int dfs(int a, int b, int c, int i){
	if(i==N){
		if(a && b && c ){
			return abs(a-A) + abs(b-B) + abs(c-C) - 30;
		}else return INF;
	}

	int ans=dfs(a,b,c, i+1);
	ans = min(ans, dfs(a+l[i], b	 , c	 , i+1) + 10);
	ans = min(ans, dfs(a	 , b+l[i], c	 , i+1) + 10);
	ans = min(ans, dfs(a	 , b	 , c+l[i], i+1) + 10);

	return ans;
}


Measured memory_bytes: 256
package main

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

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	n, _ := strconv.Atoi(nextLine())

	result := map[string]int{}

	arr := make([]string, n)
	for i := 0; i < n; i++ {
		arr[i] = nextLine()
	}

	// instruction loop
	for _, v := range arr {
		parseCommand(v, result)
	}
}

func parseCommand(line string, m map[string]int) {
	ls := strings.Split(line, " ")
	inst := ls[0]
	value := ls[1]

	switch inst {
	case "insert":
		insert(value, m)
	case "find":
		find(value, m)
	}
}

func insert(value string, m map[string]int) {
	m[value] = 1
}

func find(value string, m map[string]int) {
	_, ok := m[value]
	if ok {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}



Measured memory_bytes: 86608
#include <stdio.h>
#include <math.h>
int main(void){
    int n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double v1, v2, v3, v4;
    double cross;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        v1 = x2-x1;
        v2 = y2-y1;
        v3 = x4-x3;
        v4 = y4-y3;
        cross=fabs((v2*v3)-(v1*v4));
        if(cross<0.0000000001){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2024
def b(M,x,y,n=1):
 M[x][y]='0';t=[]
 if'1'==M[x-1][y]:t+=[b(M,x-1,y,n+1)]
 if'1'==M[x][y-1]:t+=[b(M,x,y-1,n+1)]
 if'1'==M[x+1][y]:t+=[b(M,x+1,y,n+1)]
 if'1'==M[x][y+1]:t+=[b(M,x,y+1,n+1)]
 M[x][y]='1'
 return max([n]+t)
for e in iter(input,'0'):
 n,m=int(e),int(input())
 P=[['0']*(n+2)for _ in[0]*(m+2)]
 for i in range(m):P[i+1][1:-1]=input().split()
 print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if'1'==P[i][j]))


Measured memory_bytes: 5728
#include <bits/stdc++.h>
// D - Restore the Tree

using namespace std;

vector<int> adj[100005],adj2[100005];
bool vis[100005];
vector<int> top;
int par[100005];
int dep[100005];

void dfs(int cur) {
    vis[cur] = true;

    for (int nxt : adj[cur]) {
        if (!vis[nxt])
            dfs(nxt);
    }

    top.push_back(cur);
}

int main() {
    int N,M,i,A,B;

    scanf("%d%d",&N,&M);

    for (i = 1;i < N + M;i++) {
        scanf("%d%d",&A,&B);
        adj[A].push_back(B);
        adj2[B].push_back(A);
    }

    for (i = 1;i <= N;i++) {
        if (!vis[i])
            dfs(i);
    }

    reverse(top.begin(),top.end());

    for (i = 1;i < N;i++) {
        dep[top[i]] = -1;

        for (int j : adj2[top[i]]) {
            if (dep[j] > dep[top[i]]) {
                par[top[i]] = j;
                dep[top[i]] = dep[j];
            }
        }

        dep[top[i]]++;
    }

    for (i = 1;i <= N;i++)
        printf("%d\n",par[i]);

    return 0;
}


Measured memory_bytes: 16380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define all(x) (x).begin(), (x).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n;
    vector<int> d(n);
    rep(i, 0, n) cin >> d[i];
    cin >> m;
    vector<int> t(m);
    rep(i, 0, m) cin >> t[i];

    map<int, int> mpd, mpt;
    rep(i, 0, n) mpd[d[i]]++;
    rep(i, 0, m) mpt[t[i]]++;
    rep(i, 0, m) {
        int x = t[i];
        if (mpd[x] < mpt[x]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 23364
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A==1){
            A=14;
        }
        if(B==1){
            B=14;
        }
        if(A < B){
            System.out.println("Bob");
        }
        else if(A > B){
            System.out.println("Alice");
        }
        else{
            System.out.println("Draw");
        }
    }
}


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

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

const int N = (int) 2e5 + 100;

int pref[N];
int suff[N];
bool ok[N];

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

	int n, k, c;
	cin >> n >> k >> c;

	for (int i = 1; i <= n; i++) {
		char s;
		cin >> s;

		ok[i] = s == 'o';
	}

	set<int> pos;

	for (int i = 1; i <= n; i++) {
		if (ok[i]) {
			pos.insert(i);
		}

		auto it = pos.upper_bound(i - c - 1);

		pref[i] = 1;

		if (it != pos.begin()) {
			it--;
			pref[i] += pref[*it];
		}
	}

	pos.clear();

	for (int i = n; i >= 1; i--) {
		if (ok[i]) {
			pos.insert(i);
		}

		auto it = pos.lower_bound(i + c + 1);

		suff[i] = 1;

		if (it != pos.end()) {
			suff[i] += suff[*it];
		}
	}

//	for (int i = 1; i <= n; i++) {
//		cout << pref[i] << " " << suff[i] << "\n";
//	}

	vector<pii> lastPref;
	vector<pii> nextSuff;

	for (int i = n; i >= 2; i--) {
		if (ok[i]) {
			nextSuff.emplace_back(pref[i] + suff[i] - 1, i);
		}
	}

	for (int i = 1; i <= n; i++) {
		if (!nextSuff.empty() && nextSuff.back().second == i) {
			nextSuff.pop_back();
		}

		int last = lastPref.empty() ? 0 : lastPref.back().first - (lastPref.back().second + c + 1 <= i);
		int next = nextSuff.empty() ? 0 : nextSuff.back().first - (i + c + 1 <= nextSuff.back().second);

		if (ok[i] && pref[i] + suff[i] - 2 < k && pref[i] + suff[i] - 1 >= k &&
				last < k && next < k) {
			cout << i << "\n";
		}

		if (ok[i]) {
			lastPref.emplace_back(pref[i] + suff[i] - 1, i);
		}
	}

	return 0;
}

Measured memory_bytes: 16880
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc     = new Scanner(System.in);
        char[]  S      = sc.next().toCharArray();
        long    result = 0L;

        if (S.length == 1) {
            System.out.println(S[0]);
            return;
        }

        for (int bit = 0; bit < (1 << (S.length - 1)); ++bit) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < (S.length); ++i) {
                sb.append(S[i]);
                if ((bit & (1 << i)) > 0) {
                    sb.append("+");
                }
            }
            String[] term = sb.toString().split("\\+", 0);
            result += Arrays.stream(term).mapToLong(Long::parseLong).sum();
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 27092
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  if (N>999) cout <<"ABD"<<endl;
  else cout << "ABC" << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  
{ string h;
 getline(cin,h);int k=0;
 int g=h.length();
 for(int i=0;i<g/2;i++)
 {if (h[i]==h[g-i-1])
    continue;
  else 
    {k++;
    }
 
 
 
 
 }

cout<<k;


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    string str = "";

    while (N != 0) {
        int r = N % 2;
        if (r < 0) r += 2;

        N = (N - r) / (-2);

        str += (char)('0' + r);
    }

    reverse(str.begin(), str.end());
    if (str == "") str = "0";
    cout << str << endl;
}

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

int main(){
  int n; cin >> n;
  bool ok = false;
  for(int i = 0; i < 30; i++){
    for(int j = 0; j < 20; j++){
      if(4 * i + 7 * j == n) ok = true;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}
      

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

int main(){
  string str;
  char c;
  getline(cin, str);
  for(int i = 0; i < str.size(); i++){
    if(str.at(i) == ' '){
      c = str.at(i + 1);
      break;
    }
  }
  cout << 'A' << c << 'C' << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;


int main(){
  int D,G;
  cin >> D >> G ;
  vector<pii> V(D);
  rep(i,D){
    cin >> V[i].first >> V[i].second;
  }
  int m =10000000;
  rep(i,D){
    rep(j,(1<<10)){
      int M =0;
      int count=0;
      rep(k,i) {
        if(j&(1<<k)){
          M+=(k+1)*100*V[k].first+V[k].second;
          count+=V[k].first;
        }
      }
      for(int k=i+1;k<D;k++){
        if(j&(1<<k)){
          M+=(k+1)*100*V[k].first+V[k].second;
          count+=V[k].first;
        }
      }
      if (M+(i+1)*100*V[i].first+V[i].second<G) continue;
      if (M>G) m=min(m,count);
      else if ((G-M+(i+1)*100-1)/((i+1)*100)<V[i].first) m=min(m,count+(G-M+(i+1)*100-1)/((i+1)*100));
      else m=min(m,count+V[i].first);
    }
  }
  cout << m << endl;
}

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

int main(){

    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    int sum = 0;
    sum = A1 + A2 + A3;

    string ans;
    if( sum >= 22){
        ans = "bust";
    }else{
        ans = "win";
    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n ; 
    cin >> n ; 

    vector<pair<ll,ll>> A(n);  
    for(int i = 0 ; i < n ; ++i){
        cin >> A[i].first >> A[i].second ; 
    }

    auto comp = [&](pair<ll,ll>& a,  pair<ll,ll>& b){
        return a.first + a.second < b.first + b.second ;
    };

    sort(A.begin(),A.end(),comp); 


    vector<vector<ll>> dp (n+1 , vector<ll> (n + 1, 1e14)); 

    dp[0][0] = 0 ;

    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j <= n ; ++j){
            if (j == 0){
                dp[i][j] = min(dp[i][j] , dp[i-1][j]) ; 
                continue ;
            }
            
            dp[i][j] = dp[i-1][j]; 
            
            // if(i == 1 && j == 1){
            //     cout <<"&&&&&&&&&&&&&&&77"<<"\n";
            //     cout << dp[i-1][j] << "\n";
            //     cout << dp[i-1][j-1] << "\n";
            //     cout <<A[i-1].first <<" , "<< A[i-1].second << "\n"; 
            //     cout <<"%%%%%%%%%%%%%%%%%%"<<"\n";
            // }

            if(A[i-1].first >=  dp[i-1][j-1]){
                dp[i][j] = min (dp[i][j], A[i-1].second + dp[i-1][j-1] ); 
            }


        }
        

    }

    // cout <<"dp array :: "<< "\n";

    // for(int i = 1 ; i <= n ;++i){
    //     for(int j = 1 ; j <= n ;++j){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    for(int j = n ; j >= 0 ;--j){
        if (dp[n][j] != 1e14){
            cout <<  j << "\n"; 
            break; 
        }
    }

    
  
    return 0;
}



Measured memory_bytes: 195968
#include<stdio.h>
using namespace std;
bool f[1000000005];
int main(){
	int n;bool is=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(f[x]==1) {
		is=0;break;}
		f[x]=1;
	}
	if(is) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 975360
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<int>())
#define init(a)  memset((a),0,sizeof(a))
#define pi pair<int,int>
#define pb push_back
#define pl pair<ll,ll>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
long double EPS = 1e-9;

/*struct comp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};*/

ll cel(ll a,int b){return((a-1)/b+1);} 
ll gcd(ll a, ll b){
    if (a < b)swap(a, b);
    return (b == 0)? a: gcd(b, a % b);
}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int main()
{
    FIO;
    ll n,k,t,x,y,u,ans=-mod,id,id1,p,u1;
    cin>>n>>k;
    vl v(n+1),C(n+1);
    vl A[n+1];
    rep(i,1,n+1){cin>>v[i];}
    rep(i,1,n+1){cin>>C[i];}
    rep(i,1,n+1){
        y=v[i];x=0;
        while(1){
            x+=C[y];
            A[i].pb(x);
            if(y==i)break;
            y=v[y];
        }
    }
    rep(i,1,n+1){
        id=0;y=0;u=-mod;u1=-mod;
        p=k%(A[i].size());
        //if(i==1)cout<<(A[i].size())<<" "<<p<<" ";
        for(ll t:A[i]){
            y++;
            if(t>u){u=max(t,u);id=y;}
            if(y<=p&&(t>u1)){u1=max(t,u1);}
        }
        if(k<A[i].size()){ans=max(u1,ans);}
        else if(A[i].back()<=0){ans=max(u,ans);}
        else{
            ll l=(k/(A[i].size()))+(k%(A[i].size())==0?-1:0);
            //if(i==1)cout<<id<<" "<<l<<" ";
            if(p>=id||(p==0)){u=u+(A[i].back())*(l);}
            else if(A[i].back()+u1>u){u=u1+(A[i].back())*(l);}
            else {u=u+(A[i].back())*(l-1);}
            ans=max(u,ans);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 219040
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
ll N;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>s;
    ll c=0;
    for(auto ch:s){
        if(ch=='R'){
            c++;
        }
    }
    cout<<(c>N-c?"Yes":"No")<<endl;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int parent;
    long size; //根だったらその木のサイズを表す
}node;

//union-ford木のメモリを確保→初期化して出力(0からカウント)
node* build_union_ford(int N){
    node* T;
    NEW(T,N);
 
    //T[i]には、節iの親を入れる
    for(int i=0;i<N;i++){
        T[i].parent=i;
        T[i].size=1;
    }
    return T;
}
 
//節xを含む部分木の根を返す
int find_set(node* T, int x){
    if(T[x].parent==x){
        return x;
    }
    else{
        return T[x].parent=find_set(T,T[x].parent);
    }
}
 
//節xを含む部分木と節yを含む部分木を併合する
void union_set(node* T,int x, int y){
    x=find_set(T,x);
    y=find_set(T,y);
 
    if(x==y) return;
    else{
        T[x].parent=y;
        T[y].size+=T[x].size;
        return;
    }
}

int main(void){
    int N,M;
    scanf("%d%d",&N,&M);

    //p[0]~p[N-1]に格納する(添字0スタートに対応させる)
    int* p;
    NEW(p,N);
    for(int i=0;i<N;i++){
        scanf("%d",&p[i]);
        p[i]--;
    }

    //union-ford木の作成
    node* T=build_union_ford(N);

    for(int i=0;i<M;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        x--;
        y--;
        union_set(T,x,y);
    }

    int ans=0;
    for(int i=0;i<N;i++){
        if(find_set(T,i)==find_set(T,p[i])) ans++;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 2176
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    P = []
    for k in range(2,2000):
        f = 1
        for i in range(2,int(k**(1/2))+2):
            if k%i == 0:
                f = 0
                break
        if f == 1 and k%5 == 1:
            P.append(k)
    print(*P[:N])
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N; cin >> N;
  vector<int> a(N);

  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(ALL(a));
  cout << a.back() - a.front() << endl;

  return 0;
}



Measured memory_bytes: 764
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if strings.Count(s, "a") == 1 && strings.Count(s, "b") == 1 && strings.Count(s, "c") == 1 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    vector<ll> a(3);
    cin >> a[0] >> a[1] >> a[2];

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

    if(a[0] * a[1] * a[2] % 2 == 0){
        put(0);
    }else{
        ll ans = abs(a[0] * a[1] * (a[2] / 2 + 1) - a[0] * a[1] * (a[2] / 2));
        ans = min(ans, abs(a[0] * a[1] * (a[2] / 2) - a[0] * a[1] * (a[2] / 2 + 1)));
        put(ans);
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n,0);
    rep(i,n-1){
        int a;
        cin >> a;
        ans[a-1]++;
    }
    rep(i,n){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 4048
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;

int main(){
	int n;
	cin >> n;
	vector<T3> a(n);
	for(int i = 0;i < n;i++){
		int s,l,p;
		cin >> s >> l >> p;
		a[i] = T3(s,l,p);
	}

	int dp[400] = {};

	for(int i = 0;i < n;i++){
		int s,l,p;
		tie(s,l,p) = a[i];
		for(int j = s;j <= l;j++){
			dp[j] = max(dp[j],p);
		}
	}

	for(int i = 1;i <= 400;i++){
		for(int j = 0;j < n;j++){
			int s,l,p;
			tie(s,l,p) = a[j];
			if(dp[i] == 0)continue;
			for(int k = s;k <= l;k++){
				if(i+k <= 400)dp[i+k] = max(dp[i+k],dp[i]+p);
			}
		}
	}

	int m;
	cin >> m;
	vector<int> ans(m);
	bool flag = false;
	for(int i = 0;i < m;i++){
		int w;
		cin >> w;
		if(dp[w] == 0){
			flag = true;
		}
		ans[i] = dp[w];
	}

	if(flag)cout << -1 << endl;
	else{
		for(int a:ans)cout << a << endl;
	}
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define fly ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define ll long long
#define inf 100000000000
using namespace std;

int main(int argc, char const *argv[]) {
  ll n,k;
  cin >> n >> k;
  std::vector<ll> ara(n);
  for(int i = 0;i<n;i++)cin >> ara[i];

  ll dp[n+1] {inf};
  dp[0] = 0;
  for(int i = 1;i<n;i++){
    dp[i] = dp[i-1] + abs(ara[i]-ara[i-1]);
    for(int j = 2;i-j>=0 && j<=k;j++){
      dp[i] = min(dp[i], dp[i-j]+ abs(ara[i]-ara[i-j]));
    }
  }
  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 4828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  if(N==2){
    cout << ((M==1)?1:0) << endl;
    return 0;
  }
  vector<vector<int>> g(N, vector<int>(N));
  rep(i,N) rep(j,N) g[j][i] = 0;
  int a, b;
  rep(i,M){
    cin >> a >> b;
    a--; b--;
    g[a][b] = g[b][a] = 1;
  }
  int ans = 0;
  vector<int> v(N-1);
  iota(v.begin(), v.end(),1);
  do {
    vector<int> tmp;
    for(auto x : v) tmp.pb(x);
    if(g[0][tmp[0]]==1){
      for(int k=1;k<N-1;k++){
        if(g[tmp[k]][tmp[k-1]]==1){}
        else break;
        if(k==N-2) ans++;
      }
    }
  } while(next_permutation(v.begin(), v.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    ll pos = -1;
    ll cnt0 = 0, cnt1 = 0;
    vl ans(n);
    rep(i, n) {
        if(i%2 == 0) {
            cnt0++;
        }
        else {
            cnt1++;
        }
        if(i < n-1 && s[i] == 'R' && s[i+1] == 'L') {
            pos = i;
        }
        else if(i == n-1 || (i < n-1 && s[i] == 'L' && s[i+1] == 'R')) {
            if(pos%2 == 0) {
                ans[pos] = cnt0;
                ans[pos+1] = cnt1;
            }
            else {
                ans[pos] = cnt1;
                ans[pos+1] = cnt0;
            }
            cnt0 = 0;
            cnt1 = 0;
        }
    }

    rep(i, n) {
        cout << ans[i];
        if(i < n-1) {
            cout << " ";
        }
    }
    
    re0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long int

using namespace std;

int main(void) {
    int a,b,t;
    cin >> a;
    cin >> t;
    a = min(a,t);
    cin >> t;
    a = min(a,t);
    cin >> b;
    cin >> t;
    b = min(b,t);
    cout << a+b-50 << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<int> freqs(N + 5, 0);
  for (int i = 0; i < N; ++i) {
    int a; scanf("%d", &a);
    ++freqs[a];
  }
  sort(freqs.begin(), freqs.end(), greater<int>());
  int cnt = 0;
  for (int i = 0; i < K; ++i) {
    cnt += freqs[i];
  }
  int ans = N - cnt;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  if (op == '+') {
    printf("%d\n", A + B);
  } else {
    printf("%d\n", A - B);
  }
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll a,b;

int main() {
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>a>>b;
    while (true) {
        if (a==0 && b==0) {
            cout<<1<<endl;
            return 0;
        }
        int a2 = __lg(a);
        int b2 = __lg(b);
        //cout<<a2<<" "<<b2<<endl;
        if (a2!=b2) break;
        a = a-(1ll<<a2);
        b = b-(1ll<<b2);
    }
    //cout<<a<<" " <<b<<endl;
    int b2 = __lg(b);
    ll l1 = a, l2 = (1ll<<b2) - 1;
    ll tmp = b - (1ll<<b2);
    //cout<<tmp<<endl;
    ll l3=0;
    if (tmp) {
        int tmp2 = __lg(tmp);
        l3 = (1ll<<(tmp2+1)) - 1;
    }
    //cout<<l1<<" "<<l2<<" "<<l3<<endl;
    if (l1 > l3) cout<<(l2-l1+1) + (l2-l1+1) + l3 + 1<<endl;
    else cout<<l2-l1+1+l2+1<<endl;
}


Measured memory_bytes: 256
S = input()

lm = {"N":0, "W":0, "S":0, "E":0}
for s in S:
	lm[s] += 1

n, w, s, e = lm["N"], lm["W"], lm["S"], lm["E"]

print(["Yes", "No"][not((n == s == 0 or (0 < n and 0 < s)) and (w == e == 0 or (0 < w and 0 < e)))])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fin freopen("input", "r", stdin);
#define fout freopen("output", "w", stdout);
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) {cerr << #x << ": " << x << endl;}
#define whatis2(x, y) {wt(x); wt(y); cerr << endl;}
#define whatis3(x, y, z) {wt(x); wt(y); wt(z); cerr << endl;}
#define whatis4(x, y, z, a) {wt(x); wt(y); wt(z); wt(a); cerr << endl;}
using namespace std;

typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1000000007; const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 1000 + 2;
ll dp[N][N];
char grid[N][N];

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

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> grid[i][j];
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i < n; ++i) {
        if (grid[0][i] == '.') dp[0][i] = dp[0][i-1];
        if (grid[i][0] == '.') dp[i][0] = dp[i-1][0];
    }

    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < m; ++j) {
            if (grid[i][j] == '.') {
                dp[i][j] += dp[i-1][j];
                dp[i][j] %= MOD;
                dp[i][j] += dp[i][j-1];
                dp[i][j] %= MOD;
            }
        }
    }

    cout << dp[n-1][m-1] << endl;

    


    return 0;
}


Measured memory_bytes: 9088
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), K = sc.nextInt();
    int H[] = new int[N];
    for (int i = 0; i < N; i++) H[i] = sc.nextInt();
    Arrays.sort(H);
    long sum = 0;
    for (int i = 0; i < N - K; i++) sum += H[i];
    System.out.println(sum);
  }
}

Measured memory_bytes: 64964
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e+18
int va=10e8+7;
ll val[200007]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
    //cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=sz(s);
        if(s[n-1]!='s'){
            cout<<s<<'s'<<endl;
        }
        else{
            cout<<s<<"es"<<endl;
        }
    }
 return 0;
}


Measured memory_bytes: 3576
def num(x, i):
    basecnt = (x+1)//(2**(i+1))
    base = basecnt*(2**i)
    #print(base)
    
    nokori = x - basecnt*(2**(i+1)) + 1
    #print(nokori)
    plus = nokori - 2**i
    if plus > 0:
        return base+plus
    else:
        return base
def main():
    A, B = map(int, input().split())
    maxketa = len(bin(B)[2:])

    ans = 0
    for i in range(maxketa):
        Anum = num(A-1, i)
        Bnum = num(B, i)
        one = Bnum - Anum
        if one%2!=0:
            ans += 2**i
    print(ans)
main()  

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bcools
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        long a;
        long b;
        long[] health;

        boolean enough(long T) {
            long result = 0;
            for (int i = 0; i < health.length; ++i) {
                if (health[i] > b * T)
                    result += Math.ceil(((double) health[i] - (b * T)) / ((double) a - b));
            }
            return (result <= T);
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            a = in.nextInt();
            b = in.nextInt();
            health = new long[n];
            long hmax = Long.MIN_VALUE;
            for (int i = 0; i < n; ++i) {
                health[i] = in.nextInt();
                hmax = Math.max(hmax, health[i]);
            }

            long lo = 0;
            long hi = (long) Math.ceil((double) hmax / b);
            long mid;

            while (lo + 1 < hi) {
                mid = lo + (hi - lo) / 2;
                if (enough(mid)) {
                    hi = mid;
                } else {
                    lo = mid;
                }
            }
            if (lo == hi) {
                out.println(lo + 1);
            } else {
                out.println(hi);
            }
        }

    }
}



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

int main() {
  int N;
  int x, y, b, p;
  
  cin >> N;
  
  for(int i=0; i<N; i++) {
    cin >> x >> y >> b >> p;
    int a = x*b*0.8 + y*p*0.8;
    
    if(b >= 5 && p>=2) {
      cout << a << endl;
    }
    else {
      int tmp = x*b + y*p;
      if(b >= 5 && tmp > (x*b + y*2)*0.8) cout << (x*b + y*2)*0.8 << endl;
      else if( p >= 2 && tmp > (x*5 + y*p)*0.8) cout << (x*5 + y*p)*0.8 << endl;
      else cout << tmp << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll a, b, v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    ll dis = abs(a - b);
    ll vel = v - w;

    string ans = "NO";
    if(vel<=0){
        cout << ans << endl;
        return 0;
    }else{
        if(vel*t>=dis){
            ans = "YES";
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3628