akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    rep(i, n) {
        ll B = b[i];
        ll aidx = lower_bound(all(a), B) - a.begin();
        ll cidx = c.end() - upper_bound(all(c), B);
        ans += aidx * cidx;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int N, M;
int num[4];
int main() {
    cin >> N >> M;
    memset(num, -1, sizeof(num));
    for (int i=0; i<M; i++){
        int s, c;
        cin >> s >> c;
        if (num[s] != -1 && num[s] != c){
            cout << -1 << endl;
            return 0;
        }
        num[s] = c;
    }
    if (num[1] == 0 && N != 1){
        cout << -1 << endl;
        return 0;
    }
    if (N == 1 && num[1] == -1) cout << 0;
    else cout << (num[1] != -1 ? num[1] : 1);
    for (int i=2; i<=N; i++){
        cout << (num[i] != -1 ? num[i] : 0);
    }
    cout << endl;
    return 0;
}


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

int main(int argc, const char * argv[]) {
    
    vector<int> heights(10);
    for (int i=0; i<10; i++){
        cin >> heights[i];
    }
    sort(heights.begin(), heights.end(), greater<int>());
    
    for (int i=0; i<3; i++){
        cout << heights[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
using namespace std;

int funk(int a,int b){
	int c=0;
	if(a==b){
		return 1;
	}else if(a>b){
		return 0;
	}else{
		c+=funk(a+1,b);
		c+=funk(a+2,b);
		c+=funk(a+3,b);
		return c;
	}
	
}
	
	
int main() {
	int n,aa,year;
	while(1){
	cin >> n;
	if(n==0) break;
	aa=funk(0,n);
	year=aa/3650;
	year+=1;
	cout << year << endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    bool swapi = false;
    for(int i=0;i<n;i++)
    {
        if(a[i]>b[i])
        {
            swapi=true;
            break;
        }
        if(b[i]>a[i])
        {
            break;
        }
    }
    if(swapi)
    {
        a.swap(b);
    }
    int cc=0;
    int equal=true;
    for(int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            equal=false;
            break;
        }
    }
    while(!equal)
    {
        cc++;
        next_permutation(a.begin(),a.end());
        equal=1;
        for(int i=0;i<n;i++)
        {
            if(a[i]!=b[i])
            {
                equal=false;
                break;
            }
        }
    }
    cout<<cc<<endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    ii = [2**i for i in range(21)]

    def f(a,b):
        r = 0
        for i in range(3):
            r += (a[i]-b[i]) ** 2
        return r

    while True:
        n,m = LI()
        a = [LF() for _ in range(n)]
        sa = [[0]*n for _ in range(n)]
        for i in range(n):
            for j in range(i+1,n):
                sa[i][j] = f(a[i],a[j])

        r = 0
        for i in range(2**n):
            t = [_ for _ in range(n) if i&ii[_]]
            if len(t) != m:
                continue
            tr = 0
            for i in range(m):
                for j in range(i+1,m):
                    tr += sa[t[i]][t[j]]
            if r < tr:
                r = tr

        rr.append(r)
        break

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9036
N=int(input())
A=list(map(int,input().split()))
d={}
dd={}
if len(A)==1:
    if A[0]==1:
        print(0)
    else:
        print(1)
else:
    for a in A:
        try:
            d[a]+=1
            dd[a]+=1
        except KeyError:
            d[a]=1
            dd[a]=1
        #揃ったら除くべき数値を初期化
        if dd[a]==a:
            d[a]=0
    print(sum(d.values()))

Measured memory_bytes: 113032
(* Vicfred
 * https://atcoder.jp/contests/abc073/tasks/abc073_b
 * implementation
 * *)
let n = Scanf.scanf "%d\n" ( + ) 0
let lines = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun l r -> r - l + 1
let main = Array.fold_left ( + ) 0 lines |> Printf.printf "%d\n"



Measured memory_bytes: 4236
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;
 

    

void main()
{
    int N, M, L;
    readf("%s %s %s", &N, &M, &L);
    readln;
    
    auto g = new Tuple!(int, int)[][] (N+1);
    foreach (_; 0 .. M) {
        int a, b, c;
        readf("%s %s %s", &a, &b, &c);
        readln;
        
        g[a] ~= tuple(b, c);
        g[b] ~= tuple(a, c);
    }
    
    debug { g.writeln; }
    
    auto results = new int[][] (N+1, N+1);
    foreach (i; 1 .. N+1) { results[i][] = -1; }
    
    void getResults(int u) {
        
        immutable Tuple!(int, int) INF = tuple(N+10, 0);
        
        auto vis = new int[] (N+1);
        auto cost = new Tuple!(int, int)[] (N+1);
        cost[] = INF;
        cost[u] = tuple(0, -L);
        
        auto q = make!(RedBlackTree!(Tuple!(Tuple!(int, int), int)));
        q.insert(tuple(cost[u], u));
        while (!q.empty()) {
            auto qel = q.front();
            q.removeFront();
            
            if (vis[qel[1]]) { continue; }
            vis[qel[1]] = true;
            
            results[u][qel[1]] = cost[qel[1]][0];
            
            foreach (edge; g[qel[1]]) {
                if (edge[1] > L) { continue; }
                
                auto ncost = qel[0][1] + edge[1] <= 0 ? 
                    tuple(qel[0][0], qel[0][1] + edge[1]) :
                    tuple(qel[0][0] + 1, -L + edge[1]);
                
                //debug { writeln(qel[1], ' ', edge[0], ' ', ncost); }
                
                if (ncost < cost[edge[0]]) {
                    cost[edge[0]] = ncost;
                    
                    q.insert(tuple(ncost, edge[0]));
                }
            }
        }
    }
    
    foreach (i; 1 .. N+1) { getResults(i); }
    
    int q;
    readf("%s", &q);
    readln;
    
    while (q--) {
        int u, v;
        readf("%s %s", &u, &v);
        readln;
        
        results[u][v].writeln;
    }
}

Measured memory_bytes: 12028
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;

int main(){
   string s; cin >> s;
   vector<int> a(4);
   rep(i,4) a[i] = s[i] - '0';

   for(int bit = 0; bit < (1 << 3); bit++){
      int sum = 0;
      for(int i = 0; i < 3; i++){
         if(bit & (1 << i)){
            sum += a[i + 1];
         }else{
            sum -= a[i + 1];
         }
      }
      if(sum + a[0] == 7){
         cout << a[0];
         for(int i = 0; i < 3; i++){
            if(bit & (1 << i)){
               cout << "+";
            }else{
               cout << "-";
            }
            cout << a[i + 1];
         }
         cout << "=7" << endl;
         return 0;
      }
   }
}


Measured memory_bytes: 256
def main():
    from functools import reduce
    from operator import mul
    import sys

    sys.setrecursionlimit(10 ** 7)

    def dfs(sr, sc):
        d = {'.': 0, '#': 0}
        q = [(sr, sc)]
        while q:
            r, c = q.pop()
            if checked[r][c]:
                continue
            checked[r][c] = True
            d[s[r][c]] += 1

            if r - 1 >= 0 and s[r - 1][c] != s[r][c]:
                q.append((r - 1, c))

            if c - 1 >= 0 and s[r][c - 1] != s[r][c]:
                q.append((r, c - 1))

            if r + 1 < h and s[r + 1][c] != s[r][c]:
                q.append((r + 1, c))

            if c + 1 < w and s[r][c + 1] != s[r][c]:
                q.append((r, c + 1))

        return d

    h, w = map(int, input().split())
    s = [list(input()) for _ in range(h)]

    checked = [[False] * w for _ in range(h)]

    ret = 0
    for r in range(h):
        for c in range(w):
            if checked[r][c]:
                continue
            ret += reduce(mul, dfs(r, c).values())

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34508
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* r = new int[n];
	int* later_max = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> r[i];
	}
	later_max[n - 1] = 0;
	for (int i = n - 2;i >= 0;i--) {
		later_max[i] = max(later_max[i + 1], r[i + 1]);
	}
	int point = later_max[0] - r[0];
	for (int i = 1;i < n - 1;i++) {
		point = max(point, later_max[i] - r[i]);
	}
	cout << point << endl;
}







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

using namespace std;

#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=2*1e5+7;
const int mod=1e9+7;
char ss[K];
int main(void)
{

    scanf("%s",ss+1);
    if((strlen(ss+1)%2==0) ^ (ss[1]== ss[strlen(ss+1)]))
        printf("Second\n");
    else
        printf("First\n");
    return 0;
}


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

int main() {
  int a[9],b[9];
  for(int i=0; i<9; i++) {
    a[i]=i+1;
    cin >> b[i];
  }
  int ans=0;
  do {
    bool f=1;
    for(int i=0; i<9; i++) {
      if(b[i]!=-1 && a[i]!=b[i]) f=0;
    }
    if(!f) continue;
    int d[4];
    memset(d,0,sizeof(d));
    d[0]=a[0];
    d[1]=a[1]*10+a[2];
    d[2]=a[3]*100+a[4]*10+a[5];
    d[3]=a[6]*100+a[7]*10+a[8];
    if(d[0]+d[1]+d[2]==d[3]) ans++;
  } while(next_permutation(a,a+9));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3088
using System;

class Atcoder37
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());

        if (n > k) {
            int cost = k * x + (n - k) * y;
            Console.WriteLine(cost);
        }
        else {
            Console.WriteLine(n * x);
        }
    }
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

#define PI 3.14159265359

int main(){
	int r;
	cin >> r;
	cout << 2 * PI * r;
	
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n, u, v;//u nige, v ou
	cin>>n>>u>>v; u--; v--;
	vector<int> e[100000];
	rep(i, n-1){
		int a, b;
		cin>>a>>b; a--; b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	vector<int> kita(n, -1);
	queue<int> q, nq;
	q.push(v);
	kita[v]=v;
	while(!q.empty()){
		int c=q.front(); q.pop();
		for(int d : e[c]) if(kita[d]== -1){
			kita[d]=c;
			q.push(d);
		}
	}
	int l=1;
	for(int c=u; c!=v; c=kita[c]) l++;
	int mo=l/2-1, sa=l%2+1;//sa==1 rinsetu

	int g=u;
	rep(i, mo) g=kita[g];

	q.push(g);
	int mx=0;
	while(!q.empty()){
		while(!q.empty()){
			int c=q.front(); q.pop();
			for(int d : e[c]) if(d!= kita[c]){
				nq.push(d);
			}
		}
		swap(q, nq);
		mx++;
	}

	int ans=mo+mx+sa-2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 9232
#include<stdio.h>
#include<string.h>

int main(void){
   char s[100];
   scanf("%s",s);
   int n = strlen(s);
   for(int i=0;i<n/2;i++){
      if(s[i]!=s[n/2+i+1]){
        printf("No\n");
        return 0;
      }
      else if(s[i]!=s[n-i-1]){
             printf("No\n");
             return 0;
      }
   }
   printf("Yes\n");
   return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   int n;cin >>n;
   vector<int>a(n);
   ll now=1000;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    ll stack=0;
    for (int i = 1; i < n; ++i) {
        if(a[i]>a[i-1]){
            stack+=now/a[i-1];
            now%=a[i-1];
        }
        now+=stack*a[i];
        stack=0;
//        cout <<now<<endl;
    }
    cout <<now<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <numeric>
#include <iomanip>
#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
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	string S;
	cin >> S;
	string k = "No";
	rep(i, S.size() - 1) {
		if (S.at(i) == 'A' && S.at(i + 1) == 'C') {
			k = "Yes";
		}
	}
	cout << k << endl;
	
}

Measured memory_bytes: 256
n = int(input())

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([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

factor = factorization(n)

ans = 0
for a in factor:
    if a[0] == 1:
        print(0)
        exit(0)
    else:
        for i in range(1,10000):
            a[1] -= i
            if a[1]>=0:
                ans += 1
            else:
                break

print(ans)

Measured memory_bytes: 9496
#include<iostream>
using namespace std;

int main(){

    int r,g,b,n,ans=0;
    cin >> r >> g >> b >> n;

    for(int i =0; i <= n; i++){
        for(int j = 0; j <= n;j++){
            int t =r*i + g*j;
            if((n -t) % b == 0 && n -t >= 0){
                ans++;                
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A; cin >> A;
  double B; cin >> B;
  long long B_int = B * 100 + 0.5;
  long long ans = A * B_int;
  ans = (ans - (ans % 100)) / 100;
  cout << ans;
  return 0;
}

Measured memory_bytes: 3720
/// @file

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

namespace {

bool run(std::istream& is, std::ostream& os);
}  // unnamed namespace

/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
  try {
    if (run(std::cin, std::cout) == false) {
      std::cerr << "main funciton error.\n";
      return EXIT_FAILURE;
    }
  } catch (const std::exception& e) {
    std::cerr << "catch exception\n";
    std::cerr << e.what() << "\n";
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

namespace {

/// @brief 実行処理
bool run(std::istream& is, std::ostream& os)
{
  const int CAPACITY_NUM(5);
  unsigned long n;
  std::vector<unsigned long> capacity(CAPACITY_NUM);

  is >> n;
  for (auto& v: capacity) is >> v;

  const unsigned long MIN_CAPACITY = *std::min_element(capacity.begin(), capacity.end());
  const unsigned long MAX_TRANSPORT = std::ceil(static_cast<double>(n) / MIN_CAPACITY) - 1;
  const unsigned long MIN_TIME = MAX_TRANSPORT + CAPACITY_NUM;

  os << MIN_TIME << "\n";

  return true;
}
}  // unnamed namespace


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
int a[1100];

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen(fname".in", "r", stdin);
	// freopen(fname".out", "w", stdout);
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	sort(a, a + n);
	int cur = 0;
	for(int i = 1; i < n; ++i)
		cur += a[i] - a[i - 1];
	printf("%d\n", cur);
	return 0;
}

Measured memory_bytes: 256
#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident, )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
  ($e: expr, ($arg: ident $(, $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
}

macro_rules! into {
  ($e: expr, $($name: ident)*) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! get {
  ($i: ident) => (
    let stdin = io::stdin();
    let mut $i = Vec::new();
    for line in stdin.lock().lines() {
      $i.push(
        line
          .unwrap()
          .split_whitespace()
          .map(|a| a.parse().unwrap())
          .collect()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{}", $a);
  )
}

macro_rules! pp {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let mut args: Vec<Vec<i32>>;
  let mut ab: Vec<i32>;
  get!(args);
  into!(args, ab);

  let c = ab[0] + ab[1];
  if 10 <= c {
    p!("error");
  }
  else {
    p!(c);
  }
}


Measured memory_bytes: 4352
# 二項係数を"やるだけ"にしてくれるライブラリ
from collections import Counter
MAX = 310000
MOD = 10**9+7
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX


# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD


# 前処理完了
COMinit()

N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
count = sorted(count.items(), key=lambda x: x[1], reverse=True)
# 唯一2回出ている値を取得する
dual = count[0][0]
t = 0
for i in range(len(A)):
    if A[i] == dual:
        if t == 0:
            l = i
        else:
            r = i
        t += 1
for k in range(1, N+2):
    print((COM(N+1, k) - COM(l+N-r, k-1) + MOD) % MOD)
# print(l, r)
# print(A[l], A[r])


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

int main(){
  int n;
  cin >> n;
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  int ans=1,x=0;
  while(x+1<n&&a.at(x)==a.at(x+1))
    x++;
  bool zok;
  if(x+1<n)
    zok=a.at(x)<a.at(x+1);
  for(int i=x;i<n-1;i++){
    if(zok){
      if(a.at(i)>a.at(i+1)){
        ans++;
        i++;
        while(i+1<n&&a.at(i)==a.at(i+1))
          i++;
        if(i+1<n)
          zok=a.at(i)<a.at(i+1);
      }
    }else{
      if(a.at(i)<a.at(i+1)){
        ans++;
        i++;
        while(i+1<n&&a.at(i)==a.at(i+1))
          i++;
        if(i+1<n)
          zok=a.at(i)<a.at(i+1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3796
#include<iostream>
int main(){
  int n,i,b,f,r,v,A[4][3][10];
  for(i=0; i<4; i++) for(b=0; b<3; b++) for(f=0; f<10; f++) A[i][b][f] = 0;
  std::cin >> n;
  for(i=0; i<n; i++){
    std::cin >> b >> f >> r >> v;
    A[b-1][f-1][r-1] += v;
  }
  for(i=0; i<4; i++){
    for(b=0; b<3; b++){
      for(f=0; f<10; f++) std::cout << " " << A[i][b][f];
      std::cout << "\n";
    }
    if(i != 3){
      for(r=0; r<20; r++) std::cout << "#";
      std::cout << "\n";
    }
  }
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  ll sum = 0;
  vi a(5);
  rep (i, 5) {
    cin >> a[i];
    if (a[i] % 10 == 0) sum += a[i];
    else sum += (a[i] / 10 * 10) + 10;
  }
  int ma = 0;
  rep (i, 5) {
    chmax(ma, (10 - a[i] % 10) % 10);
  }
  sum -= ma;
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
	int n, m, thres, c, sum;
	cin >> n >> m;
	vector<int> s(n);
	c = sum = 0;
	rep(i, n) {
		cin >> s[i];
		sum += s[i];
	}
	thres = ceil(sum / double(4 * m));
	rep(i, n) {
		if (thres <= s[i])	c++;
	}
	if (c < m)	cout << "No" << endl;
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,C;
    cin>>N>>C;
    vll s(N),t(N),c(N);
    for(ll i=0;i<N;i++)cin>>s[i]>>t[i]>>c[i];
    
    vector<vector<bool>> TV(C,vector<bool>(100001,false));
    for(ll i=0;i<N;i++){
        for(ll j=s[i]-1;j<t[i];j++){
            TV[c[i]-1][j]=true;
        }
    }
    
    ll ans=1;
    for(ll i=0;i<100001;i++){
        ll count=0;
        for(ll j=0;j<C;j++){
            if(TV[j][i])count++;
        }
        chmax(ans,count);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>

int main(){
    
    char a[4];
    int ans = 0;
    scanf("%s",a);
    for(int i=0; i<4; i++){
        if(a[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  n--;
  ll ans = 0;
  rep2(i, 1, n+1){
    ans += n/i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n,k;
long dp[3001][3001];
long a[3001];


long solve(int i, int j, int p)
{  
    if(i==j) return p*a[i];
    else if(dp[i][j]) return dp[i][j];
    if(p==1)
    dp[i][j]=max(p*a[i]+solve(i+1,j,-1*p), p*a[j]+solve(i,j-1,-1*p));
    else 
    dp[i][j]=min(p*a[i]+solve(i+1,j,-1*p), p*a[j]+solve(i,j-1,-1*p));
    return dp[i][j];
}
 
int main()
{   cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];;
    }
    cout<<solve(1,n,1);
}

Measured memory_bytes: 70272
/**
*Keep
**Moving
***Forward
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define f( i , x , n ) for(int i = x; i < (int)(n); ++i)
#define pb push_back
#define all(c) (c).begin(),(c).end()


int main(){
    int n,t;
    cin >> n >> t;
    cout << max(0,n-t);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;
typedef long long ll;


int a[10];

bool put(int cur,int lt, int rt) {
	if (cur == 10)
		return true;
	if (a[cur] < lt && a[cur] < rt)
		return false;
	bool lres= false,rres=false;
	if( a[cur] > lt) {
		lres = put(cur + 1, a[cur], rt);
	}
	if( a[cur] > rt) {
		rres = put(cur + 1, lt, a[cur]);
	}
	if (lres || rres)
		return true;
	else
		return false;
}

int main() {
	int T;
	cin >> T;
	for (int t = 0; t < T; t++) {
		for (int i = 0; i < 10; i++) {
			cin >> a[i];
		}
		if (put(0, 0, 0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(0, a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

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

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

    # divisors.sort()
    return divisors

ans=make_divisors(N) #listで返る
minima=10**12+1

for i in ans:
  pair=N/i
  minima=min(i+pair,minima)

print(int(minima-2))

Measured memory_bytes: 3264
=begin
－－－－－－－－－－－－－－ 
A = 100*A 水
B = 100*B 水
C,D = １回の投入可能砂糖量
E = 100(g)あたりに溶かすことのできる砂糖量
F = ビーカー許容量(水 + 砂糖 = 総質量)
sugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙)
water = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙)
sum = water[i]とsugar[j]の総質量
pos = water[i] に溶かせる砂糖量
con = sugar[j]*100 / (sugar[j] + water[i])  の砂糖濃度(%)
ans = 答え
－－－－－－－－－－－－－－
=end

A,B,C,D,E,F = gets.split.map(&:to_i);

water = [];
(0..30).each{|i|
  (0..30).each{|j|
    x = (100*A*i) + (100*B*j);
    water << x if x <= F;
  }
}
water.sort!.uniq!;

sugar = []
(0..F).each{|i|
  (0..F).each{|j|
    y = C * i + D * j;
    sugar << y if y <= F;
  }
}
sugar.sort!.uniq!;

ans = "";
dif = -1;
con = 0.0;

water.each{|x|
  sugar.each{|y|
    next if x + y > F;

    con = 100 * y / (x + y).to_f 
    next if con > 100 * E / (100 + E).to_f

    if dif < con
      dif = con
      ans = "#{x+y} #{y}"
    end
  }
}

puts ans

Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	int a1=a/100,a2=a%100;
	if(a1>0&&a1<=12)
	{
		if(a2>0&&a2<=12)
			cout<<"AMBIGUOUS";
		else
			cout<<"MMYY";
	}
	else
	{
		if(a2>0&&a2<=12)
			cout<<"YYMM";
		else
			cout<<"NA";
	}	
	return 0;
} 

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



int main()
{
    double a,b;
    std::cin>>a>>b;
    int ans=b*10-1;
    int flag=0;
    for(int i=0;i<=9;i++){
        
        ans++;
        if((int)(ans*0.08)==a){
            flag=1;
            break;
        }

    }
    if(flag) std::cout<<ans<<"\n";
    else std::cout<<"-1"<<"\n";

    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
l = r = 0
num = [0 for _ in range(n)]
while l < n-1:
    m = 0
    while r < n-1 and (s[r]!='L' or s[r+1]!='R'):
        if s[r]=='R' and s[r+1]=='L':
            m = r
        r += 1
    for i in range(l, r+1):
        if (m-i) % 2:
            num[m+1] += 1
        else:
            num[m] += 1
    l = r+1
    r = l
print(" ".join(map(str, num)))

Measured memory_bytes: 10612
def comp(a,b):
    if sum(a)<sum(b):
        return "right"
    elif sum(a)>sum(b):
        return "left"
    else:
        for i in range(8,-1,-1):
            if a[i]<b[i]:
                return "right"
            elif a[i]>b[i]:
                return "left"
        else:
            return "equal"

N,M=map(int,input().split())
A=list((map(int,input().split())))
 
m=[[1,2],[2,5],[3,5],[4,4],[5,5],[6,6],[7,3],[8,7],[9,6]]
B=[]
    
for a in A:
    B.append(m[a-1])
    
maxlist=[[0]*9 for _ in range(N+1)]
 
for i in range(N+1):
    if i!=0 and sum(maxlist[i])==0:
        continue
    else:
        for b in B:
            if i+b[1]>N:
                continue
            ans=[maxlist[i][k] for k in range(9)]
            ans[b[0]-1]+=1
            _max=maxlist[i+b[1]]
            if comp(ans,_max) == "left":
                maxlist[i+b[1]]=[ans[k] for k in range(9)]
 
for i in range(8,-1,-1):
    print(str(i+1)*maxlist[N][i],end="")
print()

Measured memory_bytes: 5252
from collections import Counter
import math
N = int(input())
A = list(map(int,input().split()))
A_count = Counter(A)
count_item = list(A_count.items())
count_item.sort()
start = 1 - (N % 2)
for i in range(math.ceil(N / 2)):
    if i == 0 and N % 2 == 1:
        if count_item[i][0] == 0 and count_item[i][1] != 1:
            print("0")
            exit()
    else:
        if count_item[i][0] != i * 2 + (1 - (N % 2)) or count_item[i][1] != 2:
            print("0")
            exit()
print(2 ** (N // 2) % (10 ** 9 + 7))

Measured memory_bytes: 56812
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    while(n) {
        if(n % 10 == 7) {
            printf("Yes\n");
            return 0;
        }
        n /= 10;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<map>
#include<string>
using namespace std;

map<string, int> memo;

int main(void){
    int n;
    cin >> n;
    for(; n--;){
        string s;
        cin >> s;
        memo[s] += 1;
    }
    int maxv = 0;
    for(const auto&x : memo){
        int v = x.second;
        if(v > maxv) maxv = v;
    }
    for(auto it = memo.begin(); it != memo.end(); it++){
        if(it->second==maxv){
            cout << it->first << endl;
        }
    }
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	if (a < c && c < b) cout << "Yes" << endl;
	else if (a > c && c > b) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Pair{
 public long a;
 public long b;
 Pair(long a,long b){
 this.a=a;
 this.b=b;
 }
 public String toString(){
	 return this.a+"::"+this.b;
 }
}
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
	    long b=sc.nextLong();
	    long arr[]=new long[a];
		for(int i=0;i<a;i++)
			arr[i]=sc.nextLong();
		Arrays.sort(arr);
		ArrayList<Pair> al=new ArrayList<>();
		for(int i=0;i<b;i++)
			al.add(new Pair(sc.nextLong(),sc.nextLong()));
	     Collections.sort(al,new Comparator<Pair>(){
			 @Override
			public int compare(Pair a,Pair b){
				if(a.b==b.b)
					return (int)(b.a-a.a);
					else return (int)(b.b-a.b);
			}
		}
		);
		int k=0;
		for(int i=0;i<b;i++){
			for(int j=0;j<al.get(i).a;j++){
				if(k<a&&al.get(i).b>arr[k])
				{
					arr[k]=al.get(i).b;
					k++;
				}
				else break;
			}
			if(k >= a || al.get(i).b<arr[k])
				break;
		}
		long s=0;
		for(int i=0;i<a;i++){
			s+=arr[i];
		}
			System.out.println(s);
	}
}

Measured memory_bytes: 93892
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int a, b;
	cin >> a >> b;
	int ans = -1;
	if (a < 10 && b < 10)ans = a * b;
	cout << ans;*/


	int n;
	cin >> n;
	int i, j;

	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			if (i * j == n) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> A(N, 0);

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

	sort(A.begin(), A.end());

	long long result = 0;
	for (int i = 1; i <= N - 1; i++)
	{
		result += A[(N - 1) - (i / 2)];
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3968
a = input().rstrip().split(" ")
n = int(a[0])
m = int(a[1])
b = input().rstrip().split(" ")

k=0
s=0

for i in range(m):
    s += int(b[k])
    k += 1

ans = n-s
if ans >=0:
    print(ans)
else:
    print(-1)



Measured memory_bytes: 9540
A=int(input())
m=0
for i in range(1,12):
    m+=26**i
    if A<m+1:
        break

li=["$"]*i
for j in range(i):
    li[j]=A%26
    if li[j]==0:
        A-=1
    A=int(A//26)
    if A==0:
        break


abc=["z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y"]

S=""
for k in range(i):
    S+=abc[li[i-1-k]]

print(S)


Measured memory_bytes: 9132
#include <iostream>
using namespace std;

int main() {
    int a,b,x=0;
    cin >> a >> b;
    if(a < b){
        x += b;
        b--;
    }else{
        x += a;
        a--;
    }
    if(a < b){
        x += b;
        b--;
    }else{
        x += a;
        a--;
    }
    cout << x << endl;
}

Measured memory_bytes: 3560
import scala.math._

object Main {
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    while(true) {
      val n, m = sc.nextInt()
      if((n, m) == (0, 0)) {
        return
      }

      val a = Array.ofDim[Int](m, n)
      for(i <- 0 until n; j <- 0 until m) {
        a(j)(i) = sc.nextInt()
      }
      val sum = a.map(_.sum)
      println(sum.map(_ * -1).zipWithIndex.sorted.map(_._2 + 1).mkString(" "))
    }
  }
}

Measured memory_bytes: 165652
n = gets.to_i
as = []
min = Float::INFINITY
n.times do
  a = gets.to_i
  if a % 10 != 0
    min = [min, a].min
  end
  as << a
end
sum = as.reduce(0){|a,e|a+=e}

if sum % 10 == 0 && min != Float::INFINITY
  puts sum - min
elsif sum % 10 == 0
  puts 0
else
  puts sum
end

Measured memory_bytes: 1788
/*
可以发现一次操作相当于一次置换
对于每个a上的位置映射到b对应 
可以找到置换群中的 所有轮换
一个k个元素的轮换需要k+1步完成 
那么答案就是边数+轮换数-1 
-1的话发现当最一个数为缺少的数时不需吧最后一步换回来 
*/
#include<map> 
#include<cstdio> 
#include<algorithm> 
#define gc getchar()
#define pc putchar
inline int read() { 
	int x = 0,f = 1; 
	char c = gc; 
	while(c < '0' || c > '9')c = gc; 
	while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = gc; 
	return x * f; 
} 
void print(int x) { 
	if(x < 0) { 
		pc('-'); 
		x = -x; 
	} 
	if(x >= 10) print(x / 10); 
	pc(x % 10 + '0'); 
} 
const int maxn = 1000007; 
int a[maxn],b[maxn],c[maxn],d[maxn]; 
int n; 
std::map<int,int>f; 
int fa[maxn]; 
int find(int x) { 
	if(fa[x] != x) fa[x] = find(fa[x]); 
	return fa[x]; 
} 
int main() { 
	n = read(); 
	for(int i = 1;i <= n;++ i) a[i] = read(); 
	for(int i = 1;i <= n;++ i) b[i] = read(); 
	int t = 0; 
	for(int i = 1;i <= n;++ i) t ^= a[i]; 
	a[n + 1] = t; 
	t = 0; 
	for(int i = 1;i <= n;++ i) t ^= b[i]; 
	b[++ n] = t; 
	for(int i = 1;i <= n;++ i) c[i] = a[i],d[i] = b[i]; 
	std::sort(c + 1,c + n + 1); 
	std::sort(d + 1,d + n + 1); 
	for(int i = 1;i <= n;++ i) { 
		if(c[i] != d[i]) { 
			puts("-1"); 
			return 0; 
		} 
	} 
	int tot = 0; 
	int ans = 0; 
	for(int i = 1;i <= n;++ i) { 
		 if(a[i] != b[i] || i == n)  { 
		 	if(i < n) ans ++; 
		  	if(!f[a[i]])f[a[i]] = ++tot; 
		  	if(!f[b[i]])f[b[i]] = ++tot; 
		  	
		 }  
	} 	 
	if(!ans) { 
		pc('0'); 
		return 0; 
	} 
	for(int i = 1;i <= tot;++ i) fa[i] = i; 
	for(int i = 1;i <= n;++ i) { 
		if(a[i] != b[i]) fa[find(f[a[i]])] = find(f[b[i]]); 
	} 
	for(int i = 1;i <= tot;++ i) if(fa[i] == i) ans ++; 
	print(ans - 1); 
	return 0; 
} 

Measured memory_bytes: 19200
#include <stdio.h>
int main(void) {
int a, b;
char op;
scanf("%d %c %d", &a, &op, &b);
while( op != '?') {
if( op == '+' ) {printf("%d\n", a + b);}
if( op == '-' ) {printf("%d\n", a - b);}
if( op == '*' ) {printf("%d\n", a * b);}
if( op == '/' ) {printf("%d\n",a / b);}
scanf("%d %c %d", &a, &op, &b);
}
return 0;
}

Measured memory_bytes: 1028
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        a: usize,
        p: usize,
    }
    let ans = (3 * a + p) / 2;
    println!("{}", ans);
}


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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i=0; i<N; i++) {
    cin >> x.at(i) >> u.at(i);
  }
  double Y = 0;
  for (int i=0; i<N; i++) {
    if (u.at(i) == "JPY") {
      Y += x.at(i);
    }
    else {
      Y += 380000.0*x.at(i);
    }
  }
  cout << fixed << setprecision(10);
  cout << Y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define vel vector<int>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
signed main(){
	int n; cin >> n;
	vvel st(n, vel(3));
	vvel to(n, vel(3));
	rep(i, n) {
		rep(j, 3) {
			int x, y; cin >> x >> y;
			st[i][j] = x * 60 + y;
			cin >> x >> y;
			to[i][j] = x * 60 + y;
		}
	}
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			rep(k, n) {
				int qans = 0;
				rep(l, n) {
					int count = 0;
					if (st[l][0] <= st[i][0] and st[i][0] <= to[l][0]) {
						count++;
					}
					if (st[l][1] <= st[j][1] and st[j][1] <= to[l][1]) {
						count++;
					}
					if (st[l][2] <= st[k][2] and st[k][2] <= to[l][2]) {
						count++;
					}
					if (count == 3) { qans++; }
				}
				mmax(ans, qans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int a,b,c; cin>>a>>b>>c;
    int k; cin>>k;
    int m = max({a,b,c});
    cout<<m*pow(2,k)+a+b+c-m<<endl;
}


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

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

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

    ll n;
    cin>>n;
    vector<P> as(n);
    rep(i, n) {
        int a;
        cin>>a;
        as[i] = P(a, i);
    }
    sort(as.begin(), as.end());
    for (auto a : as) {
        cout<<a.second + 1<<" ";
    }
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int time = sc.nextInt();
          int num1 = sc.nextInt();
          int num2 = sc.nextInt();
          if(time * num1 <= num2){
            System.out.println(time * num1);
          } else {
            System.out.println(num2);
          }
      }
    }

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

int main(){
vector<int> d(101);
int N;
cin >>N;
for(int i=0; i<N;i++){
    int c;
    cin>> c;
    d.at(c)=1;
}
int ans = 0;
for(int i=0; i<101; i++){
    ans+=d.at(i);
}
cout<<ans<<endl;
}


Measured memory_bytes: 256