akhauriyash/Code-Regression huggingface dataset:
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

use std::cmp::{min, Ordering, Reverse};
use std::collections::BinaryHeap;

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

type Graph = Vec<Vec<(usize, usize, i64)>>;

fn for_each_adjacent_states<F: FnMut(usize, usize, i64)>(
    t: usize,
    k: usize,
    exchs: &Vec<(usize, i64)>,
    g: &Graph,
    smax: usize,
    mut f: F,
) {
    let (c, d) = exchs[t];
    f(t, min(k + c, smax), d);
    for &(t_, a, b) in &g[t] {
        if k >= a {
            f(t_, k - a, b);
        }
    }
}

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let n = tr.read();
    let m = tr.read();
    let s = tr.read();
    let rails: Vec<(usize, usize, usize, i64)> =
        (0..m).map(|_| (tr.read(), tr.read(), tr.read(), tr.read())).collect();
    let exchs: Vec<(usize, i64)> =
        (0..n).map(|_| (tr.read(), tr.read())).collect();

    let mut g: Graph = vec![vec![]; n];
    for i in 0..m {
        let (u, v, a, b) = rails[i];
        g[u - 1].push((v - 1, a, b));
        g[v - 1].push((u - 1, a, b));
    }

    let smax = rails.iter().map(|(_, _, a, _)| a).sum::<usize>();
    let mut ws: Vec<Vec<i64>> = vec![vec![std::i64::MAX; smax + 1]; n];
    let mut q = BinaryHeap::new();

    q.push((Reverse(0), 0, min(s, smax)));

    while !q.is_empty() {
        let (Reverse(w), t, k) = q.pop().unwrap();
        if ws[t][k] < w {
            continue;
        }

        for_each_adjacent_states(t, k, &exchs, &g, smax, |t_, k_, d| {
            let w_ = w + d;
            if ws[t_][k_] > w_ {
                q.push((Reverse(w_), t_, k_));
            }
            for i in 0..=k_ {
                if ws[t_][k_ - i] <= w_ {
                    break;
                }
                ws[t_][k_ - i] = w_;
            }
        });
    }

    for t in 1..n {
        println!("{}", ws[t][0]);
    }
}


