akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007

/*  0 = NONE
	1 = A
	2 = G
	3 = AC
	4 = AG
	5 = GA
	6 = AT
	7 = ATG
	8 = AGT
	9 = AGG
	10 = ATGC
	11 = AGTC
	12 = AGGC
	13 = AGC
	14 = ACG
	15 = GAC
*/	

typedef long long ll;

int n;
ll memo[101][16];

ll MR0X(int i, int st)
{
	if(st == 10 || st == 11 || st == 12 || st == 13 || st == 14 || st == 15)
	return 0;
	if(i == n+1)
	return 1;
	if(memo[i][st] != -1)
	return memo[i][st];
	ll ans = 0;
	if(!st)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 0)%MOD)%MOD)%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 1)%MOD))%MOD) + (MR0X(i+1, 2)%MOD))%MOD;
	else if(st == 1)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 3)%MOD)%MOD)%MOD) + (MR0X(i+1, 4)%MOD))%MOD) + (MR0X(i+1, 6)%MOD))%MOD) + (MR0X(i+1, 1)%MOD))%MOD;
	else if(st == 2)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 5)%MOD)%MOD)%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 2)%MOD))%MOD;
	else if(st == 3)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 1)%MOD)%MOD)%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 14)%MOD))%MOD;
	else if(st == 4)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 5)%MOD)%MOD)%MOD) + (MR0X(i+1, 8)%MOD))%MOD) + (MR0X(i+1, 13)%MOD))%MOD) + (MR0X(i+1, 9)%MOD))%MOD;
	else if(st == 5)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 1)%MOD)%MOD)%MOD) + (MR0X(i+1, 6)%MOD))%MOD) + (MR0X(i+1, 15)%MOD))%MOD) + (MR0X(i+1, 4)%MOD))%MOD;	
	else if(st == 6)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 0)%MOD)%MOD)%MOD) + (MR0X(i+1, 1)%MOD))%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 7)%MOD))%MOD;
	else if(st == 7)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 0)%MOD)%MOD)%MOD) + (MR0X(i+1, 2)%MOD))%MOD) + (MR0X(i+1, 10)%MOD))%MOD) + (MR0X(i+1, 5)%MOD))%MOD;
	else if(st == 8)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 11)%MOD)%MOD)%MOD) + (MR0X(i+1, 2)%MOD))%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 1)%MOD))%MOD;
	else if(st == 9)
	ans = ((((((((ans%MOD) + (MR0X(i+1, 2)%MOD)%MOD)%MOD) + (MR0X(i+1, 0)%MOD))%MOD) + (MR0X(i+1, 12)%MOD))%MOD) + (MR0X(i+1, 5)%MOD))%MOD;
	memo[i][st] = ans;
	return ans;
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	std::cin>>n;
	ll ans = MR0X(1, 0)%MOD;
	std::cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

H, W = map(int, input().split())
C = [None] * 10
for i in range(10):
    C[i] = list(map(int, input().split()))
field = [None] * H
for i in range(H):
    field[i] = list(map(int, input().split()))

# ワーシャルフロイドで全頂点の最短距離
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

ans = 0
for i in range(H):
    for j in range(W):
        if field[i][j] != -1:
            # 該当マスの数字から1への距離を足していくだけ
            ans += C[field[i][j]][1]
print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b)System.out.println("a < b");
		if(a > b)System.out.println("a > b");
		if(a ==b)System.out.println("a == b");
		 }
	 } 

Measured memory_bytes: 17160
// C - Sugar Water

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	set<int> water;
	set<int> sugar;

	for (int i=0; i*100*A<=F; i++) {
		for (int j=0; j*100*B<=F; j++) {
			if ((i*100*A + j*100*B != 0) && (i*100*A + j*100*B <= F)) {
				water.insert(i*100*A + j*100*B);
			}
		}
	}

	for (int i=0; i*C<=F; i++) {
		for (int j=0; j*D<=F; j++) {
			if (i*C + j*D <= F) {
				sugar.insert(i*C + j*D);
			}
		}
	}

	int ans_w = 100*A;
	int ans_s = 0;
	for (int w : water) {
		for (int s : sugar) {
			if (s * (100 + E) > E * (w + s)) continue;
			if (w + s > F) continue;

			if (s * (ans_w + ans_s) > ans_s * (w + s)) {
				ans_w = w;
				ans_s = s;
			}
		}
	}

	cout << ans_w + ans_s << " " << ans_s << endl;

	return 0;
}

