akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

string s;
int n;
int ans;
int early[10];

void countDiff(int t)
{
	int mark[10];
	for (int i = 0; i < 10; ++i)
		mark[i] = 0;

	for (int i = t; i < n; ++i)
		mark[s[i] - '0'] = 1;

	for (int i = 0; i < 10; ++i)
		ans += mark[i];
}

void find(int x) // x+1,n-1 number of diff pairs
{
	int _ea[10];
	for (int i = 0; i < 10; ++i)
		_ea[i] = -1;

	for (int i = n-1; i > x; --i)
		_ea[s[i] - '0'] = i;

	for (int i = 0; i < 10; ++i)
		if(_ea[i] != -1)
			countDiff(_ea[i] + 1);
}



int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> s;
	for (int i = 9; i >= 0; --i)
		early[i] = -1;

	for (int i = n-1; i >= 0; --i)
		early[s[i] - '0'] = i;

	for (int i = 0; i < 10; ++i)
		if(early[i] != -1)
			find(early[i]);
		
	cout << ans << endl;
}

Measured memory_bytes: 384
try:
    while True:
        n = 0
        str3 = []
        str1 = input()
        str2 = [a for a in str1]
        num = len(str2)
        for num1 in range(0,num):
            if str2[num1] == "@":
                for num2 in range(int(str2[num1 + 1])):
                    print(str2[num1 + 2],end="")
                n = 2
                continue
            else:
                if n > 0:
                    n -= 1
                    continue
                else:
                    print(str2[num1],end="")
                    continue
        print()
except EOFError as e:
    n = 0


Measured memory_bytes: 5612
N = int(input())


def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor


import math

fac = math.factorial(N)
prime_fac = prime_factorize(fac)

count = 0
upper_two = {}
upper_four = {}
upper_15 = {}
upper_24 = {}
upper_74 = {}


for k, v in prime_fac.items():
    if v >= 2:
        upper_two[k] = v
    if v >= 4:
        upper_four[k] = v
    if v >= 14:
        upper_15[k] = v
    if v >= 24:
        upper_24[k] = v
    if v >= 74:
        upper_74[k] = v


upper_two = len(upper_two)
upper_four = len(upper_four)
upper_15 = len(upper_15)
upper_24 = len(upper_24)
upper_74 = len(upper_74)


ans = upper_four*(upper_four - 1) * (upper_two-2)//2 \
     + upper_74 + upper_24 * (upper_two-1) + upper_15 * (upper_four-1)


print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;

    cout << 6-a-b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val w = (0 until n).map { 
        sc.nextInt()
     }

     abc129b(n, w)
}

fun abc129b(n: Int, w: List<Int>) {
    var list: MutableList<Int> = mutableListOf()
    for (i in 1..n) {
       var s1 = w.take(i).sum()
       var s2 = w.takeLast(n - i).sum()
       var abs = Math.abs(s1 - s2)
       list.add(abs)
    }
    var ans = list.min()

    println(ans)
}