Measured memory_bytes: 3128
import java.io.*;
public class Main {
	public static void main(String[] args){
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		try{
		String s = input.readLine();
		int x=Integer.parseInt(s);
		System.out.println(x*x*x);
		}catch(IOException e){}
		}

	}

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

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

    ll ans = 1, bCnt = 0;
    FOR(i, 2, N + 1) {
        ll tmp = i, cnt = 0;
        while(tmp % 2 == 0) {
            ++cnt;
            tmp /= 2;
        }

        if(cnt > bCnt) {
            bCnt = cnt;
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define M 100001
int n,d[M];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>d[i];
	sort(d+1,d+n+1);
	cout<<d[n/2+1]-d[n/2];
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,P;
  cin>>A>>P;
  A*=3;
  P+=A;
  cout<<P/2<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long a[] = new long[num];
		long b[] = new long[num];
		for(int i = 0; i < num; i ++) {
			a[i] = sc.nextLong();
			b[i] = a[i];
		}
		Arrays.sort(a);
		int count = 0;
		for(int i = 0; i < num; i ++) {
			if(a[i] != b[i]) { count ++; }
		}

		System.out.println(count <= 2 ? "YES" : "NO");
	}
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n,m;
P A[SIZE];

int main()
{
	scanf("%d%d",&n,&m);
	int a,b;
	for(int i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		A[i].first = a;
		A[i].second = b;
	}
	if(m==1){
		printf("1\n");
		return 0;
	}
	sort(A,A+m);
	int l=A[0].first,r=A[0].second,lt,rt;
	int cnt=0;
	for(int i=1;i<m;i++){
		lt = A[i].first;
		rt = A[i].second;
		if(r <= lt){
			cnt++;
			l=lt;
			r=rt;
		}else{
			l=lt;
			r = min(r,rt);
		}
	}
	cnt++;
	printf("%d\n",cnt);

	return 0;
}


Measured memory_bytes: 1024
import sys
import numpy as np
from operator import mul
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

d = int(readline())
c = list(map(int, readline().split()))
s = []
for _ in range(d):
    add = list(map(int, readline().split()))
    s.append(add)

#t = [0] * d
day = 0
satisfy = 0
sumC = sum(c)
count = np.zeros(26)

for i in range(d):
    t = int(readline()) - 1
    up = s[day][t]
    count += 1
    count[t] = 0
    sub = map(mul, count, c)
    satisfy += (up - sum(sub))
    # satisfy
    print(int(satisfy))
    day += 1


Measured memory_bytes: 27072
from scipy.ndimage import distance_transform_cdt
H,W=map(int, input().split())
S=list(list(input()) for h in range(H))
for h in range(H):
    for w in range(W):
        if S[h][w]=="#":
            S[h][w]=0
        else:
            S[h][w]=1

print(distance_transform_cdt(S, metric='taxicab').max())


Measured memory_bytes: 52740
import numpy as np
mod=10**9+7
n=int(input())
A=list(map(int,input().split()))
A=np.array(A)

ans=0
for i in range(60):
    cnt=np.count_nonzero(A&1)
    ans +=2**i*cnt*(n-cnt)
    A >>=1

print(ans%mod)

Measured memory_bytes: 48824
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
const int N = 2e5+5;


vector<ll>ans,veca,vecb;
vector<int>adj[N];
vector<double>aka;
vector<pair<int,double>>dp[N];
vector<bool>vis;


void init(int n){
    ans.clear();veca.clear();aka.clear();vis.clear();ans.resize(n);
    vecb.clear(),vecb.resize(n);veca.resize(n);vis.resize(n);
    for (int i = 0; i <n; i++) {
        vis[i]=0;
    }
    for (int i = 0; i<=n; i++) {
        adj[i].clear();
    }
    for (int i = 0; i <=n; i++) {
        dp[i].clear();
    }
    for (int i = 0; i < n; i++) {
        ans[i]=0;
    }
}
int power(int a,int n){
    int res=1;
    for (int i = 0; i < n; i++) {
        res=(1LL*res*a)%mod;
    }
    return res%mod;
}
int add(int a){
    if(a<0) a+=mod;
    return a;
}
void solve(){
    int n;
    cin>>n;
    init(n);
    for (int i = 0; i <n; i++) {
        cin>>veca[i];
    }
    int flag=veca[0];
    for (int i = 1; i < n; i++) {
        if(veca[i]<flag){
            ans[i]=(flag-veca[i]);
            continue;
        }
        flag=veca[i];
    }
    ll cnt=0;
    for (int i = 0; i < n; i++) {
        cnt+=ans[i];
    }
    cout<<cnt<<"\n";
}

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

Measured memory_bytes: 17364
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		String s=sc.next();
		StringBuilder sb=new StringBuilder();
		for(int i=0; i<s.length(); i++) {
			sb.append((char)((s.charAt(i)-68+26)%26+65));
		}
		pl(sb.toString());
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24288
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let b = buf.trim();
	if b == "A" {
		println!("T");
	}else if b == "C" {
		println!("G");
	}else if b == "T" {
		println!("A");
	}else{
		println!("C");
	}
}

Measured memory_bytes: 4352
def main():
    n, *v = map(int, open(0).read().split())
    be = [0] * int(1e5)
    bo = [0] * int(1e5)
    for e, o in zip(*[iter(v)] * 2):
        be[e - 1] += 1
        bo[o - 1] += 1
    ve = max(be)
    vo = max(bo)
    ke = be.index(ve)
    ko = bo.index(vo)
    if ke == ko:
        be[ke] = 0
        bo[ko] = 0
        print(min(n - ve - max(bo), n - vo - max(be)))
    else:
        print(n - ve - vo)
    return


main()


Measured memory_bytes: 14324
// PA.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。
//

#include <iostream>
using namespace std;
int main()
{
	int year, yen;
	while (cin >> year >> yen)
	{
		if (year <= 5 && year >= 0)
		{
			cout << 0 << '\n';
		}
		else if (year >= 6 && year <= 12)
		{
			cout << yen / 2 << '\n';
		}
		else if (year >= 13)
		{
			cout << yen << '\n';
		}
	}
}

