akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> num(N + 1, 0);
  for (int i = 2; i <= N; i++) {
    int A;
    cin >> A;
    num[A]++;
  }
  for (int i = 1; i <= N; i++)
    cout << num[i] << endl;
  return 0;
}

Measured memory_bytes: 4052
MOD = 1000000007
N = int(input())
d = dict()

for i in range(2, N+1):
    tmp = i
    div = 2
    while tmp > 1:
        if tmp % div == 0:
            if div not in d:
                d[div] = 1
            else:
                d[div] = d[div] + 1
            tmp = tmp // div
        else:
            div += 1
ans = 1
for div in d:
    ans = ans * (d[div] + 1) % MOD

print(ans)


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

const int MXN = 1e5 + 20;
int n, k, dp[MXN];
vector <int> h;

int main () {
	cin >> n >> k;
	for (int i = 0 ; i < n; i++) {
		int tmp;
		cin >> tmp;
		h.push_back(tmp);
	}
	dp[2] = abs(h[0] - h[1]);
	for (int i = 3; i<= n; i++) {
		int tmp = 1e9;
		for (int x = 1; x <= k && x < i; x++) {
			tmp = min(tmp, dp[i - x] + abs(h[i - x - 1] - h[i - 1]));
		}
		if (tmp == 1e9)
			tmp = 0;
		dp[i] += tmp;
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define N 100
using namespace std;
int n, a[N];

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    int m = abs(a[1]), p = 1;
    for(int i = 2; i <= n; i++)
        if (abs(a[i]) > m) m = abs(a[i]), p = i;
    cout << 2 * n - 2 << endl;
    for(int i = 1; i <= n; i++)
            if (i != p) printf("%d %d\n", p, i);
    if (a[p] > 0) for(int i = 1; i < n; i++) printf("%d %d\n", i, i + 1);
    else for(int i = n; i > 1; i--) printf("%d %d\n", i, i - 1);
}


Measured memory_bytes: 256
function main(input){
    let lines = input.split("\n");
    let count = parseInt(lines.shift());
        while(count!==0){
//            console.log(lines.shift())
        let nums = allint((lines.shift()).split(" "));
        let sum = getSum(nums);
        let avg = sum/nums.length;
        let answer = 0;
        for(let i=0;i<nums.length;i++){
            answer += Math.pow(nums[i]-avg,2)/nums.length;
        }
        console.log(Math.sqrt(answer));
        
        count = parseInt(lines.shift());

    }
    
    
}
function allint(arr){
    return arr.map(x=>parseInt(x));
}
function getSum(arr){
    return arr.reduce((sum,x)=>sum+=x);
}
main(require("fs").readFileSync("/dev/stdin","utf-8"));


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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();

    ll v, s=0, n, a;
    cin>> v>> n;
    rep(i, 0, n)
    {
        cin>> a;
        s+=a;
    }
    cout<< (s>v? -1: v-s);
    nl;

    return 0;
}



Measured memory_bytes: 3644
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

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


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string a,b,c;
    cin>>a>>b>>c;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}

Measured memory_bytes: 256
@n, @m = gets.split.map(&:to_i)
@edges = @n.times.map { [] }
@m.times do
  a, b = gets.split.map(&:to_i)
  @edges[a - 1] << b - 1
  @edges[b - 1] << a - 1
end

def solve(position, remains)
  return 1 if remains.count == 0

  @edges[position].inject(0) do |sum, i|
    sum += solve i, remains - [i] if remains.include? i
    sum
  end
end
puts solve 0, (1..(@n - 1)).to_a


Measured memory_bytes: 1788
#include <iostream>
#include <set>

