akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<vector<int>> g(6, vector<int>(2, -1));
    g[0][0] = 1;
    g[0][1] = 2;
    g[1][1] = 3;
    g[2][0] = 1;
    g[3][0] = 4;
    g[3][1] = 5;
    g[4][0] = 5;
    g[4][1] = 2;
    g[5][0] = 2;
    g[5][1] = 1;
    string path;
    while(cin >> path, path != "#") {
        bool ok = true;
        int now = 0;
        for(int i=0; i<path.size(); ++i) {
            int next = g[now][path[i] - '0'];
            if(next == -1) {
                ok = false;
                break;
            } else {
                now = next;
            }
        }
        if(ok && now == 5) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3196
use proconio::*;
use std::collections::HashSet;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        S: [String; N],
    }
    let mut set: HashSet<String> = HashSet::new();
    for s in S.iter() {
        set.insert(s.clone());
    }
    let ans = set.iter().count();
    println!("{}", ans);
}


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

using namespace std;

const int N = 1e4 + 10;
const int INF = 0x3f3f3f3f;

int h, n, a[N], b[N], dp[N];

int main() {
	scanf("%d %d", &h, &n);
	for (int i = 1; i <= n; ++i) scanf("%d %d", &a[i], &b[i]);
	for (int i = 1; i <= h; ++i) dp[i] = INF;
	for (int i = 1; i <= n; ++i) {
		for (int j = a[i]; j <= h; ++j) dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
	}
	int ans = INF;
	for (int i = 1; i <= n; ++i) {
		for (int j = h; j >= max(0, h - a[i]); --j) {
			ans = min(ans, dp[j] + b[i]);
		}
	}
	printf("%d", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
 ll k;
 cin >> k;
  
 ll x[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}; 
  
  cout << x[k-1] << endl;
  
}

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

int main() {
	ios::sync_with_stdio(0);
	int n; n = 3; 
int sum = 0; 
	for(int i = 0; i < n; i++) {
		int x; cin >> x; 
		sum += x; 
	}
	if (sum >= 22) cout << "bust\n";
	else cout << "win\n";
	return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String[] year = s.split("/");
		if(Integer.parseInt(year[0]) < 2019 ) {
			System.out.println("Heisei");
		} else if(Integer.parseInt(year[0]) > 2019) {
			System.out.println("TBD");
		} else if(Integer.parseInt(year[1]) <= 4) {
			System.out.println("Heisei");
		} else {
			System.out.println("TBD");
		}
	}
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var p = ReadLine().Split().Select(int.Parse).ToArray();
        var ans = 0;
        for (int i = 2; i < p.Length; i++)
        {
            var a = new int[3];
            a[0] = p[i - 2];
            a[1] = p[i - 1];
            a[2] = p[i - 0];
            Array.Sort(a);
            if (a[1] == p[i - 1]) ans++;
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define le 100005
#define la 102
#define ll long long int
using namespace std;
int len, cost[la], cap;
ll val[la], dp[la][le];
bool vis[la][le];
ll fnc(int i, int sum){
  if(i == len) return 0;
  if(vis[i][sum]) return dp[i][sum];
  ll v1 = 0;
  if(sum + cost[i] <= cap) v1 = val[i] + fnc(i + 1, sum + cost[i]);
  ll v2 = fnc(i + 1, sum);
  dp[i][sum] = max(v1, v2);
  vis[i][sum] = true;
  return dp[i][sum];
}
int main(){
  //freopen("input.txt", "r", stdin);
  scanf("%d %d", &len, &cap);
  for(int i = 0; i < len; scanf("%d %lld", &cost[i], &val[i]), i++);
  printf("%lld\n", fnc(0, 0));
  return 0;
}


Measured memory_bytes: 87936
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    res = [[] for _ in range(2 ** 3)]

    if m == 0:
        print(0)
        exit()

    for _ in range(n):
        a = na()

        for i in range(2 ** 3):
            tmp = 0
            for j in range(3):
                if i >> j & 1:
                    tmp += -a[j]
                else:
                    tmp += a[j]
            res[i].append(tmp)

    ans = -INF
    for resi in res:
        resi.sort(reverse=True)
        ans = max(ans, sum(resi[:m]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9872
#include <bits/stdc++.h>
using namespace std;
int N;
char s1[105];
char s2[105];
char s3[105];
int main()
{
    scanf("%d", &N);
    scanf("%s%s%s", s1, s2, s3);
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(s1[i] == s2[i] && s1[i] == s3[i]) continue;
        if(s1[i] == s2[i] || s1[i] == s3[i] || s2[i] == s3[i]) ans++;
        else ans += 2;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

 int main(){

  ll n;
  string s;
  cin>>n>>s;

  vector<int>e(n,0);
  vector<int>w(n,0);

  ll west=0,east=0;

  for(ll i=0;i<n;i++){
      w[i] = west;
      if(s[i] == 'W') west++;
  }

  for(ll i=n-1;i>=0;i--){
      e[i] = east;
      if(s[i] == 'E') east++;
  }

  int ans = 1e9;
  for(ll i=0;i<n;i++){
      ans = min(ans,e[i]+w[i]);
  }

  cout<<ans<<endl;

 return 0;
 }


Measured memory_bytes: 6080
S = input()
T = input()

s=len(S)
t=len(T)

ans=0

mylist=[]

for i in range(s-t+1):
    for j in range(t):
        if S[i:i+t][j]==T[j]:
            ans=ans+1
    mylist.append(ans)
    ans=0
print(t-max(mylist))

Measured memory_bytes: 67964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N;
    ll ans = 0, s = 0;
    cin >> N;
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        s += a[i] / N;
        b[i] = a[i] / N;
        a[i] -= b[i] * N;
    }
    ans = s;
    while (1) {
        ll s1 = 0;
        for (int i = 0; i < N; i++) {
            a[i] += s - b[i];
            s1 += a[i] / N;
            b[i] = a[i] / N;
            a[i] -= b[i] * N;
        }
        s = s1;
        ans += s1;
        if (s1 == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(read().split(),np.int64)

MOD = 10 ** 9 + 7

U = 10 ** 6 + 10
is_prime = np.zeros(U, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3,U,2):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p+p] = 0

M = 10 ** 3
small_primes = np.where(is_prime[:M])[0].tolist()

B = A.copy()
lcm = 1
for p in small_primes:
    e = 0
    while np.any(A % p == 0):
        e += 1
        A[A % p ==0] //= p
    lcm *= p**e
    lcm %= MOD

for x in set(A.tolist()):
    lcm *= x
    lcm %= MOD

answer = sum(pow(x, MOD-2, MOD) for x in B.tolist()) % MOD
answer *= lcm
answer %= MOD
print(answer)

Measured memory_bytes: 22608
s=input()

def check(s,start,stop):
    a=start
    b=stop
    while(a<=b):
        if(s[a]==s[b]):
            a+=1
            b-=1
        else:
            return False
    return True

if(check(s,0,len(s)-1) and check(s,0,((len(s)-1)//2)-1) and check(s,((len(s)+3)//2)-1,len(s)-1)):
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    // (1, 1) to (a, b) => a + b - 2
    long long n, ans = 1e12 + 50;
    cin >> n;
    // procurar a e b, tal q a * b == N
    for(long long i = 1; i * i * 1LL <= n; i++) {
        if(n % i == 0) {
            ans = min(ans, i + (n / i) - 2);
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, L = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int)

s = A[1:] + A[:-1]

if s.max() >= L:
    print('Possible')
    last = s.argmax()
    ans = list(range(N - 1))
    for i in range(last):
        print(i + 1)
    for i in reversed(range(last + 1, N - 1)):
        print(i + 1)
    print(last + 1)
else:
    print('Impossible')


Measured memory_bytes: 21512
S = input()

a = "SUN"
b = "MON"
c = "TUE"
d = "WED"
e = "THU"
f = "FRI"
g = "SAT"
if S == a:
    print(7)
if S == b:
    print(6)
if S == c:
    print(5)
if S == d:
    print(4)
if S == e:
    print(3)
if S == f:
    print(2)
if S == g:
    print(1)



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LLI;

int main()
{
	int n, m;
	cin >> n >> m;
	char arr[n][m];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> arr[i][j];
			
	for(int i = 0; i < m+2; i++)
		cout << "#";
	cout << "\n";
	
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
		{
			if( j == 0 )
				cout << "#";
			cout << arr[i][j];
			if( j == m-1 )
				cout << "#\n";
		}
			
	for(int i = 0; i < m+2; i++)
		cout << "#";
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B;
  cin >> A >> B;
  if (A + B >= 24)
    cout << A + B - 24 << endl;
  else
    cout << A + B << endl;
  return 0;
}


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

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  int left[n+1], right[n+1];
  left[0] = a[0];
  for (int i=0; i<n; i++) {
    left[i+1] = gcd(left[i], a[i]);
  }
  right[n] = a[n-1];
  for (int i=n-1; i>=0; i--) {
    right[i] = gcd(right[i+1], a[i]);
  }
  int ans = max(left[n-1], right[1]);
  for (int i=1; i<n-1; i++) {
    ans = max(gcd(left[i], right[i+1]), ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// 2013/03/17
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, w;

	void run(){
		n=sc.nextInt();
		w=sc.nextInt();
		solve();
	}

	@SuppressWarnings("unchecked")
	void solve(){
		ArrayList<Integer>[] div=new ArrayList[n+2];
		for(int i=0; i<div.length; i++){
			div[i]=new ArrayList<Integer>();
		}
		for(int i=1; i<=w; i++){
			for(int j=i; j<=n; j+=i){
				div[j].add(i);
			}
		}
		int[] count=new int[n+1];
		for(int i=1; i<=w; i++){
			for(int d : div[i]){
				count[d]++;
			}
		}
		int sum=w;
		for(int i=1; i<=n-w+1; i++){
			print(sum+(i<n-w+1?" ":"\n"));
			// iを消すかも
			if(count[i]<2){ // i
				sum--;
			}
			for(int d : div[i]){
				if(--count[d]==1){
					sum--;
				}
			}
			sum++; // count[i+w] = 0
			for(int d : div[i+w]){
				if(++count[d]==2&&d<=i){
					sum++;
				}
			}
		}
	}

	boolean[] flag;
	int[] count;
	int sum, left, right;

	void solve_(){
		flag=new boolean[n+1];
		count=new int[n+1];
		sum=0;
		left=1;
		right=w+1;
		for(int i=1; i<w; i++){
			for(int k=1; k*k<=i; k++){
				if(i%k==0){
					count[k]++;
					update(k);
					if(i/k!=k){
						count[i/k]++;
						update(i/k);
					}
				}
			}
		}
		for(int i=0; i<n-w+1; i++){
			left=i+1;
			right=i+w+1;
			for(int k=1; k*k<=i; k++){
				if(i%k==0){
					count[k]--;
					update(k);
					if(i/k!=k){
						count[i/k]--;
						update(i/k);
					}
				}
			}
			for(int k=1; k*k<=i+w; k++){
				if((i+w)%k==0){
					count[k]++;
					update(k);
					if((i+w)/k!=k){
						count[(i+w)/k]++;
						update((i+w)/k);
					}
				}
			}
			update(left-1);
			update(right-1);
			// debug("i", i, "i+w-1", i+w-1);
			// debug("count", count);
			// debug("flag", flag);
			// debug("sum", sum);
			// debug(sum);
			// debug();
			print(sum+(i<n-w?" ":"\n"));
		}
		// iの約数が減って
		// i+wの約数が増える
		// iが確定じゃなくなった
		// i+wが確定する
	}

	void update(int i){
		boolean det=left<=i&&i<right;
		if(flag[i]&&!det&&count[i]<2){
			flag[i]=false;
			sum--;
		}
		if(!flag[i]&&(det||count[i]>=2)){
			flag[i]=true;
			sum++;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
		System.out.flush();
	}
}

Measured memory_bytes: 75200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rItr(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define Itr(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define setp(n) fixed << setprecision(n)
#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define All(a) (a.begin()),(a.end())
#define rAll(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll H,W,h,w;
	cin>>H>>W;
	cin>>h>>w;
	cout<<(H-h)*(W-w)<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
ac=0
wa=0
tle=0
re=0

for i in range(n):
  s=input()
  if s=='AC':
    ac+=1
  if s=='WA':
    wa+=1
  if s=='TLE':
    tle+=1
  if s=='RE':
    re+=1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << (s.size() <= n ? s : s.substr(0, n) + "...") << endl;
    return 0;
}


Measured memory_bytes: 3632
N=int(input())
M=[input().split()[2:]for _ in[0]*N]
q=[0]
d=[-1]*N;d[0]=0
while q:
 u=q.pop(0)
 for v in M[u]:
  v=int(v)-1
  if d[v]<0:d[v]=d[u]+1;q+=[v]
for i in range(N):print(i+1,d[i])


Measured memory_bytes: 5624
#include <cstdint>

using namespace std;

uint64_t merge(uint32_t vec[], size_t start, size_t mid, size_t end)
{
  uint32_t left_num = mid - start;
  uint32_t *left = new uint32_t[left_num + 1];

  uint32_t right_num = end - mid;
  uint32_t *right = new uint32_t[right_num + 1];

  for (uint32_t i = 0; i < left_num; i++) {
    left[i] = vec[start + i];
  }
  left[left_num] = UINT32_MAX;

  for (uint32_t i = 0; i < right_num; i++) {
    right[i] = vec[mid + i];
  }
  right[right_num] = UINT32_MAX;

  uint64_t cnt = 0;
  uint32_t i_left = 0, i_right = 0;
  for (uint32_t i = start; i < end; i++) {
    if (left[i_left] < right[i_right]) {
      vec[i] = left[i_left];
      i_left++;
    } else {
      vec[i] = right[i_right];
      cnt += left_num - i_left;
      i_right++;
    }
  }

  delete[] left;
  delete[] right;
  return cnt;
}

uint64_t merge_sort(uint32_t vec[], size_t start, size_t end)
{
  if (start + 1 < end) {
    size_t mid = (start + end) / 2;
    uint64_t m1 = merge_sort(vec, start, mid);
    uint64_t m2 = merge_sort(vec, mid, end);
    uint64_t m3 = merge(vec, start, mid, end);
    return m1 + m2 + m3;
  }

  return 0;
}

uint64_t number_of_inversion(uint32_t vec[], size_t size)
{
  return merge_sort(vec, 0, size);
}

#if !defined(TEST)
#include <iostream>
#include <vector>
static vector<uint32_t> vec;

int32_t main()
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 0; i < num; i++) {
    uint32_t val;
    cin >> val;
    vec.push_back(val);
  }

  cout << number_of_inversion(&vec[0], vec.size()) << endl;

  return 0;
}
#endif

Measured memory_bytes: 4472
#include <stdio.h>

int main(){
    int menu[5], i, tmp1, tmp2;
    
    for (i = 0; i < 5; i++)
        scanf("%d", &menu[i]);
    
    if(menu[0] < menu[1]){
        if (menu[1] < menu[2]) {
            tmp1 = menu[0];
        }else if(menu[0] > menu[2]){
            tmp1 = menu[2];
        }else
            tmp1 = menu[0];
    }else
        if (menu[1] < menu[2]) {
            tmp1 = menu[1];
        }else if(menu[0] < menu[2]){
            tmp1 = menu[0];
        }else
            tmp1 = menu[2];
    
    if(menu[3] < menu[4])
        tmp2 = menu[3];
    else
        tmp2 = menu[4];
    
    printf("%d\n", tmp1 + tmp2 -50);
    return 0;
}

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

using namespace std;

using llong = long long;
using ullong = unsigned long long;

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

  llong pat = 0;
  llong sum = 0;
  int j=0;
  for(int i=0;i<n;++i){
    for(;j<n&&((sum^a[j])==(sum+a[j]));++j){
      sum += a[j];
    }
    pat += j - i;
    if( j == i ){
      ++j;
    }else{
      sum -= a[i];
    }
  }
  cout << pat << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
    p[i] = p[i]-x;
  }
  sort(p.begin(), p.end());
  int i = 0;
  int k = 0;
  while(true){
    bool ok = true;
    k = 0;
    for(int j = 0; j < n; j++){
      if(p[j]*(-1) == i){
        for(int r = 0; r < n; r++){
          if(p[r] == i) ok = false;
          k = 1;
        }
      }
      if(ok == false) break;
    }
    if(ok == true) break;
    i++;
  }
  if(k == 1) cout << x+i << endl;
  else cout << x-i << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
int main()
{
	dhoom;
	ll n;
	cin >> n;
	ll i = 0;
	while(i * i <= n)
		i++;
	i -= 1;
	cout << i*i << endl;
}


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

// Numeric Constants
#define N 1000000007
#define maxs 200005
#define mins 1005
#define eps 1e-14
#define imax 2000000200
#define llmax 1000000002000000000ll
#define pi 3.141592653589793

// Others
#define ll long long
#define pb push_back
#define gc getchar_unlocked
#define iosbase ios_base::sync_with_stdio(false)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<pair<int,int>,int>
#define ppl pair<pll,ll>
#define vi vector<int>
#define sc scanf
#define pr printf
#define lld I64d
#define F first
#define S second
#define siter set<int>::iterator
#define p_pq priority_queue
#define ub upper_bound
#define lb lower_bound

string given[mins],ans[mins],ans1[mins];

int main()
{	
	iosbase;
	int h,w,i,j,k;
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>given[i];
		ans[i]=ans1[i]="";
		for(j=0;j<w;j++){
			ans1[i]+=".";
			ans[i]+=".";
		}
	}
	for(i=0;i<h;i++){
		ans[i][0]='#';
		for(j=1;j<(w-1);j++){
			if(i&1){
				ans[i][j]='#';
			}
			else{
				ans1[i][j]='#';
			}
		}
		ans1[i][w-1]='#';
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(given[i][j]=='#'){
				ans[i][j]='#';
				ans1[i][j]='#';
			}
		}
	}
	for(i=0;i<h;i++){
		cout<<ans[i]<<"\n";
	}
	cout<<"\n";
	for(i=0;i<h;i++){
		cout<<ans1[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);
#define N 100000

int parent[N + 1];

int findroot(int a){
  if (parent[a] == a)
    return a;

  int newparent = findroot(parent[a]);
  parent[a] = newparent;
  return newparent;
}

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++){
    cin >> p[i];
  }
  int x, y;
  for (int i = 1; i < n + 1; i++){
    parent[i] = i;
  }
  for (int i = 0; i < m; i++){
    cin >> x >> y;
    if (findroot(x) != findroot(y)){
      parent[findroot(x)] = y;
    }
  }

  int res = 0;
  for (int i = 0; i < n; i++){
    if (findroot(p[i]) == findroot(i + 1)){
      res++;
    }
  }
  cout << res << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 1024
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a), greater<ll>());
  ll csum[100010];
  csum[0] = 0;
  rep(i, n) csum[i + 1] = csum[i] + a[i];

  auto f = [&](int l, int r, ll t) {
    if (l == r)
      return 0LL;
    ll lo = l - 1, hi = r;
    while (hi - lo > 1)
    {
      ll mi = (lo + hi) / 2;
      if (t - a[mi] <= m)
        lo = mi;
      else
        hi = mi;
    }
    ll res = 0;
    res += t * (lo - l + 1);
    res -= csum[lo + 1] - csum[l];
    res += (r - lo - 1) * m;
    return res;
  };
  
  ll ans = p - 1;
  REP(i, p - 1, n)
  {
    ll t = a[i] + m;
    if (t < a[p - 1])
      break;
    if (f(p - 1, i, t) + f(i + 1, n, t) >= m * (v - p))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  
  int64_t N, A, B, ans; cin >> N >> A >> B;
  
  int64_t group = A + B;
  
  ans = (N / group) * A + min(N % group, A);
  
  cout << ans << endl;
  
}

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

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.size()) {
		if (s.at(i) != t.at(i)) {
			ans ++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end());
    int g = a[0];
    for(int i = 1; i < n; i++) g = __gcd(g,a[i]);
    cout << (k%g || a.back() < k? "IMPOSSIBLE" : "POSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 640
n,a,b=map(int,input().split())
s=input()
acnt=0
bcnt=0
for i in range(len(s)):
  if s[i]=="a":
    if acnt+bcnt<a+b:
      print("Yes")
      acnt+=1
    else:
      print("No")
  elif s[i]=="b":
    if acnt+bcnt<a+b and bcnt<b:
      print("Yes")
      bcnt+=1
    else:
      print("No")
  else:
    print("No")
      
      

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    printf("%.10lf %d\n", double(W)*double(H)/2, (x+x == W && y+y == H));
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int x =sc.nextInt();
        int y =sc.nextInt();
        int z =sc.nextInt();
        if(x<y && y<z){
        System.out.print(x);
        System.out.print(" ");
        System.out.print(y);
        System.out.print(" ");
        System.out.println(z);
        }else if(y<x && x<z){
        System.out.print(y);
        System.out.print(" ");
        System.out.print(x);
        System.out.print(" ");
        System.out.println(z);
        }else if(z<y && y<x){
         System.out.print(z);
        System.out.print(" ");
        System.out.print(y);
        System.out.print(" ");
        System.out.println(x);
        }else if(x<z && z<y){
        System.out.print(x);
        System.out.print(" ");
        System.out.print(z);
        System.out.print(" ");
        System.out.println(y);
        }else if(y<z && z<x){
        System.out.print(y);
        System.out.print(" ");
        System.out.print(z);
        System.out.print(" ");
        System.out.println(x);
        }else if(z<x && x<y){
        System.out.print(z);
        System.out.print(" ");
        System.out.print(x);
        System.out.print(" ");
        System.out.println(y);
        }else if(x==y && y<z){
        System.out.print(x);
        System.out.print(" ");
        System.out.print(y);
        System.out.print(" ");
        System.out.println(z);    
        }else if(x==y && y>z){
        System.out.print(y);
        System.out.print(" ");
        System.out.print(x);
        System.out.print(" ");
        System.out.println(z); 
        }else if(x==z && x>y){
         System.out.print(z);
        System.out.print(" ");
        System.out.print(y);
        System.out.print(" ");
        System.out.println(x);
        }else if(x==z && x<y){
         System.out.print(x);
        System.out.print(" ");
        System.out.print(z);
        System.out.print(" ");
        System.out.println(y); 
        }else if(y==z && x<y){
         System.out.print(x);
        System.out.print(" ");
        System.out.print(y);
        System.out.print(" ");
        System.out.println(z); 
        }else if(y==z && x>y){
         System.out.print(y);
        System.out.print(" ");
        System.out.print(z);
        System.out.print(" ");
        System.out.println(x); 
        }else if(x==z && x>y){
         System.out.print(y);
        System.out.print(" ");
        System.out.print(z);
        System.out.print(" ");
        System.out.println(x); 
        }else if(x==z && x<y){
         System.out.print(x);
        System.out.print(" ");
        System.out.print(z);
        System.out.print(" ");
        System.out.println(y); 
            }
    }
}
    



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

using ll = long long;

// 再帰関数による最大公約数
ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

// gcdを利用した最小公倍数
ll lcm(ll x, ll y) {
  return x / gcd(x, y) * y;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  
  ll keep = lcm(n, m);
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if ((keep / n * i) % (keep / m) == 0) {
      if (s.at(i) != t.at((keep / n * i) / (keep / m))) flag = false;
    }
  }
  
  if (flag) cout << keep << '\n';
  else cout << "-1\n";
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main 
{

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		Dice4[] dice = new Dice4[N];
		for(int i = 0;i<N;i++)
		{
			dice[i] = new Dice4();
			String[] str = br.readLine().split(" ");
			for(int j=0;j<6;j++)
			{
				dice[i].setNum(j,Integer.parseInt(str[j]));
			}
		}
		
		boolean flag = true;
		
		for(int i=0;i<N-1;i++)
		{
			for(int j=i+1;j<N;j++)
			{
				if(dice[i].equals(dice[j]))
				{
					flag = false;
					break;
				}
			}
			if(!flag)break;
		}
		
		System.out.println(flag ? "Yes":"No");
		// TODO 自動生成されたメソッド・スタブ

	}
}
class Dice4 
{
	int[] num;
	public Dice4()
	{
		num = new int[6];
	}
	public boolean isSame(Dice4 d)
	{
		for(int i=0;i<num.length;i++)
		{
			if(num[i] != d.num[i])return false;
		}
		
		return true;
	}
	@Override
	public boolean equals(Object o)
	{
		Dice4 D = (Dice4)o;
		for(int i=0;i<4;i++)
		{
			if(isSame(D))return true;
			rotateS();
			
			if(isSame(D))return true;
			
			for(int j=0;j<4;j++)
			{
				rotateE();
				if(isSame(D))return true;
			}
		}
		rotateE();
		
		for(int i=0;i<4;i++)
		{
			if(isSame(D))return true;
			rotateS();
			if(isSame(D))return true;
			for(int j=0;j<4;j++)
			{
				rotateE();
				if(isSame(D))return true;
			}
			
		}
		return false;
	}
	
	public void setNum(int index,int Num)
	{
		num[index] = Num;
	}
	
	public void rotateS()
	{
		int temp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = temp;
	}
	
	public void rotateN()
	{
		int temp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = temp;
	}
	
	public void rotateW()
	{
		int temp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = temp;
	}
	
	public void rotateE()
	{
		int temp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = temp;
	}
}

Measured memory_bytes: 21016
import java.util.*;
import java.awt.*;

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

    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();

    int x_max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      x_max = Math.max(x_max, sc.nextInt());
    }

    int y_min = Integer.MAX_VALUE;
    for (int i = 0; i < M; i++) {
      y_min = Math.min(y_min, sc.nextInt());
    }

    String ans = "No War";

    if (x_max >= y_min || x_max >= Y || y_min <= X) {
      ans = "War";
    }

    System.out.println(ans);
  }
}


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

ll func (ll n, ll k)
{
  if(n<k) return 1;
  else return func(n/k,k) + 1;
}

int main()
{
  ll n,k;
  cin >> n >> k;
  cout << func(n,k) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file freopen("out.out","w",stdout);
#define RE cout<<233<<endl;
#define Tone(x) cout<<x<<endl;
#define Tall(x,n) for(int i=0;i<n;i++)cout<<x[i]<<(i==n-1?"\n":" ");
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n;
pii a[111],b[111];
int con[111][111];
bool used[111];
int have[111];

bool can(int x){
	FOR(i,0,n){
		if(con[x][i]&&!used[i]){
			used[i]=1;
			if(have[i]==-1||can(have[i])){
				have[i]=x;
				return 1;
			}
		}
	}
	return 0;
}

int main() {
  fastio;
  memset(have,-1,sizeof(have));
	cin>>n;
	FOR(i,0,n){
		cin>>a[i].first>>a[i].second;
	}
	FOR(i,0,n){
		cin>>b[i].first>>b[i].second;
		FOR(j,0,n){
			if(a[j].first<b[i].first&&a[j].second<b[i].second){
				con[j][i]=1;
			}
		}
	}
	int ans=0;
	FOR(i,0,n){
		memset(used,0,sizeof(used));
		if(can(i))ans++;
	}
	Tone(ans);
	
	
	
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

template <typename T> void print(T x) { std::cout << x << '\n'; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}
signed main(){
  string aa[3];
  rep(i,3){
    cin>>aa[i];
    cout<<aa[i][i];
  }
  cout<<endl;
  return 0;
}


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

int A,B;
string ans;

void solove()
{
    if(A>8 || B>8)
    {
        ans = ":(";
    }
    else
    {
        ans = "Yay!";
    }

}

int main()
{
    cin >> A >> B;
    solove();
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from math import ceil


def can_kill(total, A, B, h_list):
    add = A - B
    num = 0
    for h in h_list:
        h -= B * total
        num += ceil(h / add)
        if num > total:
            return False
    return True


def main():
    N, A, B = map(int, input().split())
    h_list = list(sorted([int(input()) for _ in range(N)], reverse=True))

    left, right = -1, 10 ** 10
    ans = 0
    while right - left > 1:
        m = (left + right) // 2
        if can_kill(m, A, B, h_list):
            ans = m
            right = m
        else:
            left = m
    print(ans)


if __name__ == '__main__':
    main()


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    REP(i,n){
        ans += i;
    }
    COUT(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
int n;
vector<int> v;
int gsm(int a,int b){
	int res=1;
	for(int i=0;i<b;i++){
		res*=a;
	}
	return res;
}
int mn=0;
int dp[100005];
int main()
{
	cin>>n;
	v.push_back(1);
	for(int i=0;i<5;i++){
		v.push_back(gsm(9,i+1));
	}
	for(int j=0;j<6;j++){
		v.push_back(gsm(6,j+1));
	}
	sort(v.begin(),v.end());
	dp[1]=1;
	for(int i=2;i<=100005;i++){
		dp[i]=1e9+7;
	}
	for(int i=2;i<=n;i++){
		for(int j=0;j<v.size();j++){
			if(i>=v[j]){
				dp[i]=min(dp[i],dp[i-v[j]]+1);
			}
			else{
				break;
			}
		}
	}
	/*
	for(int i=1;i<=n;i++){
		cout<<dp[i]<<" ";
	}*/
	cout<<dp[n];
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        int A;
        int B;
        Scanner sc = new Scanner(System.in);
        A=sc.nextInt();
        B=sc.nextInt();
        int C=A+B;
        int D=A-B;
        int E=A*B;
        if(C>=D&&C>=E){
           System.out.println(A+B);return;
        }
        if(D>=C&&D>=E){
           System.out.println(A-B);return;
        }
        if(E>=C&&E>=D){
            System.out.println(A*B);return;
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int n; std::cin >> n;
  std::vector<int> a(n); for(int i=0; i<n; i++) std::cin >> a[i];

  std::unordered_map<int,int> e,o;
  for(int i=0; i<n; i++) {
    if ( i % 2 == 0 ) {
      if ( e.count(a[i]) == 0 ) e[a[i]] = 1;
      else e[a[i]]++;
    }
    else {
      if ( o.count(a[i]) == 0 ) o[a[i]] = 1;
      else o[a[i]]++;
    }
  }

  int E = 0, O = 0;
  int emax = 0, omax = 0;
  for(auto&& v : e) { if (emax < v.second) { emax = v.second; E = v.first; } }
  for(auto&& v : o) { if (omax < v.second) { omax = v.second; O = v.first; } }
  if ( E != O ) {
    std::cout << n - emax - omax << std::endl;
    return 0;
  }

  int e2nd = 0, o2nd = 0;
  for(auto&& v : e) { if ( E != v.first ) e2nd = std::max(e2nd, v.second); }
  for(auto&& v : o) { if ( O != v.first ) o2nd = std::max(o2nd, v.second); }

  std::cout << std::min(n-emax-o2nd, n-omax-e2nd) << std::endl;
  return 0;
}


Measured memory_bytes: 4760
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define end(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

void quicksort(ll a[],ll b[], ll first, ll last){
    ll i,j,x;

    x=a[(first+last)/2];
	i=first;
	j=last;
	while(1){
        while(a[i] < x) i++;
        while(x < a[j]) j--;
        if(i >= j) break;
        swap(a[i],a[j]);
        swap(b[i],b[j]);
        i++;
		j--;
    }
    if(first<i-1) quicksort(a,b,first,i-1);
    if(j+1<last) quicksort(a,b,j+1,last);
}
int main(void){
    
    ll n,m,i;
    cin>>n>>m;
    ll a[n],b[n];
    for(i=0;i<n;i++){
    	cin>>a[i]>>b[i];
	}
//	for(i=0;i<n;i++){
//    	cout<<a[i]<<b[i]<<endl;
//	}
    quicksort(a,b,0,n-1);
    ll ans=0;
//    for(i=0;i<n;i++){
//    	cout<<a[i]<<b[i]<<endl;
//	}
    for(i=0;i<n;i++){
    	if(b[i]<=m){
    		m-=b[i];
    		ans+=a[i]*b[i];
		}
		else{
			ans+=m*a[i];
			m=0;
		}
		if(m==0)break;
	}
    cout<<ans<<endl;
    
    
    
    
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<iomanip>

using namespace std;
int func(double x);

int main() {

	int A = 0;
	int B = 0;
	int result = 0;
	cin >> A;
	cin >> B;

	if (A == 1) {
		result += 300000;
	}
	else if(A==2) {
		result += 200000;
	}
	else if(A == 3) {
		result += 100000;
	}

	if (B == 1) {
		result += 300000;
	}
	else if(B == 2) {
		result += 200000;
	}
	else if(B == 3) {
		result += 100000;
	}

	if (A == 1 && B == 1) {
		result += 400000;
	}



	cout << std::setprecision(12) << result;
}

int func(double x)
{
	if (x > 1) {
		x *= func(x - 1);
	}
	return x;
}

Measured memory_bytes: 256
(N, ) = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

M = 1000
S = 0

i = 0
while True:
    while A[i] >= A[i+1]:
        i += 1
        if i == N - 1:
            print(M)
            exit()
    # A[i] < A[i+1]
    C = M // A[i]
    M -= A[i] * C
    S += C

    while A[i] <= A[i+1]:
        i += 1
        if i == N - 1:
            M += S * A[N-1]
            print(M)
            exit()
    # A[i] > A[i+1]
    M += A[i] * S
    S = 0


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  ll time = (60 * H2 + M2) - (60 * H1 + M1);
  COUT(time - K);

  return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int  n,k,a[200001],x,sum=0,p;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]++;				
	}
	sort(a+1,a+1+n);
	p=1;
	while(a[p]==0)p++;
	for(int i=p;i<=n-k;i++)
		sum+=a[i];
	
	cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::set<std::string> s;
  rep(i,N) {
    std::string S; std::cin >> S;
    s.insert(S);
  }
  std::cout << sz(s) << std::endl;
  return 0;
}



Measured memory_bytes: 19244