// 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表
// 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表

// 開始使用的提示: 
//   1. 使用 [方案總管] 視窗，新增/管理檔案
//   2. 使用 [Team Explorer] 視窗，連線到原始檔控制
//   3. 使用 [輸出] 視窗，參閱組建輸出與其他訊息
//   4. 使用 [錯誤清單] 視窗，檢視錯誤
//   5. 前往 [專案] > [新增項目]，建立新的程式碼檔案，或是前往 [專案] > [新增現有項目]，將現有程式碼檔案新增至專案
//   6. 之後要再次開啟此專案時，請前往 [檔案] > [開啟] > [專案]，然後選取 .sln 檔案


Measured memory_bytes: 256
H, W, D = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(H)]

aToHW = {}
for h in range(H):
    for w, a in enumerate(A[h]):
        aToHW[a] = (h, w)

cnt = [-1] * (H * W + 1)
for start in range(1, H * W + 1)[:: -1]:
    c = 0
    for now in range(start, H * W + 1, D):
        if now + D > H * W:
            break
        if cnt[now] >= 0:
            c += cnt[now]
            break

        nH, nW = aToHW[now]
        tH, tW = aToHW[now + D]
        c += abs(nH - tH) + abs(nW - tW)
    cnt[start] = c

Q = int(input())
ans = []
for _ in range(Q):
    L, R = map(int, input().split())
    ans.append(cnt[L] - cnt[R])

print(*ans, sep='\n')

Measured memory_bytes: 29108
#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()
{
    string S, T;
    cin >> S >> T;
    int ans = 1e9;
    int lens = (int)S.size(), lent = (int)T.size();
    rep(i, lens - lent + 1) {
        int cnt = 0;
        rep(j, T.size()) {
            if (S[i + j] == T[j]) cnt++;
        }
        chmin(ans, lent - cnt);
    }

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

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line="";
		int[] months = {31,29,31,30,31,30,31,31,30,31,30,31};
		while(!(line = br.readLine()).equals("0 0")){
			String[] s =line.split(" ");
			int month = Integer.parseInt(s[0]);
			int day = Integer.parseInt(s[1]);
			int sum = 0;
			for(int i = 1; i<month;i++){
				sum+=months[i-1];
			}
			sum += day;
			switch(sum%7){
			case 0:
				System.out.println("Wednesday");
				break;
			case 1:
				System.out.println("Thursday");
				break;
			case 2:
				System.out.println("Friday");
				break;
			case 3:
				System.out.println("Saturday");
				break;
			case 4:
				System.out.println("Sunday");
				break;
			case 5:
				System.out.println("Monday");
				break;
			case 6:
				System.out.println("Tuesday");
				break;
			}
		}

	}

}

Measured memory_bytes: 24188
#include<stdio.h>
int main(void){
	int a[10000]={0},i,k,small,max;
	long long gou;
	gou=0;
	scanf("%d",&i);
	for(k=0;k<i;k++){
		scanf("%d",&a[k]);
	}
	small=a[0];
	max=a[0];
	
	for(k=0;k<i;k++){
	
		
		if(small>a[k]){
		small=a[k];
		}
		
		if(max<a[k]){
		max=a[k];
		}
		
		
		
		gou+=a[k];
		
	}
	
	printf("%d %d %lld\n",small,max,gou);
	
}

Measured memory_bytes: 2756
#include<stdio.h>

int main(){
  int a,b ;
  scanf("%d%d",&a,&b);
  if (a < b){
    printf("a < b\n");
  } else if(a > b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }
 return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"
#define P           pair<int, int>
#define dint        long double


const int N = 2e5+5;
const int inf = 1e18;
vector<int> g[N];
int n;
int a[N];
int ans[N];

void dfs(int u, int par, vector<int> &dp) {
    int lb = lower_bound(dp.begin(), dp.end(), a[u]) - dp.begin();
    ans[u] = max(lb, ans[par]);
    int prv = dp[lb];
    if(dp[lb] > a[u]) {
        dp[lb] = a[u];
    }
    for(int v : g[u]) if(v != par) {
        dp.push_back(inf);
        dfs(v, u, dp);
        dp.pop_back();
    }
    dp[lb] = prv;
}

void solve() {
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=1; i<n; i++) {
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> dp;
    dp.push_back(-inf);
    dp.push_back(inf);
    dfs(1, 0, dp);
    for(int i=1; i<=n; i++) {
        cout << ans[i] << "\n";
    }
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve();
    }
    return 0;

}



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

