akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <numeric>

std::vector<int> trump_cards()
{
	std::vector<char> mark = { 'S', 'H', 'C', 'D' };
	size_t size_mark = mark.size();

	std::vector<int> trump;
	for (size_t i = 0; i < size_mark; ++i)
	{
		for (int j = 1; j <= 13; ++j)
		{
			trump.push_back(mark[i]*100+j);
		}
	}
	return trump;
}

int main()
{
	std::vector<int> trump = trump_cards();

	int n;
	std::cin >> n;

	char mark;
	int number;

	for (int i = 0; i < n; ++i)
	{
		std::cin >> mark >> number;
		int card = mark * 100 + number;
		trump.erase(std::remove_if(trump.begin(), trump.end(), [&card](int x){return x == card;}), trump.end());
	}

	for (auto& item : trump)
	{
		mark = item / 100;
		number = item % 100;
		
		std::cout << mark << " " << number << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3112
O=list(input())
E=list(input())
ANS=""
for i in range(len(E)):
    ANS+=O[i]
    ANS+=E[i]
if len(O)>len(E):
    ANS+=O[len(O)-1]
ans=""
for i in range(len(ANS)):
    ans+=ANS[i]
print(ans)

Measured memory_bytes: 38384
import java.util.Arrays;
import java.util.Scanner;

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

        scanner.nextLine();
        final int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int sum = 0;
        int oddSum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
            if (i % 2 == 0) {
                oddSum += a[i];
            }
        }
        sum /= 2;

        int[] values = new int[a.length];
        values[0] = oddSum - sum;
        for (int i = 1; i < a.length; i++) {
            values[i] = a[i - 1] - values[i - 1];
        }

        for (int i = 0; i < values.length; i++) {
            if (i > 0) {
                System.out.print(" ");
            }
            System.out.print(values[i] * 2);
        }
        System.out.println();
    }
}

Measured memory_bytes: 60248
#import<bits/stdc++.h>
using namespace std;long N,n;vector<long> A;main(){for(cin>>N;cin>>n;n=1LL<<50)A.push_back(n);auto a=begin(A),t=a+1,d=end(A),b=t+1;partial_sum(a,d,a);for(--d;t+1!=d;++t){for(;a+1!=t&&*a<*t-*(a+1);++a);if(b==t)++b;for(;b+1!=d&&*b-*t<*d-*(b+1);++b);n=min(n,max({*a,*t-*a,*b-*t,*d-*b})-min({*a,*t-*a,*b-*t,*d-*b}));}cout<<n<<" ";}

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

#define int long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int N = 405;
int arr[N];
pair<int,int> dp[N][N];
pair<int,int> minus = {-1,-1};
int n;

pair<int,int> solve(int l,int r)
{
    if(l==r)
    {
        return {0,arr[l]};
    }

    if(dp[l][r].first != -1) return dp[l][r];

    int cost = 1e18;
    int sum  = 0;

    for(int i = l;i<r;i++)
    {
        auto cur1 = solve(l,i);
        auto cur2 = solve(i+1,r);

        sum = cur1.second + cur2.second;

        cost = min(cost,cur1.first + cur2.first + sum);
    }

    return dp[l][r] = {cost,sum};
}

int32_t main()
{
    FASTIO;

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

    for(int i = 0;i<N;i++)
    {
        for(int j = 0;j<N;j++)
         dp[i][j].first = -1,dp[i][j].second = -1;
    }

    auto ans = solve(0,n-1);
    cout<<ans.first;
    // cout<<" "<<ans.second;
}
 

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

int par[100001];  // 親
int Rank[100001]; // 木の深さ
int size[100001]; // 木の要素数

void init(int n){
	for(int i=1; i<=n; i++){
		par[i] = i;
		Rank[i] = 0;
		size[i] = 1;
	}
}