Measured memory_bytes: 31516
#include <iostream>
using namespace std;
int main() {
    int n, left, right, i=0;
    long long int a, b[210000];
    cin >> n >> b[n/2];
    left = n/2 - 1;
    right = n/2 + 1;
    bool dir = (n%2!=0); // left: false, right: true
    while(cin >> a) {
        if(dir) {
            b[right] = a;
            right++;
        } else {
            b[left] = a;
            left--;
        }
        dir = !dir;
    }
    for(i=0; i<n; i++) cout << b[i] << " ";
    cout << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

//Vectorに同じ値が入っている→true
bool VectorIsSame(vector<int> a) {
	sort(a);
	rep(i, a.size() - 1) {
		if (a[i] == a[i + 1]) {
			return true;
		}
	}
	return false;
}

//vectorにある要素が含まれているか
bool vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> t(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		t[a].push_back(b);
		t[b].push_back(a);
	}
	n--;
	int ans = 0;
	rep(i, POW(n, n)) {
		int i2 = i;
		vector<int> x(n);
		rep(j, n) {
			x[j] = i2 % n + 1;
			i2 /= n;
		}
		if (VectorIsSame(x)) continue;
		bool flag = true;

		//if (x[0] == 2 &&
		//	x[1] == 3 &&
		//	x[2] == 4 &&
		//	x[3] == 5 &&
		//	x[4] == 6 &&
		//	x[5] == 1) {
		//	int as = 1;
		//}

		rep(j, n) {
			if (j == 0) {
				if (!vector_finder(t[0], x[j])) {
					flag = false;
					break;
				}
			}
			else {
				if (!vector_finder(t[x[j-1]], x[j])) {
					flag = false;
					break;
				}
			}
		}
		if(flag) ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    cout << ceil((double)N / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
if 100<=n<112:
	print("111")
elif 112<=n<223:
	print("222")
elif 223<=n<334:
	print("333")
elif 334<=n<445:
	print("444")
elif 445<=n<556:
	print("555")
elif 556<=n<667:
	print("666")
elif 667<=n<778:
	print("777")
elif 778<=n<889:
	print("888")
elif 889<=n<=999:
	print("999")	

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
    int n;
    signed int maxv,minv;
    int S[200000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    minv=S[0];
    maxv=-1;
    for(int i=1;i<n;i++){
        if(maxv<=(S[i]-minv)){
            maxv=S[i]-minv;
        }
        if(minv>=S[i]){
            minv=S[i];
        }
    }
    if(n<=2){
        maxv=S[1]-S[0];
    }
    printf("%d\n",maxv);
    return 0;
}


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

int main() {
    int N,M;
    cin >> N >> M;

    vector<vector<int>> pre_year(100001);
    vector<int> pre(100001);
    vector<int> year(100001);

    for(int i=0;i<M;i++){
        cin >> pre[i] >> year[i];
        pre_year[pre[i]].push_back(year[i]);
    }
    for(int i=1;i<=N;i++){
        sort(pre_year[i].begin(),pre_year[i].end());
    }
    for(int i=0;i<M;i++){
        cout << setfill('0') << right << setw(6) << pre[i];
        auto a=lower_bound(pre_year[pre[i]].begin(),pre_year[pre[i]].end(),year[i]);
        string ab= to_string(a-pre_year[pre[i]].begin()+1);
        cout << setfill('0') << right << setw(6) << ab << endl;
    }

}


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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

const uint64_t MOD = 1e+9 + 7;

class ModuloOps
{
private:
  std::vector<uint64_t> _fact, _fact_inv;

  void _calc_fact(uint64_t n)
  {
    for (uint64_t i = 2; i <= n; ++i) {
      _fact[i] = (_fact[i - 1] * i) % MOD;
      _fact_inv[i] = inv(_fact[i]);
    }
  }

public:
  ModuloOps(uint64_t n)
  {
    _fact = std::vector<uint64_t>(n + 1);
    _fact_inv = std::vector<uint64_t>(n + 1);

    _fact[0] = 1;
    _fact[1] = 1;
    _fact_inv[0] = 1;
    _fact_inv[1] = 1;

    _calc_fact(n);
  }

  uint64_t power(uint64_t x, uint64_t y) const
  {
    if (y <= 1) {
      return (y == 0) ? 1 : (x % MOD);
    }

    uint64_t w = power(x, y >> 1);
    uint64_t z = (w * w) % MOD;

    if (y % 2 == 1) {
      z = (x * z) % MOD;
    }

    return z;
  }

  uint64_t inv(uint64_t n) const { return power(n, MOD - 2); } 

  uint64_t fact(uint64_t n) const { return _fact[n]; }
  uint64_t fact_inv(uint64_t n) const { return _fact_inv[n]; }

  uint64_t perm(uint64_t n, uint64_t k) const {
    return (_fact[n] * _fact_inv[n - k]) % MOD;
  }

  uint64_t comb(uint64_t n, uint64_t k) const {
    return (perm(n, k) * _fact_inv[k]) % MOD;
  }

  uint64_t prem_rep(uint64_t k, uint64_t l) const
  {
    uint64_t x = _fact[k + l];
    x = (x * _fact_inv[k]) % MOD;
    x = (x * _fact_inv[l]) % MOD;
    return x;
  }

  uint64_t prem_rep(const std::vector<uint64_t> &a) const
  {
    uint64_t n = std::accumulate(a.begin(), a.end(), 0);
    uint64_t x = _fact[n];
    for (uint64_t y : a) {
      x = (x * _fact_inv[y]) % MOD;
    }
    return x;
  }

  uint64_t comb_rep(uint64_t n, uint64_t k) const {
    return comb(n + k - 1, k);
  }
};

ModuloOps mod_ops(2002002);

uint64_t f(uint64_t r, uint64_t c)
{
  uint64_t p = mod_ops.fact(r + c);
  uint64_t q = (mod_ops.fact_inv(r) * mod_ops.fact_inv(c)) % MOD;
  return (p * q) % MOD;
}

uint64_t g(uint64_t r, uint64_t c)
{
  return f(r + 1, c + 1) - 1;
}

int main()
{
  uint64_t r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  uint64_t S = (g(r2, c2) + g(r1 - 1, c1 - 1)) % MOD;
  uint64_t T = (g(r1 - 1, c2) + g(r2, c1 - 1)) % MOD;
  uint64_t ans = ((S + MOD) - T) % MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 31616
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Queue<Integer> price = new PriorityQueue<Integer>(Collections.reverseOrder());
		long sum = 0;

		for (int i = 0; i < n; i++) {
			price.add(Integer.parseInt(sc.next()));
		}

		for (int i = 0; i < m; i++) {
			price.add(price.poll() / 2);
		}

		for (int num : price) {
			sum += num;
		}
		System.out.println(sum);

	}
}

Measured memory_bytes: 48924
let s = stdin.ReadLine()
let n = s |> Seq.length
let rec f i p =
    if i<=0 then p+i+1
    elif s.[i]=s.[i-1] then f (i-3) (p+2)
    else f (i-1) (p+1)
f (n-1) 0 |> stdout.WriteLine

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

#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000000

class TreeNode{
public:
    vector<int> children;
    int parent;
};

void create_tree(int src, vector<vector<int>>& adjList, vector<TreeNode>& tree){
    for(int i = 0; i < adjList[src].size(); i++){
        if(adjList[src][i] != tree[src].parent){
            tree[src].children.push_back(adjList[src][i]);
            tree[adjList[src][i]].parent = src;
            create_tree(adjList[src][i], adjList, tree);
        }
    }
}

bool give_path(int u, int v, int curr, vector<int>& path, vector<TreeNode>& tree){

    if(curr == v){
        path.push_back(v);
        return true;
    }

    if(!tree[curr].children.size()){
        return false;
    }

    for(int i = 0; i < tree[curr].children.size(); i++){
        bool out_flag = give_path(u, v, tree[curr].children[i], path, tree);

        if(out_flag){
            path.push_back(curr);
            return true;
        }
    }

    return false;
}

int longest_path(int st, vector<TreeNode>& tree, int next){

    if(!tree[st].children.size()){
        return 0;
    }

    int ans = 1;

    for(int i = 0; i < tree[st].children.size(); i++){
        if(tree[st].children[i] != next)
            ans = max(ans , ((longest_path(tree[st].children[i], tree, next)) + 1));
    }

    return ans;
}

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

    int n, u, v, x, y;

    cin >> n >> u >> v;

    vector<vector<int> > adjList(n+1);
    vector<TreeNode> tree(n+1);

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

        adjList[x].push_back(y);
        adjList[y].push_back(x);

        tree[i].parent = -1;
    }

    tree[n].parent = -1;

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

    create_tree(v, adjList, tree);

    vector<int> path;

    give_path(v, u, v, path, tree);

    int count = ((path.size()) - 2)/2;

    cout << ((path.size()-count-1) + ((longest_path(path[count], tree, path[count+1])) - 1)) << endl;

    return 0;
}

