akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

long long int N;
long long int X, D;
long long int M;
vector<pair<long long int, long long int> > V;
pair<long long int, long long int> P;

map<long long int, long long int> C;
//long long int INF = 9999999999999999;
long long int INF = INT64_MAX/2;

int main(void) {

	cin >> N >> X >> D;

	if (X == 0 && D == 0) { cout << 1 << endl; return 0; }

	if (D == 0) {
		cout << N + 1 << endl; return 0;
	}


	M = (N*(N - 1)) / 2;

	//cout << "M= " <<M<< " D= " << D << endl;
	//cout << "INF= " << INF << endl;
	//cout <<X*N+ D*M +INF << endl;

	for (long long int i = 0; i <= N; i++) {
		long long int tmp1 = X*(N - 2 * i) + D*(M - ((long long int)i - 1)*i);
		long long int tmp2 = X*(N - 2 * i) + (M - N * 2 * i + ((long long int)i)*(i + 1))*D;
		P.first = max(tmp1, tmp2);
		P.second = min(tmp1, tmp2);
		//cout << P.first << " " << P.second << endl;
		V.push_back(P);
	}

	sort(V.rbegin(), V.rend());

	
/*	for (int i = 0; i <= N; i++) {
		P = V[i];
		for (long long int k = P.second; k <= P.first; k += abs(D)*2) {
			cout << " " << k;
		}
		cout << endl;
	}*/


	long long int ans = 0;

	long long int geta = (INF / abs(D*2))*abs(D*2);
	//cout << "geta= " << geta << endl;

	for (int i = 0; i <= N; i++) {
		P = V[i];
		C[(P.first+geta) % (abs(D) * 2)] = INF;
	}

	for (int i = 0; i <= N; i++) {
		P = V[i];
		long long int max_val = min(P.first, C[(P.first +geta)% (abs(D) * 2)]-abs(D)*2);
		long long int min_val = min(P.second, C[(P.first+geta)%(abs(D)*2)]);

		if (max_val >= P.second) {
			ans += (max_val - P.second) / (abs(D) * 2) + 1;
		}
		C[(P.first+geta) % (abs(D) * 2)] = min_val;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 16748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

class UnionFind{
public:
    vll par;
    vll siz;

    UnionFind(ll n):par(n), siz(n, 1LL){
        rep(i,0,n){par[i] = i;}
    }

    ll root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    ll size(int x){
        return siz[x];
    }

};

int main(){
    int n, k, l;
    cin >> n >> k >> l;
    int p[k], q[k], r[l], s[l];
    rep(i,0,k){
        int a, b;
        cin >> a >> b;
        a--;b--;
        p[i] = a;
        q[i] = b;
    }
    rep(i,0,l){
        int a, b;
        cin >> a >> b;
        a--;b--;
        r[i] = a;
        s[i] = b;
    }
    UnionFind road(n), rail(n);
    rep(i,0,k){
        road.merge(p[i], q[i]);
    }
    rep(i,0,l){
        rail.merge(r[i], s[i]);
    }

    map<Pll, ll> mp;
    rep(i,0,n) mp[{road.root(i),rail.root(i)}]++;
    rep(i,0,n) cout << mp[{road.root(i),rail.root(i)}] <<" ";
    

}

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

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    if(a == b && a == c){
        ans = 1;
    }
    else if(a == b && a != c){
        ans = 2;
    }
    else if(a != b && a == c){
        ans = 2;
    }
    else if(a != b && b == c){
        ans = 2;
    }
    else if(a != b && b != c){
        ans = 3;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;

int main()
{
	int n;
	cin >> n;
	
	cpp_int m = 1;
	cpp_int limit = 1000000000000000000;
	
	for(int i = 1; i <= n; i++){
		cpp_int x;
		cin >> x;
      	if(!x) m = 0;
        else if(m <= limit) m *= x;
	}
	if(m <= limit) cout << m;
	else cout << "-1";

	return 0;
}

Measured memory_bytes: 3652
package main

import "fmt"

func main() {
	var n, x, a, sum int
	count := 1
	fmt.Scan(&n, &x)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		sum = sum + a
		if sum <= x {
			count++
		}
	}
	fmt.Println(count)
}


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

int main(void) {
    int N;
    cin >> N;
    int MAX = 3 * N;
    unsigned int a[MAX];

    for (int i = 0; i < MAX; i++) {
        cin >> a[i];
    }
    sort(a, a + MAX);

    unsigned long result = 0;
    for (int i = 0; i < N; i++) {
        result += a[MAX - (2 * i) - 2];
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;

void solve(long long N, long long K, std::vector<long long> a, std::vector<long long> b){
    map<long long, long long>cnts;
    for(int i=0; i<N; i++)cnts[a[i]]+=b[i];

    auto curr=0ll;
    for(auto kv: cnts){
        curr+=kv.second;
        if(curr>=K){
            cout << kv.first << endl;
            return;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, K, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

void f(vector<vector<int>> &graph, vector<bool> &check, int x) {
  check[x] = true;
  if (graph[x].empty()) return;
  for (i : graph[x]) {
    if (check[i]) continue;
    else f(graph,check,i);
  }
  return;
}

int main() {
  int N,M; cin >> N >> M;
  vector<int> X(M),Y(M),Z(M);
  for (int i = 0; i < M; i++) cin >> X[i] >> Y[i] >> Z[i];
  
  vector<vector<int>> graph(N+1);
  for (int i = 0; i < M; i++) {
    graph[X[i]].push_back(Y[i]);
    graph[Y[i]].push_back(X[i]);
  }
  
  vector<bool> check(N+1,false);
  
  int count = 0;
  for (int i = 1; i <= N; i++) {
    if (check[i]) continue;
    count++;
    f(graph,check,i);
  }
  
  cout << count << endl;   
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N;
    int ans=0;
    cin>>N;
    char a;
    if(N%2==1){Out("No");
    return 0;}

    char s[N];
    rep(i,N/2){
        cin>>s[i];
    }
    rep(i,N/2){
        cin>>a;
        if(a!=s[i]){Out("No");
    return 0;}
    }
    

    Out("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void Solve(){
	const int mod=100000;
	int M,N,ans=1;
	vector<string> field;
	vector<int> crt,next;
	cin >> M >> N;
	crt.resize(1<<(N+1));
	next.resize(1<<(N+1));
	REP(i,0,M){
		string str;
		cin >> str;
		field.push_back(str);
	}
	crt[0]=1;
	REP(y,0,M) REP(x,0,N){
		if(field[y][x]=='?'){
			ans*=3;
			ans%=mod;
		}
		REP(mask,0,1<<(N+1)){
			//maskの後ろのほうのbitが新しい.一番最初のbitは直前にJを置いたかどうかのフラグ
			const unsigned int nmask=(mask>>2)<<1;
			switch(field[y][x]){
				case '?':
				//J
				if(x+1<N){ //右端でないならば
					next[nmask|1]+=crt[mask]; //Jを置いたのでフラグが立っている
					next[nmask|1]%=mod;
				}else{ //右端ならJを置いてもその後に影響しない
					next[nmask]+=crt[mask];
					next[nmask]%=mod;
				}
				//O
				if(mask&1){ //もし直前にJをおいていたら
					next[nmask|(1<<N)]+=crt[mask]; //JOの並びができているので最新のbitが立っている
					next[nmask|(1<<N)]%=mod;
				}else{
					next[nmask]+=crt[mask]; //直前にJを置いていないので最新のbitは立っていない
					next[nmask]%=mod;
				}
				//I
				if(((mask>>2)&1)!=1){ //いま見ているマスの上でJOの並びができていなかったらIが置ける
					next[nmask]+=crt[mask];
					next[nmask]%=mod;
				}
				break;
				case 'J':
				if(x+1<N){ //右端でないならば
					next[nmask|1]+=crt[mask]; //Jを置いたのでフラグが立っている
					next[nmask|1]%=mod;
				}else{ //右端ならJを置いてもその後に影響しない
					next[nmask]+=crt[mask];
					next[nmask]%=mod;
				}
				break;
				case 'O':
				if(mask&1){ //もし直前にJを置いていたら
					next[nmask|(1<<N)]+=crt[mask]; //JOが並びができているので最新のbitが立つ
					next[nmask|(1<<N)]%=mod;
				}else{
					next[nmask]+=crt[mask];
					next[nmask]%=mod;
				}
				break;
				case 'I':
				if(((mask>>2)&1)!=1){ //いま見ているマスの上でJOの並びができていなかったらIが置ける
					next[nmask]+=crt[mask];
					next[nmask]%=mod;
				}
				break;
				default:
				break;
			}
		}
		swap(next,crt);
		fill(begin(next),end(next),0);
	}
	const int invalid=accumulate(begin(crt),end(crt),0,[](int a,int b){return (a+b)%mod;});
	ans=(ans-invalid+mod)%mod;
	cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 17484
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		List<Integer> list_sa=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		int n = sc.nextInt();
		int k = sc.nextInt();
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		Collections.sort(list);
		for(int i=0;n-k+1>i;i++) {
			int a = list.get(i+k-1)-list.get(i);
			list_sa.add(a);
		}
		int answer = Collections.min(list_sa);
		System.out.println(answer);
	}
}

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

using namespace std;

int main()
{
    string s;

    while (getline(cin, s)) {
        while (s.find("the") == s.npos &&
                    s.find("this") == s.npos &&
                    s.find("that") == s.npos) {
            for (int i = 0; i < s.size(); i++) {
                if ('a' <= s[i] && s[i] <= 'y') {
                    s[i]++;
                } else if (s[i] == 'z') {
                    s[i] = 'a';
                }
            }
        }
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
	
int k,a,b;
int ctr = 0;
scanf("%d",&k);
scanf("%d %d",&a,&b);

  for (int i=a;i<=b;i++){
	if(i%k==0){
		ctr = 1; 
	}
  }  
	if(ctr==1){
		printf("OK\n");
	}
	else{
		printf("NG\n");
	}	
		return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
using namespace std;

int n;

int main() {
  while (1) {
    if (scanf("%d", &n) != 1) return 0;

    bool first = true;
    for (int i=0; i<10; i++) {
      if (n >> i & 1) {
        if (first) printf("%d", 1 << i);
        else printf(" %d", 1 << i);
        first = false;
      }
    }
    puts("");
  }
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll m,d,i,j,k,l;
	cin>>m>>d;

	vector<ll> vc;
	ll ans=0;
	for(i=1;i<=m;i++){
		for(j=1;j<=d;j++){
			k=j; vc.clear();
			while(k>0){
				vc.ps((k%10));
				k=k/10;
			}
			if(vc.size()==2&&vc[0]>=2&&vc[1]>=2&&vc[0]*vc[1]==i){
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

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

// Z argorithm を使う
//  

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector< int > A(N+2, 0);

  int cmax = 0;
  for(int len=0;len<S.size(); len++ ) {
    string T = S.substr(len);
    
    A[0] = T.size();
    int i = 1, j = 0;
    while (i < T.size()) {
      while (i+j < T.size() && T[j] == T[i+j]) ++j;
      A[i] = j;
//      cout << "i = " << i << ", A[i] = " << j << endl;
      if (j == 0) { ++i; continue;}
      int k = 1;
//      while (i+k < T.size() && k+A[k] < j) A[i+k] = A[k],cout << "  A[" << i+k << "] = A[" << k << "] = " << A[k] << endl, ++k ;
      while (i+k < T.size() && k+A[k] < j) A[i+k] = A[k], ++k ;
      i += k; j -= k;
    }
//    REP(i,N) cout << i << " "; cout << endl;
//    REP(i,N-T.size()) cout << "  ";
//    REP(i,T.size()) cout << T[i] << " "; cout << endl;
//    REP(i,N-T.size()) cout << "  ";
//    REP(i,T.size()) cout << A[i] << " "; cout << endl;
    REP(i,T.size()) {
      cmax = max( cmax, min( A[i], i) );
    }
  }

  cout << cmax << endl;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
vector<int> graph[55];

struct UnionFind
{
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {}
    int root(int x)
    {
        if (d[x] < 0)return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (-d[x] < -d[y])swap(x, y); //y.size()が小でx.size()が大にしておきたい
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -d[root(x)]; }
};
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    rep(i,m)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int ans = 0;
    rep(i,m)
    {
        UnionFind uf(n);
        for (int j = 0; j < m; j++)
        {
            if(i==j)continue;
            uf.unite(a[j],b[j]);
        }
        if(uf.size(0) != n)ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())
A = list(map(int, input().split()))

odd = 1
for a in A:
    if a % 2 == 0:
        odd *= 2
print(3 ** N - odd)


Measured memory_bytes: 5844
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    string s;
    int a[4], sum = 0;
    char c[2] = {'+', '-'};

    cin >> s;
    for (int i = 0; i < 4; i++)
    {
        a[i] = s[i] - '0';
    }
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            for (int k = 0; k < 2; k++)
            {
                sum = a[0];
                if (i == 0)
                {
                    sum += a[1];
                }
                else
                {
                    sum -= a[1];
                }
                if (j == 0)
                {
                    sum += a[2];
                }
                else
                {
                    sum -= a[2];
                }
                if (k == 0)
                {
                    sum += a[3];
                }
                else
                {
                    sum -= a[3];
                }
                if (sum == 7)
                {
                    cout << a[0] << c[i] << a[1] << c[j] << a[2] << c[k] << a[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}


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

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

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

    vector<int> l(n + 1), r(n + 1);

    l[0] = 0;
    for (int i = 0; i < n; i++)
    {
        l[i + 1] = max(a[i], l[i]);
    }

    r[n] = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        r[i] = max(a[i], r[i + 1]);
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << max(l[i], r[i + 1]) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] ints = new int[2];
		String[] mark = new String[] {"#", "."};

		do {
			for(int i = 0; i < 2; i++) {
				ints[i] = sc.nextInt();
			}

			if (ints[0] == 0 && ints[1] == 0) {
				break;
			}

			for (int i = 0; i < ints[0]; i++) {
				for (int j = 0; j < ints[1]; j++) {
					if (i % 2 == 0) {
						System.out.print( mark[j % 2] );
					}else {
						System.out.print( mark[(j+1) % 2] );
					}
				}
				System.out.println();
			}

			System.out.println();

		}while(true);

		sc.close();

	}

}


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

using namespace std;

int main(){
	int n;
	vector<int> l;
	cin >> n;
	for(int i = 0;i < n;i++) {
		int tmp;
		cin >> tmp;
		l.push_back(tmp);
	}

	sort(l.begin(),l.end());
	int sum = 0;
	for(int i = 0;i < n-1;i++) {
		sum += l[i];
	}
	if(sum > l[n-1]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
a=[a1,a2,a3]
n=int(input())
lst=[]
flg=False
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
if a[0][0]==a[0][1]==a[0][2]==0:
    flg=True
if a[1][0]==a[1][1]==a[1][2]==0:
    flg=True
if a[2][0]==a[2][1]==a[2][2]==0:
    flg=True
if a[0][0]==a[1][0]==a[2][0]==0:
    flg=True
if a[0][1]==a[1][1]==a[2][1]==0:
    flg=True
if a[0][2]==a[1][2]==a[2][2]==0:
    flg=True
if a[0][0]==a[1][1]==a[2][2]==0:
    flg=True
if a[0][2]==a[1][1]==a[2][0]==0:
    flg=True
if flg==True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n,h,m;
long long a,b,cnt=0; 
int main() {
	cin>>n>>h>>m;
	for(int i=1;i<=n;i++) {
		scanf("%lld%lld",&a,&b);
		if(a>=h && b>=m) cnt++;
	}
	printf("%lld",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define F first
#define S second
#define ll long long
const int MOD = 1e9 + 7;
const float epsilon = 0.0005f;
const float PI = 3.1415926535897932384626433f;
 
vector<pair<int,int>> dire{{0,1},{0,-1},{1,0},{-1,0}};
 
// std::cout << std::fixed;
// std::cout << std::setprecision(9);

void solve(){
    int x;
    cin >> x;
    if(x == 0){
        cout << 1 << "\n";
        return;
    }
    cout << 0 << "\n";
}
    
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // int t;cin>>t;
    // for(int i = 0;i<t;++i){
    //     solve();
    // }
    solve();
    return(0);
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char s[6];
  scanf("%s",s);
  int tot = 0;

  rep(i, 6) {
    tot += s[i] - '0';
  }

  printf("%d\n", tot);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int m, f, r;
	
	while (cin >> m >> f >> r)
	{
		if (m == -1 && f == -1 && r == -1) break;
		int sum = m + f;
		if (m == -1 || f == -1)
		{
			cout << "F" << endl;
		} else if (sum >= 80) {
			cout << "A" << endl;
		} else if (sum >= 65) {
			cout << "B" << endl;
		} else if (sum >= 50) {
			cout << "C" << endl;
		} else if (sum >= 30) {
			if (r >= 50)
			{
				cout << "C" << endl;
			} else {
				cout << "D" << endl;
			}
		} else {
			cout << "F" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1156
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = 0
pos = 0
while pos< N:
	posB = A[pos] -1
	total = total + B[posB]
	if A[pos] - A[pos - 1] == 1 and pos > 0:
		posC = A[pos] - 2
		total = total + C[posC]
	pos += 1
print(total)


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

ll mod = 1000000007;

ll exp(ll a, ll n) {
  if (n == 1) return a;

  if (n % 2 == 0) return exp(a, n/2) * exp(a, n/2) % mod;
  else return a * exp(a, n-1) % mod;
}
long long modpow(long long x, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { 
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return res;
}
 

ll com(ll n, ll r) {
  ll ans = 1;
  for(int i = 0;i < r; i++){
    ans *= n - i;
    ans %= mod;
  }
  for(int i= 0;i<r;i++){
    ans *= modpow(i+1,mod-2);
    ans %= mod;
  }

  return ans;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;

  ll ans = (modpow(2,n) - 1 - com(n,a) -com(n,b)) % mod;
  if (ans < 0) cout << ans + mod << endl;
  else cout << ans << endl;

  return 0;
}




Measured memory_bytes: 888
#include<bits/stdc++.h>
        #define pb push_back
        #define mp make_pair
        #define ii pair<int,int>
        #define modulo 1000000007
        #define modulus 10000000000000003
        #define INF 100000000000000000
        #define int long long int
        using namespace std;
        
		vector<int> stones;
		vector<int> depe;
        int32_t main(){
			ios_base::sync_with_stdio(0);
			cin.tie(NULL);
			int n,A,B,C;
			vector<int> a,b,c;
			cin >> n;
			vector<vector<int>> depe(n+1,vector<int>(3));
			for(int i=0;i<n;i++){
				cin  >> A >> B >> C;
				a.pb(A);
				b.pb(B);
				c.pb(C);
				}
			depe[1][0]=a[0];
			depe[1][1]=b[0];
			depe[1][2]=c[0];
			for(int i=2;i<=n;i++){
				depe[i][0]=max(depe[i-1][1]+a[i-1],depe[i-1][2]+a[i-1]);
				depe[i][1]=max(depe[i-1][0]+b[i-1],depe[i-1][2]+b[i-1]);
				depe[i][2]=max(depe[i-1][0]+c[i-1],depe[i-1][1]+c[i-1]);
				}
			cout << max(max(depe[n][0],depe[n][1]),depe[n][2]);
		}


Measured memory_bytes: 8164
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B - A + 1;
    ll countC = B / C - (A-1) / C;
    ll countD = B / D - (A-1)/ D;
    ll LCM = C * D / __gcd(C, D);
    ll countCD = B / LCM - (A-1) /LCM;
    cout << ans - ( countC + countD - countCD) << endl;
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 049 B / Link: http://abc049.contest.atcoder.jp/tasks/abc049_b  ----- */


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

	LL H, W; cin >> H >> W;
	vector<string> a(H);
	for (int i = 0; i < H; ++i) {
		cin >> a[i];
		cout << a[i] << endl;
		cout << a[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

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

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,c,b[25],a[25][25],ans = 0;
	cin >> n >> m >> c;
	for(int i = 0;i < m;i++) cin >> b[i];
	for(int i = 0;i < n;i++){
		int tmp = 0;
		for(int j = 0;j < m;j++) {
			cin >> a[i][j];
			tmp += a[i][j] * b[j];
		}
		if(tmp + c > 0) ans++;
	}
	cout << ans << endl;
} 

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  string s, ans;
  cin >> s;
  ans = "";
  REP(i, s.size()){
    if(s[i] == '0'){
      ans+='0';
    }
    else if(s[i] == '1'){
      ans+='1';
    }
    else if(ans.size() != 0){
      ans.erase(ans.size()-1);
    }
    
  }

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


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

from bisect import bisect_left 
cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    t = L[i]+L[j]
    idx = bisect_left(L,t)
    cnt += max(0,idx-j-1)
print(cnt)

Measured memory_bytes: 3188
import java.util.*;
class Road{
	int from, to, time;
}
public class Main {
	static Scanner sc = new Scanner(System.in);
	static Road[] road;
	static int[][]data, ans;
	static int[]cost;
	static int n, number_of_city;
	static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		while(read()){
			ans = new int[1][2];
			ans[0][1] = Integer.MAX_VALUE;
			ans[0][0] = 0;
			for(int i = 0; i < number_of_city+1; i++){
				solve(i);
			}
			System.out.println(ans[0][0] + " " + ans[0][1]);
		}
	}
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)return false;

		data = new int[n][2];
		cost = new int[n];
		number_of_city = 0;

		for(int i = 0; i < n; i++){
			data[i][0] = sc.nextInt(); data[i][1] = sc.nextInt();
			cost[i] = sc.nextInt();
			number_of_city = Math.max(number_of_city, data[i][0]);
			number_of_city = Math.max(number_of_city, data[i][1]);
		}

		road = new Road[2*n];

		for(int i = 0; i < n; i++){
			road[i] = new Road();
			road[i].from = data[i][0];
			road[i].to = data[i][1];
			road[i].time = cost[i];
		}
		for(int i = n; i < 2*n; i++){
			road[i] = new Road();
			road[i].from = road[i - n].to;
			road[i].to = road[i - n].from;
			road[i].time = road[i - n].time;
		}
		return true;
	}
	static void solve(int from){
		int[] d = new int[number_of_city+1];
		for(int i = 0; i < number_of_city+1; i++)
			d[i] = INF;
		d[from] = 0;
		while(true){
			boolean update = false;
			for(int i = 0; i < 2*n; i++){
				Road pass = road[i];
				if(d[pass.from] != INF && d[pass.to] > d[pass.from] + pass.time){
					d[pass.to] = d[pass.from] + pass.time;
					update = true;
				}
			}
			if(!update) break;
		}
		int res = 0;
		for(int i = 0; i < number_of_city+1; i++)
			res = res + d[i];
		if(res <= ans[0][1]){
			if(res == ans[0][1]){
				ans[0][0] = Math.min(from, ans[0][0]);
				ans[0][1] = res;
			}else{
				ans[0][0] = from;
				ans[0][1] = res;
			}
		}
	}
}

Measured memory_bytes: 11000
#include <stdio.h>
int main(){
int a,b;
scanf("%d %d",&a,&b);
int x,c,v,max;
x=a+b;
c=a-b;
v=a*b;

max=x;

if(c>max) max=c;
if(v>max) max=v;

printf("%d",max);

return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
main(){int n,ans=0,x[200000],y[200000];cin>>n;r(i,n)scanf("%d",&x[i]);r(i,n)scanf("%d",&y[i]);r(i,n)r(j,n)ans^=x[i]+y[j];cout<<ans;}

Measured memory_bytes: 5244
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#define MAX 1100
using namespace std;


int main(){
    long long pa,pb,pab,x,y,sum=0,x_y;
    cin>>pa>>pb>>pab>>x>>y;
    x_y=min(x,y);
    if(pa+pb>=2*pab){
        sum+=((x_y)*2*pab);
        if(x>=y) {
            x-=y;
            sum+=min(x*2*pab,x*pa);
        }
        else {
            y-=x;
            sum+=min(y*2*pab,y*pb);
        }
    }
    else {
        sum+=pa*x+pb*y;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int c = sc.nextInt();
    	int k = sc.nextInt();
    	int sum = 0;
    	if(a < k) {
    		k -= a;
    		sum = a;
    		if(b < k) {
    			k -= b;
    			sum -= k;
    		}
    	}else {
    		sum = k;
    	}
    	System.out.println(sum);
    }
}

Measured memory_bytes: 26928
A, B = map(int,input().split())

if A % 2 == 1:
    ans = A
    A += 1
else:
    ans = 0

if B % 2 == 0:
    ans ^= B
    B -= 1

if ((B - A - 1) // 2) % 2 == 0:
    ans ^= 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,a,b;
  cin>>K>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%K==0){
      cout<<"OK"<<endl;
      break;
  }
    if(i==b)
      cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3636
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main() {
	//PLAY();


	char a, b;
	cin >> a >> b;
	if (a < b)
		cout << "<" << endl;
	else if (a > b)
		cout << ">" << endl;
	else
		cout << "=" << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  string s = "";
  if(n == 0) out('0');
  while(n != 0) {
    if(n % 2 != 0) {
      s = '1' + s;
      n -= 1LL;
    }
    else s = '0' + s;
    n /= -2LL;
  }
  out(s);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, A, B;
  std::cin >> N >> A >> B;
  std::cout << ((B - A) % 2 == 1 ? std::min(A - 1, N - B) + 1 + (B - A - 1) / 2 : (B - A) / 2) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if(abs(a-c) <= d) {
    cout << "Yes" << endl;
  }
  else {
    if(abs(a-b) <= d && abs(b-c) <= d) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}


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

int main() {
  int a,b,c,d,x,y;

  // 変数aで入力を受け取る
  cin >> a >> b >> c >> d;
  x = a + b;
  y = c + d;
  if(x > y ) {
     cout << "Left" << endl;
  } else if (x == y) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
long gcd(long x, long y)
{
	long t;

	while (y != 0) {
		t = x % y;  x = y;  y = t;
	}
	return x;
}



int main() {
	long  X,Y,Z;
	cin >>X>>Y;
	Z = gcd(X, Y);
	cout << X*Y/Z;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

//素数判定．1:素数
ll is_prime(ll n) {
  if (n == 1) return 0;
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  for (ll i = 3; i <= sqrt(n); i += 2)
    if (n % i == 0) return 0;
  return 1;
}

int main() {
  ll q;
  cin >> q;

  vll like2017(1, 3), memop(100001, 0);
  for (ll i = 3; i <= 50000; i += 2) {
    if (memop[i] == 1 || is_prime(i) == 1) {
      if (is_prime(2 * i - 1) == 1) {
        like2017.push_back(2 * i - 1);
        memop[2 * i - 1] = 1;
      }
    }
  }
  ll m = like2017.size();

  for (ll i = 0; i < q; i++) {
    ll l, r;
    cin >> l >> r;
    ll memo1 = -1, memo2 = -1;
    for (ll j = 0; j < m; j++) {
      if (like2017[j] >= l) {
        memo1 = j;
        break;
      }
    }
    if (memo1 == -1) {
      cout << 0 << endl;
      continue;
    }
    for (ll j = 0; j < m; j++) {
      if (like2017[m - 1 - j] <= r) {
        memo2 = m - 1 - j;
        break;
      }
    }
    if (memo2 == -1) cout << 0 << endl;
    else cout << memo2 - memo1 + 1 << endl;
  }
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int x, i;

            i = 0;
            while (true)
            {
                x = cin.GetInt();

                if (x == 0)
                    break;

                Console.WriteLine("Case {0}: {1}", ++i, x);
            }
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

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

int main() {
    int a, b, c;
    vector<int> v;
    cin >> a >> b >> c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    string s;
    s = to_string(v[2]) + to_string(v[1]);
    int sum = stoi(s) + v[0];
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
d = list([input().split() for i in range(n)])
y = 0
JPY = 0
BTC = 0
c = [0] * n

for i in range(n):
    if d[i][1] == 'BTC':
        c[i]= float(d[i][0])
        BTC += c[i] * 380000
    else:
        c[i]= int(d[i][0])
        JPY += c[i]
y = BTC + JPY
print(y)


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

int main() {
  int r, D, x2000;
  cin >> r >> D >> x2000;
  vector<int> R(10);
  R[0] = r * x2000 - D;
  rep(i, 9){
    R[i + 1] = r * R[i] - D;
  }
  rep(i, 10){
    cout << R[i] << endl;
  }
  return 0;
}

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


int main()
{
    long long n;
    cin >> n;
    long long a[10000];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    cout << *min_element(a, a + n) << " "
         << *max_element(a, a + n) << " "
         << accumulate(a, a + n, 0LL) << endl;

}


Measured memory_bytes: 3172
#include <iostream>
#include<string>
#include<sstream>

using namespace std;

int main()
{
int a,b;
string s,t,u;
cin>>s>>t;
cin>>a>>b;
cin>>u;

if(u==s){cout<<--a <<" " ;cout<<b;}
if(u==t)  {cout<<a<<" " ;cout<<--b;}

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[10**10]
a.sort(reverse=True)
c=a[0]
e=c//2
for i in range(1,n):
    b.append(abs(a[i]-e))
d=a[b.index(min(b))]
print(c,d)


Measured memory_bytes: 62828
def next_koch(n):
    turn60 = 0.5 + 3 ** 0.5 * 0.5j
    n_next = [n[0]]
    for i in range(1, len(n)):
        s = (n[i - 1] * 2 + n[i]) / 3
        t = (n[i - 1] + n[i] * 2) / 3
        u = (t - s) * turn60 + s
        n_next +=[s, u, t, n[i]]
    return n_next

p1 = 0 + 0j
p2 = 100 + 0j
koch = [p1, p2]

n = int(input())
for i in range(n):
    koch = next_koch(koch)

for z in koch:
    print("{:.8f} {:.8f}".format(z.real, z.imag))

Measured memory_bytes: 6884