int main() {
    size_t n;  std::string s;  std::cin >> n >> s;
    int m = 0;
    for (size_t i = 1; i <= n-1; i++) {
        int c = 0;
        std::set<char> st;
        for (size_t j = 0; j < i; j++) {
            if (st.find(s[j]) != st.end()) {
                continue;
            }
            st.insert(s[j]);
            for (size_t l = i; l < n; l++) {
                if (s[j] == s[l]){
                    c++;
                    break;
                }
            }
        }
        m = std::max(m, c);
    }
    std::cout << m << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int const a[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 main() {
	scanf("%d",&k);
	printf("%d",a[k-1]);
	return 0;
}

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



int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    vector<int> ans;
    while(!a.empty()){
        int i,j;
        int b = 0, itr = 0;
        for(i = 0; i < a.size(); i++){
            if(a[i] == i + 1) {
                b = a[i];
                itr = i;
                break;
            }
        }
        for(j = i + 1; j < a.size(); j++){
            if(a[j] == j + 1) {
                b = a[j];
                itr = j;
            }
        }
        if(b)ans.push_back(b);
        a.erase(a.begin() + itr);
    }
    
    reverse(ans.begin(), ans.end());
    
    if(ans.size() != n) cout << -1 << endl;
    else rep(i,ans.size()) cout << ans[i] << endl;
    
}


Measured memory_bytes: 256
N = str(input())
if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9056
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
{
cin>>a[i];
}
ll ans=0;
for(ll i=0;i<60;i++)
{
ll cnt=0;
for(ll o=0;o<n;o++)
{
if(a[o] & (1ll<<i))
{
cnt++;
}
}
ll k=(cnt*(n-cnt))%mod;
ll h=(1ll<<i);
h%=mod;
ll res=(h*k)%mod;
ans=(ans+res)%mod;
}
cout<<ans%mod;
}

Measured memory_bytes: 5920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		String b = "APPROVED";
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			int j = kb.nextInt();
			a[i] = j;
		}
		for (int e : a) {
			if (e % 2 == 0) {
				if (e % 3 != 0 && e % 5 != 0) {
					b = "DENIED";
					break;
				}
			}
		}
		System.out.println(b);

		kb.close();
	}

}


Measured memory_bytes: 23764
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

prev = -1
ans = 0
for a in A:
    ans += B[a-1]
    if a == prev + 1:
        ans += C[prev-1]
    prev = a
print(ans)


Measured memory_bytes: 38384
#include"bits/stdc++.h"
#include"math.h"
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std; 
int main(){
int N;cin >>N;
  vector<int> H(N);
  rep(i,N)cin >>H[i];
  bool T=false;
  
  for(int i=N-1;i>=0;i--){

    
    
if(H[i]>=H[i-1]){
     
     continue;}
    
     else if(H[i]==H[i-1]-1){H[i-1]--;}    
    
    else{T=true;}}
      
    
      
    if(T){cout <<"No"<<endl;}
else{cout<<"Yes"<<endl;}}
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    string num="";
    for(int i=0;i<n;i++) {
        string d;
        cin>>d;
        num+=d;
    }
    for(int i=0;i<=10000;i++) {
        if(num.find(to_string(i))==string::npos) {
            printf("%d\n",i);
            break;
        }
    }
}

Measured memory_bytes: 3328
import math


def f():
    n = int(input())
    a = list(map(int, input().split(" ")))
    b = []
    c = []
    for i in range(len(a)):
        if i % 2 == 0:
            b.append(a[i])
        else:
            c.append(a[i])
    c.reverse()
    d = c+b
    if n % 2 == 1:
        d.reverse()
    d = list(map(str,d))
    print(" ".join(d))


f()


Measured memory_bytes: 35012
I = input().split()
H = int(I[0])
W = int(I[1])

while H != 0 or W != 0:
    for i in range(H):
        for j in range(W):
            if i == 0 or j == 0 or i % (H - 1) == 0 or j % (W - 1) == 0:
                print('#', end = '')
            else:
                print('.', end = '')
        print()
    print()
    I = input().split()
    H = int(I[0])
    W = int(I[1])

Measured memory_bytes: 9000
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e6;
ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll a[81], dp[81];

