akhauriyash/Code-Regression huggingface dataset:
// compile in C++11. use -std=c++11.
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef complex<double> point;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& vec){
    os << "[";
    for(const auto& v : vec){
        os << v << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

// 円と円の交点(2点ある前提)
vector<point> circles_point(point c1,double r1,point c2,double r2){
    double d = abs(c1-c2);
    double s = (r1+r2+d) / 2;
    double S = sqrt(s*(s-r1)*(s-r2)*(s-d));
    double h = 2 * S / d;
    point v = (c2-c1) / (abs(c2-c1));

    double m = sqrt(r1*r1 - h*h);

    vector<point> ret;
    ret.push_back(c1 + m*v+h*v*point(0,1));
    ret.push_back(c1 + m*v-h*v*point(0,1));
    return ret;
}

const double EPS = 1e-7;
int solve(vector<point> ps){
    int n = ps.size();
    int ret = 1;
    for(int apple=0;apple<n;apple++){
        for(int banana=0;banana<n;banana++){
            if(apple == banana) continue;

            point a = ps[apple];
            point b = ps[banana];
            if(abs(a-b) < 2){
                vector<point> check = circles_point(a,1,b,1);
                for(point c : check){
                    int cur = 0;
                    // if(abs(c-a) < EPS or abs(c-b) < EPS) continue;
                    for(const point& p : ps){
                        if(abs(c-p) <= 1 + EPS){
                            cur++;
                        }
                    }
                    ret = max(ret,cur);
                }
            }
        }
    }
    return ret;
}

int main(){
    while(true){
        int n = input<int>();
        if(n == 0) break;
        vector<point> ps;
        repeat(apple,n){
            double x,y;
            char c;
            cin >> x >> c >> y;
            ps.push_back(point(x,y));
        }
        cout << solve(ps) << endl;
    }
    return 0;
}

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

using namespace std;

void print(vector<int> a) {
    for (int i = 0; i < a.size(); i++) {
        cout << a[i];
        if (i != a.size() - 1) cout << " ";
    }
    cout << endl;
}

void selectionSort(vector<int> vi) {
    int count = 0;
    for (int j = 0; j < vi.size(); j++) {
        int mini,min = 101;

        for (int i = j; i < vi.size(); i++) {
            if(min > vi[i]){
                mini = i;
                min = vi[i];
            }
        }

        if(j != mini) {
            vi[mini] = vi[j];
            vi[j] = min;
            count++;
        }
    }
    print(vi);
    cout << count << endl;
    return;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    selectionSort(a);
    return 0;
}


Measured memory_bytes: 3156
n = int(input())
int_list = list(map(int,(input().split())))
count = 0
while True:
    for i in range(len(int_list)):
        
        if int_list[i] % 2 == 0 :
            int_list[i] = int_list[i]/2
        else:
            int_list = []
            break      
    if len(int_list) == n :
        count += 1
    else: 
        break
print(count)

Measured memory_bytes: 9116
N,X,Y=map(int,input().split())
B=[0 for i in range(N-1)]
for i in range(1,N):
  for j in range(i+1,N+1):
   B[min(j-i,abs(X-i)+abs(Y-j)+1)-1]+=1
for i in range(N-1):
   print(B[i])
    

Measured memory_bytes: 3444
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999999;



int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    int now=0;
    bool tate=true;
    ll ans=1;
    while(now<n){
        if(now==0){
            if(s[now]==t[now]){
                ans*=3;
                tate=true;
                now++;
            }else{
                ans*=6;
                tate=false;
                now+=2;
            }
            continue;
        }
        if(s[now]==t[now]){
            if(tate){
                ans*=2;
            }else{
                ans*=1;
            }
            now++;
            tate=true;
        }else{
            if(tate){
                ans*=2;
            }else{
                ans*=3;
            }
            now+=2;
            tate=false;
        }
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, a, b, c, count = 0;
  cin >> A >> B;
  
  a = A / 10000;
  b = (A / 1000) % 10;
  c = (A / 100) % 10;
    
  if (A > 10000 * a + 1000 * b + 100 * c + 10 * b + a) {
    count--;
  }
 
  for ( ; B >= 10000 * a + 1000 * b + 100 * c + 10 * b + a; ) {
    count++;
    
    if (b == 9 && c == 9) {
      a++;
      b = 0;
      c = 0;
    }
    
    else if (c == 9) {
      b++;
      c = 0;
    }
    
    else
      c++;
  }
  
  cout << count << endl;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007;

typedef long long ll; 
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

// Print fn to print array



int main(){
	float a;
    cin >> a;
    printf("%.7f",pow(a/3,3));
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
int N,X;
cin >> N >> X ;
vector<int> m(N);
for(int i = 0; i < N; i++){
cin >> m[i];
}
for(int i = 0 ; i < N; i++){
    X = X - m[i];
}
int min = *min_element(m.begin(),m.end());
cout << (X / min) + N << endl;
 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = a + b;
		double x = Double.parseDouble(c);
		x = Math.pow(x, 0.5);
		if ((x % 1) == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}

}

Measured memory_bytes: 21716
#include<stdio.h>

int main(){
	int a,n[101]={},max=0,i;
	while(scanf("%d",&a)!=EOF){
		n[a]++;
		}
	for(i=1;i<101;i++){
		if(n[i]>max){
			max=n[i];
		}
	}
	for(i=1;i<101;i++){
		if(n[i]==max){
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int min(int a, int b){
	return a > b ? b: a;
}
int main(){
	int sum = 0, b[102], n;
	cin >> n;
	for (int i = 1; i < n; ++i) cin >> b[i];
	b[0] = b[1];
	b[n] = b[n-1];
	for (int i = 0; i < n; ++i) sum += min(b[i], b[i + 1]);
	cout << sum << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>

void selectionSort(int A[100], int n)
{
  int i, j, minj, swap;
  int cnt = 0;

  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(A[j] < A[minj]){
        minj = j;
      }
    }
    if(i!=minj){
      swap = A[i];
      A[i] = A[minj];
      A[minj] = swap;
      cnt++;
    }
  }
  printf("%d", A[0]);
  for(i=1; i<n; i++){
    printf(" %d", A[i]);
  }
  printf("\n");

  printf("%d\n", cnt);

}


int main(){
  int i, N, A[100];

  scanf("%d", &N);

  for(i=0; i<N; i++){
    scanf("%d", &A[i]);
  }

  selectionSort(A,N);
}

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

typedef unsigned long long ull;
typedef long long ll;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	vector<ull> v(m);
	
	for (int i = 0; i < m; ++i) {
		cin >> v[i];
		//cout << v[i] << endl;
	}
	
	ull t = accumulate(v.begin(), v.end(), 0);
	
	if (t > n) {
		cout << -1 << endl;
	} else {
		cout << n - t << endl;
	} 
	
	
	return 0;
}


Measured memory_bytes: 3700
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(input().split())
    return li

# --------------------------------------------

dp = None

def main():
    H, W = list(map(int, input().split()))

    S = []
    for _ in range(H):
        S.append(list(input()))

    for idx_h in range(H):
        for idx_w in range(W):
            if S[idx_h][idx_w] == "#":
                continue

            bomb = 0

            for dh in range(-1, 2):
                new_h = idx_h + dh
                for dw in range(-1, 2):
                    new_w = idx_w + dw

                    if dh == 0 and dw == 0:
                        continue

                    if 0 <= new_h < H and 0 <= new_w < W and S[new_h][new_w] == "#":
                        bomb += 1

            S[idx_h][idx_w] = bomb

    for row in S:
        for cell in row:
            print(cell, end="")
        print()

main()


Measured memory_bytes: 5084
var input=require("fs").readFileSync("/dev/stdin","utf8");
var i=0;
var siki,a,op,b,ans;

input=input.split("\n");

while(1){
    siki=input[i].split(" ");
    a=parseInt(siki[0]);
    op=siki[1];
    b=parseInt(siki[2]);
    
    if(op=="?"){
        break;
    }
    
    switch(op){
        case "+":
            ans=a+b;
            break;
        case "-":
            ans=a-b;
            break;
        case "*":
            ans=a*b;
            break;
        case "/":
            ans=Math.floor(a/b);
            break;
    }
    
    console.log(ans);
    i++;
}



Measured memory_bytes: 15408
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

void solve(int N, int M, string S){
  vector<int> vec;
  while(N>0){
    for(int i=max(0,N-M);i<=N;i++){
      if(i==N){
	cout<<-1<<endl;
	return;
      }
      if(S[i]=='0'){
	vec.push_back(N-i);
	N=i;
	break;
      }
    }
  }
  for(auto it=vec.rbegin();it!=vec.rend();++it){
    if(it!=vec.rbegin())cout<<" ";
    cout<<*it;
  }
  cout<<endl;
}

int main(){
  int N;cin>>N;
  int M;cin>>M;
  string S;cin>>S;
  solve(N, M, S);
  return 0;
}


Measured memory_bytes: 1148
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

#define int long long

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

    int n;

    int a;

    int ans = 1000000000;
    
    int x;

    cin >> n;

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

        while (true)
        {
            auto hoge = a % 2;

            if (hoge == 1)
            {
                break;
            }

            a = a/2;
            ++x;
        }

        ans = std::min(x, ans);

        x = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>

typedef long long ll;

using namespace std;

void printArray(int *x, int n){
    for(int i = 0; i < n; i++){
        cout << x[i];
        if(i < n-1){
            cout << " ";
        }
    }
    cout << endl;
}

int bubbleSort(int *a, int n){
    int count = 0;
    bool flag = true;
    while(flag){
        flag = 0;
        for(int j = n-1; j > 0; j--){
            if(a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                count++;
                flag = true;
            }
        }
    }
    printArray(a, n);
    return count;
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cout << bubbleSort(a, n) << endl;
}

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

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> G[600];
    rep(i,M) {
        ll s, t;
        cin >> s >> t;
        G[s-1].push_back(t-1);
    }
    ld dp[600];
    ld ans = 10000.0;
    rep(i,N-1) {
        rep(j,N) dp[j] = 0.0;
        for(ll j = N-2; j>=0; j--) {
            ld v_size = (ld)G[j].size();
            if(j != i || v_size == 1) {
                for(auto& t : G[j]) {
                    dp[j] += dp[t];
                }
                dp[j] /= v_size;
                dp[j] += 1.0;
            } else {
                ld maxd = -1.0;
                for(auto& t : G[j]) {
                    maxd = max(dp[t], maxd);
                    dp[j] += dp[t];
                }
                dp[j] -= maxd;
                dp[j] /= (v_size - 1);
                dp[j] += 1.0;
            }
        }
        ans = min(ans, dp[0]);
    }
    cout << fixed;
    cout << setprecision(8) << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define abs(x) ((x) > 0 ? (x) : -(x))
typedef long long LL;

const double eps = 1e-8;
double R;
const double PI = acos(-1.0);
int sig(double d) {
	return (d > eps) - (d < -eps);
}
struct Point {
	double x, y;

	double dist(const Point &pt) {
		return sqrt((x - pt.x) * (x - pt.x) + (y - pt.y) * (y - pt.y));
	}
}ps[305];
struct node {
	double ang;
	int flag;
	node() {}
	node(double ang, int flag) : ang(ang), flag(flag) {}
	bool operator < (const node &pt) const {
		if (sig(ang - pt.ang) != 0) return sig(ang - pt.ang) < 0;
		return flag < pt.flag;
	}
}vec[1205];
int n;

double fit(double angle) {
	if (sig(angle) < 0) return angle += 2.0 * PI;
	if (sig(angle - 2.0 * PI) > 0) return angle -= 2.0 * PI;
	return angle;
}

int work() {
	int ret = 0;
	for (int i = 0; i < n; i++) {
		int len = 0;
		//vector<pair<double, int> > vec;
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			double d = ps[i].dist(ps[j]) / 2.0;
			if (sig(d - R) > 0) continue;
			double alpha = fit(atan2(ps[j].y - ps[i].y, ps[j].x - ps[i].x));
			double theta = acos(d / R);
			double ang1 = fit(alpha - theta);
			double ang2 = fit(alpha + theta);

			if (sig(ang1 - ang2) > 0) {
				vec[len++] = node(0, 0);
				vec[len++] = node(ang2, 1);
				vec[len++] = node(ang1, 0);
				vec[len++] = node(2.0 * PI, 1);
				//vec.PB(MP(0, 0));
				//vec.PB(MP(ang2, 1));
				//vec.PB(MP(ang1, 0));
				//vec.PB(MP(2.0 * PI, 1));
			} else {
				vec[len++] = node(ang1, 0);
				vec[len++] = node(ang2, 1);
				//vec.PB(MP(ang1, 0));
				//vec.PB(MP(ang2, 1));
			}

		}
		//sort(vec.begin(), vec.end());
		sort(vec, vec + len);
		int cnt = 0, Max = 0;
		//for (vector<pair<double, int> >::iterator it = vec.begin(); it != vec.end(); it++) {
		for (int i = 0; i < len; i++) {
			//if (it->second == 0) cnt++;
			if (vec[i].flag == 0) cnt++;
			else cnt--;
			Max = max(Max, cnt);
		}
		ret = max(ret, Max + 1);
	}
    return ret;
}

int main(int argc, char const *argv[])
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%lf%lf", &ps[i].x, &ps[i].y);
    double l = 0, r = 1005, ans=0;
    while (l <= r) {
        R = (l+r)/2;
        if (work() == n) {
            ans = r;
            r = R-0.000000001;
        } else {
            l = R+0.000000001;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    ll l=1;
    for(int i=0; i<n; i++)
    {
        ll a;
        cin>>a;
       l=(l/__gcd(l,a))*a;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	int32_t a, b, c;
	cin >> a >> b >> c;
	
	cout << (a + b == c || b + c == a || a + c == b ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
LL price=700,topping=100;
string Order;
cin >> Order;
  for(int i=0;i<Order.size();i++)
  {
  if(Order[i]=='o')
   {
    price+=topping;
   }
  }
  cout << price;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	
	static int fib(int[] a,int n){
		for(int i=0;i<=n;i++){
			if(i==0 ||i==1)
				a[i]=1;
			else 
				a[i]=a[i-1]+a[i-2];
		}
		
		return a[n];
		
	}
	
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		int n=scan.nextInt();
		int[] a=new int[n+1];
		System.out.println(fib(a,n));
	}
}


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

vector<int> vec;

int v[200005], res[200005];

int main(){

    int n; cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];

    int esq = 0, dir = n-1, flag = 0;
    for(int i = n-1; i >= 0; i--){
        if(flag == 0) res[esq++] = v[i];
        else res[dir--] = v[i];
        flag = !flag;
    }
    for(int i = 0; i < n; i++)
        cout << res[i] << " ";
    cout << endl;
    
	return 0;
}


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

int main(){
   while(1){
     int h,w;
     cin>>h>>w;
     if(h == 0&&w == 0) break;
     for(int i=0;i < h;i++){
        for(int j=0;j < w;j++){
          if((i+j)%2 == 0) cout<<"#";
          else cout<<".";
        }
        cout<<endl;
     }

   cout<<endl;
   }

   return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>

int main(void)
{
	//n?????\???
	int n;
	scanf("%d",&n);
	
	//???????????¨???
	int a[100];
	//n????????????
	for(int i=0; i < n; i++){
	//a?????\???	
	   scanf("%d",&a[i]);
	}	
	//n????????????
	for(int i=0; i < n; i++){
		//a??????????????????
		printf("%d", a[n-1-i]);
		
		if(i!=n-1){
			printf(" ");
	}
}
	
		printf("\n");
		
	return 0;
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int x, y; cin >> x >> y;
	int ans = abs(abs(x) - abs(y));
	if ((x * y < 0) || (x == 0 && y < 0) || (x > 0 && y == 0)) {
		ans++;
	} else {
		if (x > y) ans += 2;
	}

	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 504
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w", stdout);
	#endif
	int n;
	cin>>n;
	if(n==0){cout<<0;return 0;}
	vector<int> ans;int rem;
	while(n)
	{
		rem=(n%(-2));
		if(!rem)ans.push_back(0);
		else
		{
			n--;
			ans.push_back(1);
		}
		n/=-2;
	}
	reverse(ans.begin(),ans.end());
	for(auto i:ans)cout<<i;

}

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

using namespace std;

typedef long long ll;

constexpr int MAXN = 200000;

int H[MAXN + 2];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; i++) cin >> H[i];
	sort(H, H + N);
	ll ans = 0;
	for(int i = 0; i < N - K; i++) ans += H[i];
	cout << ans << '\n';
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

n, s = map(int,input().split())
A = list(map(int,input().split()))

mod = 998244353
l = 3050

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

D = [0] * 3050

M2 = [1]
M2I = [0] * l

for i in range(l-1):
    M2.append((M2[-1] * 2) % mod)
for i in range(l):
    M2I[i] = inv(M2[i], mod)

i2 = inv(2,mod)

D[0] = M2[n]
for i in range(n):
    for j in range(l-1,-1,-1):
        if j - A[i] >= 0:
            D[j] = (D[j] + D[j-A[i]] * i2) % mod
    # print(D[:10])
    
print(D[s])



Measured memory_bytes: 68896
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long a, b, c;


int main()
{
	scanf("%lld%lld", &a, &b);
	c = a * b;
	printf("%lld\n", c);

	return 0;
}


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

const int N = 1e5 + 10;

int n , ans;
char s[N];

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

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

#include<queue>

using namespace std;

int main() {

	int A, P;
	cin >> A >> P;

	int result = (P + 3 * A) / 2;
	cout << result << endl;


	return 0;
}




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

const int MAXN = 1e5 + 5;
int n;
ll M, g[MAXN], prod[MAXN], f[MAXN], pleft[MAXN], pright[MAXN];
vector<int> adj[MAXN];

void dfs(int s, int p = 0) {
    int m = adj[s].size();
    if(s != 1)
        m--;
    g[s] = 1;
    for(auto v : adj[s]) {
        if(v == p)
            continue;
        dfs(v, s);
        g[s] = (g[s] * (g[v] + 1)) % M;
    }
    pleft[0] = pright[m + 1] = 1ll;
    int ctl = 1, ctr = m;
    for(int i = 0; i < adj[s].size(); i++) {
        int v = adj[s][i];
        if(v == p)
            continue;
        pleft[ctl] = (pleft[ctl - 1] * (g[v] + 1)) % M;
        ctl++;
    }
    for(int i = adj[s].size() - 1; i >= 0; i--) {
        int v = adj[s][i];
        if(v == p)
            continue;
        pright[ctr] = (pright[ctr + 1] * (g[v] + 1)) % M;
        ctr--;
    }
    ctl = 1;
    for(auto v : adj[s]) {
        if(v == p)
            continue;
        prod[v] = (pleft[ctl - 1] * pright[ctl + 1]) % M;
        ctl++;
    }
}

void calcf(int s, int p = 0) {
    if(s != 1)
        f[s] = (prod[s] * (f[p] + 1ll)) % M;
    //cout << s << " " << prod[s] << " " << f[p] << " " << f[s] << endl;
    for(auto v : adj[s]) {
        if(v != p)
            calcf(v, s);
    }
}

int main() {
    cin >> n >> M;
    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }
    for(int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1);
    f[1] = 0;
    calcf(1);
    for(int i = 1; i <= n; i++)
        cout << ((f[i] + 1ll) * g[i]) % M << endl;
}

Measured memory_bytes: 17280
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

#define TOP 0
#define FRO 1
#define RIGHT 2
#define BACK 3
#define LEFT 4
#define BOTTOM 5
#define ROTATE_R 0
#define ROTATE_F 1
#define DIF 'a'-'A'

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

int r_table[2][6]={
  TOP,LEFT,FRO,RIGHT,BACK,BOTTOM,
  BACK,TOP,RIGHT,BOTTOM,LEFT,FRO
};

int cmp[6]={
  BOTTOM,BACK,LEFT,FRO,RIGHT,TOP
};

bool visited[2][2][2]={false};

typedef struct{char d[7];} Dice;

Dice dice[2][2][2];

void rotate(Dice &in,int flag){
  Dice tmp=in;
  rep(i,6)in.d[i]=tmp.d[r_table[flag][i]];
}

bool check(int x,int y,int z){
  rep(i,6){
    int cx=x+dx[i],cy=y+dy[i],cz=z+dz[i];
    if ( cx<0||cy<0||cx>=2||cy>=2 ||cz<0||cz>=2|| visited[cx][cy][cz]==false)continue;
    int tmp=dice[x][y][z].d[i]-dice[cx][cy][cz].d[cmp[i]];
    if ( tmp == DIF  || -tmp == DIF );
    else return false;
  }
  return true;
}

bool solve(int now,Dice *in,bool *used){
  int x=now%2,y=(now%4)/2,z=now/4;
  if ( now == 8)return true;
  visited[x][y][z]=true;
  rep(k,8){
    if ( used[k] == true)continue;
    rep(i,6){
      if ( i == 4)rep(j,2)rotate(in[k],ROTATE_R);
      if ( i ==5) rep(j,2)rotate(in[k],j);
      rep(i,4){
	rotate(in[k],ROTATE_R);
	dice[x][y][z]=in[k];
	used[k]=true;
	if ( check(x,y,z)  && solve(now+1,in,used) )return true;
	used[k]=false;
      }
      rotate(in[k],ROTATE_F);
    }
  }
  visited[x][y][z]=false;
  return false;
}


main(){
  Dice in[8];
  while(cin>>in[0].d && in[0].d[0] !='0'){
    rep(i,7)cin>>in[i+1].d;
    rep(i,8)swap(in[i].d[3],in[i].d[4]);
    bool used[8]={false};
    rep(i,2)rep(j,2)rep(k,2)visited[i][j][k]=false;
    if ( solve(0,in,used))puts("YES");
    else puts("NO");
  }
  return false;
}

Measured memory_bytes: 832
N = int(input())
A = [0] + list(map(int,input().split())) + [0]

#print(A)
SA = 0
for i in range(N+1):
    SA +=abs(A[i+1] - A[i])
#print(SA)


ans = 0
for i in range(1,N+1):
    ans =SA -(abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])) + abs(A[i+1] - A[i-1])
    print(ans)

Measured memory_bytes: 14048
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, W;
  while (cin >> N >> W) {
    vector<ll> v(N), w(N);
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
    vector<ll> dp(W + 1, 0);
    for (int i = 0; i < N; i++) {
      vector<ll> ndp = dp;
      for (int s = 0; s <= W; s++) {
        if (s + w[i] <= W) {
          ndp[s + w[i]] = max(ndp[s + w[i]], dp[s] + v[i]);
        }
      }
      dp = ndp;
    }
    ll res = *max_element(dp.begin(), dp.end());
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1804
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

int solve() {
  int ans = 0;

  bool V[MAX];
  for ( int i = 0; i < n; i++ ) {
    B[i] = A[i];
    V[i] = false;
  }
  sort(B, B+n);
  for ( int i = 0; i < n; i++ ) T[B[i]] = i;
  for ( int i = 0; i < n; i++ ) {
    if ( V[i] ) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while ( 1 ) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if ( V[cur] ) break;
    }
    ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
  }

  return ans;
}

int main() {
  cin >> n;
  s = VMAX;
  for ( int i = 0; i < n; i++ ) {
    cin >> A[i];
    s = min(s, A[i]);
  }
  int ans = solve();
  cout << ans << endl;

  return 0;
}


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

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

    string output = "";

    for (int bit = 0; bit < 1 << (s.size() - 1); bit++) {
        int sum = s.at(0) - '0';
        output = s.at(0);

        for (int i = 0; i < s.size() - 1; i++) {
            if (bit >> i & 1 == 1) {
                sum = sum + (s.at(i + 1) - '0');
                output = output + "+" + s.at(i + 1);
            } else {
                sum = sum - (s.at(i + 1) - '0');
                // output.append("-" + s.at(i + 1));
                output = output + "-" + s.at(i + 1);
            }
        }

        if (sum == 7) {
            output = output + "=7";
            break;
        }
    }

    cout << output << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
Xs = list(map(int, input().split()))
sXs = sorted(Xs)
m1 = sXs[N//2]     # 前半のメジアン (i<=m1)
m2 = sXs[N//2 - 1] # 後半のメジアン
# print(m1,m2)
if m1 == m2:
    for i in range(N):
        print(m1)
else:
    for x in Xs:
        if x <= m2:
            print(m1)
        else:
            print(m2)

Measured memory_bytes: 25228
# 2019-11-15 14:37:47(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    a = [int(x) for x in sys.stdin.readline().split()]
    b = [int(x) for x in sys.stdin.readline().split()]
    at_beginning = sum(a)
    for i in range(n):
        if a[i] >= b[i]:
            a[i] -= b[i]
        else:
            a[i+1] = max(0, a[i+1] - (b[i] - a[i]))
            a[i] = 0

    at_ending = sum(a)

    ans = at_beginning - at_ending
    print(ans)
   

if __name__ == "__main__":
    main()


Measured memory_bytes: 19376
#include <stdio.h>
#include <string.h>
int main()
{
    char st[10];
    int a;
    scanf("%d", &a);
    scanf("%s", st);
    if(a >= 3200){
      printf("%s\n", st);
    }
    else{
        printf("red\n");
    }
    return 0;
}


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

#define int long long

signed main() {
	int n,m,a,b;
	cin >> n >> m;
	vector<pair<int,int> > v;
	priority_queue<int> p;
	for(int i = 0; i < n; i++) {
		cin >> a >> b;
		v.push_back({a,b});
	}
	sort(v.begin(),v.end());
	int j = 0;
	int ans = 0;
	for(int i = 1; i <= m; i++) {
		for(j; j < n; j++) {
			int x = v[j].first;
			int y = v[j].second;
			if(x>i) break;
			p.push(y);
		}
		if(!p.empty()) {
			int z = p.top();
			ans += z;
			p.pop();
		}
	}
	cout << ans;
	return 0;
}

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

int main() {
    int n, l, r, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> l >> r;
        sum += abs(r - l) + 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr<<#x<<": "<<(x)<<'\n'
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll nax = 2e5+5; 
ll n, m;
vector<ll>arr(nax);

ll findpar(ll x){
		if(arr[x]==x) return x;
		else{
			return arr[x]=findpar(arr[x]);
		}
	}

void gabung(ll a, ll b){
		ll repa=findpar(a);
		ll repb=findpar(b);
		arr[repa]=repb;
	}

int main(){
	IOS
	cin >> n >> m;
	for(int i=1;i<=n;++i){
		arr[i]=i;
	}
	for(int i=0;i<m;++i){
		ll a, b; cin >> a >> b;
		gabung(a, b);
	}
	unordered_map<ll, ll>cnt;
	ll ans=0;
	for(int i=1;i<=n;++i){
		ll pos=findpar(i);
		cnt[pos]++;
		ans=max(ans, cnt[pos]);
	}	
	cout << ans << '\n';
}


Measured memory_bytes: 13040
import math
s = 0
n = int(input())
for i in range(1,n+1):
  for j in range(1,n+1):
    g = math.gcd(i,j)
    for k in range(1,n+1):
      h = math.gcd(g,k)
      s += h
      
print(s)      
      

Measured memory_bytes: 68760
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var arr = new List<int>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        foreach(var n in line)   arr.Add(int.Parse(n));
        arr.Sort();
        Console.WriteLine("{0} {1} {2}", arr[0], arr[1], arr[2]);


    }
}

Measured memory_bytes: 9284
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  set<int>out;
  rep(i,k){
    int a;cin>>a;
    out.insert(a);
  }
  repi(i,n,n*100){
    int ti=i;
    int f=1;
    while(ti>0){
      if(out.count(ti%10))
      {
        f=0;
        break;
      }
      ti/=10;
    }
    if(f){
      cout<<i<<endl;
      return 0;
    }
  }

  return 0;

}


Measured memory_bytes: 256
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	nm = LI()
	a = LI()
	n = nm[0]
	m = nm[1]

	for _a in a:
		n -= _a

	if n < 0:
		n = -1
	print(n)
	
if __name__ == '__main__':
	solve()


Measured memory_bytes: 10792
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int ans=0;
	if(a>b){
		ans=b;
	}else{
		ans=a;
	}
	if(c>d){
		ans+=d;
	}else{
		ans+=c;
	}
	printf("%d\n",ans);
	return 0;
} 

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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<bool> dp(k+1, false);
    vector<int> stones(n);
    for(int i=0;i<n;i++){ cin >> stones[i]; dp[stones[i]]=true; }
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-stones[j] > 0 && !dp[i-stones[j]]) dp[i]=true;
        }
    }
    //for(int i=1;i<=k;i++) cout << "stones: " << i << " winning: " << (bool)dp[i] << endl;
    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 3084
