akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009];
bool vis[200009], one[200009];

void fun(int x)
{
	bool ev = true;
	vis[x] = true;
	for (int i = x + x; i <= n; i += x) {
		if (!vis[i]) {
			fun(i);
		}
		if (one[i]) ev = !ev;
	}
	if (a[x] == 1) {
		if (ev) one[x] = true;
	}
	else {
		if (!ev) one[x] = true;
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	fun(1);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (one[i]) cnt++;
	}
	cout << cnt << E;
	for (int i = 1; i <= n; i++) {
		if (one[i]) cout << i << " ";
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=a;i<=a*b;i+=a){
		if(i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int a, b; cin >> a >> b;
	if(a > b) swap(a, b);
	if(a > 1) cout << 1 << "\n";
	else if(b > 2) cout << 2 << "\n";
	else cout << 3 << "\n";
}

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

#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

const int N =100;

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);

}
ll f(ll n) {
	return n * (n - 1) / 2;
}
bool cmp(const tuple<int, string, string>& a,
               const tuple<int, string, string>& b)
{
    return (get<0>(a) < get<0>(b));
}

void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll r=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            r = r + abs(a[i-1]-a[i]);
            a[i] = a[i-1];
        }
    }
    cout<<r<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 5208
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    vi a;
    for (int i = 0; i < 3; i++) {
        int x; cin >> x;
        a.pb(x);
    }
    sort(all(a));
    if (a[0] == a[1]) {
        if (a[1] == a[2])
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    else {
        if (a[1] == a[2])
            cout << "Yes\n";
        else
            cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<sstream> //istringstream stm(string); stm >> x;
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
long long MOD = 1e9+7;
long long ans,left,n,lef;
char a[3][1000];
int main() {
	scanf("%d",&n);
	int i;
	for (i = 1; i <= n; i++) cin>>a[1][i];
	for (i = 1; i <= n; i++) cin>>a[2][i];
	lef = 0;
	ans = 3;
	i = 1;
	while (i<=n) {
		if (a[1][i]==a[2][i]&&lef==1) {
			ans *= 2;
			lef = 1;
			i++;
			continue;
		}
		if (a[1][i]==a[2][i]&&lef==0) {
			lef = 1;
			i++;
			continue;
		}
		if (a[1][i]==a[2][i] && lef==2) {
			lef = 1;
			i++;
			continue;
		}
		if (a[1][i]!=a[2][i]&&lef==0||lef==1) {
			ans *= 2;
			lef = 2;
			i+=2;
			continue;
		}
		if (a[1][i]!=a[2][i]&&lef==2) {
			lef = 2;
			ans *= 3;
			i+=2;
			continue;
		}
	}
	printf("%lld\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	string str;
	while(cin>>str) {
		int joi=0,ioi=0;
		for(int i=0;i<str.size()-2;i++) {
			string sstr=str.substr(i,3);
			if(sstr=="JOI") joi++;
			if(sstr=="IOI") ioi++;
		}
		cout<<joi<<endl<<ioi<<endl;
	}
}

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

I n;vector<vector<I>> vw,dp;
I c1,c2;

void dfs(I i){
    I j=i/2;
    if(i>1){
        for(I k=c2;k+1;k--){
            if(dp[j-1][k]or!k){
                I ne=k+vw[i-1][1];
                if(ne<=c2)dp[i-1][ne]=max(dp[j-1][k]+vw[i-1][0],dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=min(c1,n))dfs(i*2);
    if(i*2+1<=min(c1,n))dfs(i*2+1);
}

signed main(){
    cin>>n;
    vw.resize(n);
    REP(i,n){I x,y;cin>>x>>y;vw[i]={x,y};}
    c1=1024;c2=100000;
    dp.resize(c1);REP(i,c1)dp[i].resize(c2+1);
    dp[0][vw[0][1]]=vw[0][0];
    dfs(1);
    REP(i,c1)REP(j,c2)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    I q;cin>>q;
    REP(i,q){
        I v,l;cin>>v>>l;
        vector<I> cand;
        while(v>c1){
            cand.push_back(v);
            v=v/2;
        }
        I r=cand.size();
        I ans=0;
        REP(j,1<<r){
            I v_sub=0;I w_sub=0;
            REP(k,r){
                if(j>>k&1){
                    v_sub+=vw[cand[k]-1][0];
                    w_sub+=vw[cand[k]-1][1];
                }
            }
            if(w_sub<=l)ans=max(ans,dp[v-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 419048
import java.util.Scanner;
import java.util.Stack;

public class Main {
	class Pond {
		int index, ans;
		Pond(int index, int ans) {
			this.index = index;
			this.ans = ans;
		}
	}
	void run() {
		Scanner scan = new Scanner(System.in);
		char[] a = scan.next().toCharArray();
		Stack<Integer> stack = new Stack<Integer>();
		Stack<Pond> ans = new Stack<Pond>();

		for (int i = 0; i < a.length; i++) {
			if (a[i] == '\\')
				stack.push(i);
			else if (a[i] == '/') {
				if (stack.isEmpty())
					continue;
				int n = stack.pop();
				Pond pond = new Pond(n, i - n);
				while (!ans.isEmpty()) {
					Pond p = ans.pop();
					if (p.index < pond.index) {
						ans.push(p);
						break;
					}
					pond = new Pond(pond.index, p.ans + pond.ans);
				}
				ans.push(pond);
			}
		}
		int sum = 0;
		for (int i = 0; i < ans.size(); i++)
			sum += ans.get(i).ans;
		System.out.println(sum);

		System.out.print(ans.size());
		for (int i = 0; i < ans.size(); i++)
			System.out.print(" " + ans.get(i).ans);
		System.out.println();
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 28728
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;


int main() {
    LL x;
    cin >> x;
    x = x*2 - 1;
    LL ret = ceil(x/11.0);
    cout << ret;
    return 0;
}

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

int main() {
    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;
    int l[K], r[K], idx = 0;
    for (int i = 0; i < N && idx < K; i++) {
        if (S[i] == 'o') {
            l[idx++] = i;
            i += C;
        }
    }
    idx = K - 1;
    for (int i = N - 1; i >= 0 && idx >= 0; i--) {
        if (S[i] == 'o') {
            r[idx--] = i;
            i -= C;
        }
    }
    for (int i = 0; i < K; i++) {
        if (l[i] == r[i]) cout << l[i]+1 << endl;
    }
}

Measured memory_bytes: 3332
// E - Roaming
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int N,K;

#define MOD 1000000007
#define MAX 200001 // [n+1] 1_origin
ll fac[MAX]; // 階乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の階乗 (n^-1)! = (1/n)!

// n 個の配列に、mod p で前処理する
void init(int n){
	int p = MOD;
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rp(i,2,n+1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p/i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}

// 組み合わせ nCr(mod m)
ll nCr(int n, int r){
	int m = MOD;
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

// 重複組合せ nHr(mod m)
// {n}_H_{r} = {n+r-1}_C_{r}
// ll nHr(int n, int r){return nCr(n+r-1,r);}
#define nHr(n,r) nCr((n)+(r)-1,(r))

ll solve(){
	init(N);
	K = min(K, N-1);
	ll ans = 0;
	rp(k,0,K+1){
		ll x = nCr(N,k) * nHr(N-k,k) % MOD;
		ans = (ans + x) % MOD;
	}
	return ans;
}

int main(){
	cin>>N>>K;
	cout<< solve() <<endl;
}

Measured memory_bytes: 4992
#include<stdio.h>

#define N 25

typedef struct{
  int parent;
  int left;
  int right;
}Node;

int childhigh(int);
Node T[N];

int main(){
  int id,n,i,j=0,k,c,sibling,deg,high;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].right=T[i].left=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
    if(T[id].left!=-1)T[T[id].left].parent=id;
    if(T[id].right!=-1)   T[T[id].right].parent=id;
  }
  for(k=0;k<n;k++){
    j=k;
    c=0;
    while(T[j].parent!=-1){
      c++;
      j=T[j].parent;
    }
    printf("node %d: parent = %d, ",k,T[k].parent);
    if(T[k].parent!=-1){
    if(k==T[T[k].parent].right)sibling=T[T[k].parent].left;
    else sibling=T[T[k].parent].right;
    printf("sibling = %d, ",sibling);
    } else {
      sibling=-1;
      printf("sibling = %d, ",sibling);
    }
    if(T[k].left!=-1 && T[k].right!=-1)deg=2;
    else if((T[k].left!=-1 && T[k].right==-1) || (T[k].left==-1 && T[k].right!=-1)) deg=1;
    else if(T[k].left==-1 && T[k].right==-1)deg=0;
    printf("degree = %d, depth = %d, ",deg,c);

    high=childhigh(k);
    printf("height = %d, ",high);
   





    if(T[k].parent==-1)printf("root\n");
    else if(T[k].right==-1 && T[k].left==-1)printf("leaf\n");
    else printf("internal node\n");
    }
  return 0;
}

int childhigh(int k){
  int count=0,a,b;
  if(T[k].right==-1 && T[k].left==-1)return 0;
  else if(T[k].right==-1 && T[k].left!=-1){
    count=childhigh(T[k].left);
    return count+1;
  }
  else if(T[k].right!=-1 && T[k].left==-1){
    count=childhigh(T[k].right);
    return count+1;
  }
  else {
    a=childhigh(T[k].left);
    b=childhigh(T[k].right);
    if(a>b)return a+1;
    else return b+1;
  }
}
    
    



Measured memory_bytes: 2128
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            if self.same_check(x, y) != True:
                self.size[y] += self.size[x]
                self.size[x] = 0
            self.par[x] = y
        else:
            if self.same_check(x, y) != True:
                self.size[x] += self.size[y]
                self.size[y] = 0
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def siz(self, x):
        x = self.find(x)
        return self.size[x]


N, M = map(int, input().split())
UF = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    UF.union(a, b)
Ans = set()
for i in range(N):
    Ans.add(UF.find(i))
print(len(Ans) - 1)


Measured memory_bytes: 86692
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1L<<32;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll x,n;cin>>x>>n;
  vll p(n);
  rep(i,0,n){cin>>p[i];}
  sort(p.begin(),p.end());
  rep(i,0,100){
      auto it1=find(p.begin(),p.end(),x+i),it2=find(p.begin(),p.end(),x-i);
    if(it2==p.end()){
      cout<<x-i<<endl;
      break;
    }
    if(it1==p.end()){
      cout<<x+i<<endl;
      break;
    }
  }
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    int n; cin>>n;
    vector<int> d(n);
    rep(i,n){
        cin>>d[i];
    }
    vector<int> bkt(105,0);
    rep(i,n){
        bkt[d[i]]++;
    }
    int ans =0;
    rep(i,105){
        if(bkt[i]>=1){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

s=get_nsp.map(&:to_i)
cnt_0=s.count(0)
cnt_1=s.count(1)
if cnt_0>cnt_1
    puts cnt_1*2
else
    puts cnt_0*2
end

Measured memory_bytes: 7676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


int main(void) {

    int h,w,k;
    cin>>h>>w>>k;
    vvc v(h,vc(w));
    vvi ans(h,vi(w,0));
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            v[i][j]=s[j];
        }
    }
    int num=0;
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(v[j][i]=='#'){
                num++;
                int pos=j-1;
                while(pos>=0){
                    if(ans[pos][i]==0&&v[pos][i]!='#'){
                        ans[pos][i]=num;
                        pos--;
                    } else break;
                }
                ans[j][i]=num;
                pos=j+1;
                while(pos<h){
                    if(ans[pos][i]==0&&v[pos][i]!='#'){
                        ans[pos][i]=num;
                        pos++;
                    } else break;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=1;j<w;j++){
            if(ans[i][j]==0){
                ans[i][j]=ans[i][j-1];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=w-1;j>=0;j--){
            if(ans[i][j]==0){
                ans[i][j]=ans[i][j+1];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j==0)cout<<ans[i][j];
            else cout<<" "<<ans[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

using namespace std;


int main() {

	int n;

	double a[101];


	cin >> n;

	double sum=0;

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

	sum = 1.0 / sum;

	//cout << sum << endl;
	printf("%0.9lf\n",sum);
	


	return 0;
}



Measured memory_bytes: 256
def main():
    import sys
    n, k, *a = map(int, sys.stdin.read().split())
    a = [0] + a
    check = [0] * (n + 1)
    check[1] = 1

    i = 0
    nw = 1
    path = [1]
    while True:
        nx = a[nw]
        i += 1
        if i == k:
            print(nx)
            break
        if check[nx]:
            j = path.index(nx)
            d = j + (k - i) % (i - j)
            print(path[d])
            break
        path.append(nx)
        check[nx] = True
        nw = nx


if __name__ == '__main__':
    main()


Measured memory_bytes: 32492
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  LL N, A, B;
  cin >> N >> A >> B;
  if ((B-A) % 2 == 0) {
    cout << (B-A)/2 << endl;
  } else {
    cout << min({A-1 + abs(B-A)/2 + 1, N-B + abs(B-A)/2 + 1}) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math
a = []

for i in range(5):
    a.append(int(input()))

s = 9
b = 0
for i in a:
    if int(str(i-1)[-1]) < s:
        s = int(str(i-1)[-1])
    
    b += math.ceil(i/10)*10
b = b - 10 + s + 1
print(str(b))

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val X = listOfInt().sorted()
    if (N >= M) { println(0); return }
    val L = Array(M - 1) { X[it + 1] - X[it] }.sortedArrayDescending().toList()
    val lSum = L.subList(0, N - 1).sum()
    val ans = (X.last() - X.first()) - lSum
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 52316
#define ll long long
#define pb push_back
#define mpr make_pair
#define ff first
#define ss second
#include <bits/stdc++.h>
using namespace std;
int a[1000006],cum[1000006];
int main(int argc, char const *argv[]) {
  string s;
  int n,mx=INT_MAX,r,l;
  cin>>n;
  cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='E')a[i+1] = 1;
  }
  for(int i=1;i<=n;i++){
    cum[i] = cum[i-1] + a[i];
  }
  for(int i=1;i<=n;i++){
    r  = cum[n]-cum[i];
    l = i-1-cum[i-1];
    mx = min(mx,r+l);
    //cout<<l<<" "<<r<<endl;
  }
  cout<<mx<<endl;
  return 0;
}


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

using namespace std; 
  
  
    
int main(){ 
	
	int N;
	cin >> N;
	vector<int> L(N);
	for(int i = 0; i <N; i++)
	{
		cin >> L[i];
	}
  
    int n=L.size(); 
  
    sort(L.begin(), L.end());  
  
    int count = 0; 
      
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( L[l] + L[r] > L[i]){ 
  
               
                count += r - l ;  
  
                
                r--;   
            } 
            else 
                l++;   
        } 
    } 
    
	cout << count << endl;
	return 0;
} 
    


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    scanf("%d\n",&n);
    int numbers[4][3][10]={0};
    int i;
    for(i=0;i<n;i++){
        int b,f,r,v;
        if(i!=n-1){
            scanf("%d %d %d %d\n",&b,&f,&r,&v);
        }else{
            scanf("%d %d %d %d",&b,&f,&r,&v);
        }
        numbers[b-1][f-1][r-1] += v;
    }
    int j; //building
    int k; //floor
    int l; //room
    for(j=0;j<4;j++){
        for(k=0;k<3;k++){
            for(l=0;l<10;l++){
                if(l!=9){
                    printf(" %d",numbers[j][k][l]);
                }else if(j!=3 || k!=2){
                    printf(" %d\n",numbers[j][k][l]);
                }else if(j==3 && k==2){
                    printf(" %d\n",numbers[j][k][l]);
                }
            }
        }
        if(j!=3){
            printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2032
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  char judge = S[0];
  vector <int> A;
  int cnt = 0;
  for(int i=1;i<N;i++){
    if(judge == S[i]){
      cnt++;
    }else{
      A.push_back(cnt);
      cnt = 0;
      judge = S[i];
    }
  }
  A.push_back(cnt);
  int ans = 0;
  for(int i=0;i<A.size();i++){
    ans += A[i];
  }
  cout << N - ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int a,b;
    cin>>a>>b;
    if (b%a==0)
        cout<<a+b;
    else
        cout<<b-a;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int mul(int a,int b){return (long long)a*b;}
typedef long long ll;
int main()
{
    int x,a;
    cin>>x>>a;
    if(x<a) printf("0");
    else cout<<10<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 2005

ll N,M;
ll S[SIZE],T[SIZE];
ll dp[SIZE][SIZE];
vector<int> G[SIZE];


int main(){

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

	for(ll i = 0; i < N; i++){

		scanf("%lld",&S[i]);
	}
	for(ll i = 0; i < M; i++){

		scanf("%lld",&T[i]);
	}
	for(ll i = 0; i < N; i++){
		for(ll k = 0; k < M; k++){
			if(S[i] == T[k]){

				G[i].push_back(k+1);
			}
		}
	}


	for(ll i = 0; i <= N; i++){
		for(ll k = 0; k <= M; k++){
			dp[i][k] = 0;
		}
	}

	dp[0][0] = 1;

	for(ll i = 0; i < N; i++){
		//S[i]を無視する場合
		for(ll k = 0; k <= M; k++){
			dp[i+1][k] = dp[i][k];
		}
		//S[i]から遷移する場合
		//遷移高速化のための累積和
		for(ll k = 1; k <= M; k++){
			dp[i][k] += dp[i][k-1];
			dp[i][k] %= MOD;
		}
		//printf("i:%lld\n",i);
		for(ll k = 0; k < G[i].size(); k++){

			dp[i+1][G[i][k]] += dp[i][G[i][k]-1];
			//printf("%lldに%lld加算\n",G[i][k],dp[i][G[i][k]-1]);
			dp[i+1][G[i][k]] %= MOD;
		}
	}

	ll ans = 0;
	for(ll i = 0; i <= M; i++){

		ans += dp[N][i];
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 47360
#include<iostream>
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	int a=d*2+1;
	int s=0,sum=0;
	while(sum<n)
	{
		sum+=a;
		s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

N, K = map(int, readline().split())
N = N + 1

lower = None
upper = None
answer = 0
for k in range(K, N+1):
    if lower is None:
        lower = sum(range(k))
        upper = sum(range(N-k, N))
    else:
        lower += k - 1
        upper += N - k
    answer += (upper - lower + 1)
print(answer % MOD)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define N 100010
ull a[N];

int getsize(ull num)
{
	int cnt=0;
	for (;num;)
	{
		num/=10;
		cnt++;
	}
	return cnt;
}

void solve()
{
	int n;
	cin>>n;
	ull ans=1;
	bool flag=true;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	if (a[1]==0)
	{
		cout<<"0"<<endl;
		return;
	}
	for (int i=1;i<=n;i++)
	{
		
		if ( getsize(ans)+getsize(a[i])>=20)
		{
			if (getsize(ans)+getsize(a[i])==20&&(ans*a[i]==1000000000000000000))
				;	
			else
			{
				cout<<"-1";
				return;				
			}

		}//1844674407370955161
		ans*=a[i];
		if (ans>1000000000000000000)
		{
			cout<<"-1";
			return;
		}
		
	}
	cout<<ans<<endl;
}


int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	int t;
//	cin>>t;
//	while (t--) 
	solve();
	return 0;
}

Measured memory_bytes: 4396
// inputに入力データ全体が入る
function Main(input) {
	input = input.split(" ");
	console.log('%d',Number(input[0])*Number(input[1])/2);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

template<int mod>
struct Ring_mod {
    int val;
    Ring_mod(): val(0) {}
    Ring_mod(long long x)
    {
        if (x < 0) x += mod;
        if (x >= mod) x -= mod;
        if (x >= mod) x %= mod;
        val = x;
    }
    explicit operator int() { return val; }
    Ring_mod operator+(const Ring_mod& b) { return Ring_mod(val + b.val); }
    Ring_mod operator-(const Ring_mod& b) { return Ring_mod(val - b.val); }
    void operator+=(const Ring_mod& b) { val = Ring_mod(val + b.val).val; }
    void operator-=(const Ring_mod& b) { val = Ring_mod(val - b.val).val; }
    Ring_mod operator*(const Ring_mod& b) { return Ring_mod((long long) val * b.val); }
};

const int MOD = 1e9 + 7;
typedef Ring_mod<MOD> int_mod;

class Matrix : public vector<vector<int_mod>> {
public:
    Matrix(int n, int m)
    {
        assign(n, vector<int_mod>(m));
    }
    static Matrix Identity(int n)
    {
        Matrix a(n, n);
        for (int i = 0; i < n; ++i) a[i][i] = 1;
        return a;
    }
};

Matrix operator*(Matrix a, Matrix b)
{
    Matrix c(a.size(), b[0].size());
    for (size_t i = 0; i < a.size(); ++i)
        for (size_t j = 0; j < b[0].size(); ++j)
            for (size_t k = 0; k < b.size(); ++k)
                c[i][j] += a[i][k] * b[k][j];
    return c;
}

Matrix operator^(Matrix base, long long expo)
{
    Matrix t = Matrix::Identity(base.size());
    for (; expo > 0; expo >>= 1) {
        if (expo & 1) t = t * base;
        base = base * base;
    }
    return t;
}

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    Matrix a(n, n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            int x;
            cin >> x;
            a[i][j] = x;
        }

    a = a ^ k;
    int_mod sum = 0;
    for (int i = 0; i < n; ++i)
        sum += accumulate(a[i].begin(), a[i].end(), int_mod(0));

    cout << (int) sum;
    return 0;
}


Measured memory_bytes: 3668
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (ll)1e18
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7; 
bool vis[N];
string t;
int n,k,r,s,p,ans;
map<char,int> mp;

void dfs(int x)
{
    int i,cnt=1;
    vis[x]=1;
    for(i=x+k;i<n;i+=k)
    {
        vis[i]=1;
        if(t[i]==t[i-k])
            ++cnt;
        else
            ans+=(cnt+1>>1)*mp[t[i-k]], cnt=1;
    }   
    ans+=(cnt+1>>1)*mp[t[i-k]];
}   

signed main()
{
    warmup
    
    cin>>n>>k>>r>>s>>p;
    cin>>t;
    int i,j;
    mp['r']=p, mp['s']=r, mp['p']=s;
    for(i=0;i<n;++i)
        if(!vis[i])
            dfs(i);
    cout<<ans;
        
    return 0;
}


Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 2005;
vector<int> a;
int n,k;

int count(int x){
	int cnt = 0;
	rep(i,n){
		// if(a[i] * a[i] < x)	cnt--;

		// if(a[i] == 0 && x >= 0)	cnt += n;
		// else if(a[i] < 0){
		// 	cnt += n - (lower_bound(a.begin(), a.end(), (long double)x / a[i]) - a.begin());
		// }
		// else if(a[i] > 0){
		// 	int pos = upper_bound(a.begin(), a.end(), (long double)x / a[i]) - a.begin();
		// 	cnt += pos;
		// }

		if(a[i] <= 0){ // negative or zero
			int l = i,r = n;
			while(r-l > 1){
				int mid = (l+r) / 2;
				if(a[i] * a[mid] < x)	r = mid;
				else	l = mid;
			}
			cnt += n-r;
		}
		else{			// positive
			int l = i,r = n;
			while(r-l > 1){
				int mid = (l+r) / 2;
				if(a[i] * a[mid] < x)	l = mid;
				else	r = mid;
			}
			cnt += l-i;
		}
		// cout << cnt << ' ';
	}
	// cout << endl << x << ' ' << cnt << endl;

	return cnt;
}
// O(n * log(n) * log(C)), C = 1e18 

signed main(){
	IOS
	cin >> n >> k;
	a.resize(n);
	rep(i,n)	cin >> a[i];
	sort(a.begin(), a.end());
	int l = -1e18+7, r = 1e18+7;
	while(r-l > 1){
		int mid = (l+r) / 2;
		if(count(mid) < k)	l = mid;
		else		r = mid;
	}
	cout << l << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(int argc, char** argv)
{
	double x1, y1, x2, y2, result;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	double x = fabs(x1 - x2);
	double y = fabs(y1 - y2);

	result = sqrt((x * x) + (y * y));

	printf("%f\n", result);
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }
  vector<char> V(W + 2, '#');
  for (auto v : V) cout << v;
  cout << "\n";
  for (int i = 0; i < H; i++) {
    cout << "#";
    for (auto s : S.at(i)) cout << s;
    cout << "#";
    cout << "\n";
  }
  for (auto v : V) cout << v;
  cout << "\n";
}

Measured memory_bytes: 3544
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool comp(pll a,pll b)
{
    return a.sec<b.sec;
}

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    vc<ll> v,v1;
    rep(a,0,n)
    {
        ll b=nxt(),c=nxt();
        v.pb(b);
        v1.pb(c);
    }
    sort(all(v));
    sort(all(v1));
    ll low=0,high=0;
    if(n%2==0)
    {
        low=v[(n/2)]+v[(n/2)-1];
        high=v1[(n/2)]+v1[(n/2)-1];
    }
    else
    {
        low=v[(n/2)];
        high=v1[(n/2)];
    }
    cout<<high-low+1<<endl;
    
	printclock;
	return 0;
}

Measured memory_bytes: 6692
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    print(s[:3])

main()

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

using namespace std;

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

  int first;
  cin >> first;

  int oddSum, evenSum;
  long oddCount, evenCount;

  if (first == 0) {
    oddSum = -1;
    oddCount = 1;
    evenSum = 1;
    evenCount = 1;
  } else if (first > 0) {
    oddSum = -1;
    oddCount = first + 1;
    evenSum = first;
    evenCount = 0;
  } else if (first < 0) {
    oddSum = first;
    oddCount = 0;
    evenSum = 1;
    evenCount = first * -1 + 1;
  }

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

    int nextOddSum = oddSum + a;
    int nextEvenSum = evenSum + a;

    if ((oddSum > 0 && nextOddSum < 0) || (oddSum < 0 && nextOddSum > 0)) {
      oddSum = nextOddSum;
    } else if (nextOddSum == 0) {
      oddSum = oddSum > 0 ? -1 : 1;
      oddCount += 1;
    } else if (nextOddSum > 0) {
      oddSum = -1;
      oddCount += nextOddSum + 1;
    } else if (nextOddSum < 0) {
      oddSum = 1;
      oddCount += nextOddSum * -1 + 1;
    }

    if ((evenSum > 0 && nextEvenSum < 0) || (evenSum < 0 && nextEvenSum > 0)) {
      evenSum = nextEvenSum;
    } else if (nextEvenSum == 0) {
      evenSum = evenSum > 0 ? -1 : 1;
      evenCount += 1;
    } else if (nextEvenSum > 0) {
      evenSum = -1;
      evenCount += nextEvenSum + 1;
    } else if (nextEvenSum < 0) {
      evenSum = 1;
      evenCount += nextEvenSum * -1 + 1;
    }
  }

  long answer = min(oddCount, evenCount);

  cout << answer << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
#define pb push_back

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}


string s;
vector<char> ops({'+', '-', '*', '.', '.'});
map<char, int> ran;

int64 calc(int64 l, int64 r);
int64 expr(const string& s, int& p);
int64 number(const string& s, int& p);
int64 digit(const string& s, int& p);


int64 expr(const string& s, int& p, int rank = 0) {
    int64 l = p;
    int64 now = 0;
    if (rank == 3) {
        if (s[p] == '(') {
            p++;
            now = expr(s, p, 0);
            p++;
            return now;
        }
        return number(s, p);
    }

    now = expr(s, p, rank+1);
    while (p < s.size() && s[p] != ')' && ran[s[p]] == rank) {
        char op = s[p++];
        int64 nxt = expr(s, p, rank+1);
        if (op == '+') now += nxt;
        else if (op == '-') now -= nxt;
        else if (op == '*') now *= nxt;
    }
//    cout << l << " " << p << " " << rank << " " << now << " " << s.substr(l, p-l+1) << endl;
    return now;
}

int64 number(const string& s, int& p) {
    int64 now = 0;
    while(p < s.size()) {
        if ('0' > s[p] || s[p] > '9')
            break;
        now = now*10 + digit(s, p);
    }
    return now;
}

int64 digit(const string& s, int& p) {
    return s[p++]-'0';
}



int main(void){
    cin >> s;
    sort(all(ops));
    int64 res = numeric_limits<int64_t>::min();
    do {
        int cnt = 0;
        REP(i, ops.size()) {
            if (ops[i] == '.') cnt++;
            else ran[ops[i]] = cnt;
//            cout << ops[i] << " ";
        }
//        cout << endl;
        int p = 0;
        int64 ret = expr(s, p, 0);
//        cout << ret << endl;
        chmax(res, ret);
    }while(next_permutation(all(ops)));
    cout << res << endl;
}




Measured memory_bytes: 3232
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = new List<string>();
            for (int i = 0; i < n; i++)
            {
                s.Add(Console.ReadLine());
            }

            var m = int.Parse(Console.ReadLine());
            var t = new List<string>();
            for (int i = 0; i < m; i++)
            {
                t.Add(Console.ReadLine());
            }

            var count = new List<int>();
            foreach (var item in s)
            {
                count.Add(s.Count(x => x == item) - t.Count(x => x == item));
            }

            var ans = count.Max() >= 0 ? count.Max() : 0; 

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
use std::io;

fn read() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

 fn main(){
    loop{
        let mut x = read();
        
        if x[0]==0 && x[1]==0 && x[2]==0{
            break;
        }
        
        let mut max = 0;
        
        for i in 1..x[2]{
            for j in 1..x[2]{
                if i*(100+x[0])/100 + j*(100+x[0])/100 == x[2]{
                    let mut sum = i*(100+x[1])/100 + j*(100+x[1])/100;
                    if sum > max{
                        max = sum;
                    }
                }
            }
        }
        println!("{}",max);
    }
 }
 


Measured memory_bytes: 5028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	VV<bool> e(N,V<bool>(N,true));
	rep(i,N) e[i][i] = false;
	if(N%2==0){
		rep(i,N/2) e[i][N-1-i] = false;
	}else{
		rep(i,N/2) e[i][N-2-i] = false;
	}
	int M = 0;
	rep(i,N) for(int j=i+1;j<N;j++) if(e[i][j]) M++;
	cout << M << endl;
	rep(i,N) for(int j=i+1;j<N;j++) if(e[i][j]) cout << i+1 << " " << j+1 << endl;
}


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

#define MAX 1000

void func_print(char string[], int start, int end)
{
    for (int i = start; i <= end; i++)
    {
        printf("%c", string[i]);
    }
    printf("\n");
}

void func_reverse(char string[], int start, int end)
{
    // printf("TEST : %d %d\n", start, end);
    char temp;
    for (; start < end; start++)
    {
        // printf("before %d: %c, %d: %c\n", start, string[start], end, string[end]);
        temp = string[start];
        string[start] = string[end];
        string[end] = temp;
        // printf("after %d: %c, %d: %c\n", start, string[start], end, string[end]);
        end--;
    }
}

void func_replace(char string[], int start, int end, char rep_string[])
{

    for (int i = 0, j = start; j <= end; i++, j++)
    {
        string[j] = rep_string[i];
    }
}

int main(void)
{
    char string[MAX + 1];
    int q_num;

    char question_name[8];

    char replace[] = "replace";
    char reverse[] = "reverse";
    char print[] = "print";

    scanf("%s", string);
    scanf("%d", &q_num);
    for (int i = 0; i < q_num; i++)
    {
        scanf("%s", question_name);
        if (strcmp(question_name, replace) == 0)
        {
            int start, end;
            scanf("%d %d", &start, &end);
            char rep_string[end - start + 1];
            scanf("%s", rep_string);
            func_replace(string, start, end, rep_string);
        }
        else if (strcmp(question_name, reverse) == 0)
        {
            int start, end;
            scanf("%d %d", &start, &end);
            func_reverse(string, start, end);
        }
        else if (strcmp(question_name, print) == 0)
        {
            int start, end;
            scanf("%d %d", &start, &end);
            func_print(string, start, end);
        }
    }
    return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k, s;
    cin >> n >> k >> s;
    int m = 1e9;
    REP(i,n) {
        if (i < k) {
            cout << s << '\n';
        } else {
            if (s != m) cout << m << '\n';
            else cout << m-1 << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 1280
n = int(input())
x = []
y = []
h = []
I = 0
for i in range(n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c > 0:
        I = i
H = 0
X = Y = 0
flag = 0
cnt = 0
for i in range(101):
    for j in range(101):
        tmp = abs(x[I]-i) + abs(y[I]-j) + h[I]
        for k in range(n):
            if h[k] > 0:
                cnt += 1
                if tmp != abs(x[k]-i) + abs(y[k]-j) + h[k]:
                    break
        else:
            if cnt == 1:
                print(x[I], y[I], h[I])
                exit(0)
            else:
                H = tmp
                X = i
                Y = j
print(X, Y, H)


Measured memory_bytes: 3064
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
u=k

b=0
while k > 0:
  k = k>>1
  b +=1

c=[0]*b
for i in range(b):
   m=2**i
   for j in range(n):
      c[i]+= 1 if a[j]&m else 0

x = 0
for i in range(b-1,-1,-1):
  if 2*c[i]<n:
    if x+2**i <= u:
      x += 2**i

t=0
for i in range(n):
  t += a[i]^x

print(t)


Measured memory_bytes: 14620
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    using ll = long long;
    using P = pair<int,int>; 
    
    
    int main() {
     ll x;
     cin >> x;
     int happy = 0;
     
     while(true){
     	if(x>=500){
     		x-=500;
     		happy+= 1000;
     	}else{
     		if(x>=5){
     			x-=5;
     			happy+=5;
     		} else{
     			cout << happy << '\n';
     			return 0;
     		}
     	}
     }
     
    }

Measured memory_bytes: 256