int main()
{
    fast_io;
    ll n, i, j, k, mn, s, ans = 1000;
    cin >> n;
    for (i = 1; i <= n; i++) cin >> a[i];
    dp[1] = dp[0] = 1000;
    for (i = 2; i <= n; i++)
    {
        for (j = i - 1; j >= 0; j--)
        {
            mn = inf;
            for (k = j + 1; k < i; k++) mn = min(mn, a[k]);
            s = dp[j] / mn;
            dp[i] = max(dp[i], s * a[i] + dp[j] - s * mn);
        }
        //cout << i << ' ' << dp[i] << '\n';
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}

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

using namespace std;

double ar[3000];
int n;
double dp[3000][3000];
bool visited[3000][3000];

double solve(int i, int heads) {
    if (i == n)
        return heads * 2 >= n;
    double &ans = dp[i][heads];
    if (visited[i][heads])
        return ans;
    visited[i][heads] = true;
    ans = ar[i] * solve(i + 1, heads + 1) + (1-ar[i]) * solve(i+1 , heads);
    return ans;
}

int main() {

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> ar[i];
    cout << setprecision(10) << fixed << solve(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 79488
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
int main() {
	int n; cin >> n;
	string s, t;
	cin >> s >> t;
	char u[300];
	for (int i = 0; i < n; ++i) {
		u[2 * i] = s[i];
		u[2 * i + 1] = t[i];
	}
	u[2 * n] = '\0';
	cout << u << endl;
	return 0;
}

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

int main () {
  string s,t;
  cin >> s >> t;
  bool ans = false;
  
  for (int i = 0; i < s.size(); i++){
    s = s.back() + s.substr(0,s.size()-1);
    if (s == t) ans = true;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            bool Ans = true;
            if (N / 1000 == (N%1000) / 100 || (N%1000)/100 == (N%100) /10 || (N%100)/10 == N%10)
            {
                Ans = false;
            }
            if(Ans == true)
            {
                Console.WriteLine("Good");
            }
            else
            {
                Console.WriteLine("Bad");
            }
        }

    }
}


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

int main(){
  string s;
  cin >> s;
  int ex = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'o') ex++;
  }
  cout << 700 + 100 * ex << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;

    string ans="";

    for(int i=0;i<abs(ty-sy);++i){
        ans+='U';
    }

    for(int i=0;i<abs(tx-sx);++i){
        ans+='R';
    }

    for(int i=0;i<abs(ty-sy);++i){
        ans+='D';
    }

    for(int i=0;i<abs(tx-sx);++i){
        ans+='L';
    }

    ans+="L";

    for(int i=0;i<abs(ty-sy)+1;++i){
        ans+='U';
    }


    for(int i=0;i<abs(tx-sx)+1;++i){
        ans+='R';
    }

    ans+="DR";

    for(int i=0;i<abs(ty-sy)+1;++i){
        ans+='D';
    }

    for(int i=0;i<abs(tx-sx)+1;++i){
        ans+='L';
    }

    ans+='U';

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  ll n;
  cin >> n;
  ll a[200000];
  ll s = 0;
  rep(i, n){
    cin >> a[i];
    s += a[i];
    s = s % MOD;
  }
  ll ans = 0;
  rep(i, n){
    s = (s - a[i] + MOD)%MOD;
    ans = (ans + (s* a[i] % MOD))%MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N; cin>>N;
    vector<pint> a(N),b(N);
    REP(i,N) cin>>a[i].first>>a[i].second;
    REP(i,N) cin>>b[i].first>>b[i].second;
    sort(ALL(b));

    int ans=0;
    bool used[110]={0};

    REP(i,N){ //i->blue
        int maxY=-1,idx=-1;
        REP(j,N){ //j->red
            if(used[j]) continue;
            if(a[j].first<b[i].first and a[j].second<b[i].second){
                if(a[j].second>maxY){
                    maxY=a[j].second;
                    idx=j;
                }
            }
        }
        if(idx!=-1){
            ans++;
            used[idx]=true;
        }
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define Q 1000
 
typedef struct{
  char name[10];
  int time;
} Data;
 
int main(){
  int n, t, i;
  int cnt = 0, head = 0, ta;
  Data data[N];
 
  scanf("%d%d", &n, &t);
  ta = n;
 
  for(i = 0; i < n; i++){
    scanf("%s%d", data[i].name, &data[i].time);
  } 
 
  while(head != ta){
    if(data[head].time > t){
      data[head].time -= t;
      data[ta] = data[head];
      ta++;
      cnt += t;
    }
    else{
      cnt += data[head].time;
      printf("%s %d\n", data[head].name, cnt);
    }
    head++;
    if(head >= N) head = 0;
    if(ta >= N) ta = 0;
  }
 
  return 0;
}



Measured memory_bytes: 3260
N,M = map(int,input().split())

A = [list(map(int,input().split())) for i in range(0,N)]

total = 0

for i in range(1,len(A[0])):
	con = 1
	for j in range(1,N):
		a = A[0][i]

		if a in A[j][1:]:
			con *= 1
		else:
			con *= 0
	total += con
	
if N != 1:
	print(total)
else:print(A[0][0])

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
	int A, B, C;
	int A_def, B_def;

	cin >> A >> B >> C;

	A_def = A - B;
	B_def = C - A_def;

	if (B_def < 0) {
		cout << 0 << endl;
	}
	else {
		cout << B_def << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import qualified Data.IntMap as M
import qualified Data.ByteString.Char8 as B
import Data.Maybe
 
main = B.getContents >>= print . solve . tail . map readB . B.words

readB = fst . fromJust . B.readInt
 
solve = calc . count
 
count [] = M.empty
count (a:as) = M.insertWith (+) a 1 $ count as
 
calc = M.foldrWithKey op 0
 
op k v s
  | k <= v = s + v - k
  | otherwise = s + v


Measured memory_bytes: 16380
N,Q,*X=`dd`.split.map &:to_i
A=[0]*(N%2)+X.shift(N)
M=-~N/2
L=[]
S=[A[M..-1].reduce(:+)]
M.times{|i|S<<S[-1]+(l=A[2*i+1])-r=A[i+M];L<<(l+r)/2}
X.map{|e|p S[(0...M).bsearch{|i|L[i]>=e}||M]}

Measured memory_bytes: 30832
H, W = [int(s) for s in input().split()]
N = int(input())
A = [int(s) for s in input().split()]

def chunk(list, n):
    for i in range(0, len(list), n):
        yield list[i:i + n]

def main():
    a = []
    for i in range(N):
        a += [i + 1] * A[i]

    chunks = list(chunk(a, W))
    for i, c in enumerate(chunks):
        if i % 2 != 0:
            c.reverse()
        print(*c)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
N = int(input())
A, B = [0]*N, [0]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())

A = sorted(A)
B = sorted(B)

if N % 2 == 1:
    ans = B[N//2] - A[N//2] + 1
else:
    ans = B[N//2-1]+B[N//2] - (A[N//2-1]+A[N//2]) + 1

print(ans)

Measured memory_bytes: 27096
import collections
N=int(input())
L=list(map(int,input().split()))
E=L[0::2]
O=L[1::2]
e = collections.Counter(E).most_common()
o = collections.Counter(O).most_common()
if e[0][0] != o[0][0]:
    print(N - e[0][1] - o[0][1])
else:
    if len(e) == 1 or len(o) == 1:
        print(N // 2)
    else:
        a = N - e[1][1] - o[0][1]
        b = N - e[0][1] - o[1][1]
        print(min(a, b))

Measured memory_bytes: 21084
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

bool is_exp(uint32_t val) {
	return (((~val + 1) & val) == val);
}

bool is_digit_up(uint32_t a, uint32_t b)
{
	return (((((a + b) >> 1) & a) << 1) > a);
}

uint32_t counter_part(uint32_t val)
{
	uint32_t in = val;
	uint32_t digit = 0;
	while (val != 0) {
		val >>= 1;
		digit++;
	}
	uint32_t ans = (1 << digit);
	uint32_t ret = ans - in;
	return ret;
}

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

	multiset<uint32_t> as;
	for (int i = 0; i < n; i++) {
		uint32_t val;
		cin >> val;
		as.insert(val);
	}
	vector<bool> used(n, false);

	uint32_t count = 0;
	while (as.size() >= 2) {
		uint32_t val = *as.rbegin();
		as.erase(--as.end());

		uint32_t cp = counter_part(val);
		auto it = as.find(cp);
		if (it != as.end()) {
			as.erase(it);
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=505;
const long long INF=4557430888798830399;
int n;
int a[N][N];
long long s1[N][N],s2[N][N];
long long f[N][N];
long long calc1(int l1,int r1,int l2,int r2)
{
	if(l1>r1) return 0;
	if(l2>r2) return 0;
	return s1[r1][r2]-s1[l1-1][r2]-s1[r1][l2-1]+s1[l1-1][l2-1];
}
long long calc2(int l1,int r1,int l2,int r2)
{
	if(l1>r1) return 0;
	if(l2>r2) return 0;
	return s2[r1][r2]-s2[l1-1][r2]-s2[r1][l2-1]+s2[l1-1][l2-1];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j) scanf("%d",&a[i][j]);
	for(int i=1;i<=n+1;i++)
		for(int j=1;j<=n+1;j++)
		{
			s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1];
			if(i>j) s1[i][j]+=a[i][j];
			s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1];
			if(i<j) s2[i][j]+=a[i][j];
		}
	memset(f,63,sizeof(f));
	f[0][0]=0;
	for(int i=0;i<=n;i++)
		for(int j=i;j<=n;j++)
			if(f[i][j]<INF)
				for(int k=j+1;k<=n+1;k++)
					f[j][k]=min(f[j][k],f[i][j]+calc1(k+1,n+1,i+1,j)+calc2(j+1,k,j+1,k));
	long long res=INF;
	for(int i=0;i<=n;i++)
		res=min(res,f[i][n+1]);
	printf("%lld",res);
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 1e6 + 6;
const long long MOD  = 1e9 + 7;


long long N, G = -1, arr[SIZE], m[SIZE];
unordered_map<long long, long long> bag;

void prec () {

	for (long long i = 2; i <= 1000000; i++) {
		if (m[i] == 0) {
			m[i] = i;
			for (long long j = i * 1LL * i; j <= 1000000; j += i)
				m[j] = i;
		}
	}

}

void eraser (long long num) {
	while (num > 1) {
		bag[m[num]]--;
		num /= m[num];
	}
}

bool checker (long long num) {
	while (num > 1) {
		if (bag[m[num]] != 0)
			return true;
		num /= m[num];
	}
	return false;
}


int main() { speedhack()

	prec ();

	cin >> N;

	forn (i, N) {
		cin >> arr[i];
		if (G == -1)
			G = arr[i];
		else 
			G = gcd (G, arr[i]);
	}

	for (int i = N; i >= 1; i--) {
		long long temp = arr[i];
		while (temp > 1) {
			bag[m[temp]]++;
			temp /= m[temp];
		}
	}


	forn (i, N) {
		eraser (arr[i]);

		if (checker (arr[i])) {
			if (G == 1) 
				cout << "setwise coprime";
			else 
				cout << "not coprime";
			return 0;
		}
	}

	cout << "pairwise coprime";
	
	return 0;
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    char c;
    cin >> A >> c >> B;
    if (c == '+')
        cout << A + B << endl;
    else
        cout << A - B << endl;
}

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

int main(void) {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
using namespace std;
typedef long long ll;

class Edge
{
	public:
	ll cost;
	int from;
	int to;

	Edge(int n,ll c)
	{
		to=n;
		cost=c;
	}

	Edge(int f,int t,ll c)
	{
		from=f;
		to=t;
		cost=c;
	}
};

vector<Edge> g[100010];
bool used[100010];

int dfs(int now)
{
	used[now]=true;
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(used[e.to])
			continue;
		dfs(e.to);
	}
	return 0;
}

int main()
{
	int n,m;
	ll ans=0;
	cin>>n>>m;
	fill(used,used+n+10,false);
	for(int i=0;i<m;i++)
	{
		int u,v;
		ll w;
		cin>>u>>v>>w;
		g[u].push_back(Edge(v,w));
		g[v].push_back(Edge(u,w));
	}
	used[0]=true;
	for(int i=1;i<n+1;i++)
	{
		if(!used[i])
		{
			ans++;
			dfs(i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11008
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int s = 0;
	for (int i = 0; i < 4; ++i)
	{
		int t;
		scanf("%d", &t);
		s += t;
	}
	printf("%d\n%d\n", s / 60, s % 60);
}

Measured memory_bytes: 0
S = input()
L = len(S)
c = 0
l = 1
State = S[0]
ans = 0
for i in range(L):
    if S[i] == State:
        if S[i] == "<":
            ans += c+1
            c += 1
            l += 1
        else:
            ans += c-1
            c -= 1
            l += 1
    else:
        if State == ">":
            if c <= 0:
                ans += l * (-c)
            else:
                ans -= (l-1)*c
            ans += 1
            c = 1
        else:
            ans += c-1
            c -= 1
        State = S[i]
        l = 2
if State == ">":
    if c <= 0:
        ans += l * (-c)
    else:
        ans -= (l-1)*c
print(ans)

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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    double a , b;
    cin >> a >> b;
    cout << ceil((b-1)/(a-1)) << endl;
    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3724
import sys
from heapq import heappush, heappop
input = sys.stdin.readline

N, M = map(int, input().split())
L = [int(v) for v in input().split()]
LL = [[int(v) for v in input().split()] for _ in range(M)]

heap = []
for a in L:
    heappush(heap, (-a, 1))

for a in LL:
    heappush(heap, (-a[1], a[0]))
    
l = N
ans = 0
for i in range(N + M):
    t = heappop(heap)
    
    if l >= t[1]:
        l -= t[1]
        ans += t[0] * t[1] * -1
    else:
        ans += l * t[0] * -1
        l = 0
        
    if l == 0:
        break
        
print(ans)

Measured memory_bytes: 47128
#include <bits/stdc++.h>
#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;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n;
cin >> n;
vector<int> p(n);
rep(i,n) cin >> p[i];

int c = 0;
rep(i,n) if(p[i] != i+1) c++;
if( c == 0 || c == 2) cout << "YES"  << endl;
else cout << "NO" << endl;

return 0;
}

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

int main() {
    //ifstream cin("data.in");
    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];
    for(int i=0; i<n; ++i) {
        if(b[i]<a[i]) {
            cout << -1;
            return 0;
        }
    }

    auto get_dif = [&] (int i) {
        return b[i] - b[(i - 1 + n) % n] - b[(i + 1) % n] ;
    };


    vector<int>dif(n);
    auto cmp = [&] (const int &i, const int &j) {
        if(b[i] == b[j])
            return i < j;
        return b[i] > b[j];
    };

    multiset<int, decltype(cmp)>S(cmp);
    for(int i = 0; i < n; ++i) {
        if(a[i] != b[i] && get_dif(i) - a[i] >= 0)
            S.insert(i);
    }

    long long ops = 0;
    while(!S.empty()) {
        int poz = *S.begin();
        S.erase(S.begin());
        vector<int>neighb = {(poz - 1 + n) % n, (poz + 1 + n) % n};
        bool both_fixed = true;
        int sumNeighb = 0;
        for(int x : neighb) {
            if(S.find(x) != end(S))
                both_fixed = false;
            sumNeighb += b[x];
        }
        if(both_fixed) {
            int k = (b[poz] - a[poz]) / sumNeighb;
            if(!k) {
                cout << -1;
                return 0;
            }
            ops += k;
            b[poz] -= sumNeighb * k;
        } else {
            b[poz] -= sumNeighb;
            ops++;
        }

        for(int x : neighb)
        {
            if(S.find(x) == end(S) && get_dif(x) - a[x] >= 0)
                S.insert(x);
        }

        if(get_dif(poz) - a[poz] >= 0)
            S.insert(poz);
    }

    for(int i = 0; i < n; ++i) {
        if(a[i] != b[i]) {
            cout << -1;
            return 0;
        }
    }

    cout << ops;
}


Measured memory_bytes: 7296
# coding: utf-8
# Your code here!

N = int(input())
S = list(input())
ctr = 0
max_ctr = 0

for i in range(N):
    if S[i] == "I":
        ctr += 1
    else:
        ctr -= 1
    if max_ctr < ctr:
        max_ctr = ctr
print(max_ctr)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	int a, b;
	int area, length;

	scanf("%d %d\n", &a, &b);

	if(1<=a && b<=100){
		area = a * b;
		length =(a * 2) + (b * 2);
		printf("%d %d\n", area, length);
	}

	return 0;

}

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

int main(){
    int alln;
    cin>>alln;
    vector<int> sle(alln,0);
    for(int &x:sle)cin>>x;

    sort(sle.begin(),sle.end(),greater<int>());

    unsigned long sides1=0,sides2=0;
    vector<int>::size_type i=0;
    for(;i<sle.size()-1;i++){
        if(sle.at(i)==sle.at(i+1)){
            sides1=sle.at(i);
            i+=2;
            break;
        }
    }
    for(;i<sle.size()-1;i++){
        if(sle.at(i)==sle.at(i+1)){
            sides2=sle.at(i);
            break;
        }
    }
    cout << sides1*sides2 << endl;
    return 0;
}

Measured memory_bytes: 640
import itertools
N = int(input())
testimony = []
for n in range(N):
    A = int(input())
    testimony.append([list(map(int,input().split())) for _ in range(A)])

ans = 0
for bit in itertools.product([0,1],repeat = N):
    for n in range(N):
        if bit[n]:
            for t in testimony[n]:
                if bit[t[0]-1] != t[1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans,sum(bit))
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  while (cin >> N) {
    double res = 0;
    for (int i = 0; i < N; i++) {
      double x;
      string u;
      cin >> x >> u;
      if (u == "JPY") {
        res += x;
      } else {
        res += x * 380000;
      }
    }
    printf("%.20f\n", res);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,W,w[101],v[101],dp[101][100001];
signed main(){
	cin>>n>>W;
	for(int i=1;i<=n;i++)	cin>>w[i]>>v[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=W;j++){
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>=0)
				dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
		}
	cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
const ll inf = 2e18 + 7;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 7;
const ld pi = 3.14159265358979;

void solve() {
    ll n;
    cin>>n;
    vector<ll> arr(n);
    ll pro=1;
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    for(int i=0;i<n;i++) {
        if(pro==0) {
            cout<<"0";
            return ;
        }
        if(((ll)(1e18)/pro)<arr[i]) {
            cout<<"-1";
            return ;
        }
        pro=pro*arr[i];
    }
    cout<<pro;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<"\n";
    }
    return 0; 

}


Measured memory_bytes: 3976
/*Lucky_Glass*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N=250;
#define fir first
#define sec second

int n,mod;

struct MNUM{
    int num;
    MNUM(){}
    MNUM(int x):num(x){}
    MNUM operator +(const MNUM &B)const&{return (1ll*num+B.num)%mod;}
    MNUM operator -(const MNUM &B)const&{return ((1ll*num-B.num)%mod+mod)%mod;}
    MNUM operator *(const MNUM &B)const&{return (1ll*num*B.num)%mod;}
    MNUM operator +=(const MNUM &B){return *this=(*this)+B;}
    MNUM operator -=(const MNUM &B){return *this=(*this)-B;}
    MNUM operator *=(const MNUM &B){return *this=(*this)*B;}
}dp[N*2+3][N+3],ans;

vector< pair<int,int> > per;

int main(){
    scanf("%d%d",&n,&mod);
    /*
    f(i) (0<=i<n) > g(i)
    f(i) (0<=i<n) > f(i) (n<=i<2n)
    */
    for(int i=0,Nf=2*n-1,Ng=2*n-1;i<2*n;i++){
		while(i*i+Nf*Nf>4*n*n && Nf>=0) Nf--;
		while(i*i+Ng*Ng>=n*n && Ng>=0) Ng--;
		if(i<n){
            int Vf=Nf,Vg=Ng;
            per.push_back(make_pair(Vg+1,Vf+1));
        }
        else{
            int Vf=Nf;
            per.push_back(make_pair(Vf+1,0));
        }
    }
    sort(per.begin(),per.end());
    // for(auto it : per) printf("%d %d\n",it.fir,it.sec);
    for(int k=0;k<=n;k++){
        memset(dp,0,sizeof dp);
        dp[0][0]=1;
        int cnt_2f=0; //前面有多少个 f(i) n<=i<2n
        int cnt_fg=0; //前面有多少个 f(i)/g(i) 0<=i<n
        for(int i=0;i<(int)per.size();i++){
            for(int j=0;j<=k;j++)
                if(per[i].sec==0)
                    //1.比它小的 cnt_2f 个f(i)；2.比它小的 j 个g(i)
                    dp[i+1][j]+=dp[i][j]*(per[i].fir-j-cnt_2f);
                else{
                    //前面比它小的有：1.选择的j个g(i)；2.出现的cnt_2f个f(i) i>=n
                    if(j<k) dp[i+1][j+1]+=dp[i][j]*(per[i].fir-j-cnt_2f);
                    //1.所有n个f(i) i>=n；2.前面出现的cnt_fg-j个f(i)；3.所有k个g(i)
                    dp[i+1][j]+=dp[i][j]*(per[i].sec-n-k-(cnt_fg-j));
                }
            if(per[i].sec==0) cnt_2f++;
            else cnt_fg++;
        }
        if(k%2) ans-=dp[per.size()][k];
        else ans+=dp[per.size()][k];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>

using namespace std;

int main()
{
    int n;
    while( scanf ( "%d\n", &n ) != EOF )
    {
        if( n % 39 == 0 && n != 0 )
        {
            printf( "3C39\n" );
        }
        else
        {
            printf( "3C%02d\n", n % 39 );

        }
    }
    return 0;
}


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

const int maxn = 2E+3 + 5;

int n, x, y;
int dis[maxn][maxn], ans[maxn];

int main()
{
	scanf("%d%d%d", &n, &x, &y);
	
	for(int i = 1; i <= x; ++i)
		for(int j = i; j <= x; ++j)
			dis[i][j] = dis[j][i] = j - i;
			
	for(int i = y; i <= n; ++i)
		for(int j = i; j <= n; ++j)
			dis[i][j] = dis[j][i] = j - i;
	
	for(int i = x; i <= y; ++i)
		for(int j = i; j <= y; ++j)
			dis[i][j] = dis[j][i] = min(j - i, i - x + y - j + 1);
	
	for(int i = 1; i <= x; ++i)
		for(int j = x; j <= y; ++j)
			dis[i][j] = dis[j][i] = dis[i][x] + dis[x][j];
	
	for(int i = y; i <= n; ++i)
		for(int j = x; j <= y; ++j)
			dis[i][j] = dis[j][i] = dis[i][y] + dis[y][j];
	
	for(int i = 1; i <= x; ++i)
		for(int j = y; j <= n; ++j)
			dis[i][j] = dis[j][i] = x - i + j - y + 1;
	
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
			++ans[dis[i][j]];
	
	for(int i = 1; i < n; ++i)
		printf("%d\n", ans[i]);
}

Measured memory_bytes: 15872
#include<stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a>=c){
    if(a-c<=d||(a-b<=d&&b-c<=d))printf("Yes\n");
    else printf("No\n");
  }    
  if(c>a){
    if(c-a<=d||(c-b<=d&&b-a<=d))printf("Yes\n");    
    else printf("No\n");
  }
  return 0;
}


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

int main(){
    ll N; cin >> N;
    ll c =0;
    ll ans =1;

    while(c*c <= N){
        c++;
    }

    for(ll i=c; i>=0; i--){
        if(N % i == 0){
            ans = i;
            break;
        }
    }

    cout << ans + (N/ans) -2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    int a, b, c, k, Max;
    cin >> a >> b >> c >> k;
    Max = a;
    if(b > Max)
        Max = b;
    if(c > Max)
        Max = c;
    
    if(Max == a)
        cout << ((pow(2,k)*a) + b + c) << endl;
    else if(Max == b)
        cout << ((pow(2,k)*b) + a + c) << endl;
    else if(Max == c)
        cout << ((pow(2,k)*c) + a + b) << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

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

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



int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	map<ll, ll> x;
	map<ll, ll> y;
	for(ll i = 0; i < n; i++) {
		cin >> a[i];
		x[a[i] + i]++;
		y[i - a[i]]++;
	}
	ll ans = 0;

	for (auto itr = x.begin(); itr != x.end(); itr++) {
		ans += y[itr->first] * itr->second;
	}
	

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


Measured memory_bytes: 38956
N, K = map(int, input().split())
S = input()
A = []
if S[0] == '0':
  A.append(0)
i = 0
while i < len(S):
  j = i
  while j < len(S) and S[i] == S[j]:
    j += 1
  A.append(j - i)
  i = j
ans = 0
tot = 0
r = 0
for l in range(len(A)):
  while r < len(A) and r - l < 2 * K + 1:
    tot += A[r]
    r += 1
  if l % 2 == 0:
    ans = max(ans, tot)
  if r == l:
    r += 1
  else:
    tot -= A[l]
print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);

    for(int i = 0; i < N; ++i) {
        cin >> d.at(i);
    }
    
    sort(d.begin(), d.end());
    int ans = 1;
    int prev = d.at(0);
    for(int i = 1; i < N; ++i) {
        if(d.at(i) != prev) {
            prev = d.at(i);
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math

X, K, D = map(int, input().split())

X = abs(X)

#n = roundup(X/D)
n = math.floor(X/D)

if K<=n:
    ans = abs(X-K*D)
else:
    tmp = X-D*n
    if (K-n)%2==0:
        ans = abs(tmp)
    else:
        ans = abs(tmp-D)

print(ans)

Measured memory_bytes: 9184
// atcoder 
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    float mean = 0;
    for(int i=0; i<N; i++){
        mean += a[i];
    }
    mean = mean/N;
    int ans = 0;
    float sa = max(mean-a[0], a[0]-mean);
    for(int i=1; i<N; i++){
        float sa_i = max(mean-a[i], a[i]-mean);
        if(sa > sa_i){
            ans = i;
            sa = sa_i;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vvll vector<vll>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18+5
#define inf 1e9+5
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

template <typename T> T max(T a, T b, T c){ return max(a, max(b, c));}
template <typename T> T min(T a, T b, T c){ return min(a, min(b, c));}

int M = 1e9+7; //check
const int maxn = 3005;
int n ,t;
vii v;
int dp[maxn][maxn];
int val(int i, int remt)
{
	if(remt <= 0 || i == n) return 0;
	int &ans = dp[i][remt];
	if(ans != -1) return ans;
	return ans = max(val(i+1, remt-v[i].ff)+v[i].ss, val(i+1, remt));
}
int main() {
	_69e27;
	scanf("%d %d", &n, &t);
	v.resize(n);
	loop(i, n) scanf("%d %d", &v[i].ff, &v[i].ss);
	sort(all(v));
	memset(dp, -1, sizeof(dp));
	int ans = val(0, t);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

const int Nmax = 1e5 + 1;

int n, res;
int f[Nmax];

int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int x;
        cin >> x;
        f[x-1]++;
        f[x]++;
        f[x+1]++;
    }
    for(int i = 0; i <= Nmax; ++i){
        res = max(res, f[i]);
    }
    cout << res;
}


Measured memory_bytes: 640