akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

//AtCoder Beginner Contest 128
//B	Guidebook
public class Main {

	static class Pair {
		int i;
		String S;
		int P;

		Pair(int i, String S, int P) {
			this.i = i;
			this.S = S;
			this.P = P;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Pair> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			inList.add(new Pair(i + 1, sc.next(), sc.nextInt()));
		}
		sc.close();

		inList.sort(new Comparator<Pair>() {

			@Override
			public int compare(Pair o1, Pair o2) {
				if (o1.S.equals(o2.S)) {
					if (o1.P == o2.P) {
						return o1.i - o2.i;
					}
					return o2.P - o1.P;
				}
				return o1.S.compareTo(o2.S);
			}
		});

		for (Pair pair : inList) {
			System.out.println(pair.i);
		}
	}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.rbegin(), A.rend());
  vector<pair<int, int>> CB(M);
  for (int i = 0, b, c; cin >> b >> c; i++) CB.at(i) = {c, b};
  sort(CB.rbegin(), CB.rend());
  long ans = 0;
  for (int i = 0, cnt1 = 0, cnt2 = 0; i < N; i++) {
    if (cnt2 == M || A.at(cnt1) >= CB.at(cnt2).first) {
      ans += A.at(cnt1), cnt1++;
    } else {
      ans += CB.at(cnt2).first;
      CB.at(cnt2).second--;
      if (!CB.at(cnt2).second) cnt2++;
    }
  }
  cout << ans << "\n";
}

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

int main(){
  	int H, N;
	cin >> H >> N;
  	
  	vector<int> A(N);
  	for(int i = 0;i < N;i++){
  		cin >> A.at(i);
  	}
  	 
  	for(int i = 0;i < N;i++){
    	H -= A.at(i);
    }
  	
  	if(H > 0){
    	cout << "No" << endl;
    } else {
    	cout << "Yes" << endl;
    }
}

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

int main() {
    string a, b, c; cin >> a >> b >> c;
    int ai=0, bi=0, ci=0; 
    char tern = 'a';
    while(1){
        if(ai==a.size() && tern == 'a'){
            cout << "A" << endl;
            return 0;
        } else if(bi==b.size() && tern == 'b'){
            cout << "B" << endl;
            return 0;
        } else if(ci==c.size() && tern == 'c'){
            cout << "C" << endl;
            return 0;
        }

        if(tern=='a'){
            tern = a[ai];
            ai++;
        } else if(tern=='b'){
            tern = b[bi];
            bi++;
        } else if(tern=='c'){
            tern = c[ci];
            ci++;
        }
        //cout << tern << endl;
    } 
}

Measured memory_bytes: 256
import sys
from itertools import chain

readline = sys.stdin.readline
class Bit:
    def __init__(self, lst):
        t = 1
        while (t << 1) <= len(lst):
            for i in range(t, len(lst) - t + 1, t << 1):
                lst[i + t - 1] += lst[i - 1]
            t <<= 1
        self.lst = lst

    def add(self, pos, value):
        pos += 1
        while pos <= len(self.lst):
            self.lst[pos - 1] += value
            pos += pos & (-pos)

    def update(self, pos, value):
        diff = value - self.at(pos)
        self.add(pos, diff)

    def at(self, pos):
        return self.sum(pos + 1) - self.sum(pos)
    
    def sum(self, pos):
        # sum of [0, pos)
        if pos == 0:
            return 0
        s = 0
        while pos > 0:
            s += self.lst[pos - 1]
            #pos -= pos & (-pos)
            pos &= ~(-pos)
        return s
    