Measured memory_bytes: 3644
// Problem: Many Formulas
// Contest: Virtual Judge - AtCoder
// URL: https://vjudge.net/problem/AtCoder-arc061_a
// Memory Limit: 262 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////

char str[N];
LL getval(int l,int r){
  LL res=0;
  rep(i,l,r)res=res*10+str[i]-'0';
  return res;
}

LL f[N],f2[N];
void Solve(){
  cin>>str+1;
  int len=strlen(str+1);
  f2[0]=1;
  rep(i,1,len){
    rep(j,1,i){
      f2[i]+=f2[j-1];
      f[i]+=f[j-1]+f2[j-1]*getval(j,i);
    }
  }
  cout<<f[len]<<endl;
} 


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
    int N;
    int i;
    scanf("%d",&N);
    int A[N];

    for(i = 0;i < N;i++){
    scanf("%d",&A[i]);
    }

    int d = 0;
    int manufaction = 1,count = 0;
    while(manufaction == 1){
        
        for(i = 0;i < N;i++){
            d += A[i] % 2;
            /*printf("%d\n",A[i]);*/
            /*printf("d = %d\n",d);*/
            }

        if(d == 0){
            count++; 
            for(i = 0;i < N;i++){
                A[i] = A[i]/2;
                  
                }
            }else{
                manufaction = 0;
        }    
    }
    printf("%d",count);

    return 0;
}

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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<pair<int,int>>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first;
        v[i].second=i+1;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++) cout<<v[i].second<<" ";
    return 0;
}


Measured memory_bytes: 1664
N, X, Y, Z = map(int, input().split())
MOD = 10 ** 9 + 7
ng = (1 << (Z - 1)) + (1 << (Y + Z - 1)) + (1 << (X + Y + Z - 1))
S = (1 << (X + Y + Z)) - 1

dp = [[0] * (S + 1) for i in range(N + 1)]

dp[0][0] = 1
for i in range(1, N + 1):
    for j in range(S + 1):
        for k in range(1, 11):
            s = ((j << k) | 1 << k - 1) & S
            if (s & ng) == ng:
                continue
            dp[i][s] += dp[i - 1][j]
            dp[i][s] %= MOD


ans = pow(10, N, MOD)
num = 0
for i in range(S + 1):
    num += dp[N][i]
    num %= MOD

print((ans - num + MOD) % MOD)

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

int main() {
  
  int N,A,B;
  
  cin >> N >> A >> B;
  
  if (A*N >= B) {
    cout << B << endl;
  }
  if (A*N < B) {
    cout << A*N << endl;
  }
        
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		int D=stdIn.nextInt();
		
		while(A>0&&C>0) {
			C=C-B;
			if(C<=0)break;
			A=A-D;
		}
		if(A<=0)
			System.out.println("No");
		else
			System.out.println("Yes");

	}

}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

vector<int>::iterator bin_search(vector<int>& vec, const int& key) {
  int a = 0, b = vec.size() - 1;

  while (a <= b) {
    int c = (a + b) / 2;
    if (key == vec[c])
      return vec.begin() + c;
    else if (key < vec[c])
      b = c - 1;
    else
      a = c + 1;
  }

  return vec.begin() + a;
}