N = int( input() )
a = list( map( int, input().split() ) )


num4, num2 = 0, 0
for a in a:
    if a % 4 == 0: num4 += 1
    elif a % 2 == 0: num2 += 1

if num2 > 1:
    if num4 >= (N-(num2-1))//2: print( 'Yes' )
    else: print( 'No' )
else:
    if num4 >= N//2: print( 'Yes' )
    else: print( 'No' )

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T, class U> using p = pair<T, U>;

#define REP(i, n) for(ll i = 0; i < n; ++i)
#define REP3(i, s, e) for(ll i = s; i <= e; ++i)

constexpr double PI=3.14159265358979323846;

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

int main(){
    auto S = read<string>();
    ll N = (ll)S.size();
    
    ll ans = 0;
    for(ll i = 0; i < N/2; ++i){
        if(S[i] != S[N - i - 1]) ++ans;
    }
    write(ans);
    
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

money = 1000
stock = 0
price = float("INF")
for i in range(N-1):
    if price < A[i] and stock != 0:
        money += stock * A[i]
        stock = 0
        price = float("INF")

    if A[i] < A[i+1]:
        stock += money // A[i]
        money -= A[i] * stock
        price = A[i]

if price < A[N-1] and stock != 0:
    money += stock * A[N-1]
    
print(money)

Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;

ll N,P;
string s;
map<ll,ll> mp;
ll sum[maxn];
int main(){
    cin>>N>>P>>s;
    ll cnt = 0;
    if(P == 2){
        for(int i = s.size()-1;i>=0;i--){
            int t = s[i] - '0';
            if(t%2 == 0) cnt += i+1;
        }
    }else if(P == 5){
        for(int i = s.size()-1;i>=0;i--){
            if(s[i] == '0' || s[i] == '5')
                cnt += i+1;
        }
    }else{
        reverse(s.begin(),s.end());
        ll cur = 1;
        mp[0]++;
        for(int i = 1;i<=s.size();i++){
            if(i>1) cur = cur*10%P;
            sum[i] = (cur*(s[i-1]-'0')+sum[i-1])%P;
            mp[sum[i]]++;
        }
        for(auto p:mp){
            cnt += p.second*(p.second-1)/2;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 2556
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x-a) > abs(x - b))
	{
		cout << "B" << endl;
	}
	else
	{
		cout << "A" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#define ff first
#define ss second
#define M 1000000007
typedef long long int ll;
using namespace std;
ll power(ll a,ll b){
    ll ans = 1;
    while(b>0){
        if(b%2!=0){
            ans = ((ans)*(a));
        }
        a = ((a)*(a));
        b=b/2;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector <ll> a(n);
    vector <ll> b(n);
    vector <ll> c(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    for(ll i=1;i<n;i++){
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(a[i-1],c[i-1]);
        c[i]+=max(a[i-1],b[i-1]);
    }
    cout<<max(a[n-1],max(b[n-1],c[n-1]));
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,i,j;
    long long int s=0,x=0;
    vector<unsigned long long> a, m;
    cin >> n;
    m.assign(n,0);
    a.assign(n,0);
    for(i=0;i<n;i++){
        cin >> a[i];
        s+=a[i];
    }
    for(i=1;i<n;i+=2) x+=a[i];
    m[0] = s-2*x;
    cout << m[0] << ' ';
    for(i=1;i<n;i++){
        m[i] = 2*a[i-1] - m[i-1];
        cout << m[i] << ' ';
    }
    cout << endl;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n;
int c[100010],s[100010],f[100010];

signed main() {
    cin>>n;
    rep(i,0,n-1){
        cin>>c[i]>>s[i]>>f[i];
    }
    
    int now=0;
    int tugi=1;
    int goal[100010];
    rep(i,0,n){
        int t=0;
        rep(j,i,n-1){
            if(t<s[j])t=s[j];
            else if(t%f[j]==0);
            else t=t+f[j]-t%f[j];
            t+=c[j];
        }
        cout<<t<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

struct Card {
  char suit;
  int value;
};
Card a[100003];

int mypartition(int p, int r) {
  int x = a[r].value;
  int i = p-1;
  for (int j=p; j<r; ++j) {
    if (a[j].value <= x) {
      i++;
      Card tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  Card tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;
  return i+1;
}

void quicksort(int p, int r) {
  if (p < r) {
    int q = mypartition(p, r);
    quicksort(p, q-1);
    quicksort(q+1, r);
  }
}

void printAns(Card a[], Card b[], int n) {
  rep(i,n-1) {
    if (a[i].value == a[i+1].value) {
      int left, right;
      rep(j,n-1) {
	if (b[j].suit == a[i].suit && b[j].value == a[i].value) left = j;
	if (b[j].suit == a[i+1].suit && b[j].value == a[i+1].value) right = j;
      }
      if (left > right) {
	cout << "Not stable" << endl;
	rep(i,n) cout << a[i].suit << ' ' << a[i].value << endl;
	return;
      }
    }
  }
  cout << "Stable" << endl;
  rep(i,n) cout << a[i].suit << ' ' << a[i].value << endl;
}

int main() {
  int n;
  cin >> n;
  rep(i,n) cin >> a[i].suit >> a[i].value;

  Card b[n];
  rep(i,n) {
    b[i].suit = a[i].suit;
    b[i].value = a[i].value;
  }
  
  quicksort(0, n-1);

  printAns(a, b, n);
  return 0;
}



Measured memory_bytes: 4652
(defun read-list (N &optional (l nil)) 
  (if (zerop N) l
      (read-list (1- N) (cons (read) l))
))


(defvar  K (read))
(defvar  N (read))
(defvar  A1 (read))
(defvar lst (cons (+ K A1)
             (read-list (1- N) (list A1))
  ))

(princ (+ K (apply #'min (mapcar #'- (cdr lst) lst))))



Measured memory_bytes: 67680
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]){
	int l,r,d;
	while(cin>>l>>r>>d){
		int ans = 0;
		for (int i = l; i <= r; ++i){
			ans += i%d==0;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
def run():
  N, M = map(int, input().split())
  stairs = [1] * (N+1)
  for m in range(M):
    a = int(input())
    stairs[a] = 0
  #print(stairs)
  for n in range(2, N+1):
    stairs[n] = (stairs[n-1] + stairs[n-2])*stairs[n]
  print(stairs[N]%1000000007)
  
if __name__ == '__main__':
  run()

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  vector<pair<int,int>> v;
  for (int i=0; i<m; i++) {
    int b,c;
    cin>>b>>c;
    v.push_back({c,b});
  }
  for (int i=0; i<n; i++) {
    v.push_back({a[i],1});
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int cnt=0;
  ll ans=0;
  for (int i=0; ; i++) {
    int b=v[i].second,c=v[i].first;
    if (cnt+b<n) {
      ans+=(ll)c*b;
      cnt+=b;
    }
    else {
      ans+=(ll)c*(n-cnt);
      break;
    }
  }
      
  cout<<ans<<endl; 
  return 0;
}




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

int main(){
  char s[100];
  char k[] = "keyence";
  scanf("%s",s);
  int len = (int) strlen(s);
  int i,j;
  int d = 0;
  for(i=0;i<8;i++) {
    int c = 0;
    for(j=0;j<7;j++) {
      if(i+j<7) {
        if (s[j] == k[j]) {
          c++;
        }
      } else {
        if(s[j+len-7] == k[j]) {
          c++;
        }
      }
    }
    if(c==7) {
      d++;
    }
  }
  if(d>0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128