Measured memory_bytes: 18304
N = int(input())
SP = [input().split() for i in range(N)]
for i in range(N):
    SP[i][1] = int(SP[i][1])
    SP[i].append(i+1)
SP = sorted(SP, key = lambda x: (x[0], -x[1]))
for i in range(N):
    print(SP[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=5000000000000000000;
ll MOD=1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    ll o=0,p=0;
    rep(i,n){
        if (o*2<a.at(i)) p=i;
        o+=a.at(i);
    }
    cout << n-p << endl;
}


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


using namespace std;


using ll = long long;


int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);

    for (ll i = 0; i < N; i++)
        cin >> A[i];

    map<ll, ll> l, r;
    for (ll i = 0; i < N; i++) {
        l[i - A[i]]++;
        r[i + A[i]]++;
    }
    ll ans = 0;
    for (auto p : r) {
        ans += p.second * l[p.first];
    }
    cout << ans << endl;
}


Measured memory_bytes: 39172
import bisect
N = int(input())
A = list(map(int,input().split()))
cums = [0]
for a in A:
    cums.append(cums[-1] + a)

half = cums[-1]//2

i = bisect.bisect_left(cums, half)
if cums[i] == half:
    print(0)
    exit()
if cums[-1]%2 and cums[i] == half+1:
    print(0)
    exit()

a,b = cums[i], cums[-1]-cums[i]
ans = abs(a-b)

if i>0:
    a,b = cums[i-1], cums[-1]-cums[i-1]
    ans = min(ans, abs(a-b))

print(ans)

Measured memory_bytes: 25884
#include<stdio.h>