int main(int argc, char* argv[]) {
  const int N = 2e5 + 1;
  char A[N];
  int slen;

  scanf("%s", A);
  slen = strlen(A);

  set<char> s;
  vector<int> pos1[26];
  vector<int> pos2;

  for (int i = slen - 1; i >= 0; i--) {
    pos1[A[i] - 'a'].push_back(i);
    s.insert(A[i]);

    if (s.size() == 26) {
      s.clear();
      pos2.push_back(i);
    }
  }

  FOR(i, 26) reverse(pos1[i].begin(), pos1[i].end());
  reverse(pos2.begin(), pos2.end());

  string ans;
  int i = 0;
  int pos = 0;
  while (i < pos2.size()) {
    for (char c = 'a'; c <= 'z'; c++) {
      auto it = bin_search(pos1[c - 'a'], pos);
      if (it == pos1[c - 'a'].end() || pos2[i] <= *it) {
        ans += c;
        i++;
        pos = *it + 1;
        break;
      }
    }
  }

  for (char c = 'a'; c <= 'z'; c++) {
    auto it = bin_search(pos1[c - 'a'], pos);
    if (it == pos1[c - 'a'].end()) {
      ans += c;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)

const int maxn = 2e5 + 5;
int N, A[maxn], L[maxn], R[maxn];
int sta[maxn], top;

int main() {
  scanf("%d", &N);
  foru(i, 1, N) scanf("%d", &A[i]);
  top = 0;
  foru(i, 1, N) {
    while (top && A[sta[top]] > A[i]) top--;
    L[i] = sta[top], sta[++top] = i;
  }
  sta[top = 0] = N + 1;
  ford(i, N, 1) {
    while (top && A[sta[top]] > A[i]) top--;
    R[i] = sta[top], sta[++top] = i;
  }
  long long Ans = 0;
  foru(i, 1, N) {
    long long len_l = i - L[i];
    long long len_r = R[i] - i;
    Ans += len_l * len_r * A[i];
  }
  printf("%lld\n", Ans);
  return 0;
}


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

long long N;
vector<pair<long long, long long> >tree[100005];
long long color[100005];

void dfs(long long cur) {
	for(long long i = 0; i < tree[cur].size(); i++){
		long long to = tree[cur][i].first;
		long long distance = tree[cur][i].second;
		if(color[to] != 0){
			continue;
		}
		if(distance % 2 == 0){
			color[to] = color[cur];
		} else {
			color[to] = -1 * color[cur];
		}
		dfs(to);
	}
}

int main(){
	cin >> N;
	for(long long i = 0; i < N - 1; i++){
		long long u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		tree[u].push_back(make_pair(v, w));
		tree[v].push_back(make_pair(u, w));
	}
	color[0] = 1;
	dfs(0);

	for(long long i = 0; i < N; i++){
		if(color[i] == 1){
			cout << 0 << endl;
		} else {
			cout << 1 << endl;
		}
	}
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    int a[7]={1,3,5,7,8,10,12};
    int b[7]={4,6,9,11};
    if(x==2) cout<<"No\n";
    else if(x==1 || x==3 || x==5 || x==7 || x==8 || x==10)
    {
        for(int i=0;i<7;i++)
        {
            if(y==a[i])
                {cout<<"Yes\n";return 0;}

        }
        cout<<"No\n";
    }
    else
    {
        for(int i=0;i<4;i++)
        {
            if(y==b[i])
            {cout<<"Yes\n";return 0;}
        }
        cout<<"No\n";
    }
}


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

int main(){
    int a;
    cin >> a;
    int ans;
    ans = a+a*a+a*a*a;
    ans = a + std::pow(a, 2) + std::pow(a,3);
    cout << ans << endl;
}

Measured memory_bytes: 4036
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = a[0]
    for i in range(1,n):
        b = b^a[i]
    ans = []
    for i in range(n):
        ans.append(b^a[i])
    print(*ans)
if __name__ == "__main__":
    main()

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

using namespace std;

int main(int argc, char * argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int tv = 0;

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

    int c = 0;
    double min = (double)tv/(double)(4*m);

    for(auto v : a) {
        if(((double)v - min) >= 0)
            ++c;
        if(c == m) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}



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

int main(){

    ll n,k;
    cin >> n >>k;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }

    vector<ll> roop;
    map<ll,int> count;
    map<ll,ll> ain;
    ll nextc = 1;
    roop.push_back(0);
    count[0] ++;
    ain[0] = 0;
    ll loopc;
    rep(i,n){
        count[a[nextc-1]] ++;
        if(count[a[nextc-1]] == 2){
            loopc = a[nextc-1];
            break;
        }else{
            ain[a[nextc-1]] = i+1;
        }
        roop.push_back(a[nextc-1]);
        nextc = a[nextc-1];
    }

    if(k < roop.size()){
        cout << roop[k];
    }else {
        cout << roop[ain[loopc] + (k-roop.size()) % ( roop.size() - ain[loopc])] << endl;
    }
    return 0;
}


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

using namespace std;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define ll long long
const double pi=acos(-1);
const int maxn=1e6+10;
const int mod=1e9+7;


int main()
{
    int n,m;
    cin>>n>>m;
    printf("%d",(n*(n-1)/2+m*(m-1)/2));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;

    if(a % 2 == 0 || b % 2 == 0)
    {
        cout << "Even";
    }
    else
    {
        cout << "Odd";
    }
}

Measured memory_bytes: 768
#include <stdio.h>

int const M = 998244353;
int i, n, x, c[7 << 14];

int pow(int a, int b) {
  int r = 1;
  for(; b; b >>= 1) {
    if(b & 1)
      r = (long long) r * a % M;
    a = (long long) a * a % M;
  }
  return r;
}  

int main() {
  scanf("%d%d", &n, &x);
  int r = 0;
  if(x == 0) {
    for(i = 0; ++i < n; c[x]++) scanf("%d", &x);
    if(c[0] == 0) {
      c[0] = r = 1;
      for(i = 0; c[++i];) {
        n -= c[i];
        r = (long long) r * pow(c[i - 1], c[i]) % M;
      }
    }
  }
  printf("%d\n", n > 1 ? 0 : r);
  return 0;
}


Measured memory_bytes: 512
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto H = RD!int;
	auto W = RD!int;
	auto a = new string[](H);
	foreach (y; 0..H)
		a[y] = RD!string;

	auto cnt = new long[](26);
	foreach (y; 0..H)
	{
		foreach (x; 0..W)
		{
			++cnt[a[y][x]-'a'];
		}
	}

	bool ans = true;
	auto hh = H/2;
	auto ww = W/2;
	foreach (i; 0..hh*ww)
	{
		auto pos = cnt.MIN_POS!"a > b"();
		if (cnt[pos] < 4)
		{
			ans = false;
			break;
		}
		cnt[pos] -= 4;
	}

	auto hhh = H%2;
	auto www = W%2;
	foreach (i; 0..hhh*ww+www*hh)
	{
		auto pos = cnt.MIN_POS!"a > b"();
		if (cnt[pos] < 2)
		{
			ans = false;
			break;
		}
		cnt[pos] -= 2;
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;

int main(){
	int n;
	cin>>n;
	ll a[n],b[n];
	plll tmp[n];
	rep(i,n){
		cin>>a[i]>>b[i];
		tmp[i].second=pll(a[i],b[i]);
		tmp[i].first=a[i]+b[i];
	}
	sort(tmp,tmp+n);
	ll taka=0,aoki=0;
	for(int i=n-1;i>=0;i--){
		if((n-1-i)%2)aoki+=tmp[i].second.second;
		else taka+=tmp[i].second.first;
	}
	cout<<taka-aoki<<endl;
	return 0;
}

Measured memory_bytes: 7492
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n, m);
    makev(a, n);
    int sm = accumulate(ALL(a), 0ll);
    int z = 0;
    for(int i = 0; i < n; ++i){
       if (a[i] * 4 * m >= sm){
           z++;
       }
    }
    if (z >= m){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 256
N = int(input())
M = [input().split() for i in range(N)]
O = [M[j][0] for j in range(N)]
P = list(set(O))
P.sort()
Q = [int(M[k][1]) for k in range(N)]
Q.sort()
Q.reverse()
for l in P:
  for m in Q:
    R = [l, str(m)]
    if (R in M) == True:
      print(M.index(R) + 1)

Measured memory_bytes: 3064
using System;
class Program
{
	static void Main()
	{
	string input = Console.ReadLine();

  int i = 0;
  int j = input.Length -1;
  int answer = 0;
  do
  {
    if(input[i] == input[j])
    {
    i++;
    j--;
    }
    else if(input[i] == 'x')
    {
    i++;
    answer++;
    }
    else if(input[j] == 'x')
    {
    j--;
    answer++;
    }
    else
    {
    answer = -1;
    break;
    }
  } while(j-i > 0);

	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 13120
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    a = []
    for i in range(n):
        a.append(read_int(1)[0])
    return a


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    return len(set(a))


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 38256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
   int n;
   long long  s02=0,s=0;
   cin >> n;
   vector<long long> a(n);
   vector<long long> p(n);
   for(int i=0; i<n; i++){
       cin >> a.at(i);
       if(i%2==0){
           s02+=a.at(i);
       }
       else{
           s+=a.at(i);
       }
   }
   p.at(0)=(s02-s)/2;
   for(int i=1; i<n; i++){
       p.at(i)=a.at(i-1)-p.at(i-1);
   }
   for(int i=0; i<n-1; i++){
       cout << p.at(i)*2 << " " ;
   }
   cout << p.at(n-1)*2  <<endl;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;

const int M = 60;
const ll MOD = 1e9 + 7;

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

    ll res = 0;
    int n;
    cin >> n;
    vector<int> dp(M);
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        for (int j = 0; j < M; j++) {
            ll p = 1LL << j;
            const ll b = x & p;
            int cnt;
            if (b)
                cnt = i - dp[j]++;
            else
                cnt = dp[j];

            p %= MOD;
            (res += cnt * p) %= MOD;
        }
    }

    cout << res << '\n';
}

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

int main()
{	
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
    int n;
    cin >> n;
    ll mn = 1e18, mnn = 1e18;
    ll mx = -1e18, mxx = -1e18;
    while (n--)
    {
        ll x, y;
        cin >> x >> y;
        mn = min(mn, x + y);
        mx = max(mx, x + y);
        mnn = min(mnn, x - y);
        mxx = max(mxx, x - y);
    }
    cout << max(mx - mn, mxx - mnn);
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int main(void){
    int K, S; cin >> K >> S;
    ll ans = 0;
    rep(x, K + 1) {
        rep(y, K + 1) {
            int z = S - x - y;
            if (0 <= z && z <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
static const int N =100;



int main()
{
  int O[N][N];
  int n, a, b, c, i, j;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++) O[i][j] = 0;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d %d",&a,&b);
      a--;
      for(j=0;j<b;j++)
	{
	  scanf("%d",&c);
	  c--;
	  O[a][c] = 1;
	}
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(j)printf(" ");
	  printf("%d",O[i][j]);
	}
      printf("\n");
    }


  return 0;
}



Measured memory_bytes: 2148
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define INF (INT_MAX >> 1)

using namespace std;

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

    map<int, bool> numMap;

    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        numMap[a] ^= true;
    }

    int count = 0;
    
    for (auto i : numMap) {
        if (i.second)
            count++;
    }

    cout << count << endl;

    return 0;
}


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

int main() {  
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  vector<int> number(n);
  
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    number.at(a.at(i)-1)++;
  }
  sort(number.begin(), number.end());
  
  int ans = 0;
  for(int i = n-1; i >= n-k; i--) {
    ans += number.at(i);
  }
    
  cout << n-ans << endl;

}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    n /= 2;
    long long m = 5;
    long long ans = 0;
    while (n >= m) {
        ans += n / m;
        m *= 5;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
// $n = (int)trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$k = (int)$input[1];
$s = trim(fgets(STDIN));

$map = [
	'A' => 'a',
	'B' => 'b',
	'C' => 'c',
];
$s[$k-1] = $map[$s[$k-1]];

echo $s;

Measured memory_bytes: 4728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace panasonic2020
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int[] ans = new int[32] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
            int k = int.Parse(Console.ReadLine());
            Console.WriteLine(ans[k - 1]);
        }
    }
}


