akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cassert>
#include<climits>
#include<map>
#include<set>
#include<queue>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define LLINF (LLONG_MAX)
#define MAX_V 10000

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;
struct edge{ 
  ll to,cap,cost,rev;
  edge(ll to=LLINF,ll cap=LLINF,ll cost=LLINF,ll rev=LLINF):to(to),cap(cap),cost(cost),rev(rev){}
};
int V;
vector<edge> G[MAX_V];
ll h[MAX_V],dist[MAX_V],prevv[MAX_V],preve[MAX_V];

void add_edge(ll from,ll to,ll cap,ll cost){
  G[from].push_back(edge(to,cap,cost,(ll)G[to].size()));
  G[to].push_back(edge(from,0,-cost,(ll)G[from].size()-1));
}

ll min_cost_flow(ll s,ll t,ll f){
  ll res = 0;
  rep(i,V)h[i] = 0;
  while( f > 0 ){
    priority_queue<P,vector<P>,greater<P> > que;
      rep(i,V)dist[i] = LLINF;
      dist[s] = 0;
      que.push(P(0,s));
      while(!que.empty()){
	P p = que.top(); que.pop();
	ll v = p.second;
	if( dist[v] < p.first )continue;
	for(int i=0;i<G[v].size();i++){
	  edge &e = G[v][i];
	  if( e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to] ){
	    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    que.push(P(dist[e.to],e.to));
	  }
	}
      }
      if(dist[t]==LLINF)return -1;
      for(int v=0;v<V;v++)h[v] += dist[v];
      ll d = f;
      for(int v=t;v!=s;v=prevv[v])d = min(d,G[prevv[v]][preve[v]].cap);
      f -= d;
      res += d * h[t];
      for(int v=t;v!=s;v=prevv[v]){
	edge &e = G[prevv[v]][preve[v]];
	e.cap -= d;
	G[v][e.rev].cap += d;
      }
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  int *A = new int[N];
  int *B = new int[N];
  map<int,int> getIndex;
  int dex = 0;
  rep(i,N){
    cin >> A[i] >> B[i];
    if( getIndex.find(A[i]) == getIndex.end() )getIndex[A[i]] = dex++;
    if( getIndex.find(B[i]) == getIndex.end() )getIndex[B[i]] = dex++;
  }
  V = N + (int)getIndex.size();
  int source = V,sink = source+1,grave = sink+1;
  V += 3;
  add_edge(grave,sink,LLINF,0);
  rep(i,N)add_edge(source,i,1,0);
  rep(i,(int)getIndex.size())add_edge(N+i,sink,1,0);
  rep(i,N){
    int to1 = getIndex[A[i]]+N;
    int to2 = getIndex[B[i]]+N;
    add_edge(i,to1,1,-B[i]);
    add_edge(i,to2,1,-A[i]);
    add_edge(i,grave,LLINF,0);
  }
  delete [] A;
  delete [] B;
  cout << -min_cost_flow(source,sink,N) << endl;

  return 0;
}

Measured memory_bytes: 2164
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int inf = 1e9;

struct SegmentTree_Rect{
    vector<vector<int>> node;
    int n;
    
    SegmentTree_Rect(vector<int> v){
        int s = v.size();
        n = 2;
        while(n < s) n *= 2;
        node = vector<vector<int>>(2*n -1);
        for(int i=0; i<s; i++){
            node[n-1 +i] = {v[i]};
        }
        for(int i=n-2; i>=0; i--){
            node[i] = node[2*i+1];
            node[i].insert(node[i].end(), node[2*i+2].begin(), node[2*i+2].end());
            sort(node[i].begin(), node[i].end());
        }
    }
    