int main(void){
	int tc,max;
	scanf("%d", &max);
	for(tc=0;tc<max;++tc){
		int i;
		int X,Y,W,H;
		int ncats;
		int insideCats = 0;

		scanf("%d%d%d%d", &X, &Y, &W, &H);
		scanf("%d", &ncats);

		for(i = 0; i < ncats; i++){
			int x, y;
			scanf("%d%d", &x, &y);
			if( (X <= x && x <= X + W) && (Y <= y && y <= Y + H) ){
				insideCats++;
			}
		}

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

Measured memory_bytes: 0
mod=10**9+7

n,k = map(int,input().split())
l = list(map(int,input().split()))
l2 = l+l

x=0
for i in range(n-1):
    for j in range(i,n-1):
        if l[i] > l[j+1]:
                x+=1

y=0
for i in range(2*n-1):
    for j in range(i,2*n-1):
        if l2[i] > l2[j+1]:
                y+=1

y-=(2*x)

tmp = (k*(k-1)//2)%mod
ans = ((tmp*y)%mod + (x*k)%mod)%mod
print(ans)

Measured memory_bytes: 9248
#include<stdio.h>
int cnt,dx[4]={0,-1,0,1},dy[4]={-1,0,1,0},max,x,y,m,n,i,j,a[90][90];
void func(int y,int x){
	int i,xx,yy;
	for(i=0;i<4;i++){
		xx=x+dx[i]; yy=y+dy[i];
		if(xx<m&&xx>=0&&yy<n&&yy>=0&&a[yy][xx]==1){
			cnt++;
			a[yy][xx]=0;
			if(max<cnt) max=cnt;
			func(yy,xx);
			a[yy][xx]=1; cnt--;
		}
	}
}
int main(void){
	int i,j;
	while(1){
		scanf("%d %d",&m,&n);
		if(m==0&&n==0) break;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++) scanf("%d",&a[i][j]);
		}
		max=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				cnt=0;
				func(i,j);
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;

int main()
{
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) cin >> B[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int A;
    int sum = C;
    for (int j = 0; j < M; j++) {
      cin >> A;
      sum += A * B[j];
    }
    if (sum > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split(' '))
S=[['x']*(W+2)]
for i in range(H):
  S.append(['x']+list(input())+['x'])
S.append(['x']*(W+2))

for h in range(H+2):
  for w in range(W+2):
    if S[h][w] == '.':
      S[h][w] = str([S[x][y] for x in [h-1,h,h+1] for y in [w-1,w,w+1]].count('#'))
      
for i in range(H):
  print(''.join(S[i+1]).replace('x',''))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int q;
	cin>>q;
	while(q--){
		ll a,b;
		cin>>a>>b;
		if(a>b) swap(a,b);
		if(a==b){
			cout<<2*(a-1)<<endl;
			continue;
		}
		ll c=sqrt(a*b);
		ll ans=0;
		if(c*(c+1)<a*b){
			ans=c-1+c;
		}else{
			ans=c-2+c;
		}
		if(c*c==a*b) ans--;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

int main()
{
	int N;
	std::cin >> N; std::cin.ignore();

	std::unordered_map<std::string, int> textCountMap;
	std::string S;
	int maxTextCount = 0;
	for (int count = 0; count < N; ++count) {
		std::cin >> S; std::cin.ignore();
		textCountMap[S] += 1;
		if (maxTextCount < textCountMap[S]) {
			maxTextCount = textCountMap[S];
		}
	}

	std::vector<std::string> result;
	result.reserve(N);
	for (std::pair<std::string, int> textAndCount : textCountMap) {
		if (maxTextCount == textAndCount.second) {
			result.emplace_back(textAndCount.first);
		}
	}
	std::sort(result.begin(), result.end());
	for (std::string output : result) {
		std::cout << output << std::endl;
	}
}

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

using namespace std;

int n, a[300001], nxt[300001];
long long ans = 0;
int main( ) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
		scanf("%d", &a[i]);
	nxt[n + 1] = n + 1;
	for (int i = n; i >= 1; i --) {
		if (a[i]) nxt[i] = i;
		else nxt[i] = nxt[i + 1];
	}

	for (int i = 1; i <= n; i ++) {
		int x = 0, y = 0, cnt = 0;
		for (int j = i; j <= n; j ++) {
			if (a[j]) {
				x ^= a[j];
				y += a[j];
				if (x == y) ++ ans;
				++ cnt;
				if (cnt >= 22) break;
			}
			else {
				if (x == y) ans += nxt[j] - j;
				j = nxt[j] - 1;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
S = int(input())
yymm = True
mmyy = True


if S >= 1300 or S < 100:
    mmyy = False
if S%100 >= 13 or S%100 == 0:
    yymm = False

if yymm == True:
    if mmyy == True:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if mmyy == True:
        print("MMYY")
    else:
        print("NA")

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(void){
  int a, b, i;
  cin >> a >> b;
  int tmp, ans = 0;
  for(i = 0; b > i; i++){
    cin >> tmp;
    ans += tmp;
  }
  
  if(a > ans){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  return 0;
}


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

using namespace std;

const int MaxN = 1e5 + 15;
int p[MaxN];
int n, m;
vector <int> v[MaxN];

bool used[MaxN];

vector <int> o1, o2;

void dfs(int x)
{
    used[x] = true;
    o1.push_back(x);
    o2.push_back(p[x]);

    for(int to : v[x])
        if(!used[to])
            dfs(to);
}

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

    cin >> n >> m;

    for(int i = 1; i <= n; ++i)
        cin >> p[i];

    for(int i = 1; i <= m; ++i)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    int ans = 0;

    for(int i = 1; i <= n; ++i)
    {
        if(!used[i])
        {
            o1.clear();
            o2.clear();
            dfs(i);

            sort(o1.begin(), o1.end());
            sort(o2.begin(), o2.end());

            int l1 = 0, l2 = 0;
            while(l1 < o1.size() && l2 < o2.size())
            {
                if(o1[l1] == o2[l2])
                {
                    ++ans;
                    ++l1;
                    ++l2;
                }else
                if(o1[l1] < o2[l2])
                    ++l1;
                else
                    ++l2;
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 10156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  string S;
  cin >> S;
  int N=S.size();
  
  bool flag=!(N%2);
  if(flag) {
    rep(i,N/2) flag&=S[2*i]=='h'&&S[2*i+1]=='i';
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

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

int main(){

  string s;cin>>s;

  ll ans=0;
  rep(i,0,s.size()){
    if(s[i]=='1')ans++;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char S[101];
	int K;
	int len;
	int i;
	
	scanf("%d %s",&K,S);
	len=strlen(S);
	if(len<=K){
		printf("%s",S);
	}
	else{
		for(i=0;i<K;i++){
			printf("%c",S[i]);
		}
		printf("...\n");
	}
	return 0;
}



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

int main(){
    int n;
    ll a, b;
    cin >> n >> a >> b;
    ll x[n];
    for(int i = 0; i < n; i++) cin >> x[i];
    ll sum = 0;
    for(int i = 1; i < n; i++) sum += min(a * (x[i] - x[i - 1]), b);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
a = list(input())
Q = int(input())
d = deque(a)
ans = 1
for i in range(Q):
  b = list(input().split())
  if len(b) == 1:
    ans += 1
  elif b[1] == "1" and ans % 2 == 1:
    d.appendleft(b[2])
  elif b[1] == "1" and ans % 2 == 0:
    d.append(b[2])
  elif b[1] == "2" and ans % 2 == 1:
    d.append(b[2])
  elif b[1] == "2" and ans % 2 == 0:
    d.appendleft(b[2])
if ans % 2 == 0:
  d.reverse()
print("".join(d))

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

int main(){
  char c[9];
  cin >> c[0] >> c[1] >> c[2];
  cin >> c[3] >> c[4] >> c[5];
  cin >> c[6] >> c[7] >> c[8];
  cout << c[0] << c[4] << c[8]; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int n;
  cin >> n;
  ll x[n];
  ll y[n];
  rep(i,n)
    cin >> x[i] >> y[i];
  ll sax[n][n];
  ll say[n][n];
  rep(i,n){
    rep(j,n){
      sax[i][j]=x[i]-x[j];
      say[i][j]=y[i]-y[j];
    }
  }
  map<pair<ll,ll>,int> m;
  rep(i,n){
    rep(j,n){
      if(i==j)continue;
      if(!m.count(make_pair(sax[i][j],say[i][j]))){
        m[make_pair(sax[i][j],say[i][j])]=1;
        continue;
      }
      m[make_pair(sax[i][j],say[i][j])]++;
    }
  }
  int ma=0;
  for(auto p:m)
    ma=max(p.second,ma);
  cout << n-ma << endl;  
      
}

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

int main(){
  int i=0; int n; int c; int d; int co=0; int maxs = 0;
  cin >> n;
 int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int b[n];
  for(i=0; i<n; i++){
    b[i] = a[i];
  }

  sort(a,a+n);
  c = a[n-1];

  for(i=0; i<n; i++){
    if(b[i] != c){
   cout << c << endl;
   }else{
     cout << a[n-2] << endl;
   }
  }
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
	int a,b,d,r;
	double f;
	cin >> a >> b ;

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	cout << d << " " << r << " ";
	printf("%.5lf\n",f);
	return 0;
}

Measured memory_bytes: 1240
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if l > r or R-L >= 2019:
    print(0)
    exit()

ans = 2019
for i in range(l, r):
    for j in range(l+1,r+1):
        ans = min((i*j)%2019, ans)

print(ans)


Measured memory_bytes: 3060
N,Y=map(int,input().split())
x,y,z=-1,-1,-1
for i in range(0,Y//10000+1):
    for j in range(0,((Y-i*10000)//5000)+1):
        if (N-i-j>=0)&(10000*i+5000*j+1000*(N-i-j)==Y):
            x=i
            y=j
            z=N-x-y
print(x,y,z)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int cnt = 0;
  string s;
  cin  >> s;
  for(int i=0;i<3;i++)
    {
      if(s[i] == 'o')cnt++;
    }
  cout << cnt * 100 + 700 << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
using namespace std;
typedef pair<int,int> P;
#define INF 1e9

struct edge{
	int to,cost;
	edge(int to, int cost): to(to),cost(cost){}
};


int main() {
	int v,e,r;
	vector<edge> g[100100];
	int ans[100100];
	priority_queue<P, vector<P>, greater<P> > q;


	cin>>v>>e>>r;
	for (int i=0;i<e;i++) {
		int s,t,d;
		cin>>s>>t>>d;
		g[s].push_back(edge(t,d));
	}

	fill(ans,ans+v+1,INF);
	ans[r]=0;
	q.push(P(0,r));
	while (!q.empty()) {
		P x = q.top();
		q.pop();
		if (ans[x.second] < x.first) continue;
		for (int i=0;i<g[x.second].size();i++){
			edge e = g[x.second][i];
			//cout<<ans[e.to] <<endl;
			if (ans[e.to] > ans[x.second]+e.cost) {
				//cout<<e.to<<endl;
				ans[e.to] = ans[x.second]+e.cost;
				q.push(P(ans[e.to],e.to));
			}
		}
	}

	for (int i=0;i<v;i++) {
		if (ans[i]==1e9) {
			cout<<"INF"<<endl;
		} else {
			cout<< ans[i] <<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 13124
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

int main()
{
  string S;
  int w;
  cin >> S >> w;

  int len = (int)S.size();

  for (int i = 0; i < len; i += w) {
    cout << S[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

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

n = int(input())

c = collections.Counter(prime_factorize(n))
ans = 0
for k, v in c.items():
  i = 1
  while True:
    v -= i
    if v < 0:
      break
    ans += 1
    i += 1

print(ans)



Measured memory_bytes: 9464
//
//  ALDS.cpp
//  aoj
//
//  Created by shiro kobayashi on 2017/02/15.
//  Copyright ?? 2017??´ shiro kobayashi. All rights reserved.
//

#include <stdio.h>
#include <iostream>

using namespace std;

void insertionSort(int a[], int n);
void print_array(int a[], int n);

int main()
{
    int N, A[100];
    
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    
    insertionSort(A, N);
    return 0;
}

void insertionSort(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        int v = a[i];
        int j = i - 1;
        
        while( j >= 0 && a[j] > v )
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        
        print_array(a, n);
    }
}

void print_array(int a[], int n)
{
    for(int i = 0; i < n ; i++)
    {
        cout << a[i];
        if( i == (n - 1))
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	string S;
	cin >> S;
	int N=S.size();
	S.pop_back();
	rep(i,N-1){
		if(S.size()%2){
			S.pop_back();
			continue;
		}
		else{
			rep(j,S.size()/2){
				if(S[j]!=S[j+S.size()/2]){
					S.pop_back();
					break;
				}
				if(j==S.size()/2-1){
					cout << S.size() << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int k = 1;
    int count = 0;
    rep(i, n) {
        if(k!=a[i]) count++;
        else k++;
    }
    if(count == n)count= -1;
    cout << count << endl;
}

Measured memory_bytes: 4052
n = int(input())
s_list = [input() for _ in range(n)]

c1 = str(s_list.count('AC'))
c2 = str(s_list.count('WA'))
c3 = str(s_list.count('TLE'))
c4 = str(s_list.count('RE'))

print('AC' + ' x ' + c1)
print('WA' + ' x ' + c2)
print('TLE' + ' x ' + c3)
print('RE' + ' x ' + c4)

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

using namespace std;

const int MAX_N = 100000, MAX_M = 100000, INDEX = 1;
const long long MOD = 1000000007;

int n, m;
long long x[MAX_N + INDEX], y[MAX_M + INDEX];

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

    cin >> n >> m;

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

    for (int i = 1; i <= m; i++) {
        cin >> y[i];
    }

    sort(x + INDEX, x + INDEX + n, less<long long>());
    sort(y + INDEX, y + INDEX + m, less<long long>());

    long long sdx = 0, sdy = 0;

    for (int i = 1; i <= n; i++) {
        sdx += (2 * i - (n + 1)) * x[i];

        sdx %= MOD;
    }

    for (int i = 1; i <= m; i++) {
        sdy += (2 * i - (m + 1)) * y[i];

        sdy %= MOD;
    }

    cerr << sdx << ' ' << sdy << endl;

    cout << (sdx * sdy) % MOD << endl;

    return 0;
}


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

#define ll long long
#define ld long double
#define debug(x) \
	//    (cout << #x << ": " << (x) << endl)
#define eb emplace_back
#define fi first
#define se second

using namespace std;

ll n;

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	cin >> n;
	ll res = 0;
	for (ll i = 2; i * i <= n; i++) {
		int s = 0;
		while (n % i == 0) {
			s++;
			n /= i;
		}
		int j = 0;
		while ((j + 1) * (j + 2) / 2 <= s) {
			j++;
		}
		res += j;
	}
	if (n > 1) {
		res++;
	}
	cout << res << "\n";
}


Measured memory_bytes: 3636
N=gets.to_i
as=Array.new(N)
ds=Array.new(N){Array.new(N,false)}
N.times do |i|
  as[i]=gets.to_i
  as[i].times do |j|
    e,f=gets.split.map(&:to_i)
    ds[i][e-1]=f
  end
end

ans=0
(1<<N).times do |i|
  ok=true
  cnt=0
  N.times do |j|
    next if ((i & (1<<j))==0)
    cnt+=1
    ds[j].each_with_index do |e,k|
      next if !e
      ok=false if ((e==1) && (i & (1<<k))==0) || ((e==0)  && (i & (1<<k))!=0)
    end
  end
  ans=ans<cnt ? cnt : ans if ok
end
puts ans


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

void fnInput(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int fnGcdGet(int nNumA, int nNumB)
{
  int nDividend = max(nNumA, nNumB);
  int nDivisor  = min(nNumA, nNumB);

  while (nDividend % nDivisor != 0)
  {
    int nRemain = nDividend % nDivisor;
    nDividend = nDivisor;
    nDivisor  = nRemain;
  }
  return nDivisor;
}

int fnMaxGcd(const vector<int>& cnrvnNum)
{
  vector<int> vnLeftGcd(cnrvnNum.size());
  vector<int> vnRigtGcd(cnrvnNum.size());
  int nMaxGcd = 0;

  vnLeftGcd[0] = cnrvnNum[0];
  
  for (int i = 0; i < cnrvnNum.size() - 1; i++)
    vnLeftGcd[i + 1] = fnGcdGet(vnLeftGcd[i], cnrvnNum[i + 1]);
  
  vnRigtGcd[cnrvnNum.size() - 1] = cnrvnNum[cnrvnNum.size() - 1];

  for (int i = cnrvnNum.size() - 1; i > 0; i--)
    vnRigtGcd[i - 1] = fnGcdGet(vnRigtGcd[i], cnrvnNum[i - 1]);

  for (int i = 0; i < cnrvnNum.size(); i++)
    if (i == 0)
      nMaxGcd = max(nMaxGcd, vnRigtGcd[i + 1] );
    else if (i == cnrvnNum.size() - 1)
      nMaxGcd = max(nMaxGcd, vnLeftGcd[i - 1] );
    else
      nMaxGcd = max(nMaxGcd, fnGcdGet(vnLeftGcd[i - 1], vnRigtGcd[i + 1] ));
  
  return nMaxGcd;
}
 
int main()
{
  vector<int> vnNum;

  fnInput(vnNum);
  cout << fnMaxGcd(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 4576
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
    private static void Solve(){
        Scanner in = new Scanner(System.in);
        int a, b; a = in.nextInt(); b = in.nextInt();
        System.out.println(Math.max(a-(2*b), 0));
    }
    public static void main(String []args){
        Solve();
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <ios>
#include <limits.h>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
typedef vector<long> vec;
long long c = 0;

void Merge(vec& vA, int l, int m, int r)
{
	int n1 = m - l;
	int n2 = r - m;
	vec vL(n1 + 1, 0);
	vec vR(n2 + 1, 0);
	FOR(i, 0, n1) vL[i] = vA[l + i];
	FOR(i, 0, n2) vR[i] = vA[m + i];
	vL[n1] = LONG_MAX;
	vR[n2] = LONG_MAX;
	int s = 0, t = 0;
	FOR(i, l, r){
		if ( vL[s] > vR[t]){
			vA[i] = vR[t];
			++t;
			c += n1 - s;
		}else{
			vA[i] = vL[s];
			++s;
		}
	}
}

void CountCross(vec& vA, int l, int r)
{
	if (l + 1 >= r) return;
	int m = (l + r) / 2;
	CountCross(vA, l, m);
	CountCross(vA, m, r);
	Merge(vA, l, m, r);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vec vA(n, 0);
	FOR(i, 0, n) cin >> vA[i];
	CountCross(vA, 0, n);
	cout << c << "\n";
	return 0;
}

Measured memory_bytes: 4152
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(int(readline()) for _ in range(N))
    print(len(set(A)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
#include<iostream>

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	
		if (a*b%2 == 1) {
			cout << "Yes";
			return 0;
		}
		else if (a*b*3 % 2 == 1) {
			cout << "Yes";
			return 0;
		}

		cout << "No";
	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 200005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}

int main()
{
  boost
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif 
   ll n;
   cin>>n;
   ll i,a[n];
   ll s=0;
   REP(i,n)
   {
    cin>>a[i];
    s^=a[i];
   }
   REP(i,n)
   {
    ll p=s^a[i];
    cout<<p<<" ";
   }
 }


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a;
    string s;
    int b;
    cin >> a >> s;
    if (s.length() == 1) {
        b = stoi(s) * 100;
    } else if (s.length() == 3) {
        b = (s[0] - '0') * 100 + (s[2] - '0') * 10;
    } else {
        b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    }
    print(a * b / 100);

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<deque>
#define LL long long 
using namespace std;
deque<int> b;
deque<int>::iterator it;
int a[200010],c[200010];
int main()
{
   int n,i;
   cin>>n;
   for (i=1;i<=n;i++)
   {
       c[i]=(n-i)%2;
       cin>>a[i];
   }

   for (i=1;i<=n;i++)
   {
       if (c[i]) b.push_back(a[i]);
       else b.push_front(a[i]);
   }
   for (it=b.begin();it!=b.end();it++)
       cout<<*it<<' ';
   cout<<endl;
}


Measured memory_bytes: 4608
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int N, A, B;
	cin >> N >> A >> B;

	if (abs(A - B) % 2 == 0) {
		cout << "Alice";
	}
	else {
		cout << "Borys";
	}




}


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

using namespace std;

int main() {
    int n; cin >> n;
    if (n == 1) {
        cout << 1;
        return 0;
    }
    vector<int> primes;
    int arr[100000];
    for (int i = 2; i < 100000; i++) arr[i] = 0;
    for (int i = 2;i  < 100000; i++) {
        if (arr[i] == 0) {
            primes.push_back(i);
            for (int j = 1; j*i < 100000; j++) arr[i*j] = 1;
        }
    }
    cout << n << ":";
    for (int i:primes) {
        if (n%i == 0) {
            while (n%i == 0) {
                cout << " " << i;
                n /= i;
            }
        }
    }
    if (n != 1) cout << " " << n;
    cout << endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define Rep(i,N) for(i=0;i<N;i++);
#define mod 1000000007

long mmax(long a,long b,long c){return a<b?max(b,c):max(a,c);}

long mmin(long a,long b,long c){return a<b?min(a,c):min(b,c);}

long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

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

long long modncr(long long n,long long r){
  long long i,plus=1;
  for(i=0;i<r;i++){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

long long euclidean_gcd(long long a, long long b) {
  if(a < b) return euclidean_gcd(b, a);
  long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int i,N,K;
  char ss[5];
  vector<int> a(5);
  scanf("%s",ss);
  for(i=0;i<4;i++){
    a[i]=ss[i]-'a';
  }
  sort(a.begin(),a.end());
  if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
using namespace std;


void solve()
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans1=a*c;
ll ans2=a*d;
ll ans3=b*c;
ll ans4=b*d;

cout<<max(max(ans1,ans2) , max(ans3,ans4)) ;
}


int32_t main()
{
FAST
l T=1;
//cin>>T;
while(T--)
{
solve();
}
}










Measured memory_bytes: 3652
import java.io.IOException;
import java.util.StringTokenizer;

class Main{

	public static void main(String[] args) throws IOException {
		java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
		try{
			String s = in.readLine();
			StringTokenizer st;
			while(s != null){
				st = new StringTokenizer(s);
				int p = Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken());
				System.out.println((int)Math.log10(p)+1);
				s = in.readLine();
			}
		}catch(Exception ex){
			System.exit(0);
		}
	}
}

Measured memory_bytes: 15052
while (True):
    H,W = map(int,input().split())
    if H == W and H==0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2 ==0:
                print("#",end="")
            else:
                print(".",end="")
        print("")
    print("")


Measured memory_bytes: 7012