int find(int x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(Rank[x] < Rank[y]){
		par[x] = y;
		size[y] += size[x];
	}else{
		par[y] = x;
		size[x] += size[y];
		if(Rank[x] == Rank[y]) Rank[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
	int N, M;
	cin >> N >> M;
	int p[N+1], pos[N+1];
	for(int i=1; i<=N; i++){
		cin >> p[i];
		pos[p[i]] = i;
	}
	init(N);
	for(int i=0; i<M; i++){
		int a, b;
		cin >> a >> b;
		unite(a, b);
	}
	int ans = 0;
	for(int i=1; i<=N; i++){
		if(same(i, pos[i])) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(){
    int n, x;
    int i, j, k;
    
    while (1) {
        int ans = 0;
        
        scanf("%d %d", &n, &x);
        
        if (n == 0 && x == 0) {
            break;
        }
        
        for (i = 1; i <= n; i++) {
            for (j = 1; j <= n; j++) {
                for (k = 1; k <= n; k++) {
                    if (((i + j + k) == x) && (i < j) && (j < k)) {
                        ans++;
                    }
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return 0;
}



Measured memory_bytes: 2140
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    string s;
    cin >> s;
    if (s.back() == 's') {
        cout << s + "es" << '\n';
    } else {
        cout << s + "s" << '\n';
    }
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases
// multiset erase is does not do what it is supposed to


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[300005],c=0,i;
    long long sum=0;
    scanf("%d",&n);
    for(i=0;i<3*n;i++)
    scanf("%d",&a[i]);
    sort(a,a+3*n);
    for(i=3*n-2;c<n;c++,i-=2)
    sum+=a[i];
    printf("%lld",sum);
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  ll h,n,sum=0;
  cin>>h>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>=h){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define N 2505
#define M 5005
using namespace std;
typedef long long ll;

ll n, m, p, a[M], b[M], c[M], d[N];
int main() {
	int i, j;
	cin >> n >> m >> p;
	for(i=0; i<m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] -= p;
	}
	for(i=2; i<=n; i++) d[i] = -1e18;
	for(i=0; i<2*n; i++) for(j=0; j<m; j++) {
		if(d[a[j]] == -1e18) continue;
		if(d[a[j]] + c[j] > d[b[j]]) {
			if(i<n) d[b[j]] = d[a[j]] + c[j];
			else d[b[j]] = 1e18;
		}
	}
	if(d[n]==1e18) cout << -1;
	else cout << max(0LL, d[n]);
	return 0;
}

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

int main(){
  long long int A, B, X;
  cin >> A >> B >> X;
  
  long long int gap = X - (A % X);
  if (gap != X){
    A += gap;
  }
  
  long long int ans;
  if (B - A >= 0){
    ans = ((B - A) / X) + 1;
  }
  else{
    ans = 0;
  }
  
  cout << ans << endl;
}

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

map<ll,ll>mp,vis;
vector<ll>v;

int main()
{
	ll n, k, i , q, ans, x;

	cin>>n>>k>>q;
	for(i=1; i<=q; i++)
	{
		cin>>x;
		v.push_back(x);
		mp[x]++;
	}
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
	ll sum=0;
	for(i=0; i<v.size(); i++)
	{
		  sum+=mp[v[i]];
	}
	ll baki=0;
	for(i=1; i<=n; i++)
	{
		baki=sum;
		if(mp[i]!=0)
		{
		 baki=sum-mp[i];
		}
		if((k-baki)>0){
			cout<<"Yes"<<endl;
		}
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 7668
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        S: String,
        K: usize,
    }

    // 元の文字列の1~K文字目が全て1ならば、5000兆日後のK文字目も1
    // そうでない場合は、左から見た時に1ではない最初の数値が解

    for i in 0..min(S.len(), K) {
        if &S[i..=i] != "1" {
            println!("{}", &S[i..=i]);
            return;
        }
    }

    println!("1");
}


Measured memory_bytes: 2124
def f(l,r):
    p=2019
    for i in range(l,r+1):
        for j in range(l,r+1):
            if i==j:
                continue
            p=min((i*j)%2019,p)
    return p
    
l,r=map(int,input().split())
print(0 if r//2019-(l-1)//2019!=0 else f(l,r))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
	
using namespace std;
 
#define int long long
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)
 
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX/2;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;
	
	int n;
	cin >> n;
	vi a(n);
	for (int& x: a) cin >> x;
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans ^= a[i];
	}
	
	for (int i = 0; i < n; i++) {
		a[i] = ans^a[i];
	}
	
	for (int x: a) cout << x << ' ';
	cout << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;
int a,b,c,x,n,maxi,mini,i;

int main()
{
    cin>>n;
    maxi=0; mini=1001;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x>maxi) maxi=x;
        if(x<mini) mini=x;
    }
    cout<<maxi-mini<<'\n';
    return 0;
}


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

int main(){

    int A, B, K;
    cin >> K >> A >> B;

    for (int i = A; i <= B; i++){
        if (i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3624
# ABC109D - Make Them Even
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    A = list(list(map(lambda x: int(x) % 2, input().split())) for _ in range(H))
    ans = []
    for i in range(H):  # move left to right
        for j in range(W - 1):
            if A[i][j]:
                A[i][j] ^= 1
                A[i][j + 1] ^= 1
                ans += ["{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)]

    for i in range(H - 1):  # move up to down
        if A[i][W - 1]:
            A[i][W - 1] ^= 1
            A[i + 1][W - 1] ^= 1
            ans += ["{} {} {} {}".format(i + 1, W, i + 2, W)]
    print(len(ans))
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 18392
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.print((H-h)*(W-w));
	}
}


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

bool is_square(int n) {
    for(int i=1; i*i<=n; i++) {
        if(i * i == n) return true;
    }
    return false;
}

int main() {
    int N, D; cin >> N >> D;
    vector< vector<int> > X(N);
    for(int i=0; i<N; i++) {
        for(int j=0; j<D; j++) {
            int val; cin >> val;
            X[i].emplace_back(val);
        }
    }

    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            int sum = 0;
            for(int k=0; k<D; k++) {
                int diff = X[i][k] - X[j][k];
                sum += diff * diff;
            }

            if(is_square(sum)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<string> s(N);
  for(int i=0;i<N;++i){
    cin>>s[i];
  }
  
  int M;
  cin>>M;
  
  vector<string> t(M);
  for(int i=0;i<M;++i){
    cin>>t[i];
  }
  
  int ans=0;
  map<string,int> mp;
  for(int i=0;i<N;++i){
    ++mp[s[i]];
  }
  for(int i=0;i<M;++i){
    --mp[t[i]];
  }
  
  for(int i=0;i<N;++i){
    ans=max(mp[s[i]],ans);
  }
  
  cout<<ans<<endl;
}


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

int main(){
  long long x, s, t;
  t = 0;
  s = 10;
  cin >> x;
  if(x % 2ll == 1){
    cout << '0' << endl;
    return 0;
  }
  else{
    while(x / s > 0){
      t = t + x / s;
      s = s * 5ll;
    }
    cout << t << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC66();
}

void ABC66(void){
    int i,max;
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    max=a[0];
    for(i=1;i<3;++i){
        if(max<a[i])max=a[i];
    }
    cout<<a[0]+a[1]+a[2]-max<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a,b,c,x,d;
  d=0;
  scanf("%d %d %d", &a,&b,&c);

  for(x = a; x <= b; x++){
  if ( c%x == 0 )
  d++;
  }
  printf("%d\n", d);
  return 0;
}

Measured memory_bytes: 596
n = int(input())
a = list(map(int,input().split()))
cost = [0] + a + [0]

q = [0] * (n + 2)
SUM = 0
for i in range(n + 1):
    temp = abs(cost[i + 1] - cost[i])
    SUM += temp
    q[i] += temp
    q[i + 1] += temp
#print(SUM)

for i in range(n):
    temp = abs(cost[i + 2] - cost[i])
    print(SUM + temp - q[i + 1])

Measured memory_bytes: 59884
#include <stdio.h>

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

    int multip = ((n*(n - 1))/2);
    int multii = ((m*(m - 1))/2);

    int resultado = multip + multii;

    printf("%d", resultado);

    return 0;
}



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

using namespace std;

void solve()
{
	int x, y, z;
	cin >> x >> y >> z;
	int s = (x + y + z) / 2;
	cout << sqrt(s * (s - x) * (s - y) * (s - z)) << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 764
from math import sqrt, floor, log


def is_prime(num):
    if num <= 1:
        return False

    for i in range(2, floor(num / 2) + 1):
        if i == num:
            break
        if num % i == 0:
            return False
    return True


def get_divisors3(num):
    ans = []
    value = num
    i = 2
    while (i * i) <= num:
        count = 0
        while value % i == 0:
            count += 1
            value = value // i

        if count != 0:
            ans.append((i, count))
        i += 1
    return ans


def main():
    n, p = [int(i) for i in input().split()]
    if n == 1:
        print(p)
    elif p == 1:
        print(1)
    else:
        ds = get_divisors3(p)
        ans = 1
        for d in ds:
            if d[1] >= n:
                ans *= d[0] ** (d[1] // n)
        print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
n = int(input())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
P = []
P_1 = 0
P_2 = 0
P_3 = 0
P_m = 0

for i in range(n):
    if X[i] > Y[i]:
        P.append(X[i]-Y[i])
    else:
        P.append(Y[i]-X[i])

for i in range(n):
    P_1 += P[i]
    P_2 += P[i]**2
    P_3 += P[i]**3
P_2 = P_2**(1/2)
P_3 = P_3**(1/3)
P_m = max(abs(x-y) for x,y in zip(X,Y))

print('{:.6f}'.format(P_1))
print('{:.6f}'.format(P_2))
print('{:.6f}'.format(P_3))
print('{:.6f}'.format(P_m))


Measured memory_bytes: 5656
#include<iostream>
#include<cmath>

using namespace std;

void StringHandle(string, int&, int&);
int Atoi(string);

int main(){
  int i, n, hour, minute;
  double h_radian, m_radian, radian;
  string clock;

  cin >> n;

  for(i=0; i<n; ++i){
    cin >> clock;
    StringHandle(clock, hour, minute);

    h_radian = (60*hour + minute) * M_PI / 360;
    m_radian = minute * M_PI / 30;
    radian = h_radian - m_radian;
    if(radian < 0) radian = -radian;
    if(radian > M_PI) radian = 2*M_PI - radian;

    if(radian < M_PI/6)
      cout << "alert" << endl;
    else if(radian >= M_PI/2)
      cout << "safe" << endl;
    else
      cout << "warning" << endl;
  }

  return 0;
}

void StringHandle(string s, int& h, int& m){
  string s1, s2;
  copy(s.begin(), s.begin()+2, back_inserter(s1));
  copy(s.begin()+3, s.end(), back_inserter(s2));
  h = Atoi(s1);
  m = Atoi(s2);
}

int Atoi(string s){
  int one, ten;
  ten = s[0] - 48;
  one = s[1] - 48;
  return 10*ten + one;
}

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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

// Sieve of Eratosthenes
vi get_primes(int input) {
    int N = max(input, 100);

    vb Alive(N, true);
    Alive.at(0) = false;
    Alive.at(1) = false;

    // i番目の素数が分かる (0-origin)
    vi Ps;

    FORE(smallest, 2, (int)(sqrt(N)+1)) {
        if (!Alive.at(smallest)) {
            continue;
        }

        for(int i = smallest * 2; i < N; i += smallest) {
            Alive.at(i) = false;
        }
    }

    REP(i, N) {
        if (Alive.at(i)) {
            Ps.pb(i);
        }
    }

    return Ps;
}


signed main() {
    make(int, X);

    vi primes = get_primes(1000000);
    for(auto p : primes) {
        if (p >= X) {
            cout << p << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 4092
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

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

    if(x<100)
    	cout<<0<<endl;
    else
    {
    	ll z=x/100;
    	ll rem=x-100*z;
    	if(rem<=5*z)
    		cout<<1<<endl;
    	else cout<<0<<endl;
    }

   }

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	double xa, ya, xb, yb, xc, yc, xd, yd;
	while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
		double b1x, b1y, b2x, b2y;
		b1x = xb-xa;
		b1y = yb-ya;
		b2x = xd-xc;
		b2y = yd-yc;
		if (fabs(b1x*b2x+b1y*b2y) <= 0.00000000001) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

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

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

	int rateBound[] = { 399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 4801 };
	int rateDist[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 9; ++j) {
			if (a[i]<=rateBound[j]) {
				rateDist[j]++;
				break;
			}
		}
	}

	int result = 0;
	for (int i = 0; i < 8; ++i) {
		if (rateDist[i]!=0) {
			result++;
		}
	}

	cout << max(result,1) << " " << max(result+rateDist[8],1) << endl;
}


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

using namespace std;

bool is_palindrome(string s)
{
    string s1=s;
    reverse(s.begin(),s.end());
    return(s==s1);
}

int main()
{
    string s;
    int ans=0;
    cin>>s;
    if(!is_palindrome(s))
    {
        for(int i=0;i<s.size()/2;i++)
        {
            if(s[i]!=s[s.size()-i-1]) ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int W,H,x,y,r,circle;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x-r<0 || x+r>W){
    printf("No\n");
  }
  else if(y-r<0 || y+r>H){
    printf("No\n");
  }
  else printf("Yes\n");
  return 0;
}


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

using namespace std;

long double pi = 6.28318530717958623200;

int main() {
	int n,m;
	cin >> n >> m;
	std::vector<int> arr(m);
	long long int sum = 0;
	for (int i=0;i<m;++i){
	    cin >> arr[m];
	    sum += arr[m];
	}
	if (sum > n) cout << -1;
	else cout << n - sum ;
	return 0;
}

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

using namespace std;

int h, w;
int a[85][85];
int dp[85][85][14000];

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

    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int b;
            cin>>b;
            a[i][j] -= b;
            a[i][j] = abs(a[i][j]);
        }
    }
    dp[0][0][a[0][0]] = 1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<=80*(i+j+1);k++){
                if(!dp[i][j][k]) continue;
                dp[i+1][j][k+a[i+1][j]] = 1;
                dp[i+1][j][abs(k-a[i+1][j])] = 1;
                dp[i][j+1][k+a[i][j+1]] = 1;
                dp[i][j+1][abs(k-a[i][j+1])] = 1;
            }
        }
    }

    for(int i=0;i<=80*(h+w+1);i++){
        if(dp[h-1][w-1][i]){
            cout<<i;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 375424
inf = float('inf')
N = int(input())

from math import floor
# 約数全列挙(ソート済み)
# n = 24 -> [1,2,3,4,6,8,12,24]
def divisor(n):
    left = [1]
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            left.append(p)
            right.append(n//p)
    return left, right

ans = inf
left, right = divisor(N)
for i, j in zip(left, right):
    d = abs(i-1) + abs(j-1)
    ans = min(ans, d)

print(ans)

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  int n;
  cin >> n;
  vector<double> x(n, 0);
  vector<string> u(n, "@");
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> u[i];
  }
  double res = 0;
  for (int i = 0; i < n; i++) {
    if(u[i] == "JPY") res += x[i];
    else res += x[i] * 380000;
  }

  printf("%lf\n",res);

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

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

typedef long long ll;

using namespace std;



int main() {

	int N,M;
	cin >> N >> M;

	priority_queue<int> q;	//include<queue>が必要
	rep(i, N) {
		int A;
		cin >> A;
		q.push(A);
	}

	rep(i, M) {
		int A = q.top();	
		q.pop();
		q.push(A / 2);
	}

	ll ans = 0;
	rep(i, N) {
		ans += q.top();
		q.pop();
	}

	cout << ans << endl;

	//現段階でのMAXを取得する→priority_queueを使用する
	//優先順位つきキューで検索
	//
	//
	//
	//
	//

	return 0;
}


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

int main()
{
  int e, y;
  cin >> e >> y;

  if(e == 0){
    if(1868 <= y && y <= 1911) cout << 'M' << y - 1868 + 1;
    if(1912 <= y && y <= 1925) cout << 'T' << y - 1912 + 1;
    if(1926 <= y && y <= 1988) cout << 'S' << y - 1926 + 1;
    if(1989 <= y && y <= 2016) cout << 'H' << y - 1989 + 1;
  }

  else if(e == 1) cout << 1868 + y - 1;
  else if(e == 2) cout << 1912 + y - 1;
  else if(e == 3) cout << 1926 + y - 1;
  else if(e == 4) cout << 1989 + y - 1;

  cout << endl;

  return 0;

}






Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
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<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i, 2) rep(j, 2) {
        vector<int> ans(n);
        ans[0] = i;
        ans[1] = j;
        for (int k = 0; k < n; ++k) {
            ans[(k+2)%n] = ans[k]^ans[(k+1)%n]^(s[(k+1)%n] == 'x');
        }
        if (ans[0] == i && ans[1] == j) {
            rep(k, n) cout << (ans[k] ? 'W' : 'S');
            cout << endl;
            return 0;
        }
    }
    puts("-1");
}


Measured memory_bytes: 4248
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();

      long[] arr = new long[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextLong();

      long time = 0;
      long a = 1;
      for(int i = 0; i < n; i++) {
          a = lcm(a, arr[i]);
          time = Math.max(time, a);
      }
      
      System.out.println(time);
  }
  
  private static long lcm(long a, long b) {
      return a * (b / gcd(a, b));
  }
  
  private static long gcd(long a, long b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int a, b, q;
    cin >> a >> b >> q;
    VL s(a + 2), t(b + 2);
    s[0] = -100000000000, s[a + 1] = 100000000000;
    t[0] = -100000000000, t[b + 1] = 100000000000;
    eFOR(i, 1, a)cin >> s[i];
    eFOR(i, 1, b)cin >> t[i];

    ll x;
    while (q--) {
        cin >> x;
        VL S, T;
        S = { *--lower_bound(all(s), x),*upper_bound(all(s), x) };
        T = { *--lower_bound(all(t), x),*upper_bound(all(t), x) };

        ll ans = LLINF;
        FOR(i, 0, 2)FOR(j, 0, 2) {
            ll d = abs(S[i] - T[j]);
            chmin(ans, d + min(abs(S[i] - x), abs(T[j] - x)));
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int cal(int x,int y){
  return x * y;
}


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

 s1 = cal(a,b);
 s2 = cal(c,d);

 if(s1 > s2){
   cout << s1 << endl;
 }else{
   cout << s2 << endl;
 }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   pii;
typedef vector<int>     vi;
typedef long double     ld;
#define MOD         1000000007
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        '\n'
#define PI          3.14159265359d
#define sz(x)       (int)x.size()
int A[100005];
int main()
{
    //std::ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n,i,res=0;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>A[i];
    for(i=1;i<=n;i++)
        if(A[i]==i)
        {
            swap(A[i],A[i+1]);
            res++;
        }
    cout<<res;
    return 0;
}


Measured memory_bytes: 640
main :: IO ()
main = do
  s <- getLine
  print $ length $ solve $ deleteLast s

deleteLast s = take (length s - 1) s

solve s =
  if isEvenString s
    then s
    else solve $ deleteLast s

isEvenString s
  | length s `mod` 2 == 1 = False
  | otherwise =
      let len = length s `div` 2
          first = take len s
          second = drop len s
      in
        first == second


Measured memory_bytes: 892
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var [a,b,x]=input.trim().split(" ").map(Number);
var min=Infinity;
for(var i=0;i<=20;i++){
   for(var j=0;j<=40;j++){
      if(i*1000+j*500>=x)min=Math.min(min,i*a+j*b);
   }
}
console.log(min);


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

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

    ll num1, num2;
    num1 = t[0];
    num2 = a[0];
    rep(i, 0, n)
    {
        ll m = max(
                (num1 + t[i] - 1) / t[i],
                (num2 + a[i] - 1) / a[i]);
        num1 = m * t[i];
        num2 = m * a[i];
        // cout << num1 << ' ' << num2 << ' ' << m << endl;
    }
    cout << num1 + num2 << endl;
    return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	int n =sz(s), ans = sz(s);
	VI ct(2);
	rep(i, n) ct[s[i]-'0']++;

	for(int i=0; ct[0] && ct[1] && i<n; i++){
		ans--;
		ct[s[i]-'0']--;
		ct[s[n-1-i]-'0']--;
	}
	cout << ans <<"\n";
	
	
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

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

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

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

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

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

int main() {
	ll n; cin >> n;
	vector<pair<ll,ll>> a(n);
	for (int i = 0; i < n; i++) {
		ll x; cin >> x;
		a[i] = make_pair(x, i);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		cout << a[i].second+1 << " ";
	}
}

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

#define ll long long
#define ar array

int n, h[100000], dp[100000];

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

	cin >> n;
	for (int i=0; i<n; ++i) cin >> h[i];
	dp[1]=abs(h[1]-h[0]);
	for (int i=2; i<n; ++i) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[n-1];
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 4336
from itertools import combinations
dic = dict(zip(list("MARCH"),[0]*len("MARCH")))
N = int(input())
for i in range(N):
    tmp = input()[0]
    if tmp in "MARCH":
        dic[tmp] += 1
c = combinations(list("MARCH"),3)
ans = 0
for i in c:
    ans += dic[i[0]]*dic[i[1]]*dic[i[2]]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...)
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 2000010

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int main(){
    int j,k,i,T,ca=0,K=0,m;
    ll n;
    scanf("%lld", &n);
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(i * i > n)break;
        if(n % i == 0){
            if(i > 1 && n / i < i - 1)ans += i - 1;
            ll j = n / i;
            if(j > i){
                if(j > 1 && n / j < j - 1)ans += j - 1;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 200010, M = 2000005;
ll n, a[N],pre=1, res=0;
int solve()
{
	in1(n);
	for(int i=0;i<n;i++) in1(a[i]);
		sort(a, a+n);
	for(int i=0;i<n;i++)
	{
		if(pre==0) break;
		ll k = (ll)MAX/pre;
		// out(k);
		if(a[i]<=k) pre*=a[i];
		else
		{
			res=-1;
			break;
		} 
		// out(pre);
	}
	if(res==0) res=pre;
	printf("%lld\n", res);
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int ret = solve();
	return 0;
}
/*

*/


Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
int n,m,sum=0;
int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1;i<=m;i++){
		int temp;
		scanf("%d",&temp);
		sum+=temp;
	}
	if (sum>n) printf("-1\n");
	else printf("%d\n",n-sum);
	return 0;
}

Measured memory_bytes: 3764
#include "bits/stdc++.h"

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int N, A, B;
	cin >> N >> A >> B;
	int p[123];
	int a=0, b=0, c=0;
	for (int i = 0; i < N; i++){
		cin >> p[i];
		if (p[i] <= A) a++;
		else if (p[i] <= B) b++;
		else c++;
	}
	int d = min(min(a, b), c);

	cout << d << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int Maxn=1e6+5;
int main()
{
   long long ans=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){
            ans+=i;
        }
    }
    cout<<ans;
} 

Measured memory_bytes: 3164
n = int(input())
d = list(map(int,input().split()))
M = [sum(d[::2])-sum(d[1::2])]
print(M[0],end=" ")
M += [0]*(n-1)
for i in range(n-1):
  ans = 2*d[i]-M[i]
  M[i+1] = ans
  print(M[i+1],end=" ")
  




Measured memory_bytes: 14028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

int main(){
  int K, X;
  cin >> K >> X;
  int left, right;
  left = max(X-K+1, -1000000);
  right = min(X+K-1, 1000000);
  for(int i = left; i < right; i++){
    cout << i << " ";
  }
  cout << right << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
  
void solve() {
	ll n, W;
	cin >> n >> W;
	ll w[n], v[n];
	ll total = 0;
	For(i, 0, n) {
		cin >> w[i] >> v[i];
		total += v[i];
	}
	ll dp[total + 1];
	For(i, 0, total + 1) {
		dp[i] = ee;
	}
	dp[0] = 0;
	For(i, 0, n) {
		For(j, total, -1) {
			if(j - v[i] > -1) {
				dp[j] = min(dp[j], w[i] + dp[j - v[i]]);
			}
		}
	}
	ll ans = 0;
	For(i, 0, total + 1) {
		if(dp[i] <= W)
			ans = max(i, ans);
	}
	cout << ans << "\n";
}

int main() {
    fio;
    ll t = 1;
    //cin >> t;
    while(t--) {
    	solve();
    }
}

Measured memory_bytes: 4420
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
#define mod 1000000007
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin>>x;
    cout<<x*x*x;
}  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b;
	cin >> a >> b;
	if (b > 13) b = 12;

	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256