akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,ans,HASH[200001],tr[200001];
struct point{int x,y;}a[200001];
struct seg{int k,x,y,r;}s[2000001];
inline bool cmp3(seg a,seg b){
    if(a.y==b.y)return a.k>b.k;
    return a.y<b.y;
}
int find(int x)
{
    int l=0,r=m+1;
    while(l+1<r)
    {
        int mid=(l+r)>>1;
        if(HASH[mid]>=x)r=mid;
        else l=mid;
    }
    return r;
}
void insert(int k,int l,int r,int t)//0横线,1竖线
{
    if(!k){s[++cnt].x=find(l);s[cnt].r=find(r);s[cnt].y=t;s[cnt].k=0;}
    else{
        s[++cnt].x=find(t);s[cnt].y=l;s[cnt].k=1;
        s[++cnt].x=find(t);s[cnt].y=r;s[cnt].k=-1;
    }
}
void update(int x,int y)
{
    while(x<2e5)
    {
        tr[x]+=y;
        x+=x&(-x);
    }
}
int ask(int x)
{
    int s=0;
    while(x){
        s+=tr[x];
        x-=x&(-x);
    }
    return s;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++){
        scanf("%d%d",&a[i].x,&a[i].y);
        HASH[i]=a[i].x;
    }
    sort(HASH+1,HASH+2*n+1);
    m=unique(HASH+1,HASH+2*n+1)-(HASH+1);
    for(int i=1;i<2*n;i+=2){
        if(a[i].x==a[i+1].x){
            if(a[i].y>a[i+1].y)swap(a[i],a[i+1]);
            insert(1,a[i].y,a[i+1].y,a[i].x);
        }else{
            if(a[i].x>a[i+1].x)swap(a[i],a[i+1]);
            insert(0,a[i].x,a[i+1].x,a[i].y);
        }
    }
    sort(s+1,s+cnt+1,cmp3);
    for(int i=1;i<=cnt;i++){
//        if(!s[i].k)cout<<s[i].x<<" "<<s[i].r<<endl;
//        else cout<<s[i].x<<" "<<s[i].y<<" "<<s[i].k<<endl;
        if(!s[i].k)ans+=ask(s[i].r)-ask(s[i].x-1);
        else update(s[i].x,s[i].k);
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 8812
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 998244353
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

ll pow1(ll a, ll b, ll m = mod)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2, m);
		x *= x;
		x %= m;
		if (b%2)
		{
			x *= a;
			x %= m;
		}
		return x;
	}
}

template <class avgType>
avgType avg(avgType a, avgType b) {
	return (a + b)/2;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int randInt() {
	return rng() % INT_MAX;
}

ll randLL() {
	return rng64() % LLONG_MAX;
}

vector< int > hashmods = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093};

ll n, s, a[3100], dp[2][3100];

int main() {
	fastio;

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

	ll ans = 0; 

	for (int i = 1; i <= n; i++) {
		dp[1][a[i]] += i;
		for (int j = 0; j <= s-a[i]; j++) {
			dp[1][j + a[i]] += dp[0][j];
		}

		for (int j = 0; j <= s; j++) {
			dp[0][j] += dp[1][j];
			dp[0][j] %= mod;
			if (j == s) {
				ans += (dp[1][j] * ll(n - i + 1));
				ans %= mod;
			}
			dp[1][j] = 0;
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    int a, b, c;
    cin >> a >> b >> c;

    int flag;
    if (a == b && b == c){
        flag = 0;
    }
    else if (a == b || b == c || a == c){
        flag = 1;
    }
    else flag = 0;


    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}





//              g++ -std=c++1z


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

int main(void)
{
	int A,B,H,M;
	double c,Ha,Ma,answer,t;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&H);
	scanf("%d",&M);
	Ma=(double)M*360/60;
	Ha=(double)H*360/12+Ma/12;
	if(Ha>Ma)c=(double)(Ha-Ma)*3.14159265359/180;
	else c=(double)(Ma-Ha)*3.14159265359/180;
	t=cos(c)*A*B*2;
	answer=(double)sqrt(A*A+B*B-t);
	printf("%.9f",answer);
	return 0;
}

Measured memory_bytes: 2624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
  cin>>n;
  vec1(x,n);
  sort(all(x));
  int ans=100000000;
  int mi=x[0],ma=x[n-1];
  REP(i,mi,ma+1){
    int cnt=0;
    rep(j,n){
       cnt+=(i-x[j])*(i-x[j]);
    }
    ans =min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	int odd=0;
	REP(i,n){
		cin >> a[i];
		if(a[i]%2==1){
			odd++;
		}
	}
	if(odd==0){
		cout << "second" << endl;
	}
	else{
		cout << "first" << endl;
	}
}

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

long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}