def solve():
    N = int(readline())
    A = [float(readline()) for i in range(N)]

    C = [0] * N
    c5s = set()

    for i, a in enumerate(A):
        #b = int(a * (10 ** 9))
        #b = a * (10 ** 9)
        b = round(a * (10 ** 9))
        c2, c5 = -9, -9
        while b % 2 == 0:
            b //= 2
            c2 += 1
        while b % 5 == 0:
            b //= 5
            c5 += 1
        
        C[i] = (c2, c5)
    
    Q = [(-a, -b) for a,b in C]

    count0 = sum(a >= 0 and b >= 0 for a,b in C)

    # Coordinate compression
    xs = sorted(set(chain((a for a,b in C), (a for a,b in Q))))
    ys = sorted(set(chain((b for a,b in C), (b for a,b in Q))))
    compA = {v: i for i, v in enumerate(xs)}
    compB = {v: i for i, v in enumerate(ys)}
    C = [(compA[a], compB[b]) for a,b in C]
    Q = [(compA[a], compB[b]) for a,b in Q]
    H, W = len(xs), len(ys)

    C.sort()
    Q.sort(reverse=True)

    bit = Bit([0] * W)
    ans = 0

    j = N - 1
    for x, y in Q:
        while j >= 0 and C[j][0] >= x:
            bit.add(C[j][1], 1)
            j -= 1
        ans += bit.sum(W) - bit.sum(y)

    print((ans - count0) // 2)


solve()

Measured memory_bytes: 133792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    ll n;
    cin >> n;
    ll ret = 10;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ll a = 0;
            ll b = 0;
            ll ii = i;
            ll ni = n / i;
            while (ii != 0) {
                a++;
                ii /= 10;
            }
            while (ni != 0) {
                b++;
                ni /= 10;
            }
            ll maxab = max(a, b);
            chmin(ret, maxab);
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {

    int n, m;
    cin >> n >> m;

    vector<P> ans;

    if (n % 2) {

        for (int l = 1, r = n - 1; l < r; l++, r--) {
            ans.emplace_back(l, r);
        }

    } else {
        bool flag = false;
        for (int l = 1, r = n - 1; l < r; l++, r--) {
            if (!flag && r - l <= n / 2) {
                r--;
                flag = true;
            }
            ans.emplace_back(l, r);
        }
    }

    rep(i, m) printf("%lld %lld\n", ans[i].first, ans[i].second);


}


Measured memory_bytes: 5260
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	a, b := scanInt(), scanInt()

	ans := make([]bool, 4)

	ans[a] = true
	ans[b] = true

	for i := 1; i < 4; i++ {
		if !ans[i] {
			fmt.Println(i)
			return
		}
	}
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll h, w, k;
    cin >> h >> w >> k;

    Graph g(h, vector<ll>(w, 0));
    REP(i, h) {
      REP(j, w) {
        char c_in;
        cin >> c_in;
        if (c_in == '#') {
          g[i][j] = 1;
        }
      }
    }

    ll k_count = 0;
    REP(i, pow(2, h)) {
      REP(j, pow(2, w)) {
        ll num_black = 0;
        REP(bit_i, h) {
          REP(bit_j, w) {
            if ((i & (1 << bit_i)) and (j & (1 << bit_j))) {
              num_black += g[bit_i][bit_j];
            }
          }
        }
        if (num_black == k) {
          k_count++;
        }
      }
    }

    COUT(k_count);

}

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

/*

3 2
*/


Measured memory_bytes: 4084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		char c = 0;
		int a=0,b=0;


		ArrayList<Integer> al = new ArrayList<Integer>();
		ArrayList<Integer> al2 = new ArrayList<Integer>();

		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			if(tes.equals("")){
				break;
			}
			try{
				String[] fruit = tes.split(" ", 0);
				a = Integer.parseInt(fruit[0]);
				b = Integer.parseInt(fruit[1]);
				if(a == 0 && b == 0){
					break;
				}
				al.add(a);
				al2.add(b);
			}catch(NumberFormatException e){
				break;
			}

			
			//al.add(a);
		}
		
		for(int r=0;r<al2.size();r++){
			ArrayList<Integer> al3 = new ArrayList<Integer>();
			for(int i=1;i<=al.get(r);i++){
				al3.add(i);
			}
			int point =al2.get(r)-1;
			al3.remove(point);
			
			while(true){
				if(al3.size() == point){
					point = 0;
				}
				if(al3.size() == 1){
					break;
				}
				for(int i=0;i<al2.get(r)-1;i++){
					point++;
					if(al3.size() == point){
						point = 0;
					}
					//System.out.println(point + "  :"+al3.size());
				}
				
				al3.remove(point);
			}
			System.out.println(al3.get(0));
			
			
			
		}
		
		
	}

}

Measured memory_bytes: 18600
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC\n";
    } else {
        cout << "ARC\n";
    }
}


Measured memory_bytes: 256
// AOJ Volume 0 Problem 0008

#include <stdio.h>

int c;

void combination(int n, int depth)
{
    int i;
    
    if (n < 0){
        return;
    }
    if (depth == 1){
        if (n <= 9){
            c++;
        }
        return;
    }

    for (i = 0; i <= 9; i++){
        combination(n - i, depth - 1);
    }
}