Measured memory_bytes: 384
#[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, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($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);
        read_value!($next, [$t; len])
    }};
    ($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! {
        n: usize,
    }
    let mut ans = vec![0; n + 1];
    for i in 1..101 {
        for j in 1..101 {
            for k in 1..101 {
                let val = i * (i + j + k) + j * (j + k) + k * k;
                if val <= n {
                    ans[val] += 1;
                }
            }
        }
    }
    for i in 1..n + 1 {
        puts!("{}\n", ans[i]);
    }
}

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: 2316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N){
    cin >> a.at(i);
  }
  rep(i,N){
    rep(j,N-1){
      if(a.at(j)<a.at(j+1)){
        int temp=a.at(j);
        a.at(j)=a.at(j+1);
        a.at(j+1)=temp;
      }
    }
  }
  int Alice=0;
  int Bob=0;
  rep(i,N){
    if(i%2==0){
      Alice+=a.at(i);
    }
    if(i%2){
      Bob+=a.at(i);
    }
  }
  cout << Alice-Bob << endl;         
}

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    println(solve(readLine()!!.trim()))
}
fun solve(statement: String): String {
    tailrec fun takeWords(position: Int, last: String = "sentinel", length: Int = 0): Triple<String, Int, Int> {
        return when{
            statement.startsWith(last, position) -> Triple(last, position, length)
            statement.length == position -> Triple(last, position, length)
            statement.startsWith("egg", position) -> takeWords(position + 3, "egg", length + 1)
            else -> takeWords(position + 7, "chicken", length + 1)
        }
    }
    tailrec fun sub(position: Int, first: String = "", generation: Int = 0): String {
        return when(position) {
            statement.length -> first
            else -> {
                val (word, pos, gen) = takeWords(position)
                if (generation >= gen) sub(pos, first, generation)
                else sub(pos, word, gen)
            }
        }
    }
    return sub(0)
}


Measured memory_bytes: 30816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    int cnt = 0,ans = 0;
    REP(i,S.size()){
        if(S[i] == 'S') cnt++;
        else{
            if(cnt == 0) ans++;
            else cnt--;
        }
    }
    ans += cnt;
    cout << ans << endl;
}

Measured memory_bytes: 720
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	vector<map<int, int> > ans(11);
	rep(i, 11){
		int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
		do{
			int sum = 0;
			rep(j, i) sum += a[j] * (j+1);
			if(ans[i].count(sum))
				ans[i][sum]++;
			else
				ans[i][sum] = 1;
			reverse(a+i, a+10);
		}while(next_permutation(a, a+10));
	}

	int n, s;
	while(scanf("%d%d", &n, &s) != EOF){
		if(n < 0 || 10 < n)
			puts("0");
		else
			printf("%d\n", ans[n].count(s) ? ans[n][s] : 0);
	}
}

Measured memory_bytes: 824
# 再帰は深くなりすぎる
N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
accum_A, accum_B = [0] * (len(A)+1), [0] * (len(B)+1)
for i in range(len(A)):
    accum_A[i+1] = accum_A[i] + A[i]
for i in range(len(B)):
    accum_B[i+1] = accum_B[i] + B[i]

ans = 0
i, j = len(A), 0
while i >= 0 and j <= len(B) :
    if accum_A[i] + accum_B[j] > K:
        i -= 1
    else:
        ans = max(ans, i+j)
        j += 1

print(ans)