    int query(int lb, int ub, int l, int r){
        return get(ub, l, r) -get(lb, l, r);
    }
    int get(int x, int l, int r){
        if(l == r) return inf;
        return _get(x, l, r, 0, 0, n);
    }
    int _get(int x, int l, int r, int k, int cl, int cr){
        if(l <= cl && cr <= r){
            return lower_bound(node[k].begin(), node[k].end(), x) -node[k].begin();
        }
        if(r <= cl || cr <= l){
            return 0;
        }
        int m = (cl +cr)/2;
        return _get(x, l, r, 2*k+1, cl, m) + _get(x, l, r, 2*k+2, m, cr);
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    vector<pair<string, int>> s_ord(n);
    sort(s.begin(), s.end());
    for(int i=0; i<n; i++){
        s_ord[i] = {s[i], i};
    }
    auto r_ord = s_ord;
    for(auto &p: r_ord){
        reverse(p.first.begin(), p.first.end());
    }
    sort(r_ord.begin(), r_ord.end());
    vector<string> r(n);
    vector<int> seq(n);
    for(int i=0; i<n; i++){
        r[i] = r_ord[i].first;
        seq[i] = r_ord[i].second;
    }
    SegmentTree_Rect segtree(seq);

    for(int i=0; i<q; i++){
        string a,b;
        cin >> a >> b;
        reverse(b.begin(), b.end());
        int aidx_lb = lower_bound(s.begin(), s.end(), a) -s.begin();
        int bidx_lb = lower_bound(r.begin(), r.end(), b) -r.begin();
        a.back()++; b.back()++;
        int aidx_ub = lower_bound(s.begin(), s.end(), a) -s.begin();
        int bidx_ub = lower_bound(r.begin(), r.end(), b) -r.begin();
        cout << segtree.query(aidx_lb, aidx_ub, bidx_lb, bidx_ub) << endl;
    }
    return 0;
}



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

vector<int> adj[51];
bool visited[51];
vector<pair<int, int>> edgelist;


void dfs(int current, int a, int b)
{
	int result = 0;
	visited[current] = true;
	for (int i = 0; i < adj[current].size(); i++)
	{
		int k = adj[current][i];
		
		if (!visited[k] && !(current == a && k == b))
		{
			dfs(k, a, b);
		}
	}
}

int main()
{
	int n, m, a, b, ans = 0;
	cin >> n >> m;
	
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		edgelist.push_back(make_pair(a, b));
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	for (int i = 0; i < m; i++)
	{
		memset(visited, 0, sizeof(visited));
		dfs(edgelist[i].first, edgelist[i].first, edgelist[i].second);
		
		for (int j = 1; j <= n; j++)
		{
			if (!visited[j])
			{
				ans++;
				break;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include                        <bits/stdc++.h>
#define   lli                   unsigned long long int
#define   ll                    long long int
#define   PI                    acos(-1.0)
#define   UNIQUE(V)             (V).erase(unique(ALL(V), (V).end()) //vector/string etc must need to be sorted
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define   ALL(V)                (V).begin(), (V).end()
#define   MEMSET(a, val)        memset(a, val, sizeof(a))
using     namespace             std;


template  <class T> T GCD(T a, T b) { return (b != 0 ? GCD <T> (b, a%b) : a); }
template  <class T> T LCM(T a, T b) { return ((a*b)  / GCD <T> (a, b)); }


int main()
{
//  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    //timesave;

    //while(1){

    int n;

    cin >> n;

    int a[n+5], b[n+5], c[n+5];

    for(int i = 0; i < n; i++) cin >> a[i];
    b[0] = a[0]; c[n-1] = a[n-1];

    for(int i = 1; i < n; i++) {b[i] = __gcd(a[i], b[i-1]);}
    for(int i = n-2; i >= 0; i--) {c[i] = __gcd(a[i], c[i+1]);}

    int x, y, gcd = max(c[1], b[n-2]);

    for(int i = 1; i < n-1; i++){
        x = b[i-1]; y = c[i+1];
        gcd = max(gcd, __gcd(x, y));
    }

    cout << gcd << endl;

    //}

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<tuple<string, int, int>> data(N);
  for (int i = 0; i < N; i++) {
    string cityName;
    int score;
    cin >> cityName >> score;
    
    data.at(i) = make_tuple(cityName, -1 * score, i + 1);
  }
  
  sort(data.begin(), data.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(data.at(i)) << endl;
  }
}

Measured memory_bytes: 256
import numpy as np

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

A = np.array(A)

A.sort()

d = {}

for a in A:
    d.setdefault(a,0)
    d[a] += 1



sieve = [True] * (A[-1] + 1)

for a in A:
    if d[a] > 1:
        sieve[a] = False
    for i in range(a + a, A[-1] + 1, a):
        sieve[i] = False

print(sum(1 for a in A if sieve[a]))

Measured memory_bytes: 55252
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 31;
const int mod = 1e9+7;


int main() {
	int n,m,a=0;
	ll dp[100010];
	vector<bool> broken(100010,true);
	cin >> n;
	rep(i, n + 10)dp[i] = 0;
	dp[0] = 1;
	cin >> m;
	rep(i, m){
		cin >> a; 
		broken[a] = false;
	}

	for (int i = 0; i < n;i++) {
		for(int j = i+1;j <= min(n,i + 2);j++)
			if (broken[j]) {
				dp[j] += (dp[i]);
				dp[j] %= mod;
		}
	}
	cout << dp[n] << endl;

}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long sum = 1;
		long mod = (long)Math.pow(10,9)+7;
		for(int i=1;i<=a;i++){
			sum*=i;
			sum%=mod;
		}
		System.out.print(sum);
	}
}


Measured memory_bytes: 23380
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

#define FOR(_i, s, e) for(_i = s; _i < e; ++_i)
#define FOR_INV(_i, s, e) for(_i = e - 1; _i >= s; --_i)

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


using pos = std::pair<LONG, LONG>;

int main(){
    LONG i, j, k;

    LONG A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    LONG L = std::abs(B - A);
    double dif = V - W;

    if(dif <= 0){
        cout << "NO" << endl;
    }
    else{
        LONG turn = std::ceil(L / dif);

        if(turn <= T){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3688
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//list($A,$B,$K) =  explode(" ",trim(fgets(STDIN)));
//$A = explode(" ",trim(fgets(STDIN)));
$v = array_count_values(str_split($S));
if (count($v)==1) {
  printf("0\n");
  exit;
}
printf("%d\n",min($v)*2);


Measured memory_bytes: 10872
#include <bits/stdc++.h>
#define lli long long int
#define intMax 2147483647
#define INFTY (1<<30)
using namespace std;

int main(){
    int n, in;
    cin >> n;
    vector<int> a(n+1, 0);

    for(int i=2; i<=n; i++){
        cin >> in;
        a[in]++;
    }
    for(int i=1; i<=n; i++){
        printf("%d\n", a[i]);
    }
}

Measured memory_bytes: 3992
#include<stdio.h>

#define CLF 48
#define CFL 51
#define CB 54
#define CFE 57
#define CL 60
#define CLW 64
#define CW 69
#define CLM 75
#define CM 81
#define CLH 91

int main(){
  double w;
  int f;
  
  while(scanf("%lf",&w)!=EOF){
    if(w<=CLF)f=1;
    else if(w<=CFL)f=2;
    else if(w<=CB)f=3;
    else if(w<=CFE)f=4;
    else if(w<=CL)f=5;
    else if(w<=CLW)f=6;
    else if(w<=CW)f=7;
    else if(w<=CLM)f=8;
    else if(w<=CM)f=9;
    else if(w<=CLH)f=10;
    else f=11;
    switch(f){
    case 1:printf("light fly\n");break;
    case 2:printf("fly\n");break;
    case 3:printf("bantam\n");break;
    case 4:printf("feather\n");break;
    case 5:printf("light\n");break;
    case 6:printf("light welter\n");break;
    case 7:printf("welter\n");break;
    case 8:printf("light middle\n");break;
    case 9:printf("middle\n");break;
    case 10:printf("light heavy\n");break;
    case 11:printf("heavy\n");break;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[3][100000], a[3][100000];
long long calc(int u, int abc)
{
    int next = (abc+1)%3, next2 = (abc+2)%3;
    if(u == n-1) return max(a[next][u], a[next2][u]);

    if(dp[abc][u] != -1)
        return dp[abc][u];

    dp[abc][u] = max(a[next][u] + calc(u+1, next), a[next2][u] + calc(u+1, next2));
    return dp[abc][u];
}

int main( )
{
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[0][i] >> a[1][i] >> a[2][i];
    }
    cout << max(calc(0, 0), max(calc(0, 1), calc(0, 2))) << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
// constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n, x);
    Cins(int, n, a);
    ll ans = 0;
    For(i, n-1){
        int need = max(0, a[i] + a[i+1] - x);
        a[i+1] = max(0, a[i+1] - need);
        ans += need;
    }
    Cout(ans);
}


Measured memory_bytes: 640
n,m = map(int,input().split())
h = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(m)]
flag = [1] * n
for i in range(m):
         if h[ab[i][0] - 1] > h[ab[i][1] - 1]:
                  if flag[ab[i][1] -1] == 1:
                           flag[ab[i][1] -1] = 0
         elif h[ab[i][0] - 1] < h[ab[i][1] - 1]:
                  if flag[ab[i][0] -1] == 1:
                           flag[ab[i][0] -1] = 0
         else:
                  if flag[ab[i][1] -1] == 1:
                           flag[ab[i][1] -1] = 0
                  if flag[ab[i][0] -1] == 1:
                           flag[ab[i][0] -1] = 0                  
print(sum(flag))


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

using namespace std;

int fun(int *ar,int n){
	int a=0;
	int b=abs(ar[0]-ar[1]);
	int c;
	for(int i=2;i<n;i++){
		c= min(abs(ar[i-1]-ar[i])+b,abs(ar[i-2]-ar[i])+a);
		a =b;
		b=c;
	}
	return b;
}

int ar[100002];

int main(int argc, char const *argv[])
{
  int n;
	cin>>n;
  for(int i=0;i<n;i++)cin>>ar[i];
  cout << fun(ar,n)<<"\n";
	return 0;
}

Measured memory_bytes: 4004
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    var input = input.split("\n");
    const a = input[0];
    const s = input[1];
    
    if(a >= 3200){
        console.log(s);
    }else{
        console.log("red");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import numpy as np
N, M = [int(x) for x in input().split()]
c = np.zeros(N+1, dtype=int)
for i in range(M):
    a, b = [int(x) for x in input().split()]
    c[a] += 1
    c[b] += 1
for i in range(1,N+1): print(c[i])

Measured memory_bytes: 12612
import java.util.*;
public class Main{
	static String BeautStr(String s){
		if(s.length()%2 != 0)return "No";
		for(int i=0; i<s.length(); i++){
			int count = 0;
			for(int j=0; j<s.length(); j++){
				if(s.charAt(i)==s.charAt(j))count++;
			}
			if(count %2 != 0)return"No";
		}
		return "Yes";
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		System.out.println(BeautStr(w));
	}
}

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

sumA = sum(A)

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.sort()
  divisors = divisors[::-1]
  return divisors

div = make_divisors(sumA)
#print(div)

for d in div:
  tmp = []
  for a in A:
    tmp.append(a % d)
  tmp.sort()
  tmp = tmp[::-1]
  sum_tmp = sum(tmp)
  
  if sum(tmp[sum_tmp // d:]) <= K:
    print(d)
    exit()

Measured memory_bytes: 42732
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000007;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int n;  cin >> n;
  int hon = n%10;
  if(hon==3){
    cout << "bon" << endl;
  }else if(hon==0||hon==1||hon==6||hon==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3592
while True:
	a, l = map(int, input().split())
	if (a, l) == (0, 0):
		break

	arr = [a]
	for i in range(20):
		p = list(map(int, '{0:0>{1}}'.format(a, l)))
		a = int(''.join(map(str,sorted(p, reverse=True)))) - int(''.join(map(str,sorted(p))))
		if a in arr:
			break
		arr.append(a)

	j = arr.index(a)
	print('{} {} {}'.format(j, a, len(arr)-j))

Measured memory_bytes: 7608
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint A, B;
	lint C = 0;
	cin >> A >> B;

	if (B == 0)
	{
		cout << 0 << endl;
		return;
	}

	for (int bit = 1; ((lint)1 << bit) <= B; bit++)
	{

		lint check_A = A % ((lint)1 << (bit + 1));
		bool flag;

		if (check_A < ((lint)1 << bit))
		{
			flag = false;
		}
		else
		{
			if (check_A & 1)
			{
				flag = true;
			}
			else
			{
				flag = false;
			}
		}

		lint check_B = B % ((lint)1 << (bit + 1));

		if (check_B < ((lint)1 << bit))
		{
			flag = flag;
		}
		else
		{
			if (check_B & 1)
			{
				flag = flag;
			}
			else
			{
				flag = !flag;
			}
		}

		if (flag)
			C += ((lint)1 << bit);
	}

	if (!(((B - 1) / 2 - A / 2) & 1))
		C++;

	cout << C << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    int n, k;
    cin >> n >> k;
    int d = 0;
    while (n > 0) {
        n /= k;
        ++d;
    }
    cout << max(1, d) << endl;
    return 0;
}


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

int slove(int x, int y) {
  int a, b;
  a = (y / 2) - x;
  b = x - a;
  if (b < 0 || a < 0) return 0;
  if ( (x == a + b) && (y == a * 4 + b * 2) ) { 
    return 1;
  } else {
    return 0;
  } 
}

int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  if (slove(x, y)) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 3828
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()
#define int long long
typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;


const int maxn = 1e6 + 228, mod = 1e9 + 7;

int fact[maxn], invfact[maxn];

int binpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b % 2) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        b /= 2;
    }
    return res;
}


main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fact[0] = invfact[0] = 1;
    for (int i = 1; i < maxn; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
        invfact[i] = binpow(fact[i], mod - 2);
    }
    int x, y;
    cin >> x >> y;
    int ans = 0;
    for (int i = 0; i <= x; i++) {
        int first = i, second = i * 2;
        int q = x - first, w = y - second;
        if (w >= 0 && q == w * 2) {
            ans = fact[i + w] * invfact[i]  % mod * invfact[w];
            ans %= mod;
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 15872
n = 0
eqs = []

def dfs(i, eq):

    if(i == n - 1):
        eqs.append(eq)
        return False

    if(dfs(i+1, eq + "+")):
        return True

    if(dfs(i+1, eq + "_" )):
        return True

    return False

def calc():
    ans = 0
    p = 0
    for eq in eqs:
        for i in range(n):
            if(i == n-1):
               # print("end: " + S[p:n])
                ans += int(S[p:n])
            elif(eq[i] == "+"):
                #print(S[p:i+1])
                ans += int(S[p:i+1])
                p = i + 1
        #print(eq)
        #print("----")
        p = 0
    return ans

S = input()
n = len(S)
dfs(0, "")
print(calc())


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

int main(){
	int N;
	cin >> N;
	vector<int> L(2*N);
	for(int i=0;i<2*N;i++){
		cin >>L[i];
	}
	int sum=0;
	sort(L.begin(),L.end());
	for(int i=0;i<N;i++){
		sum+=L[2*i];
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i]; a[i]--;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (a[i] == i)
    {
      cnt++;
      if (i != n - 1)
      	swap(a[i], a[i+1]);
    }
  cout << cnt << endl;
}

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

int main() {
    string S,T;
    cin >> S >> T;
    for (int i=0; i<S.size(); i++) {
        if (S.at(i)!=T.at(i)) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef  long long int ll;
using namespace std;
const int M=1e9+7;
const int N=1e5+5;
#define fi first
#define se second
#define pb push_back
int main()
{
    ll n,x,t;cin>>n>>x>>t;
    ll val=0;
    if(n%x!=0)
    ++val;
    val+=(n/x);
    val*=t;
    cout<<val;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] data = new int[n];
    	for (int i = 0; i < n; i++) {
    		data[i] = sc.nextInt();
    	}
		
    	Arrays.sort(data);
    	for (int i = 0; i < n / 2; i++) {
    		int temp = data[i];
    		data[i] = data[n - i - 1];
    		data[n - i - 1] = temp;
    	}
    	
    	int q = sc.nextInt();
    	for (int i = 0; i < q; i++) {
    		if (solve(data, 0, sc.nextInt())) {
    			System.out.println("yes");
    		} else {
    			System.out.println("no");
    		}
    	}

    	sc.close();
	}

	private static boolean solve(int[] data, int p, int m) {
		if (m == 0) {
			return true;
		} else if (m < 0 || p >= data.length) {
			return false;
		} else {
			if (solve(data, p + 1, m - data[p])) {
				return true;
			}
			if (solve(data, p + 1, m)) {
				return true;
			}
			
			return false;
		}
	}
}

Measured memory_bytes: 20248
#coding: UTF-8

from bisect import bisect_right

max_number = 1000000
prime_flag_list = [True] * max_number

prime_flag_list[0] = False
prime_flag_list[1] = False

prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2])

for i in range(3, int(max_number**0.5) + 1, 2):
    prime_flag_list[i*i::i] = [False] * len(prime_flag_list[i*i::i])

prime_list = [i for i in range(2, max_number) if prime_flag_list[i]]

while True:
    try:
        input = int(raw_input())
    except EOFError:
        break

    print bisect_right(prime_list, input)

Measured memory_bytes: 44452
h, w = map(int, input().split())
table = [list(input()) for i in range(h)]
mask = [[1,0], [0,1], [-1, 0], [0, -1]]
flag = True

for i in range(h):
  for j in range(w):
    if table[i][j] == '#':
      count = 0
      for k in range(len(mask)):
        if (i + mask[k][0]) >= 0 and (i + mask[k][0]) < h and (j + mask[k][1]) >= 0 and (j + mask[k][1]) < w:
          if table[i+mask[k][0]][j+mask[k][1]] == '#':
            count+=1
     
      if count == 0:
        flag = False
  if flag == False:
    break
       
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

const ll INF = 1LL << 60;

ll a[1002];
int N;

// 0-origin BIT
template <typename T>
class BIT{
public:
    vector<T> data;
    int n;
    BIT(){}
    BIT(int n_){
        n = n_;
        data.assign(n, T(0));
    }
    // v[a] += w
    void add(int a, T w){
        for (int x = a; x < n; x |= x + 1) data[x] += w;
    }
    // sum of v[i] for i in [0, a)
    T sum(int a){
        T ret = 0;
        for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
            ret += data[x];
        }
        return ret;
    }
};

int main(){
    cin >> N;

    BIT<ll> even_bit(N), odd_bit(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(i%2 == 0) even_bit.add(i, max(a[i], 0LL));
        else odd_bit.add(i, max(a[i], 0LL));
    }

    ll ans = -INF;
    int ans_l = -1, ans_r = -1;
    for(int l=0;l<N;l++){
        for(int r=l;r<N;r += 2){
            assert(l%2 == r%2);
            ll ans_this = a[l];
            if(r != l){
                ans_this += a[r];
                if(l%2 == 0) ans_this += even_bit.sum(r) - even_bit.sum(l + 1);
                else ans_this += odd_bit.sum(r) - odd_bit.sum(l + 1);
            }
            if(ans_this > ans){
                ans = ans_this;
                ans_l = l;
                ans_r = r;
            }
        }
    }

    cout << ans << endl;

    vector<int> op;
    for(int i=N-1;i>ans_r;i--){
        op.push_back(i + 1);
    }
    for(int i=0;i<ans_l;i++){
        op.push_back(1);
    }
    for(int i=ans_l+2;i<=ans_r;i+=2){
        if(i == ans_r || a[i] > 0){
            op.push_back(2);
        }else{
            op.push_back(3);
        }
    }

    cout << op.size() << endl;
    for(int o : op){
        cout << o << endl;
    }

    return 0;
}

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

using namespace std;

#define int int64_t

signed main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    for(auto &it: a) {
        cin >> it;
    }
    int dp[n][2] = {0};
    dp[0][0] = a[0] % 2 ? 2 : 1;
    dp[0][1] = a[0] % 2 ? 1 : 2;
    for(int i = 1; i < n; i++) {
        dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1] * (a[i] % 2 ? 2 : 1);
        dp[i][1] = dp[i - 1][1] * (a[i] % 2 ? 1 : 2);
    }
    cout << dp[n - 1][0] << "\n";
}


Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b
class in_t{public:
	int a;in_t(){cin>>a;}
	operator int() {return a;}
};
class lin_t{public:
	llint a;lin_t(){cin>>a;}
	operator llint() {return a;}
};
class ld_t{public:
	long double a;ld_t(){cin>>a;}
	operator long double() {return a;}
};
vector<int> ro;
vector<int> dis;
vector<vector<int>>ko;
vector<pair<int,int>> zyn;
vector<bool> used;
int ans=0;
int n,k;
void make_tree(int now=0,int di=0){
	dis[now]=di;
	zyn[now]=mp(di,now);
	for(int i=0;i<ko[now].size();i++){make_tree(ko[now][i],di+1);}
}
void tle(int now){
	if(used[now]){return;}
	used[now]=true;
	for(int i=0;i<ko[now].size();i++){tle(ko[now][i]);}
}
void mle(int now){
	if(used[now]){return;}
	ans++;
	for(int i=0;i<k-1;i++){now=ro[now];}
	if(ro[now]==0){now=0;}
	tle(now);
}
int main(void){
	cin>>n>>k;
	if(n<k){k=n;}
	int i;
	ro.res(n);
	dis.res(n);
	ko.res(n);
	zyn.res(n);
	used.res(n);
	for(i=0;i<n;i++){cin>>ro[i];ro[i]--;if(i!=0){ko[ro[i]].pub(i);}}
	if(ro[0]!=0){ro[0]=0;ans++;}make_tree();
	sort(zyn.rbegin(),zyn.rend());
	for(i=0;i<n;i++){
		int kes=zyn[i].sec;
		mle(kes);
	}
	cout<<ans-1<<endl;
	return 0;
}

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

def calc(x):
    res = 0
    
    for A, B in AB:
        if A|x==x:
            res += B
    
    return res

N, K = map(int, input().split())
S = format(K, 'b')
AB = [tuple(map(int, input().split())) for _ in range(N)]
ans = calc(K)
now = 0

for i in range(len(S)):
    if S[i]=='1':
        bit = len(S)-i-1
        ans = max(ans, calc(now+2**bit-1))
        now += 2**bit

print(ans)

Measured memory_bytes: 54492
a = int(input())
b = input()
c = [0] * a
d = [0] * a
for i in range(a):
    if i == 0:
        if b[i] == "W":
            c[i] = 1
    else:
        if b[i] == "W":
            c[i] = c[i-1] + 1
        else:
            c[i] = c[i - 1]

    if i == 0:
        if b[-i-1] == "E":
            d[-i-1] = 1
    else:
        if b[-i-1] == "E":
            d[-i-1] = d[-i] + 1
        else:
            d[-i-1] = d[-i]
e = 10 ** 9
for i in range(a):
    e = min(c[i] + d[i] - 1, e)
print(e)


Measured memory_bytes: 17636
n,m = map(int,input().split())
g = [[] for _ in range(0,n)]
for i in range(0,m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans = 0
global visit
visit = [1 for i in range(0,n)]

def dfs(s):
    if sum(visit) == 0:
        global ans
        ans += 1
        return
    for i in g[s]:
        # print(ans,visit)
        if visit[i] == 1:
            visit[i] = 0
            dfs(i)
            visit[i] = 1
    return

visit[0] = 0
dfs(0)
print(ans)


Measured memory_bytes: 3064
from collections import Counter

N, M = map(int, input().split())
ct = Counter(map(int, input().split()))

G = [0] * M
pairs_num = [0] * M
for k, v in ct.items():
    G[k % M] += v
    pairs_num[k % M] += v // 2

ans = G[0] // 2
if not M % 2:
    ans += G[M // 2] // 2
for i in range(1, (M + 1) // 2):
    if G[i] >= G[M - i]:
        ans += G[M - i] + min(pairs_num[i], (G[i] - G[M - i]) // 2)
    else:
        ans += G[i] + min(pairs_num[M - i], (G[M - i] - G[i]) // 2)
print(ans)


Measured memory_bytes: 27136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<pair<ll,ll>> vp(n);
  for(int i = 0; i < n; ++i){
    cin >> vp[i].second >> vp[i].first;
  }
  sort(begin(vp),end(vp));
  ll start = 0;
  for(auto& p : vp){
    if(start + p.second <= p.first) start += p.second;
    else{
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int order = 1;
  int n = N;
  while(n >= 10) {
    n /= 10;
    order++;
  }
  int ans = 0;
  for(int i = order; i > 0; i--) {
    if(i % 2 == 0) {
      continue;
    }
    else if(i == order) {
      ans += N - pow(10, order - 1) + 1;
    }
    else {
      ans += pow(10, i) - pow(10, i - 1);
    }
  }
  cout << ans << endl;
}

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int M;
   cin>>M;
   cout<<24+24-M;
   return 0; 
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n, r := readInt(), readInt()
	if n >= 10 {
		fmt.Println(r)
	} else {
		fmt.Println(100*(10-n) + r)
	}
}


Measured memory_bytes: 640
import math

def is_prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

X = int(input())
i = 0
while(1):
    if(is_prime(X + i)):
        print(X + i)
        break
    i += 1


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

int main()
{
    int a, b;
    cin >> a >> b;
    int area = a * b;
    int perimeter = 2*(a+b);
    cout << area << " " << perimeter << endl;
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> c(n, 0);

    REP(i, q) {
        int a; cin >> a;
        c[a - 1]++;
    }

    REP(i, n) {
        if (k - (q - c[i]) > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
# cf16-finalC - Interpretation
class UnionFind:
    def __init__(self, size):
        self.parent = [i for i in range(size + 1)]
        self.rank = [0] * (size + 1)

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

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def main():
    N, M = map(int, input().split())
    A = [(map(int, input().split())) for _ in range(N)]
    uf, spoken = UnionFind(M), set()
    for _, *langs in A:
        spoken.update(langs)
        primary = langs[0]
        for l in langs[1:]:
            uf.unite(primary, l)
    cur = uf.find(spoken.pop())
    flg = all(uf.find(lang) == cur for lang in spoken)
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 48104
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,vector<ll>> Data;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define ALL(a) a.begin(),a.end()
int main(){
  vector<ll> n(3);
  rep(i,3) cin>>n[i];
  ll k;cin>>k;
  vector<vector<ll>> v(3);
  rep(i,3){
    rep(j,n[i]){
      ll tmp;cin>>tmp;
      v[i].push_back(tmp);
    }
    sort(ALL(v[i]),greater<ll>());
  }
  priority_queue<Data> que;
  que.push(Data(v[0][0]+v[1][0]+v[2][0],vector<ll>({0,0,0})));
  set<Data> st;
  rep(i,k){
    auto c=que.top();que.pop();
    cout<<c.first<<endl;
    rep(iter,3){
      if(c.second[iter]+1<n[iter]){
        ll sum=c.first-v[iter][c.second[iter]]+v[iter][c.second[iter]+1];
        auto num=c.second;num[iter]++;
        auto d=Data(sum,num);
        if(!st.count(d)) st.insert(d),que.push(d);
      }
    }
  }
}

Measured memory_bytes: 1408
def main():
  n = int(input())
  h = input_list()
  ans = 0
  while True:
    ans += count_section_by_zero(h)
    h = list(map(lambda x: 0 if x == 0 else x-1, h))
    if all([v == 0 for v in h]):
      break
  print(ans)

def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math
import fractions
import collections
from functools import reduce
main()

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = -1;
  if(s.size() == 2) {
    if(s[0] == s[1]) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  for(int i = 1; i <= s.size() - 2; i++) {
    set<char> ch1;
    set<char> ch2;
    int sum = 0;
    for(int j = 0; j < i; j++) {
      ch1.insert(s[j]);
    }
    for(int k = i; k < s.size(); k++) {
      ch2.insert(s[k]);
    }
    for(auto ch : ch1) {
      if(ch2.count(ch) == 1) sum++;
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}

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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
 
using namespace std;

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

    vector<int> v;
    int t=n;
    while(t>=1){
        v.pb(t%10);
        t/=10;
    }

    int m=v.size();
    bool flag=true;
    REP(i, m-1){
        if(v[i]!=9){
            flag=false;
            break;
        }
    }

    if(flag){
        cout << 9*(m-1)+v[m-1] << endl;
    }
    else{
        cout << 9*(m-1)+v[m-1]-1 << endl;
    }
}



Measured memory_bytes: 256
N = int(input())
MOD = 10 ** 9 + 7
res = pow(10, N, MOD) - 2 * pow(9, N, MOD) + pow(8, N, MOD)
if res < 0:
    while res < 0:
        res += MOD
elif res > MOD:
    while res > MOD:
        res -= MOD
print(res)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	int N;
	cin >> N;
	vi L(N);
	int Lsum = 0;
	int Lmax = 0;
	rep(i,N){
		cin>>L[i];
		Lmax = max(Lmax,L[i]);
		Lsum+=L[i];
	}
	string ans = "No";
	if(Lsum-Lmax > Lmax)ans = "Yes";
	cout << ans << endl;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	string s;
	cin >> s;
	if(s.size() < 7){
		cout << "NO" << endl;
		return 0;
	}
	REP(i, 7){
		string s1 = s.substr(0, i+1);
		string s2 = s.substr(s.size()-6+i, 6-i);
		if(s1 + s2 == "keyence"){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
} 

Measured memory_bytes: 256
import Data.List
import Data.List.Split
import Data.Char (isSpace)

trim :: String -> String
trim = f . f
  where
    f = reverse . dropWhile isSpace

calc :: Int -> String -> String
calc index s = "Case " ++ show index ++ ": " ++ s

main = do
  s <- getContents
  let xs = splitOn "\n" $ trim s
  putStrLn $ intercalate "\n" [calc i s | (i, s) <- zip [1..] xs, s /= "0"]

Measured memory_bytes: 7132
//35
#include<iostream>
#include<vector>
#include<cctype>

using namespace std;

typedef vector<vector<int> > mat;

int x;
char p[81];
mat v[128];

const int M=32768;

mat expr();
mat term();
mat factor();
mat primary();

mat expr(){
  mat l=term();
  while(p[x]=='+'||p[x]=='-'){
    int f=(p[x++]=='+')?1:-1;
    mat r=term();
    for(int i=0;i<l.size();i++){
      for(int j=0;j<l[0].size();j++){
	l[i][j]=(l[i][j]+f*r[i][j]+M)%M;
      }
    }
  }
  return l;
}

mat term(){
  mat l=factor();
  while(p[x]=='*'){
    x++;
    mat r=factor();
    if(l.size()*l[0].size()==1){
      swap(l,r);
    }
    if(r.size()==1&&r[0].size()==1){
      for(int i=0;i<l.size();i++){
	for(int j=0;j<l[0].size();j++){
	  l[i][j]=(l[i][j]*r[0][0])%M;
	}
      }
    }else{
      mat n=mat(l.size(),vector<int>(r[0].size()));
      for(int i=0;i<l.size();i++){
	for(int j=0;j<r[0].size();j++){
	  for(int k=0;k<l[0].size();k++){
	    n[i][j]=(n[i][j]+l[i][k]*r[k][j])%M;
	  }
	}
      }
      l=n;
    }
  }
  return l;
}

mat factor(){
  if(p[x]=='-'){
    x++;
    mat r=factor();
    for(int i=0;i<r.size();i++){
      for(int j=0;j<r[0].size();j++){
	r[i][j]=(M-r[i][j])%M;
      }
    }
    return r;
  }else{
    return primary();
  }
}

mat primary(){
  mat l;
  if(p[x]=='('){
    x++;
    l=expr();
    x++;
  }else if(isalpha(p[x])){
    l=v[p[x++]];
  }else if(isdigit(p[x])){
    int d=0;
    while(isdigit(p[x])){
      d=d*10+p[x++]-'0';
    }
    l=mat(1,vector<int>(1,d));
  }else{
    x++;
    do{
      mat rs=expr();
      while(p[x]==' '){
	x++;
	mat rss=expr();
	for(int i=0;i<rss[0].size();i++){
	  for(int j=0;j<rss.size();j++){
	    rs[j].push_back(rss[j][i]);
	  }
	}
      }
      l.insert(l.end(),rs.begin(),rs.end());
    }while(p[x++]==';');
  }
  while(p[x]=='('||p[x]=='\''){
    if(p[x++]=='\''){
      mat nl(l[0].size(),vector<int>(l.size()));
      for(int i=0;i<l.size();i++){
	for(int j=0;j<l[0].size();j++){
	  nl[j][i]=l[i][j];
	}
      }
      l=nl;
    }else{
      mat fi=expr();
      x++;
      mat li=expr();
      x++;
      mat id=mat(fi[0].size(),vector<int>(li[0].size()));
      for(int i=0;i<id.size();i++){
	for(int j=0;j<id[0].size();j++){
	  id[i][j]=l[fi[0][i]-1][li[0][j]-1];
	}
      }
      l=id;
    }
  }
  return l;
}

int main(){
  for(int n;cin>>n,n;){
    cin.ignore();
    while(n--){
      cin.getline(p,81);
      x=2;
      char c=p[0];
      v[c]=expr();
      for(int i=0;i<v[c].size();i++){
	for(int j=0;j<v[c][i].size();j++){
	  cout<<v[c][i][j]<<((j==v[c][i].size()-1)?'\n':' ');
	}
      }
    }
    cout<<"-----"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1504
n = int(input())
c = []
not_c = []
chosen = set()
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	not_c.append([max(a, b), i])
	c.append([min(a, b), i])
	ans += min(a, b)
	if a < b:
		chosen.add("a")
	elif a > b:
		chosen.add("b")

if len(chosen) < 2:
	print(ans)
else:
	c = sorted(c, reverse=True)
	not_c = sorted(not_c)
	#print(c, not_c)
	#used_c = [False] * n
	#used_n = [False] * n

	if c[0][1] != not_c[0][1]:
		ans = ans - c[0][0] + not_c[0][0]
		c_cur = 1
		not_cur = 1
	else:
		ans = min(ans - c[1][0] + not_c[0][0], ans - c[0][0] + not_c[1][0])
		if ans - c[1][0] + not_c[0][0] <= ans - c[0][0] + not_c[1][0]:
			c_cur = 2
			not_cur = 1
		else:
			c_cur = 1
			not_cur = 2
	if c_cur < n and not_cur < n:
		while c[c_cur][0] > not_c[not_cur][0]:
			if c[c_cur][1] != not_c[not_cur][1]:
				ans = ans - c[c_cur][0] + not_c[not_cur][0]
				c_cur += 1
				not_cur += 1
			elif c_cur == n - 1 or not_cur == n - 1:
				break
			else:
				ans = min(ans - c[c_cur+1][0] + not_c[not_cur][0], ans - c[c_cur][0] + not_c[not_cur+1][0])
				if ans - c[c_cur+1][0] + not_c[not_cur][0] <= ans - c[c_cur][0] + not_c[not_cur+1][0]:
					c_cur += 2
					not_cur += 1
				else:
					c_cur += 1
					not_cur += 2
			if c_cur >= n or not_cur >= n:
				break
	print(ans)


Measured memory_bytes: 34424
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
ll mul(ll a,ll n, ll mod)
{
	ll ret;
	if(n==0) return 0;
	ret = mul(a,n/2, mod);
	ret = (ret+ret)%mod;
	if(n%2)	ret=(ret+a)%mod;
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	int n, a, b;
	cin >> n;
	vector<ll > v1, v2, v3;
	while(n--)
	{
		cin >> a >> b;
		v1.push_back({a + b});
		v2.push_back({a - b});
		v3.push_back({b - a});
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	sort(v3.begin(), v3.end());
	ll ans = max((v1.back() - v1[0]), max(v2.back() - v2[0], v3.back() - v3[0]));
	cout << ans;
}

Measured memory_bytes: 8156