int main(void)
{
    int n;

    while (scanf("%d", &n) != EOF){
        c = 0;
        combination(n, 4);
        printf("%d\n", c);
    }

    return (0);
}

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

break_cnt = 0
find_num = 1

for i in range(N):
    if a[i] == find_num:
        find_num += 1
    else:
        break_cnt += 1

if find_num == 1:
    print(-1)
else:
    print(break_cnt)


Measured memory_bytes: 24744
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar(); }
	do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
	return x * f;
}

int main() {
	int r = read();
	std::printf("%.20lf\n",r * 2 * 3.14159265);
	return 0;
}


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

#define int long long

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

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

#define X first
#define Y second

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

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

using T = tuple<int, int, int>;
vector<T> v;
int n;

void calc() {
	int n; cin >> n;
	const int mod = 1e9 + 7;
	vector<int> facs;
	facs.push_back(1);
	{
		int x = 1;
		rep(i, 1, n + 1) {
			(x *= i) %= mod;
			facs.push_back(x);
		}
	}
	vector<int> dp(n);
	vector<int> mass;
	vector<int> xs(n);
	input(xs);
	dp[0] = xs[0];
	int pre = -1;
	int ans = 1;
	int sum = 0;
	rep(i, 1, n) {
		int d = xs[i] - xs[i - 1];
		if (!dp[i - 1]) dp[i] = d;
		else dp[i] = dp[i - 1] + d - 2;
		if (!dp[i] || i == n - 1) {
			int mass = i - pre;
			ans *= mass + sum;
			ans %= mod;
			sum += mass - 1;
			pre = i;
		}
	}
	ans *= facs[sum];
	cout << ans % mod << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 2804
#include<stdio.h>

int main(void)
{
        int a, b, k, n, i, c=0;

        scanf("%d%d%d", &a,&b,&k);

        if(a > b) {
                n = a;
        } else {
                n = b;
        }

        for(i = n; i >= 1; i--) {
                if(a%i==0 && b%i==0) {
                        c++;
                        if(c == k) {
                                printf("%d", i);
                                return 0;
                        }
                }
        }
}

Measured memory_bytes: 128
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    insertion_sort(A, N)

def insertion_sort(A, N):
    print(' '.join([str(n) for n in A]))

    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v

        print(' '.join([str(n) for n in A]))

    return A

if __name__ == '__main__':
    main()

Measured memory_bytes: 7740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1000000007; // 998244353 = (119<<23)+1
// head
const int nax=1e5+7;
int n,e=0,o=0;
vector<pair<pii,int>> edge[nax];
int col[nax];
void dfs(int v,int p,int pcol) {
	int pw=0;
	for(auto a:edge[v]) {
		if(a.fi.fi==p) {
			pw=a.fi.se;
			break;
		}
	}
	if(pw%2==0) {
		col[v]=pcol;
	//	e=pcol;
	//	o=e^1;
	} else {
		col[v]=pcol^1;
	//	o=pcol;
	//	e=o^1;
	}
//	cout<<v<<' '<<col[v]<<'\n';
	for(auto a:edge[v]) {
		if(a.fi.fi==p) continue;
//		if(a.fi.se%2==0) col[a.fi.fi]=col[v];
//		else col[a.fi.fi]=o;
		dfs(a.fi.fi,v,col[v]);
	}
}
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n;
		repn(i,n-1) {
			int a,b,c;
			cin>>a>>b>>c;
			edge[a].eb(mp(mp(b,c),i));
			edge[b].eb(mp(mp(a,c),i));
		}
		dfs(1,0,0);
		repn(i,n) cout<<col[i]<<'\n';
		return 0;
}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1e6+5;
char s[N];
s64 ca[N],cb[N],sb[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	scanf("%s",s+1);
	rep(i,1,n)
	{
		ca[i]=ca[i-1]+(s[i]=='D');
		cb[i]=cb[i-1]+(s[i]=='M');
		sb[i]=sb[i-1]+(s[i]=='M')*ca[i];
	}
	int m;
	cin>>m;
	while(m--)
	{
		int k;
		scanf("%d",&k);
		s64 ans=0;
		rep(i,1,n)
		if(s[i]=='C')
		{
			ans+=sb[i-1];
			if(i>=k)ans-=sb[i-k]+ca[i-k]*(cb[i-1]-cb[i-k]);
		}
		printf("%lld\n",ans);
	}
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<set<int>> v(n);
	REP(i, n)v[i].insert(i);
	vector<pii> p(m);
	REP(i, m) {
		cin >> p[i].first >> p[i].second;
	}
	sort(ALL(p));
	vi u(n, 0), d(n, 0);
	REP(i, m) {
		int a = p[i].second;
		u[a] = 1 + u[a - 1];
		d[a - 1] = 1 + d[a];
	}
	REP(i, n) {
		cout << u[i] + d[i] + 1;
		if (i != n - 1)cout << " ";
		else cout << endl;
	}
}