Measured memory_bytes: 117768
#include <bits/stdc++.h>
typedef long long ll;
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define dbg2(x,y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl
#define dbg4(x,y,z,q) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<", "<<#q<<" = "<<q<<endl
#define dbg_array(x,sz) for (int i = 0; i < sz; ++i) cout << x[i] << " \n"[i==sz-1]
using namespace std;

const ll N = 1e5 + 9, M = 400 - 9, Max_ans = 1LL * (1e16);
int ans[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ECLIPSE
	freopen("input.in", "rt", stdin);
	//freopen("output.out", "wt", stdout);
#endif
	int n;
	cin >> n;
	for (int i = 1; i <= 100; ++i)
		for (int j = 1; j <= 100; ++j)
			for (int k = 1; k < 100; ++k) {
				int num = i * i + j * j + k * k + i * j + j * k + i * k;
				++ans[num];
			}
	for (int i = 1; i <= n; ++i)
		printf("%d\n", ans[i]);
	return 0;
}



Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int temp;
    cin>>temp;
    if(temp>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}



Measured memory_bytes: 3632
#b
n=int(input())
d=[int(i) for i in input().split()]

import collections
c = collections.Counter(d)

m=998244353
ans=1
if d[0]!=0 or set(d)!=set(range(len(set(d)))) or 0 in d[1:]:
    print(0)
else:
    for i in range(1,len(c)):
        ans = (ans* c[i-1]**c[i]) %m
    print(ans)

Measured memory_bytes: 75628
S=int(input())
cond=0

if S<=10**9:
 print(0,0,1,0,0,S)
elif S==10**18:
 print(0,0,10**9,0,0,10**9)
else:
 for x2 in reversed(range(1,10**9+1)):
   if int(S/x2)+1 <=10**9:
      print(0,0,x2,1,x2-S%x2,int(S/x2)+1)
      break



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    if (a == b && b == c && a % 2 == 0)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        while (true)
        {
            if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
            {
                int xa = a / 2;
                int xb = b / 2;
                int xc = c / 2;
                a = xa + xc;
                b = xa + xb;
                c = xb + xc;
                ans++;
            }
            else
            {
                cout << ans << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;
ll dp[1000010];
int main(){
	int n; cin >>n;
	for(int i=1;i<=1000010;i++){
		dp[i]=INF;
	}
	dp[0]=0;
	for(int i=1;i<=100000;i++){
		chmin(dp[i],dp[i-1]+1);
		ll a=6;
		while(a<=i){
			chmin(dp[i],dp[i-a]+1);
			a*=6;
		}
		ll b=9;
		while(b<=i){
			chmin(dp[i],dp[i-b]+1);
			b*=9;
		}
	}
	cout << dp[n]<<endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
pair<int, int> a[maxn];
int n;
int t = 0;
int main() {
	cin >> n;
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		a[i] = {y, x};
	}
	sort(a, a + n);
	for(int i = 0; i < n; i++) {
		int A = a[i].second;
		int B = a[i].first;
		if(t + A > B)
			return cout << "No", 0;
		t += A;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 1792
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,l[N],r[N];
priority_queue<ll> L;
priority_queue<ll,vector<ll>,greater<ll>> R;

int main() {
	n=read();
	for (int i=1;i<=n;++i) l[i]=read(),r[i]=read();
	L.push(l[1]),R.push(l[1]); ll addl=0,addr=0,ans=0;
	for (int i=2;i<=n;++i) {
		addl-=r[i]-l[i],addr+=r[i-1]-l[i-1];
		ll lb=L.top()+addl,rb=R.top()+addr;
		if (lb<=l[i]&&l[i]<=rb) L.push(l[i]-addl),R.push(l[i]-addr);
		else if (l[i]<lb) {
			ans+=lb-l[i];
			R.push(lb-addr);
			L.pop(),L.push(l[i]-addl),L.push(l[i]-addl);
		} else {
			ans+=l[i]-rb;
			L.push(rb-addl);
			R.pop(),R.push(l[i]-addr),R.push(l[i]-addr);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  auto v = vector<vector<int>>(n + 1, vector<int>(n + 1, 0));
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    v[r][l]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      v[j][i] += v[j - 1][i];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i - 1; j++) {
      v[i][j + 1] += v[i][j];
    }
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    int sum = v[r][r] - v[r][l - 1];
    cout << sum << endl;
  }
  return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    vector<vector<int>> graph(N);
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        a--;
        if(i) graph[a].emplace_back(i);
        else if(a) ans++;
    }
    auto dfs = [&](auto &&dfs, int cur, int pre, int dep) -> int {
        int n = 1;
        for(auto &to : graph[cur]) {
            if(to == pre) continue;
            n = max(n, dfs(dfs, to, cur, dep + 1) + 1);
        }
        if(pre && n == K) ans++, n = 0;
        return n;
    };
    dfs(dfs, 0, 0, 0);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 16448
a = int(input())
 
AC = 0
WA = 0
TLE = 0
RE = 0
 
for i in range(a):
    s = input()
    if s == "AC":
        AC = AC + 1
        continue
    if s == "WA":
        WA = WA + 1
        continue
    if s == "TLE":
        TLE = TLE + 1
        continue
    if s == "RE":
        RE = RE + 1
        continue
 
 
print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

Measured memory_bytes: 69820
# 桁DP

MOD = 10 ** 9 + 7
DIVISOR = 13
s = gets.chomp.split("")
length = s.length
# dp[上から i 桁まで][13 で割ったあまり]の出現回数
# 桁の自由度(smaller)は本問では不要
dp = (length + 1).times.map { Array.new(DIVISOR, 0) }
# 初期化
# dp[0 桁目まで][13 で割ったあまりが 0]の出現回数は 1
dp[0][0] = 1
# （右から見た）桁数 % 6
mod_memo = [4, 1, 10, 9, 12, 3]

# 桁数分ループする（i は遷移元の桁）
length.times do |i|
  # 13 で割ったあまりの増加分を求める
  addition = mod_memo[(length - i) % 6]
  # 桁の数字が "?" の場合は 10 回ループ、それ以外の場合はその数字のみ
  nums = s[i] == "?" ? (0..9).to_a : [s[i].to_i]
  # 最適化のため、事前に dp を 1 行ずつ参照渡しをする
  # dp_current と dp[i]、dp_next と dp[i + 1] の object_id は同じなので、更新も可能
  dp_current = dp[i]
  dp_next = dp[i + 1]
  # 13 で割ったあまりごとに確認する
  DIVISOR.times do |mod|
    current_count = dp_current[mod] % MOD
    nums.each do |d|
      # 次の桁に遷移する
      dp_next[(mod + addition * d) % DIVISOR] += current_count
    end
  end
end

puts dp[length][5] %= MOD


Measured memory_bytes: 34812
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
#include <complex>

using namespace std;

// deq notes ½Êô½É¨¯éxNgZ http://www.deqnotes.net/acmicpc/2d_geometry/

typedef complex<double> P;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

// àÏ (dot product) : a&#8901;b = |a||b|cosÆ
double dot(P a, P b)
{
	return (a.real() * b.real() + a.imag() * b.imag());
}

// OÏ (cross product) : a~b = |a||b|sinÆ
double cross(P a, P b)
{
	return (a.real() * b.imag() - a.imag() * b.real());
}

// 2¼üÌ¼ð»è : aÛb <=> dot(a, b) = 0
int is_orthogonal (P a, P b)
{
	return EQ( dot(a, b), 0.0 );
}

// 2¼üÌ½t»è: a//b <=> cross(a, b) = 0
int is_paralell (P a, P b)
{
	return EQ ( cross(a, b), 0.0 );
}
//	       ¨   ¨
// PÊxNg e = a/|a|
P unit_vector (P a)
{
	double len = abs(a);
	
	return a/len;
}

// xNgÌñ]
P rotate_vector (P a, double theta )
{
	P r (cos(theta), sin(theta) );

	return a*r;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.th2", "r", stdin);
	string str = "";
	int n;

	while (getline (cin, str ) ){
		n = 0;
		stringstream ss(str);
		ss >> n;
		if (n == -1){
			break;
		} // end if
		P p(1.0, 0.0 );
		P o(0.0, 0.0 );

		int i;
		for (i = 0; i < n - 1; ++i){
			P po = o - p;
			P u = unit_vector (po );
			P v = rotate_vector (u, -M_PI/2.);
			p = p + v;
//			cout << '(' << p.real() << ',' << p.imag() << ')' << endl;
		} // end for
		cout << p.real() << endl;
		cout << p.imag() << endl; 
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  long long t;
  cin>>n>>t;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  long long a[n];
  REP(i,n){
    cin>>a[i];
  }
  long long opt[n]={};//町iでりんごを買って最適に売った時の利益
  vector<int> p[n];//町iで買ったりんごをどの町で売るのが最適か?
  long long M=0;
  for(int i=n-2;i>=0;i--){
    if(M<a[i+1]){
      M = a[i+1];
      p[i].push_back(i+1);
    }else if(M==a[i+1]){
      p[i].push_back(i+1);
      REP(j,(int)p[i+1].size()){
        p[i].push_back(p[i+1][j]);
      }
    }else{
      REP(j,(int)p[i+1].size()){
        p[i].push_back(p[i+1][j]);
      }
    }
    opt[i]=(M-a[i])*(t/2);
  }
  long long maxp=0;
  REP(i,n){
    maxp = max(maxp,opt[i]);
  }
  bool used[n]={};
  int ans=0;
  REP(i,n){
    if(opt[i]==maxp){
      REP(j,(int)p[i].size()){
        if(!used[p[i][j]]){
          ans++;
          used[p[i][j]] = true;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7424
n=input()
s=""
a=""
sd,ad=0,0
for i in range(len(n)):
  if i%2:
    s+="1"
    a+="0"
  else:
    s+="0"
    a+="1"
for i in range(len(n)):
  if n[i]!=a[i]:ad+=1
  if n[i]!=s[i]:sd+=1
print(min(ad,sd))

Measured memory_bytes: 3316
using System;

namespace ABC108_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b;

            b = (a / 2) * ((a + 1) / 2);
            Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var s = Console.ReadLine();

        Console.WriteLine(Regex.IsMatch(s, "^(hi)+$") ? "Yes" : "No");
    }
}


Measured memory_bytes: 16204
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int main() {
  INCANT;
  cin >> N;
  string ans;
  if (N==25) ans = "Christmas";
  else if (N==24) ans = "Christmas Eve";
  else if (N==23) ans = "Christmas Eve Eve";
  else ans = "Christmas Eve Eve Eve";
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),v(100000);
    set<ll> s;
    rep(i,n){
        cin >> a[i];
        a[i]--;
        s.insert(a[i]);
        v[a[i]]++;
    }
    ll cnt=0;
    rep(i,100000){
        if(v[i]>=2) cnt+=v[i]-1;
    }
    if(cnt%2==0) cout << s.size() << endl;
    else cout << s.size()-1 << endl;
    return 0;
}


Measured memory_bytes: 9436
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int power[20];
void function2()
{
	power[0]=1;
	int j;
	for(j=1;j<20;j++)
	{
		power[j]=2*power[j-1];
	}
}
int binary_search(int prefix[][20],int index,int start,int end,int first)
{
	if(start>end)
	   return -1;
	else
	{
		int mid=(start+end)/2;
		int here=prefix[mid][index]-prefix[first-1][index];
		if(here<=1)
		{
			int x=mid;
			int y=binary_search(prefix,index,mid+1,end,first);
			if(y==-1)
			   return x;
			else
			   return y;
		}
		else
		{
			return binary_search(prefix,index,start,mid-1,first);
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int totaleast=0,totalwest=0;
	int n;
	cin>>n;
	string str;
	cin>>str;
	int j;
	for(j=0;j<n;j++)
	{
		if(str[j]=='E')
		   totaleast++;
		else
		  totalwest++;
	}
	int answer=n;
	int east=0,west=0;
	for(j=0;j<n;j++)
	{
		int here;
		if(str[j]=='E')
		{
			east++;
			here=west+(totaleast-east);
			answer=min(answer,here);
		}
		else
		{
			here=west+(totaleast-east);
			answer=min(answer,here);
			west++;
		}
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3860
#include <iostream>
#include <algorithm>
#define MAX 1000000
using namespace std;

int N;

pair<int, int> itv[MAX];

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

    int rate = R;

    if(N < 10){
      rate += 100 * (10 - N);
    }

    cout << rate << endl;
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for (int& x : h) {
    cin >> x;
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  vector<bool> used(n);
  for (int i = 0; i < n; ++i) {
    if (used[i]) {
      continue;
    }
    bool flag = true;
    for (int u : g[i]) {
      flag &= h[u] < h[i];
    }
    if (flag) {
      for (int u : g[i]) {
        used[u] = true;
      }
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 8744
import math
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append(cnt)
  if temp!=1:
    arr.append(1)
  if arr==[]:
    arr.append(1)
  return arr
n = int(input())
if n== 1:
  print(0)
  exit()
x = factorization(n)
c = 0
for xi in x:
  s = 0
  i = 1
  while True:
    if s+i <=xi:
      s += i
      c += 1
    else:
      break
    i += 1    
print(c)


Measured memory_bytes: 9480
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		List<List<Integer>> obs = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			obs.add(new ArrayList<>());
		}
		
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			a--;
			b--;
			
			obs.get(a).add(b);
			obs.get(b).add(a);
		}
		
		int cnt = 0;
		
		outer:
		for (int i = 0; i < n; i++) {
			List<Integer> list = obs.get(i);
			
			int size = list.size();
			if (size == 0) {
				cnt++;
				continue;
			}
			
			for (int j = 0; j < size; j++) {
				if (h[i] <= h[list.get(j)]) {
					continue outer;
				}
			}
			
			cnt++;
		}
		
		System.out.println(cnt);
		
	}
}


Measured memory_bytes: 63228
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;

    vector<vector<int>> sum(N + 1, vector<int>(N + 1, 0));

    rep(i, M) {
        int p, q;
        cin >> p >> q;
        sum[p][q]++;
    }

    rep(i, N) {
        rep(j, N) {
            sum[i + 1][j + 1] += sum[i][j + 1] + sum[i + 1][j] - sum[i][j];
        }
    }

    rep(i, Q) {
        int p, q;
        cin >> p >> q;
        cout << sum[q][q] - sum[p - 1][q] - sum[q][p - 1] + sum[p - 1][p - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int main()
{
	int n,m;
	scan(n,m);
	LL ans;
	ans=(m*1900)+(n-m)*100;
	ans<<=m;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
def lcm(m, n):
    return m*n//gcd(m, n)
n = int(input())
ans = 1
for i in range(n):
    ans = lcm(ans, int(input()))
print("%d" % ans)


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

int main (){
    ll M, Sum, Keta;
    Sum=0;
    Keta=0;
    cin>>M;
    vector<ll> C(M), D(M);
    for(ll i=0; i<M; i++){
        cin>>D.at(i)>>C.at(i);
        Sum += D.at(i)*C.at(i);
        Keta += C.at(i);
    }
  	//cout<<Keta<<" "<<Sum<<endl;
    cout<<(Keta - 1 + (Sum -1) / 9 )<< endl;
}
 

Measured memory_bytes: 3328
#include <stdio.h>

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

  int A[M];
  int a;
  int K;
  for(int i = 0;i <M;i++) A[i] = 0;
  for(int i = 0;i < N;i++){
    scanf("%d",&K);
    for(int j = 0;j < K;j++){
      scanf("%d",&a);
      a--;
      A[a]++;
    }
  }

  int cnt = 0;
  for(int i = 0;i < M;i++){
    if(A[i] == N) cnt++;
  }

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

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var A = cin.nextInt();
            var B = cin.nextInt();



            Console.WriteLine(new int[] { A + B, A - B, A * B }.Max());
        }
    }





    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>

int main(){
   int H, W;
   std::cin >> H >> W;
   std::vector<std::vector<char>> C(H, std::vector<char> (W));
   std::vector<std::vector<char>> Cout(2*H, std::vector<char> (W));
   for (int i=0; i<H; i++){
      for (int j=0; j<W; j++){
         std::cin >> C.at(i).at(j);
      }
   }

   for (int i=0; i<2*H; i++){
      for (int j=0; j<W; j++){
         std::cout << C.at(i/2).at(j);
      }
      std::cout << std::endl;
   }

}



Measured memory_bytes: 256
<?php

$cup = array('A' => 1, 'B' => 0, 'C' => 0);
while (($line = trim(fgets(STDIN))) !== '') {
    list($from, $to) = explode(',', $line);
    $tmp = $cup[$from];
    $cup[$from] = $cup[$to];
    $cup[$to] = $tmp;
}
echo array_search(1, $cup), PHP_EOL;

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

// 移動元と行先と辺のコストを記録する構造体
template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int s, T d) : to(s), cost(d) {}
    Edge(int f, int s, T d) : from(f), to(s), cost(d) {}

    bool operator<(const Edge &e) const {
        return to < e.to;
    }
};

template <typename T>
using Graph = vector< vector< Edge<T> > >;

// 最小共通先祖 (Lowest Common Ancestor, LCA) を求める
// Verified: AOJ GRL_5_C (Lowest Common Ancestor)

template <typename T>
struct TreeLCA {
public:
    int const MAX_LOG_V;
    vector< vector< Edge<T> > > G;
    int root, vn;
    vector< vector<int> > parent;
    vector<int> depth;

    // constructor (Graph, root)
    TreeLCA(vector< vector< Edge<T> > > &_G, int _r) : 
        MAX_LOG_V(35), G(_G), root(_r), vn(G.size()), 
        parent(MAX_LOG_V, vector<int>(vn, 0)), depth(vn, -1)
        { depth[root] = 0; init(vn); }

    void dfs(int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for(int i=0; i<G[v].size(); i++) {
            if(depth[ G[v][i].to ] >= 0) continue;
            if(G[v][i].to != p) dfs(G[v][i].to, v, d+1);
        }
    }

    void init(int V) {
        dfs(root, -1, 0);
        for(int k=0; k+1 < MAX_LOG_V; k++) {
            for(int v=0; v < V; v++) {
                if(parent[k][v] < 0) parent[k+1][v] = -1;
                else parent[k+1][v] = parent[k][parent[k][v]];
            }
        }
    }

    // u と v の最小共通祖先
    int lca(int u, int v) {
        if(depth[u] > depth[v]) swap(u, v);
        for(int k=0; k < MAX_LOG_V; k++) {
            if((depth[v] - depth[u]) >> k & 1) {
                v = parent[k][v];
            }
        }
        if(u == v) return u;
        for(int k=MAX_LOG_V - 1; k>=0; k--) {
            if(parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }

    // u と v のパスの長さ (LCA を使って計算)
    int dist(int u, int v) {
        int anc = lca(u, v);
        return depth[u] + depth[v] - 2 * depth[anc];
    }
};

int main() {
    int N; scanf("%d", &N);
    Graph<int> G(N);
    for(int i=1; i<N; i++) {
        int par; scanf("%d", &par); par--;
        G[par].push_back(Edge<int>(i, 1));
    }
    for(int i=0; i<N; i++) {
        sort(G[i].begin(), G[i].end());
    }

    int root = 0, u = 0;
    long long int ans = 0;
    TreeLCA<int> lca(G, root);
    vector< Edge<int> > children = G[root];
    int max_depth = *max_element(lca.depth.begin(), lca.depth.end());
    for(int t=0; t<max_depth; t++) {
        vector< Edge<int> > nxt_children;
        for(auto e : children) {
            int v = e.to;
            // printf("dist (%d and %d): %d\n", u+1, v+1, lca.dist(u, v));
            ans += (long long int)lca.dist(u, v);
            u = e.to;
            for(auto x : G[v]) {
                nxt_children.push_back(x);
            }
        }
        swap(nxt_children, children);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 30244
# 初期入力
import sys
input = sys.stdin.readline
K_black_num,X_coordinate = (int(x) for x in input().split())

#
start = X_coordinate -K_black_num +1
finish =X_coordinate +K_black_num -1

x =[i for i in range(start,finish+1) ]
print(*x)

Measured memory_bytes: 3060
N = gets.to_i
As = gets.split.map(&:to_i)

# $stdout = File.open(File::NULL, "w")

def main
  max = 0
  sum = 0
  As.each do |a|
    if a > max
      max = a
    else
      sum += max - a
    end
  end
  return sum
end

STDOUT.puts main


Measured memory_bytes: 28060
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,i,res=1;
  int a[N_MAX];
  bool f=1;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  for(i=1;i<n;i++)
    if(a[i]!=a[i-1]||f==0){
      res++;
      f=1;
    }else{
      res--;
      f=0;
    }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int h[n],m[n+1],c=0;
  for(int i=0;i<n+1;i++)
    cin>>m[i];
  for(int i=0;i<n;i++)
    cin>>h[i];
  for(int i=0;i<n;i++)
  {
    if(m[i]>h[i])
      c+=h[i];
    else
    {
      c+=m[i];
      h[i]-=m[i];
      if(m[i+1]>h[i])
      {
        c+=h[i];
        m[i+1]-=h[i];
      }
      else
      {
        c+=m[i+1];
        m[i+1]=0;
      }
    }
  }
  return cout<<c,0;
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, R;
  cin >> N;
  cin >> A;
  
  R = N % 500;
  
  if (R <= A){
	cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R){
    cout << "Left" << endl;
  } else if (L < R){
    cout << "Right" << endl;
  } else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
c = list(input())
li = 0

import sys
if "R" not in c or "W" not in c:
    print (0)
    sys.exit()
    
ans = 0
for i in range(N-1,-1,-1):

    if c[i] == "R":
        while c[li] != "W" and li <= i:
            li += 1
        if li >= i:
            break
        c[i] = "W"
        c[li] = "R"
        ans += 1
print (ans)

Measured memory_bytes: 73620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 1e5+1;
const ll VAL_MAX = 1e5+1;
const ll INF=1e14;

void solve(){
    string s;cin>>s;
    int n=s.size();
    int cnt=0;
    for(int i=0;2*i<=n-1;i++){
    	if(s[i]!=s[n-i-1]){
    		cnt++;
    	}
    	// cout<<i<<" "<<s[i]<<" "<<s[n-i-1]<<nl;
    }
    cout<<cnt;
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b>9) puts("error");
    else cout << a+b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define size_t szt
using ll = long long;
using namespace std;
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3;
  int x4;
  int y3;
  int y4;

  x3 = x2 + (-1) * (y2 - y1);
  y3 = y2 + (x2 - x1);
  cout << x3 << " " << y3 << " ";
  x4 = x3 + (-1) * (y3 - y2);
  y4 = y3 + (x3 - x2);
  cout << x4 << " " << y4 << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
t = 10**9+7
z = list(map(int,input().split() ))
_sum = 0
x = sum(z)
y = len(z)
for i in range(y-1):
    x = x-z[i]
    _sum += (z[i]*x)
        #print("_sum:"+str(_sum))
print(_sum%t)
    

Measured memory_bytes: 31520
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll N,a[200200],h[21],ans;

int main(){
  ans=0;
  cin>>N;
  REP(i,N){
    cin>>a[i];
  }
  ll i=0,j=0,bit=0;
  //[i,j)でbitはxorの結果。
  while(true){
    while(true){
        if(j==N)break;
        if(bit & a[j]){
          break;
        }else{
          bit |=a[j];
          j++;
        }
    }

    while(true){
      ans+=j-i;
      bit &= ~a[i];
      i++;
      if(i==N)break;
      if(!(bit&a[j])){
        break;
      }
    }
    if(i==N)break;
  }

  cout<<ans<<endl;
}


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

int main(){
	string s;
	cin>>s;
	int l=s.size();
	int i;
	int c=0;
	int t=0,f=0;
	for(i=0;i<l;i++){
		if(s[i]=='A'){
		t=i;
		break;	
		}
	}
	for(i=l-1;i>=0;i--){
		if(s[i]=='Z'){
		f=i;
		break;	
		}
	}
	
	
	cout<<f-t+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b:i--)

int main() {
    // your code goes here
    ll n,m,memo,s[100],c[100];
    cin >> n >> m;
    rep(i,1,m) cin >> s[i] >> c[i];
    rep(i,0,9){
        if(n<=2&&i>0) continue;
        if(n==3&&i==0) continue;
        rep(j,0,9){
            if(n<=1&&j>0) continue;
            if(n==2&&j==0) continue;
            rep(k,0,9){
                bool ok=true;
                rep(q,1,m){
                    if(n==1){
                        if(s[q]==1&&k!=c[q]) ok=false;
                    }
                    if(n==2){
                        if(s[q]==1&&j!=c[q]) ok=false;
                        if(s[q]==2&&k!=c[q]) ok=false;
                    }
                    if(n==3){
                        if(s[q]==1&&i!=c[q]) ok=false;
                        if(s[q]==2&&j!=c[q]) ok=false;
                        if(s[q]==3&&k!=c[q]) ok=false;
                    }
                }
                if(ok){
                    if(n==1) cout << k << endl;
                    if(n==2) cout << j << k << endl;
                    if(n==3) cout << i << j << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1" << endl;
    return 0;
}

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

using namespace std;

int main(void) {
  int n, m, a;
  while (cin >> n >> m >> a, n) {
    int line[1001][101][2] = {}, h, p, q, d;
    for (int i = 0; i < m; i++) {
      cin >> h >> p >> q;
      d = (p < q) ? 1 : 0;
      line[h][p][d] = 1;
      line[h][q][(d + 1) % 2] = 1;
    }

    for (int i = 1000; i >= 0; i--) {
      if (line[i][a][0]) a--;
      else if (line[i][a][1]) a++;
    }
    cout << a << endl;
  }

  return 0;
}


Measured memory_bytes: 3864
#include <stdio.h>

int main()
{
    int k, z, a, b, checker = 0, num[1001] = {0};
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    int difference = b - a;

    //bikin range
    for (int i = 0; i <= difference; i++)
    {
        num[a-1] = a;
        if (num[a-1] % k == 0)
        {
            checker = 1;
            break;
        }
        a++;
    }
    checker == 1 ? printf("OK\n") : printf("NG\n");

    return 0;
}

Measured memory_bytes: 1660
void main() {
	auto ip = readAs!(ulong[]), a = ip[0], b = ip[1], x = ip[2];
	ulong tmp;
	ulong f(ulong a) {
		return a == -1 ? 0 : a/x + 1;
	}
	(f(b) - f(a-1)).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256