Measured memory_bytes: 11092
S = input()
n = len(S)
# create ptn
ptn = []
for bit in range(2**(n-1)):
    p = []
    for i in range(n-1):
        if ((bit>>i)&1):
            p.append('+')
        else:
            p.append('-')
    ptn.append(p)
# calc
for p in ptn:
    for i, s in enumerate(S):
        if i == 0:
            result = int(s)
            continue
        if p[i-1]=='+':
            result += int(s)
        else:
            result -= int(s)
    if result == 7:
        print('{}{}{}{}{}{}{}=7'.format(S[0],p[0],S[1],p[1],S[2],p[2],S[3]))
        break

Measured memory_bytes: 3064
N = int(input()) - 1
A = list(map(int, input().split()))

ans = int(A[N])

if 0 in A:
    ans = 0
else:
    while N > 0:
        ans = ans * A[N-1]
        N = N-1
        if ans > 10 ** 18:
            N = 0
        else:
            N = N

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21652
N = int(input())
L = list(map(int, input(). split()))
count = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if (L[i] + L[j] > L[k])and(L[j] + L[k] > L[i])and(L[k] + L[i] > L[j])and(L[i] != L[j])and(L[j] != L[k])and(L[k] != L[i]):
                count += 1
            else:
                continue
print(count)