Measured memory_bytes: 23940
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int N; cin >> N;
  vector<pii> red(N), blue(N);
  REP(i,N) {
    int a, b; cin >> a >> b;
    red[i] = make_pair(a,b);
  }
  REP(i,N) {
    int c, d; cin >> c >> d;
    blue[i] = make_pair(c,d);
  }

  SORT(red);
  SORT(blue);

  vector<bool> used(N,false);
  int ans = 0;
  REP(i,N) {
    int max_r_y_index = -1;
    int max_r_y = -1;
    REP(j,N) {
      if (!used[j] && red[j].FI < blue[i].FI && red[j].SE < blue[i].SE && max_r_y < red[j].SE) {
        max_r_y = max(max_r_y, red[j].SE);
        max_r_y_index = j;
      }
    }
    if (max_r_y_index != -1) {
      ans++;
      used[max_r_y_index] = true;
    }
  }

  cout << ans << endl;
}

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

int main(void){

	int N;
	cin >> N;

	vector<int> ht(N,0);

	for(int i=0;i<N;i++){
		cin >> ht[i];
	}

	vector<int> ans(N,INT_MAX);

	ans[0] = 0;

	for(int i=1;i<N;i++){
		if(i==1){
			ans[i]= ans[i-1]+abs(ht[i]-ht[i-1]);
		}
		else{
			ans[i] = min(ans[i-1]+abs(ht[i]-ht[i-1]), ans[i-2]+abs(ht[i]-ht[i-2]));
		}
	}

	cout << ans[N-1];
}

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

int main(){
  long long int X,ans;
  cin>>X;
  if(X==2)ans =2;
  else{
    if(X%2==0)X=X+1;
    while(1){
      int c=0;
      for(int i=2;i<1+(X/2);i++){
          if(X%i==0){
            c=1;
            break;}
      }
      if(c==0){
        ans = X;
        break;
      }
      X+=2;
    }
  }

    cout<<ans;
}


Measured memory_bytes: 256
N=int(input())
lis1=list(map(int,input().split()))
lis2=list(map(int,input().split()))
lis3=lis1

for i in range(N):
    lis3[i]=lis1[i]-lis2[i]

sum=0
for j in range(N):
    if lis3[j]>0:
        sum=sum+lis3[j]

print(sum)

Measured memory_bytes: 3064
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-02-07 16:39:40
# @Description: Think twice. Code once. 
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int n , k , a[maxn];
int main()
{
    close;
    cin >> n >> k;
    ll ans = 0;
    for(int i = 0; i < n ; i++){
        cin >> a[i];
        ans += 2ll*min(a[i], k - a[i]);
    }cout << ans << endl;
    
    
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 504
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
void Yay(bool condition){

    if(condition){
        p("Yay!");
    }else{
        p(":(");
    }
    return;
}

//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll s,t;
ll x[300005],y[300005],z[100005];
ll dp[5505][5505];


int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	sort(x,x+n);
	ans = x[n/2] - x[n/2 - 1];
	p(ans);
	

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int s[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s, s + n);

  if (!(sum % 10)) {
    for (int i = 0; i < n; i++) {
      if (s[i] % 10) {
        cout << sum - s[i] << endl;
        return 0;
      }
    }
  } else {
    cout << sum << endl;
    return 0;
  }

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

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        set.add(s);
        s = s % 2 == 0 ? s / 2: s * 3 + 1;
        while (!set.contains(s)) {
            set.add(s);
            s = s % 2 == 0 ? s / 2: s * 3 + 1;
        }
        System.out.println(set.size()+1);
	}

}