int main() {
  srand (time(NULL));
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      neg -= c[j] * (i - last[j]);
    }
    
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  /* reversed: 109149564 */
  /* sorted: 110465449 */
  /* stocahstic */
  
  for (int t = 1; t <= 2000000; ++t) {
    int dd = rand() % n;
    int tt = rand() % 26;
    int ot = options[dd];
    if (ot == tt) continue;
    long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                        options, dd, tt, ot);
    if (ns > 0) {
      total += ns;
      options[dd] = tt;
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	long long n,i,t,ans;
	long long a[100010]={};
	while(~scanf("%lld",&n)){
		for(i=0;i<n;i++){
			scanf("%lld",&a[i]);
		}sort(a,a+n);
		t=n/2;
		ans=a[t]-a[t-1];
		printf("%lld\n",ans);
	}
}

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

#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

int main(){
    io

    int n;
    string s;
    cin >> n >> s;

    int cont(1);
    char last = s[0];
    for(int i(0); i<s.length(); i++){
        if(s[i] != last){
            cont++;
            last = s[i];
        }
    }
    
    cout << cont << endl;

    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 100010;
int a[N],n,x;
map<int,int> Map;
int main(){
	scanf("%d",&n);
	for(int i =1;i<=n;i++){
		scanf("%d",&x);
		Map[x]++;
	}
	int ans = 0;
	for(auto x:Map){
		if(x.second<x.first) ans += x.second;
		else ans += x.second-x.first;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 4736
#include <cstdio>
#include <iostream>

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

long long int dp[11][101][1001] = {0};

void solve(){
    dp[0][0][0] = 1;
    dp[1][0][0] = 1;
    reep(cou,1,11){
        reep(num,1,101){
            reep(sum,num,1001){
                reep(k,0,num){
                    dp[cou][num][sum] += dp[cou-1][k][sum-num];
                }
            }
        }
    }
}

int main(){
    solve();
    int n,s;
    while(cin >> n >> s,n+s){
        long long int ans = 0;
        rep(i,101){
            ans += dp[n][i][s];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 9052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  
  if (N <= K){
    cout << N * X << endl;
  }
  
  else{
    cout << K*X + (N-K)*Y << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

bool check(LL n, LL bit, vector<vector<LL>>& a, vector<vector<LL>>& b){
    for(LL i = 0; i < n; ++i){
        if(((1LL<<i) & bit) == 0) continue;
        for(LL j: a[i]){
            if(((bit >> j) & 1) == 0) return false;
        }
        for(LL j: b[i]){
            if(((bit >> j) & 1) == 1) return false;
        }
    }
    return true;
}

LL pop_cnt(LL v){
    LL cnt = 0;
    while(v > 0){
        if(v & 1) ++cnt;
        v /= 2;
    }
    return cnt;
}

int main(){
    LL n;
    cin >> n;
    vector<vector<LL>> a(n);
    vector<vector<LL>> b(n);
    for(LL i = 0; i < n; ++i){
        LL m;
        cin >> m;
        for(LL j = 0; j < m; ++j){
            LL x, y;
            cin >> x >> y;
            --x;
            if(y == 0) b[i].push_back(x);
            else a[i].push_back(x);
        }
    }
    LL ans = 0;
    for(LL i = 0; i < (1LL<<n); ++i){
        if(check(n, i, a, b)){
            LL cnt = pop_cnt(i);
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
ans=r*g*b
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if s[i]!=s[j]:
            k=j+j-i
            if k>=len(s):
                break
            else:
                if s[i]!=s[k] and s[j]!=s[k]:
                    ans-=1
print(ans) 


Measured memory_bytes: 9056
#coding:utf-8

m = 0
f = 0
r = 0

while m + f + r >-3:
    m , f, r =[int(i) for i in input().rstrip().split(" ")]
    if m+f+r == -3:
        break
    
    if m == -1:
        print("F")
    elif f == -1:
        print("F")
    elif m+f <30:
        print("F")
    elif m+f <50:
        if r>=50:
            print("C")
        else:
            print("D")
    elif m+f <65:
        print("C")
    elif m+f <80:
        print("B")
    else:
        print("A")

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

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

	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (auto& e : h)
		cin >> e;

	vector<int> a(m), b(m);

	map<int, set<int>> adj;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		adj[a[i]].insert(b[i]);
		adj[b[i]].insert(a[i]);
	}


	int ans = 0;
	for (int i = 1; i <=n; i++) {

		bool ok = true;
		for (auto w : adj[i]) {
			if (h[w - 1] >= h[i - 1]) {
				ok = false;
				break;
			}
		}
		if (ok) ans++;
	}

	cout << ans << "\n";
}

Measured memory_bytes: 23112
/* ABC133-C.c
   Takatan */

#include<stdio.h>
#include<math.h>
int main(void){
    double number;
    int range;

    scanf( "%lf %d" , &number, &range);
    number = ceil(number / (2 * range + 1));
    printf( "%1.0f" , number);
    return 0;
}

Measured memory_bytes: 256
l=list(map(int,input().split()))
T=[l[0],l[1]]
A=[l[2],l[3]]
bool = True
while(True):

	if(bool):
		A[0] -= T[1]
		bool = False
		if(A[0] <= 0):
			print("Yes")
			break
	else:
		T[0] -= A[1]
		bool = True	
		if(T[0] <= 0):
			print("No")
			break	

Measured memory_bytes: 9196
def ans(res, L, N):
    for i in range(N):
        count = 0
        for new in res:
            for k in L[i]:
                if(new == k):
                    count += 1
        if(count >= 2):
            return 1
    return 0



a, b = map(int, input().split())
res  = []
for i in range(a,b+1, 1):
    res.append(i)
N = int(input())
L = []
for i in range(N):
    l = []
    s, f = map(int, input().split())
    for i in range(s,f + 1,1):
        l.append(i)
    L.append(l)
print(ans(res, L, N))



Measured memory_bytes: 5608
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, x, y = LI()
    ans = [0 for _ in range(n)]
    m = y-x-1

    for i in range(1,n):
        for j in range(i+1,n+1):
            direct = j-i
            short = abs(i-x) + 1 + abs(y-j)
            cnt = min(direct,short)
            ans[cnt] += 1

    print(*ans[1:],sep="\n")
main()


Measured memory_bytes: 76220
#(41)コッホ曲線

import math

def plot(x,y):
     print(f'{x:.8f} {y:.8f}')
     
def Koch(n, x1,y1, x2,y2):
     if n==0:
          plot(x1,y1)
          return
     sx=(2*x1+x2)/3
     sy=(2*y1+y2)/3
     tx=(x1+2*x2)/3
     ty=(y1+2*y2)/3
     ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
     uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
     Koch(n-1, x1,y1, sx,sy)
     Koch(n-1, sx,sy, ux,uy)
     Koch(n-1, ux,uy, tx,ty)
     Koch(n-1, tx,ty, x2,y2)
n=int(input())
Koch(n, 0,0, 100,0)
plot(100,0)


Measured memory_bytes: 5752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, k;
	cin >> n >> k;
	ll a[n];
	ll sm = 0;
	zep(i, 0, n){
		cin >> a[i];
		sm += a[i];
	}
	
	vector<P> v;
	ll all = 1;
	for(ll i = 2; i*i <= 5e8; i++){
		ll cnt = 0;
		while(sm%i == 0){
			sm /= i;
			cnt++;
		}
		if(cnt > 0){
			v.push_back(P(i, cnt));
			all *= cnt+1;
		}
	}
	if(sm > 1){
		v.push_back(P(sm, 1));
		all *= 2;
	}
	//print(all)
	ll ans = 1;
	zep(j, 1, all){
		ll tmp = j;
		ll mod = 1;
		zep(k, 0, v.size()){
			mod *= pow(v[k].first, tmp%(v[k].second+1));
			tmp /= v[k].second+1;
		}
		
		ll b[n];
		zep(i, 0, n){
			b[i] = a[i]%mod;
		}
		sort(b, b+n);
		
		ll l = 0;
		ll li = 0;
		ll r = 0;
		ll ri = n-1;
		while(li <= ri){
			if(l < r){
				l += b[li];
				li++;
			}
			else{
				if(r < l){
					r += mod-b[ri];
					ri--;
				}
				else{
					if(b[li] < mod-b[ri]){
						l += b[li];
						li++;
					}
					else{
						r += mod-b[ri];
						ri--;
					}
				}
			}
		}
		if(max(l, r) <= k){
			ans = max(mod, ans);
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
def input_from_console():
    k = int(input().rstrip())
    a, b = map(int, input().split())
    return k, a, b


def solve(k, a, b):
    result = "NG"
    if a % k == 0 or (b // k > a // k):
        result = 'OK'
    return result


def main():
    k, a, b = input_from_console()
    print(solve(k, a, b))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


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

int main() {
    int count = 0;
    std::string s;
    int n;
    std::cin >> n;
    std::cin >> s;
    for (int i = 0; i < n-1; i++) {
        std::string p = {s[i], s[i+1]};
        if (p == "OX" || p == "XO") {
            count++;
            i++;
        }
    }
    std::cout << count << std::endl;

}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())                 //昇順
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>()) //降順
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

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

  vec a(N);
  ll ansmax = -1;
  REP(i, N) {
    cin >> a[i];
    ansmax = max(ansmax, a[i]);
  }
  vec anslist(N);
  REP(i, N) {
    anslist[i] = a[i];
    if (anslist[i] > ansmax / 2)
      anslist[i] = ansmax - anslist[i];
  }

  ISORT(anslist);

  //   vdebug(anslist);
  //   debug(Lower_bound(a, anslist[0]));
  //   debug(Upper_bound(a, anslist[0]));
  SORT(a);
  if (Lower_bound(a, anslist[0]) == Upper_bound(a, anslist[0]))
    anslist[0] = ansmax - anslist[0];

  //   vdebug(anslist);
  //   vdebug(a);
  //   if (Lower_bound(a, anslist[0]) == Upper_bound(a, anslist[0]))
  //     cout << "error" << endl;

  cout << ansmax << " " << anslist[0] << endl;

  return 0;
}

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

int main(){
	// sengen
	int x;
	int count =0;


	// nyuryoku
	cin >> x;
	// keisan
	int a = x/500;
	int b = x%500;
	int c = b/5;
	if(x>=500){
		count += a*1000;
	}
	if(b>=5){
		count += c*5;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int getGCD( int a, int b );

int main( void )
{
	int a;
	int b;
	int GCD;
	int LCM;
	
	while( scanf( "%d %d", &a, &b ) != EOF )
	{
		GCD = getGCD( a, b );
		LCM = ( a / GCD ) * ( b / GCD ) * GCD;
		printf( "%d %d\n", GCD, LCM );
	}
	
	return (0);
}

int getGCD( int a, int b )
{
	int big;
	int small;
	if( a > b )
	{
		big = a;
		small = b;
	}
	else
	{
		big = b;
		small = a;
	}
	
	if( small == 0 )
	{
		return ( big );
	}
	else
	{
		return ( getGCD( small, big %  small ) );
	}
}

Measured memory_bytes: 596
A,B,M = map(int,input().split())
a =  list(map(int,input().split()))
b =  list(map(int,input().split()))
xyc = []
ans = 2*(10**5)
for i in range(M):
    x,y,c = list(map(int,input().split()))
    x -= 1
    y -= 1
    ans = min(ans,a[x] + b[y] - c)
ans = min(ans,min(a)+min(b))
print(ans)



Measured memory_bytes: 18608
import sys
input = sys.stdin.readline
mod  = int(1e9+7)

n,k = map(int,input().split())
L = list(map(int,input().split()))
ans = 1 
if k==n:
    for i in L:
        ans*=i
        ans%=mod
    print(ans%mod)
    sys.exit()

pos = []
neg = []
for i in L:
    if i>=0:
        pos.append(i)
    else:
        neg.append(i)

pos.sort(reverse=True)
neg.sort()

if len(pos) == 0 and k%2!=0:
    for i in range(1,k+1):
        ans *= neg[-i]
        ans %= mod
    print(ans%mod)
    sys.exit()

if k%2!=0:
    ans*=pos.pop(0)
    k-=1

l=[]
for i in range(1,len(pos),2):
    l.append(pos[i]*pos[i-1])
    
for i in range(1,len(neg),2):
    l.append(neg[i]*neg[i-1])

l.sort(reverse = True)
for i in range(k//2):
    ans *= l[i]
    ans %= mod
print(ans%mod)



Measured memory_bytes: 113136
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int a=sc.nextInt();
        int b=sc.nextInt();
        int r=1,c=0;
        while (r<b) {
        	c++;
        	r+=a-1;        	
		}
        
        out.println(c);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22356
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;

	int passed = 0;
	int rank_b = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'a') {
			if (passed < A + B) {
				++passed;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (S[i] == 'b') {
			if (passed < A + B && rank_b < B) {
				++passed;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
			++rank_b;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 896
n = int(input())

m = 10**12
for i in range(2,int(n**0.5)+1):
    if n%i == 0:
        m = min(m,i+n//i-2)
    if i == int(n**0.5) -1:
        m = min(m,n-1)
if n <= 2:
    m = n-1
elif n == 3:
    m = 2
print(m)

Measured memory_bytes: 3060
N = input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            A = int(N[0])
            B = int(N[1])
            C = int(N[2])
            D = int(N[3])
            op1 = '+'
            op2 = '+'
            op3 = '+'
            if i == 0:
                B *= -1
                op1 = '-'
            if j == 0:
                C *= -1
                op2 = '-'
            if k == 0:
                D *= -1
                op3 = '-'
            if A + B + C + D == 7:
                print(str(abs(A)) + op1 + str(abs(B)) + op2 + str(abs(C)) + op3 + str(abs(D)) + '=7')
                exit()

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int e;
    cin >> e;
    if(e==0) return 0;
    int ans=1000000000;
    for(int i=0;i<=100;i++){
      for(int j=0;j<=1000;j++){
        if(e>=i*i*i+j*j) ans=min(ans,i+j+e-i*i*i-j*j);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
public class
Main
{
  public static void
  main (
    String[ ] args
    )
  {
    java.util.Queue<Integer> lis
      = new java.util.PriorityQueue<Integer> ( 16,
          new java.util.Comparator<Integer> ( )
          {
            public int
            compare (
              Integer a,
              Integer b
              )
            {
              return ( b - a );
            }
          } );
    java.util.Scanner cin = new java.util.Scanner ( System.in );
    int i;

    for ( i = 0; i < 10; ++i )
    {
      lis.add ( new Integer ( cin.nextInt ( ) ) );
    }
    for ( i = 0; i < 3; ++i )
    {
      System.out.println ( lis.poll ( ) );
    }

    return ;
  }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int h,a,t,m;
	scanf("%d%d",&h,&a);
	if(h%a){
		t=h/a+1;
	}
	else t=h/a;
	printf("%d",t);
 } 

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;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}

int main(){
  char a,b,c;
  cin >> a >> b >> c;
  if (a == '7' || b == '7' || c == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

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

    vector<int> vec(N);
    for(int i=0; i<N; i++) {
        scanf("%d", &vec[i]);
    }
    sort(vec.rbegin(), vec.rend());
    vec.push_back(0);

    int idx = 0;
    while(idx < N && idx < vec[idx]) idx++;
    idx--;

    // printf("idx = %d\n", idx);

    int vl = vec[idx] - idx;

    int height = idx;
    while(idx < N && height < vec[idx + 1]) idx++;
    int vr = idx - height + 1;

    fprintf(stderr, "vl = %d, vr = %d\n", vl, vr);

    if(vl % 2 == 0 || vr % 2 == 0) printf("First\n");
    else printf("Second\n");
    return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=[]
for i in range(15):
  d=(N-1)%26
  e=(N-1)//26
  A.append(d+1)
  N=e
  if N==0:
    break
  
A=A[::-1]
r=''
for i in A:
  r=r+chr(96+i)
print(r)

Measured memory_bytes: 9176
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val mod = 1e9.toInt + 7

  val N, M = in.next().toInt

  val modComb = new ModComb(100*N, mod)

  var i = 2
  var now = M
  var ans = 1L
  while (i <= now) {
    if(now % i == 0) {
      var cnt = 0
      while (now % i == 0) {
        cnt += 1
        now /= i
      }

      ans = ans * modComb.comb(N+cnt-1, cnt)
      ans = ans % mod
    }

    i += 1
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

class ModComb(maxNum: Int, mod: Long) {

  private def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2)
    else
      (x * repeatSquares(x*x % mod, n/2)) % mod
  }

  private val fact = new Array[Long](maxNum + 1)

  fact(0) = 1
  for (i <- 1 to maxNum)
    fact(i) = (i * fact(i-1)) % mod

  private val factInv = new Array[Long](maxNum + 1)

  factInv(maxNum) = repeatSquares(fact(maxNum), mod-2)
  for (i <- (1 to maxNum).reverse)
    factInv(i-1) = (i * factInv(i)) % mod

  // nCk
  def comb(n: Int, k: Int): Long = {
    val numer = fact(n)
    val denom = (factInv(n-k) * factInv(k)) % mod

    (numer * denom) % mod
  }

}


Measured memory_bytes: 183732
#include <stdio.h>
int main(){
    int x,y,i;
    i = 0;
    while(1){
        scanf("%d %d",&x,&y);
        if (x == 0 && y == 0)break;
        if(y < x){
        i = x;
        x = y;
        y = i;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}


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

int main() {
  int N, x, cnt=0, cntold=0, target;
  cin >> N;
  
  for(int i=1; i<=N; i++){
    x = i;
    while(x % 2 == 0){
      x /= 2;
      cnt++;
    }
    if(cnt >= cntold){
      target=i;
      cntold = cnt;
    }
    cnt = 0;
  }

  cout << target << endl;
  
  return 0;
}

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

#define ll long long
#define pb push_back
#define mod 1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define dbg(x) cout<<#x<<" = "<<x<<'\n';

ll isPrime(ll x) {ll i, flag = 1; if(x == 0 || x == 1) flag = 0; for(i = 2; i<=sqrt(x); i++) { if(x%i == 0) {flag = 0; break;}} return flag;}
ll power(ll x, ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}

void solve()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;

  // if(b>0 and d>0)
  //   {cout<<b*1LL*d<<endl; return;}

  // if(a<0 and c<0)
  // {cout<<a*1LL*c<<endl; return;}

  ll ans=max(a*1LL*c,max(b*1LL*d,max(a*1LL*d,b*1LL*c)));
  cout<<ans;
  
}  
   
 

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  int tc=1;
  //cin>>tc;
  while(tc--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#define int long long int
using namespace std;
int dp[2][100001],now=0,n,W;
int w[100001],v[100001];
signed main()
{
	scanf("%lld%lld",&n,&W);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w[i],&v[i]);
	}
	for(int i=1;i<=n;i++)
	{
		now^=1;
		for(int j=1;j<=W;j++)
		{
			dp[now][j]=dp[now^1][j];
			if(j>=w[i])
			{
				dp[now][j]=max(dp[now^1][j-w[i]]+v[i],dp[now][j]);
			}
		}
	}
	printf("%lld",dp[now][W]);
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int r[n];
    for(int i=0;i<n;i++) cin >> r[i];

    int maxv=-2000000000, minv=r[0];

    for(int i=1;i<n;i++){
        maxv = max(maxv, r[i]-minv);
        minv = min(minv, r[i]);
    }
    
    cout << maxv << endl;
}


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

int main()
{
	int n;
	cin>>n;
	unordered_map<int,int> m;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
 	if(m[1]==1)
    {
      cout<<1;
      return 0;
    }
	if(m[1]>1)
	{
		cout<<0;
		return 0;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int v=a[i];
		if(m[v]>1)
		{
			ans++;
			continue;
		}
		for(int j=2;j*j<=v;j++)
		{
			if(v%j==0)
			{
				if(m[j]>0||m[v/j]>0)
				{
					ans++;
					break;
				}
			}
		}
	}
	cout<<n-ans;
	return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;
const int INF = 1e6;

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

long long mul(long long a, long long b) {
    return (((a % mod) * (b % mod)) % mod);
}

long long potolok(long long a, long long b){   // округление вверх для целых
    return (a + b - 1) / b;
}


long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }
    if(x > y){
         return gcd(y, x % y);
    }
    else{
         return gcd(x, y % x);
    }
}

bool cmpr(int x, int y){            // сортировка по абсолютной величине
    if(abs(x) < abs(y)) return true;
    else{
        return false;
    }
}

bool comp(pair<int, int> x, pair<int, int> y){  // сортировка по первой компоненте
    if(x.first < y.first)return true;
    else if(x.first == y.first){
        if(x.second < y.second)return true;
        else return false;
    }
    else{
        return false;
    }
}

int cnt(string &s, string &p, int m, int n){
    if((m == 0 && n == 0) || n == 0){
        return 1;
    }
    if(m == 0){
        return 0;
    }
    if(s[m - 1] == p[n - 1]){
        return cnt(s, p, m - 1, n - 1) + cnt(s, p, m - 1, n);
    }
    else{
        return cnt(s, p, m - 1, n);
    }
}

int main(){
    string s;
    cin >> s;
    if(s[s.length() - 1] == 's'){
        s += "es";
        cout << s << endl;
    }
    else{
        s += "s";
        cout << s << endl;
    }
 }


Measured memory_bytes: 3632
n=int(input())
a=[int(input()) for i in range(n)]

if a[0]!=0:
  print(-1)
  exit()

cnt=0
for i in range(1,n):
  if a[i]==0:
    continue
  elif a[i]==a[i-1]+1:
    cnt+=1
  elif a[i]==a[i-1]:
    cnt+=a[i]
  elif a[i]<a[i-1]:
    cnt+=a[i]
  else:
    print(-1)
    exit()

print(cnt)

Measured memory_bytes: 17032
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)

///priority_queue <int, vector<int>, greater<int>> g
#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;

bool rs(ll a, ll b){return(a>b);}
ll spd(ll n){ if(n%2==0)return 2; for(ll i=3; i*i<=n; i++){if(n%i==0)return i;}return n;}

int main(){

ll n; cin>>n;
if(n>=400 && n<=599)cout<<8<<endl;
if(n>=600 && n<=799)cout<<7<<endl;
if(n>=800 && n<=999)cout<<6<<endl;
if(n>=1000 && n<=1199)cout<<5<<endl;
if(n>=1200 && n<=1399)cout<<4<<endl;
if(n>=1400 && n<=1599)cout<<3<<endl;
if(n>=1600 && n<=1799)cout<<2<<endl;
if(n>=1800 && n<=1999)cout<<1<<endl;

return 0;
}



Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main() {
  int n ,x;
  int l;
  
  cin >> n >> x;
  
  int x_now = 0;
  for(int i = 0; i <= n; i++) {
    cin >> l;
    x_now += l;
    
    if (x_now > x) {
      cout << i+1;
      return 0;
    }
  }
  cout << n+1;

  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, n;
    cin >> k >> n;
    vector<ll> v(k);
    for (int i = 0; i < n; i++) cin >> v[i];
    ll dis = oo;
    ll tot = 0;
    int prev = v[0];
    int cur;
    for (int i = 1; i < 2 * n; i++) {
        cur = v[i % n];
        if (cur > prev)
            tot = prev + k - cur;
        else
            tot = prev - cur;
        dis = min(dis, tot);
        prev = v[i % n];
    }
    cout << dis << '\n';
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define ll long long
#define int long long
# define INF 1000005
#define ar array
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}

int32_t main()
{
    c_p_c();
    int n;
    cin>>n;
    vector<int> v(n);
    v.clear();
    int s=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
        s^=x;
    }
    vector<int>res;
    for (int i = 0; i <n ; ++i)

    {
        res.push_back(s^v[i]);
        
    }
    for(int i=0;i<res.size();i++)cout<<res[i]<<' ';
    

    


 
    
      return 0;
       }
        
        

        




















Measured memory_bytes: 6832
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 3e6 + 111;
        
using namespace std;          

int n, k;

void solve(){             
	cin >> n >> k;

	if (n >= 10)
		cout << k;
	else
		cout << (10 - n) * 100 + k;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

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

import numpy
from queue import deque

def main():
  l = list(map(int, input().split()))
  w1, w2, s1, s2, spwr, mm = l
  w1, w2 = 100*w1, 100*w2
  flags = numpy.zeros((mm+1, mm+1))
  dq = deque([(w1, 0)])
  max_conc = -1.0
  ans = (0, 0)
  while dq:
    w, s = dq.pop()
    flags[w, s] = 1
    if w != 0 and s <= spwr * w // 100:
      conc = s / (w + s)
      if max_conc < conc:
        max_conc = conc
        ans = (w+s, s)
    for sx in [s1, s2]:
      if w + s+sx <= mm and flags[w, s+sx] == 0:
        flags[w, s+sx] = 1
        dq.append((w, s+sx))
    for wx in [w1, w2]:
      if w+wx + s <= mm and flags[w+wx, s] == 0:
        flags[w+wx, s] = 1
        dq.append((w+wx, s))
  print(*ans)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 27252
d1 = {" ":"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000",}
d2 = {"00000":"A","00001":"B","00010":"C","00011":"D","00100":"E","00101":"F","00110":"G","00111":"H","01000":"I","01001":"J","01010":"K","01011":"L","01100":"M","01101":"N","01110":"O","01111":"P","10000":"Q","10001":"R","10010":"S","10011":"T","10100":"U","10101":"V","10110":"W","10111":"X","11000":"Y","11001":"Z","11010":" ","11011":".","11100":",","11101":"-","11110":"'","11111":"?"}

while 1:
    try:
        c,dc='',''
        n=raw_input()
        for i in n:
            c+=d1[i]
        if len(c)%5!=0:
            c+='0'*(5-len(c)%5)
        for i in range(0,len(c),5):
            dc+=d2[c[i:i+5]]
        print dc
    except:
        break

Measured memory_bytes: 6304
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

ll n, k;
bool vis[114514], fir[114514];
vector<ll> alr;
vector<P> v;

int main() {
  cin >> n >> k;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    v.pb(P(b, a));
  }
  sort(v.begin(), v.end(), greater<P>());

  REP(i, v.size()) {
    if (vis[v[i].second] == true) {
      if (i < k)
        alr.pb(v[i].first);
    } else {
      vis[v[i].second] = true;
      fir[i] = true;
    }
  }
  ll sum = 0, ans = 0, spe = 0;
  REP(i, k) {
    sum = ans = sum + v[i].first;
    if (fir[i]) {
      spe++;
    }
  }
  ans += spe * spe;
  sum += spe * spe;

  for (ll i = k; i < n; i++) {
    if (fir[i] == 1 && alr.size()) {
      spe++;
      sum -= alr.back();
      alr.pop_back();
      sum += v[i].first;
      sum += spe * spe - (spe - 1) * (spe - 1);

      // cout << spe * spe - (spe - 1) * (spe - 1) << endl;
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2800
#include <stdio.h>

#define N 8
#define NOT_FREE 1
#define FREE -1

int row[N];
int col[N];
int dpos[2*N-1];
int dneg[2*N-1];
int board[N][N];

void putQueen(int);
void printBoard();
int main(){
  int i, j, x, y, num;

  for(i = 0 ; i < N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }

  for(i = 0 ; i < 2*N-1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
  
  scanf("%d", &num);
  getchar();
  for(i = 0 ; i < num; i++){
    scanf("%d%d", &x, &y);
    board[x][y] = NOT_FREE;

    row[x] = y;
    col[y] = dpos[x+y] = dneg[x-y+N-1] = NOT_FREE;
  }
  /*
  for(j = 0; j < N; j++){
    printf("%d",row[j]);
  }
  printf("\n");
  for(j = 0; j < N; j++){
    printf("%d",col[j]);
    }
  printf("\n");
  for(j = 0; j < 2*N; j++){
    printf("%d",dpos[j]);
  }
  printf("\n");
    for(j = 0; j < 2*N; j++){
    printf("%d",dneg[j]);
  }
  printf("\n");
  */
  
  putQueen(0);
  return 0;
}

void putQueen(int i){
  int j;
  
  if(i == N){
    printBoard();
    return;
  }
  else  if(row[i] != FREE){
    putQueen(i+1);
  }
  else{
    for(j = 0; j < N; j++){
      if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){
	continue;
      }
      
      board[i][j] = NOT_FREE;
      //printf("put board[%d][%d]\n", i, j);
      
      row[i] = j;
      col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
      
      putQueen(i+1);
      
      board[i][j] = FREE;
      row[i] = FREE;
      col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
      
    }
    
  }
   
}

void printBoard(){
  int i, j;
  
  for(i = 0 ; i < N; i++){
    for(j = 0; j < N; j++){
      if(board[i][j] == NOT_FREE){
	printf("Q");
      }
      else{
	printf(".");
      }
    }
    printf("\n");
  }
}



Measured memory_bytes: 2088
#include<stdio.h>

int main(){
  int number[30],  w, n, barL, barR;
  int i, swap;
  
  for (i = 0;i < 30;i++) number[i] = i + 1;
  
  scanf("%d", &w);
  scanf("%d", &n);
  
  for(i = 0;i < n;i++) {
    scanf("%d,%d", &barL, &barR);
    swap = number[barL - 1];
    number[barL - 1] = number[barR - 1];
    number[barR - 1] = swap;
  }
  
  for(i = 0;i < w;i++) printf("%d\n", number[i]);
  
  return 0;
}

Measured memory_bytes: 0
using System;

class A
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		var r = (h[0] + h[1]).CompareTo(h[2] + h[3]);
		Console.WriteLine(r > 0 ? "Left" : r == 0 ? "Balanced" : "Right");
	}
}


Measured memory_bytes: 27476