Measured memory_bytes: 9076
/*  -*- coding: utf-8 -*-
 *
 * 2931.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef stack<int> sti;

/* global variables */

int qs[MAX_N];
char s[MAX_N * 2 + 4];
sti st;

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int pi;
    scanf("%d", &pi);
    pi--;
    qs[pi] = i;
  }
  //for (int i = 0; i < n; i++) printf("%d ", qs[i]); putchar('\n');

  for (int i = 0, j = 0, k = 0; i < n || j < n; i++) {
    while (! st.empty() && st.top() == j)
      s[k++] = ')', j++, st.pop();

    if (i >= n) {
      if (j < n) {
	puts(":(");
	return 0;
      }
      break;
    }

    st.push(qs[i]);
    s[k++] = '(';
  }

  puts(s);
  return 0;
}



Measured memory_bytes: 3804
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>

using namespace std;

const int mod = 1e9+7;

int main() {
	int n;
	long long K;
	scanf("%d%lld", &n, &K);

	int a[n][n];
	long long x[n][n];
	for(int i=0; i<n; i++) {
		for(int j=0; j<n; j++) {
			scanf("%d", &a[i][j]);
			x[i][j] = a[i][j];
		}
	}
	long long prod[n][n];
	memset(prod, 0, sizeof prod);
	for(int i=0; i<n; i++) prod[i][i] = 1;
	while(K>0) {
		if(K&1) {
			// prod = prod * x;
			long long tmp[n][n];
			for(int i=0; i<n; i++) for(int j=0; j<n; j++) tmp[i][j] = prod[i][j];
			memset(prod, 0, sizeof prod);
			for(int i=0; i<n; i++) {
				for(int j=0; j<n; j++) {
					for(int k=0; k<n; k++) {
						prod[i][k] += tmp[i][j] * x[j][k] % mod;
					}
				}
			}
			for(int i=0; i<n; i++) for(int j=0; j<n; j++) prod[i][j] %= mod;
		}
		// x = x * x;
		{
			long long tmp[n][n];
			for(int i=0; i<n; i++) for(int j=0; j<n; j++) tmp[i][j] = x[i][j];
			memset(x, 0, sizeof x);
			for(int i=0; i<n; i++) {
				for(int j=0; j<n; j++) {
					for(int k=0; k<n; k++) {
						x[i][k] += tmp[i][j] * tmp[j][k] % mod;
					}
				}
			}
			for(int i=0; i<n; i++) for(int j=0; j<n; j++) x[i][j] %= mod;
		}
		K >>= 1;
	}
	long long sum = 0;
	for(int i=0; i<n; i++) {
		for(int j=0; j<n; j++) {
			sum += prod[i][j];
		}
	}
	printf("%lld\n", sum % mod);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int n;

int main() {
    cin >> n;
    vector<int> a(n);
    for (auto& ai : a) cin >> ai;

    sort(a.rbegin(), a.rend());

    int diff = 1e9+7, j = -1;
    for (int i = 1; i < n; ++i) {
        int d = abs(a[0] / 2 - a[i]);
        if (d < diff) {
            diff = d;
            j = i;
        }
    }

    cout << a[0] << " " << a[j] << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
#define M 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<endl;
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e];
using namespace std;

int main()
{
	fastio;
	LL a, i;
	cin>>a;
	LL ans=a-1;
	for(i=floor(sqrt(a))+1; i>1; i--){
		if(a%i==0){
			ans = (a/i-1) + (i-1);
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256