Measured memory_bytes: 21844
n=int(input())
H=[]
for i in range(n):
    a,b,c=map(int,input().split())
    H.append([a,b,c])

if n==1:
    print(max(H[0][0],H[0][1],H[0][2]))
    exit()
dp=[[0,0,0]for j in range(n)]
for i in range(3):
    dp[0][i]=H[0][i]

for i in range(0,n-1):
    dp[i+1][0]=max(dp[i][1],dp[i][2])+H[i+1][0]
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + H[i + 1][1]
    dp[i + 1][2] = max(dp[i][1], dp[i][0]) + H[i + 1][2]

print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

Measured memory_bytes: 42588
#include<bits/stdc++.h>
#define Int long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int U;
	cin>>U;
	while(U--) 
	{
		Int ans=0,res=0,add=0;
		int tmp;
		cin>>tmp;
		tmp--;
		queue<Int> q;
		for(int i=0;i<n;i++)
		{
			if(s[i]=='D')
			{
				q.push(add);
			}
			else if(s[i]=='M')
			{
				res+=q.size();
				add++;
			}
			else if(s[i]=='C')
			{
				ans+=res;
			}
			if(i>=tmp)
			{
				int k=i-tmp;
				if(s[k]=='D')
				{
					res-=(add-q.front());
					q.pop();
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 9452
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main (int argc, char * const argv[]) {
    // insert code here...
    double x1, y1, x2, y2, x3, y3, xp, yp;
	
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		/*
		if( ((x1-x2)*yp-xp*(y1-y2))>0 && ((x2-x3)*yp-xp*(y2-y3))>0 && ((x3-x1)*yp-xp*(y3-y1))>0 ){
			cout<<"YES"<<endl;
		}else if( ((x1-x2)*yp-xp*(y1-y2))<0 && ((x2-x3)*yp-xp*(y2-y3))<0 && ((x3-x1)*yp-xp*(y3-y1))<0 ){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
		*/
		
		if( (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1) >0 && (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2) >0 && (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3) >0 ){
			cout << "YES" << endl;
		}else if( (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1) <0 && (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2) <0 && (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3) <0 ){
			cout << "YES" << endl;
		}else{
			cout <<"NO" <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1220
def get_strength(x):
    if x == 1:
        strength = 13
    else:
        strength = x - 1

    return strength


A, B = map(int,input().split())

Sa = get_strength(A)
Sb = get_strength(B)

if Sa == Sb:
    message = "Draw"
elif Sa > Sb:
    message = "Alice"
else:
    message = "Bob"

print(message)



Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        a: [[i32; 3]; 3],
        n: usize,
        b: [i32; n],
    }
    let mut tbl = vec![0; 3];
    for i in 0..3 {
        for j in 0..3 {
            for k in 0..n {
                if a[i][j] == b[k] {
                    tbl[i] |= 1 << j;
                }
            }
        }
    }
    let mut ok = false;
    for i in 0..3 {
        if tbl[i] == 7 { ok = true; }
    }
    let kk = tbl[0] & tbl[1] & tbl[2];
    ok |= kk != 0;
    ok |= ((tbl[0] >> 2) & (tbl[1] >> 1) & tbl[2] & 1) != 0;
    ok |= ((tbl[2] >> 2) & (tbl[1] >> 1) & tbl[0] & 1) != 0;
    puts!("{}\n", if ok { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import sys
import bisect
input = sys.stdin.buffer.readline


n = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

A_B = [0] * n
B_C = [0] * n
ans = 0

# A-B
for idx, a in enumerate(A):
    A_B[idx] = bisect.bisect_right(B, a)
# B-C
for idx, b in enumerate(B):
    B_C[idx] = n - bisect.bisect_right(C, b)

cul_sum = [0] * (n + 1)

for i in range(1, n + 1):
    cul_sum[i] = cul_sum[i - 1] + B_C[i - 1]


for idx in A_B:
    ans += cul_sum[n] - cul_sum[idx]

print(ans)


Measured memory_bytes: 105664
n,m=map(int,input().split())
h=list(map(int,input().split()))

f=[1]*n
a=0
b=0

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if h[a]<=h[b]:
        f[a]=0
    if h[a]>=h[b]:
        f[b]=0

ans=0

for i in f:
    ans+=i

print(ans)

Measured memory_bytes: 19892
# 入力
str1,str2=map(str,input().split())
int1,int2=map(int,input().split())
str3=str(input())

# 処理
if str3==str1:
    int1-=1
elif str3==str2:
    int2-=1

# 出力
print(int1,int2)

    

Measured memory_bytes: 2940
#include <stdio.h>
#include<string.h>
int main()
{
   long int b,i,j,c;
   char a[101][101],temp[101];
   scanf("%ld%ld\n",&b,&c);
   
   gets(a[0]);
   for(i=1;i<b;i++)
   {
       gets(a[i]);
       for(j=0;j<i;j++)
       {
           if(strcmp(a[i],a[j])<0)
           {
               strcpy(temp,a[i]);
               strcpy(a[i],a[j]);
               strcpy(a[j],temp);
           }
       }
   }
   for(i=0;i<b;i++)
   {
       printf("%s",a[i]);
   }
   
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, presum=0, ans = 0;
  cin >> n;
  vector<long long> vec(n);
  for (long long i = 0; i < n; i++) {
    cin >> vec[i];
  }

  for (long long i = 0; i < n; i++) {
    if (vec[i]!=0) {
      presum += vec[i];
    }
    else if (vec[i] == 0) {
      ans += floor(presum/2);
      presum = 0;
    }
  }
  ans += presum/2;
  cout << ans << '\n';

}


Measured memory_bytes: 1024
import itertools

N = input()
L = input().split()

num = 0
for x in itertools.combinations(L, 3):
  if x[0] != x[1] and x[0] != x[2] and x[1] != x[2]:
      if int(x[0]) + int(x[1]) > int(x[2]) and int(x[0]) + int(x[2]) > int(x[1]) and int(x[1]) + int(x[2]) > int(x[0]) :
          num = num+1

print(num)

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

int main() {
  int n,numbers[32]={1,1,1,2,1,2,1,5,
                   2,2,1,5,1,2,1,14, 
                   1,5,1,5,2,2,1,15, 
                   2,2,5,4,1,4,1,51};
  cin>>n;
  cout<<numbers[n-1]<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) YES;
  else NO;
  return 0;
}

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

int main() {
	// your code goes here
	ll n, ans=0, i,j;
	cin>>n;
	for(i=2;i<=sqrt(n);i++) {
	    j=i;
	    while(n%j==0) ans++,n/=j,j*=i;
	    while(n%i==0) n/=i;
	}
	cout<<ans+(n>1)<<endl;
	return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int a[15];
int main() {
    ios::sync_with_stdio(false),cin.tie(0);
    int n,m,k,s;
    cin >> n >> m;
    for (int i = 0;i < m;i++) {
        cin >> k;
        for (int j = 0;j < k;j++) {
            cin >> s;
            a[s] |= (1 << i);
        }
    }
    int ans = 0;
    for (int i = 0;i < m;i++) {
        cin >> s;
        ans |= (s << i);
    }
    int cnt = 0;
    for (int i = 0;i < (1 << n);i++) {
        int tmp = 0;
        for (int j = 0;j < n;j++) {
            int cur = i >> j;
            if (cur & 1)
                tmp ^= a[j+1];
        }
        if (tmp == ans)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 1134: Name the Crossing
// 2017.11.13 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HASHSIZ 503
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;			// Hash table

int insert(char *s, int w, int id)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

int lookup(char *s, int w)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	return -1;
}

char name[202][36]; int sz;
char rel[202][202], tmp[202][202];
int cross[202];

void found(int j, int k)
{
	int i;

	cross[j] = k;
	for (i = 0; i < sz; i++) {
		if (!cross[i] && (rel[i][j] || rel[j][i])) found(i, -k);
	}
}

int main()
{
	int n, m, w, i, j, k;
	char buf[36], *p, *q;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(hash, 0, sizeof(hash));
		memset(rel, 0, sizeof(rel));

		n = atoi(buf), sz = 0;
		while (n--) {
			fgets(name[sz], 35, stdin);
			p = q = name[sz]; while (*p != '-') p++; w = p - q, *p++ = 0;
			if ((i = insert(q, w, sz)) < 0) i = sz++;
			q = p; while (*p > ' ') p++; w = p - q, *p = 0;
			if ((j = insert(q, w, sz)) < 0) j = sz++;
			rel[i][j] = 1;
		}
		printf("%d\n", sz);

		memset(cross, 0, sizeof(cross));
		for (k = 1, i = 0; i < sz; i++)	if (!cross[i]) found(i, k++);

		memset(tmp, 0, sizeof(tmp));
		for (i = 0; i < sz; i++) for (j = 0; j < sz; j++) if (j != i) {
			int comm = 0, strong = 1;
			for (k = 0; k < sz; k++) if (k != i && k != j) {
				if ((rel[i][k] || rel[k][i]) && (rel[j][k] || rel[k][j])) comm = 1;
				if ((rel[i][k] && rel[k][j]) || (rel[j][k] && rel[k][i])) strong = 0;
				if (comm && !strong) break;
			}
			if (comm && strong) tmp[i][j] = 1;
		}
		for (i = 0; i < sz; i++) for (j = 0; j < sz; j++) rel[i][j] |= tmp[i][j];

		for (k = 0; k < sz; k++) for (i = 0; i < sz; i++) for (j = 0; j < sz; j++)
			if (rel[i][k] && rel[k][j]) rel[i][j] = 1;

		fgets(buf, 10, stdin); m = atoi(buf);
		while (m--) {
			fgets(buf, 35, stdin);
			p = q = buf; while (*p != '-') p++;	w = p - q, *p++ = 0;
			if ((i = lookup(q, w)) < 0) goto no;
			q = p; while (*p > ' ') p++; w = p - q, *p = 0;
			if ((j = lookup(q, w)) < 0) goto no;
			if (cross[i] == -cross[j] && rel[i][j]) puts("YES");
			else {
no:				puts("NO");
			}
		}
	}
	return 0;

}

Measured memory_bytes: 1800
N = int(input())
lis = []
all10 = True
res = 0
for _ in range(N):
    tmp = int(input())
    res += tmp
    lis.append(tmp)
    if all10 and tmp % 10 != 0:
        all10 = False

if all10:
    print(0)
    exit()
if res % 10 != 0:
    print(res)
    exit()
else:
    lis.sort()
    for i in lis:
        if i % 10 != 0:
            print(res-i)
            exit()


Measured memory_bytes: 3064
n,m = map(int, input().split())

# init
A = []
b = []
for _ in range(n):
    A.append(list(map(int, input().split())))
for _ in range(m):
    b.append(int(input()))


for row in range(n):
    p = 0
    for i, j in zip(A[row], b):
        p += i * j
    print(p)

Measured memory_bytes: 7996
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 100
#define MAX_set 200

typedef long long int ll;
using namespace std;


int main(){

	int a,b;

	while(scanf("%d %d", &a, &b) != EOF){
		printf("%d\n", (int)log10((double)a+b) + 1);
	
	}

	return 0;

}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, A[101010], B[101010], C[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i] >> B[i];
    rep(i, 0, N) C[i] = A[i] + B[i];

    vector<int> ord;
    rep(i, 0, N) ord.push_back(i);
    sort(all(ord), [&](int a, int b) { return C[a] > C[b]; });

    ll ans = 0;
    rep(i, 0, N) {
        if (i % 2 == 0) ans += A[ord[i]];
        else ans -= B[ord[i]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    char S[100000];
    cin >>N>>S;
    for(int i=0;S[i]!='\0';i++){
        int x=S[i]-'A';
        x=(x+N)%26;
        S[i]='A'+x;
        cout <<S[i];
    }    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

struct Point{
  double x, y;
  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(x*a, y*a); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;

double dot(Vector a, Vector b){
  return a.x*b.x + a.y*b.y;
}

double cross(Vector a, Vector b){
  return a.x*b.y - a.y*b.x;
}

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

  rep(i, q){
    int x0, y0; cin >> x0 >> y0;
    int x1, y1; cin >> x1 >> y1;
    int x2, y2; cin >> x2 >> y2;
    int x3, y3; cin >> x3 >> y3;
    Point p0 = Point(x0, y0);
    Point p1 = Point(x1, y1);
    Point p2 = Point(x2, y2);
    Point p3 = Point(x3, y3);
    Vector a = Vector(x0-x1, y0-y1);
    Vector b = Vector(x2-x3, y2-y3);
    if(equals(cross(a, b), 0.0)) cout << 2 << endl;
    else if(equals(dot(a, b), 0.0)) cout << 1 << endl;
    else cout << 0 << endl;
  }

  return 0;

}





Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){//桁数
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){//最小公倍数
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){//最大公約数
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
}
  


Measured memory_bytes: 256