akhauriyash/Code-Regression huggingface dataset:
s = input().split()

h = int(s[0])
w = int(s[1])

strings = []

for i in range(h):
    p = input()
    strings.append(p)

for i in range(w + 2):
    print('#', end='')

print('')


for i in range(h):
    print('#', end='')
    print(strings[i], end='')
    print('#')

for i in range(w + 2):
    print('#', end='')
    
print('')


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

int main(){
  long long int N;
  cin >> N;
  if(N%2!=0){
    cout << 0 << endl;
  }else{
    unsigned long long int i=10;
    long long int sum5=0;
    unsigned long long int j=50;
    unsigned long long int k=100;
    while(i<=1000000000000000000){
      sum5+=N/i;
      i*=10;
    }
    while(j<=1000000000000000000){
      sum5+=N/j;
      j*=5;
    }
    while(k<=1000000000000000000){
      sum5-=N/k;
      k*=10;
    }
    cout << sum5 << endl;
  }
}   

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

using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> c(n);
  vector<int> s(n);
  vector<int> f(n);
  for(int i=0;i<n-1;i++)
  {
    cin >>c[i]>>s[i]>>f[i];
  }
  for(int i=0;i<n-1;i++)
  {
    int t=0;
    for(int j=i;j<n-1;j++)
    {
      int a;
      a=(t-s[j]+f[j]-1)/f[j];
      if(a<0){a=0;}
      t=a*f[j]+s[j]+c[j];
    }
    cout<<t<<endl;
  }
  cout<<0<<endl;


}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int H;
	int W;
	int i, j;

	while (1) {
		scanf("%d", &H);
		scanf("%d", &W);

		if (H == 0 && W == 0) {
			break;
		}
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2108
from collections import deque
d = deque()
S = input().split()
for s in S:
    if s == "+":
        a = d.pop()
        b = d.pop()
        d.append(a+b)
    elif s == "-":
        a = d.pop()
        b = d.pop()
        d.append(b-a)
    elif s == "*":
        a = d.pop()
        b = d.pop()
        d.append(a*b)
    else:
        d.append(int(s))

print(d[0])


Measured memory_bytes: 6000
c = [list(map(int, input().split())) for _ in range(3)]
for i in range(2):
    for j in range(1, 3):
        if (c[i][0] - c[j][0]) != (c[i][1] - c[j][1]) or (c[i][2] - c[j][2]) != (c[i][1] - c[j][1]) or (c[i][2] - c[j][2]) != (c[i][0] - c[j][0]):
            print('No')
            exit()
print('Yes')

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
ll ans;

int main(void){
	cin>>n;

	for (int i = 1; i < n; i++) ans += i;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

#define MAX 1000005


bool primos[MAX];
bool pot[MAX];

void sieve() {
    memset(primos, true, sizeof(primos));
    memset(pot, false, sizeof(pot));
    primos[0] = primos[1] = false;

    for ( int i = 2; i * i < MAX; i++ ) {
        if ( primos[i] ) {
            int at = 2;
            for ( int j = i * i; j < MAX; j += i ) {
                primos[j] = false;
                if ( pow(i, at) == j ) {
                    at++;
                    pot[j] = true;
                }
            }
        }
    }
}


int main() {

    ll n;
    cin >> n;
    sieve();

    if ( n == 1 ) {
        cout << 0 << endl;
        return 0;
    }

    int ops = 0;
    for ( int i = 2; ; i++ ) {
        if ( i > n or (i * (ll) i > n and n > MAX) ) {
            break;
        }

        if ( (primos[i] or pot[i]) and n % i == 0 ) {
            n /= i;
            ops++;
        }
    }

    if ( n > MAX ) {
        cout << ops + 1 << endl;
    } else {
        cout << ops << endl;
    }

    return 0;
}

Measured memory_bytes: 6036
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        sc.nextLine();
        String _a = sc.nextLine();
        String[] a = _a.split(" ");
        int max = 0;
        int count = 0;
        int pre = Integer.valueOf(a[a.length-1]);
        for (int i = a.length-1; i > 0; i-- ) {
            int now = Integer.valueOf(a[i-1]);
            if (pre - now > max) {
                max = pre - now;
                count = 1;
            } else if (pre - now == max) {
                count += 1;
            }
            if (now > pre) {
                pre = now;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 34984
#include <iostream>

int main(){

    int n, q;
    int cnt = 0;

    std::cin >> n;

    int s[n];

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

    std::cin >> q;

    int t[q];

    for(int i = 0; i < q; i++){
        std::cin >> t[i];
    }

    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if(t[i] == s[j]){
                cnt++;
                break;
            }
        }
    }

    std::cout << cnt << "\n";



}


Measured memory_bytes: 3080
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N,C,K) = (input[0],input[1],input[2])
var T = (0..<N).map{_ in Int(readLine()!)!}.sort()
var ans = 1
var t = T.removeFirst()
var c = 1
for T_i in T {
    c += 1
    if t+K < T_i || c > C {
        ans += 1
        c = 1
        t = T_i
    }
}
print(ans)

Measured memory_bytes: 4208
#include <stdio.h>

int	main(void)
{
  	int	A;
  	int	B;
  	int	max;
  
  	scanf("%d %d", &A, &B);
  
  	max = -100000;
  
  	if (max < A + B)
      	max = A + B;
  
  	if (max < A * B)
      	max = A * B;
  
  	if (max < A - B)
      	max = A - B;
  
  	printf("%d", max);
  	return (0);
}

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

using namespace std;
typedef long long ll;
const int N=3e5+100;
ll mod=1e9+7;
ll gcd(ll a,ll b )
{
     return  b==0?a:(gcd(b,a%b));

}
int a[200100];
ll jc(int x,int k)
{
    ll an=1;
    for(int i=1;i<=k;i++) an*=x;
    return an;
}
int main()
{
    ll n;cin>>n;
    ll k=10;
    ll ans=0;
    if(n&1) return cout<<0, 0;
    while(n>=k){
        ans+=n/k;
        k*=5;
    }
    cout<<ans;
    return 0;
}


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


Measured memory_bytes: 1024
import itertools
import math


D, G = map(int, input().split())
basic = []
bonus = {}
p_c_list = []
for i in range(1, D+1):
    p, c = map(int, input().split())
    p_c_list.append([p, c])


min_count = float("inf")
for ans in itertools.product([0, 1], repeat=D):
    point = 0
    count = 0
    for idx, a in enumerate(ans):
        point += (p_c_list[idx][0]*(100*(idx + 1)) + p_c_list[idx][1])*a
        count += p_c_list[idx][0]*a

    if point < G:
        for idx, a in enumerate(reversed(ans)):
            if a == 0:
                plus_count = math.ceil((G - point) / ((D-idx)*100))
                # print(idx, D-idx, p_c_list[D-idx-1], G - point, plus_count)
                if plus_count >=  p_c_list[D-idx-1][0]:
                    count = float("inf")
                    point = 0
                else:
                    count += plus_count
                    point = G
                break
    # print(G, point, count)
    if point >= G:
        min_count = min(min_count, count)

print(min_count)

Measured memory_bytes: 41072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(string S)
        {
            int i = 0;
            int cnt = 0;
            long sum = 0;
            while (i < S.Length)
            {
                while (i < S.Length && S[i] == 'B') { ++i; }
                if (i < S.Length) { sum += i - cnt; }
                ++i;
                ++cnt;
            }
            return sum;
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Read()));
        }
    }
}


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

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

	long long n, m;
	cin >> n >> m;

	long long raw = min(n, m / 2);

	raw += max(0LL, (m - raw * 2) / 4);

	cout << raw << endl;

	return 0;
}

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

int main() {
  int a, b, N; cin >> a >> b >> N;
  vector<int> s(N + 1), f(N + 1), time(1001);
  for (int i = 1; i <= N; i++) {
    cin >> s[i] >> f[i];
    for (int j = s[i]; j < f[i]; j++) time[j]++;
  }
  for (int j = a; j < b; j++) time[j]++;
  int is_zero = 0;
  for (int i = 0; i <= 1000; i++) if (time[i] >= 2) is_zero = 1;
  if (is_zero) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,a[maxn],b[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		read(a[i]); b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for (int i=1;i<=n;i++) {
		if (b[n]==a[i]) printf("%d\n",b[n-1]);
		else printf("%d\n",b[n]);
	}
	return 0;
}

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

using namespace std;

int main(){
  int n,d,x; cin >> n >> d >> x;
  vector<vector<int> > p(d,vector<int>(n));
  for(int i=0;i<d;++i)
    for(int j=0;j<n;++j)
      cin >> p[i][j];
  int maxi=x;
  for(int i=0;i<d-1;++i) {
    int dp[100001]={};
    for(int j=1;j<=maxi;++j) dp[j]=j;
    for(int j=0;j<n;++j) {
      for(int k=p[i][j];k<=maxi;++k) {
        dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]);
      }
    }
    maxi=*max_element(dp,dp+maxi+1);
  }
  cout << maxi << endl;
  
  return 0;
}


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

int main(void){
    long long n;
    cin >>n;
    vector<long long > a(n+1);
    vector<long long > dp(n+1,0);
    vector<long long > solve(n+1,1);
    for(long long i=0;i<n;i++){
        solve.at(i)=i*(i-1)/2;
    }
    
    
    for(long long i=1;i<=n;i++){
        cin >>a.at(i);
        dp.at(a.at(i))+=1;
    }
    long long ans=0;
    for(long long i=1;i<=n;i++){
        ans+=solve[dp[i]];
    }
    for(long long i=1;i<=n;i++){
        cout <<ans-solve[dp[a[i]]]+solve[dp[a[i]]-1]<<endl;
    }
}


Measured memory_bytes: 8008
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());
    int amax = a[0];
    a.erase(a.begin());
    sort(ALL(a));
    auto it = lower_bound(ALL(a), (amax + 1) / 2);
    if (it == a.begin()) {
        cout << amax << " " << *it << endl;
    } else {
        if ((*it - (amax + 1) / 2) < ((amax / 2) - *(it - 1))) {
            cout << amax << " " << *it << endl;
        } else {
            cout << amax << " " << *(it - 1) << endl;
        }
    }
}


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

int main() {
	int n, m; cin >> n >> m;
	char a[100][100], b[100][100];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			cin >> b[i][j];
		}
	}

	bool is_found = false;
	for (int ly = 0; ly < n; ly++) {
		for (int lx = 0; lx < n; lx++) {
			if (ly + m - 1 >= n || lx + m - 1 >= n) continue;

			bool match = true;
			for (int y = 0; y < m; y++) {
				for (int x = 0; x < m; x++) {
					if (a[ly + y][lx + x] != b[y][x]) {
						match = false;
					}
				}
			}
			if (match) is_found = true;
		}
	}

	cout << (is_found ? "Yes" : "No") << endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    rep(i, n){
        cin >> a[i];
    }

    sort(all(a));
    reverse(all(a));
    long long res = a[0];
    n -= 2;
    int ind = 1;
    while (n != 0){
        res += a[ind];
        n--;
        if (n > 0){
            res += a[ind];
            n--;
        }
        ind++;
    }
    cout << res << endl;
}

Measured memory_bytes: 4808
h,w = map(int, input().split())

S = [list(input()) for i in range(h)]
for i in range(h):
  S[i] = ["a"] + S[i] + ["a"]
  
S.insert(0,["a"] * (w+2))
S.append(["a"]*(w+2))

for i in range(1,h+1):
  for j in range(1,w+1):
    if S[i][j] == ".":
      p = 0
      for k in [-1,0,1]:
        for l in [-1,0,1]:
          if S[i-k][j-l] == "#":
            p += 1
      S[i][j] = str(p)

for i in range(1,h+1):
  S[i].pop(0)
  S[i].pop()

ans = []
for i in range(1,h+1):
  ans.append("".join(S[i]))
 
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 3188
module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string

end

let min (x : int) y = if x < y then x else y

let solve h w c =
  let s = Array.make w 0 in
  let t = Array.make w 0 in
  let r = ref 0 in
  for j = 0 to w - 1 do
    if c.(0).(j) then begin
      s.(j) <- 1;
      r := 1;
    end
  done;
  if !r = 0 then begin
    let rec doit i =
      if i = h then ()
      else if c.(i).(0) then r := 1
      else doit (i + 1) in
    doit 0
  end;
  for i = 1 to h - 1 do
    if c.(i).(0) then t.(0) <- 1;
    for j = 1 to w - 1 do
      if not c.(i).(j) then t.(j) <- 0
      else begin
        t.(j) <- min s.(j-1) (min s.(j) t.(j-1)) + 1;
        if t.(j) > !r then r := t.(j)
      end
    done;
    Array.iteri (fun i e -> s.(i) <- e) t
  done;
  !r * !r

let () =
  match IO.read_ns () with
  | [h; w] ->
    let c = Array.make_matrix h w false in
    for i = 0 to h - 1 do
      IO.read_ns () |> List.iteri (fun j e -> c.(i).(j) <- e = 0);
    done;
    solve h w c |> Printf.printf "%d\n"
  | _ -> assert false

Measured memory_bytes: 25352
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,x,s=0;cin>>N>>x;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  int i;
  for(i=0;i<N;i++){
    s+=a.at(i);
    if(s>x)break;
  }
  if(s==x)cout<<N<<endl;
  else if(s>x)cout<<i<<endl;
  else cout<<N-1<<endl;
}

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


void solve(std::string S){
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll H,W,K;
ll val[int(1e3)*3+5][int(1e3)*3+5];
ll dp[int(1e3)*3+5][int(1e3)*3+5][4];

int main() {
    cin >> H >>W >> K;
    for(int i=0;i<K;i++){
        ll r,c,v;
        cin >> r >> c >> v;
        --r;--c;
        val[r][c] = v;
    }
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        for(int k=0;k<4;k++){
            dp[i+1][j+1][k] = max(dp[i+1][j+1][k],dp[i+1][j][k]);
            dp[i+1][j+1][0] = max(dp[i+1][j+1][0],dp[i][j+1][k]);
             if(val[i][j] && k<3){
                dp[i+1][j+1][k+1] = max(dp[i+1][j+1][k+1],dp[i+1][j][k] + val[i][j]);
            }
             dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i][j+1][k] + val[i][j]);
        }
        // cerr <<"i=" << i <<"j=" << j <<"field val = " << dp[i+1][j+1][0] << endl;
       
    }

    ll ans =0;
    for(int i=0;i<4;i++){
        ans = max(ans,dp[H][W][i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 355360
# Problem C - Five Transportations

import math

# input
N = int(input())
trans = [0]*5
for i in range(5):
    trans[i] = int(input())

# initialization
min_pos = 0
for i in range(5):
    if trans[min_pos]>trans[i]:
        min_pos = i

# calc
time_1 = min_pos
time_2 = math.ceil(N/trans[min_pos])
time_3 = 6 - (min_pos + 2)
ans = time_1 + time_2 + time_3

# output
print(ans)


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

int main()
{
    int n; cin>>n;
    vector<int> a(n);
    for(auto& e: a) cin>>e;
    sort(rbegin(a), rend(a));
    int res=0;
    for(int i=0; i<n; ++i)
        res+=i%2 ? -a[i] : a[i];
    cout<<res<<endl;
}

Measured memory_bytes: 256
from collections import deque

seen=[]
first_order =[]
last_order = []

def dfs(g, v, first_ptr, last_ptr):
    first_ptr=first_ptr+1
    last_ptr=first_ptr
    
    first_order[v] = first_ptr
    seen[v]=True 
    for next_v in g[v]:
        if seen[next_v]:
            continue
        first_ptr, last_ptr=dfs(g, next_v, first_ptr, last_ptr)
    last_ptr=last_ptr+1
    first_ptr=last_ptr

    last_order[v] = last_ptr
    return first_ptr, last_ptr

icase=1
if icase==0:
    n,m=map(int,input().split())
    g = [deque([]) for _ in range(n + 1)]
    for i in range(m):
        a,b=map(int,input().split())
        g[a].append(b)
#        g[b].append(a) # 無向グラフ
elif icase==1:        
    n=int(input())
    u=[0]*n
    k=[0]*n
#    v=[[] for i in range(n)]
    g = [deque([]) for _ in range(n + 1)]
    for i in range(n):
        ai=list(map(int,input().split()))
        u[i]=ai[0]
        k[i]=ai[1]
        g[i]=deque(ai[2:])
        for j in range(len(g[i])):
            g[i][j]-=1    
elif icase==2:
    n=6
    u=[1,2,3,4,5,6]
    k=[2,2,1,1,1,0]
    g = [deque([]) for _ in range(n + 1)]

    g[0]=deque([1,2])
    g[1]=deque([2,3])
    g[2]=deque([4])
    g[3]=deque([5])
    g[4]=deque([5])
    g[5]=deque([])
    g[5]=deque()

seen=[False]*n
first_ptr=0
last_ptr=0
first_order =[-1]*n
last_order = [-1]*n

for v in range(n):
    if seen[v]:
        continue
    else:
        first_ptr, last_ptr=dfs(g,v,first_ptr, last_ptr)

for v in range(n):
    print(v+1,first_order[v],last_order[v]) 
    


Measured memory_bytes: 6184
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  vector<int> x(5);
  rep(i, 5) cin >> x[i];

  rep(i, 5) {
    if (x[i] == 0) cout << i + 1;
  }
  return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl A(N);
  rep(i, N){
    cin >> A[i];
  }

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

  rep(i, N-1){
    if(A[i] == A[i + 1]){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  
  return 0;
}

Measured memory_bytes: 2560
H, W, M = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(M)]
row = [0] * H
col = [0] * W
for i in range(M):
    row[hw[i][0] - 1] += 1
    col[hw[i][1] - 1] += 1
row_ = sorted(row, reverse=True)
col_ = sorted(col, reverse=True)
r = 0
for i in row_:
    if i != row_[0]:
        break
    r += 1
c = 0
for i in col_:
    if i != col_[0]:
        break
    c += 1
count = 0
for i in range(M):
    if row[hw[i][0] - 1] == row_[0] and col[hw[i][1] - 1] == col_[0]:
        count += 1
if r * c == count:
    print(row_[0] + col_[0] - 1)
else:
    print(row_[0] + col_[0])


Measured memory_bytes: 73628
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {
i64 x,k,d;
cin>>x>>k>>d;
i64 mx=LLONG_MAX,mn=LLONG_MIN;
if(x<0)
{
  i64 jmps=(abs(x))/d,jmp2,ans=abs(x);
jmp2=jmps+1;
if(k<jmps)
ans=abs(x+k*d);
  if(jmps<=k)
  {
i64 rem=k-jmps;
if(rem&1)
ans=abs(x+jmp2*d);
else ans=abs(x+jmps*d);
  }

  cout<<ans;

  return ;
}
else
{
 i64 jmps=(abs(x))/d,jmp2,ans=abs(x);
 jmp2=jmps+1; 
 if(k<jmps)
 ans=abs(x-k*d);
  if(jmps<=k)
  {
i64 rem=k-jmps;
if(rem&1)
ans=abs(x-jmp2*d);
else ans=abs(x-jmps*d);
}

  cout<<ans;
  return ;
}

  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string S, T; cin >> S >> T;
    vector<int> s(26, -1);
    vector<int> g(26, -1);
    for(int i = 0; i < S.size(); ++i){
        int a = S[i] - 'a';
        int b = T[i] - 'a';
        if(s[a] != -1 || g[b] != -1){
            if(s[a] != b || g[b] != a){
                cout << "No" << endl;
                return 0;
            }
        }else{
            s[a] = b;
            g[b] = a;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

string v="Vacant";
void solve(){
    ll n;cin>>n;
    cout<<0<<endl;
    string s;cin>>s;
    if(s==v)return;
    ll base=0;
    for(ll i=17;i>=0;i--){
        if(base+(1<<i)>=n)continue;
        cout<<base+(1<<i)<<endl;
        string t;cin>>t;
        if(t==v)return;
        if(t==s)base+=1<<i;
    }
}

int main(){
    solve();
}


Measured memory_bytes: 852
n,m,q=gets.split(' ').map(&:to_i)
abcds=Array.new(q){gets.split(' ').map(&:to_i)}
ans=0
[*1..m].repeated_combination(n).to_a.each do |ary|
  tmp=0
  abcds.each do |abcd|
    tmp+=abcd[3] if ary[abcd[1]-1]-ary[abcd[0]-1]==abcd[2]
  end
  ans=tmp if tmp>ans
end
puts ans

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

int main(void) {
	int len,i;
	string s,t;
	cin >> s;
	len = (int)s.length();
	int cnt = 0;
	for (i=len-1; i> 0; i--) {
		if (s[i-1] == s[i]) {
			if (i == 1) {
				cnt++;
				break;
			}
			i -= 2;
			cnt +=2;
		}
		else {
			cnt++;
		}		
	}
	if (i == 0)cnt++;
	cout << cnt;	
}

Measured memory_bytes: 640
##### 解けた #####

import numpy as np

A,B,C,D=list(map(int,input().split(" ")))
R=np.zeros((100,))

if B<100:
    R[B]+=-1
if D<100:
    R[D]+=-1

R[A]+=1
R[C]+=1

Rcum=np.cumsum(R)
print((Rcum==2).sum()) # 2人同時に押している時間

Measured memory_bytes: 12380
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[1000];
stack<int> st;
signed main(){
  int n;
  scanf("%lld", &n);
  rrep(i,n)scanf("%lld", &a[i]);
  int ans = 0;
  rrep(i,n){
    if(st.empty()){st.push(a[i]);continue;}
    if(st.top() > a[i]){
      ans += st.top()-a[i];st.pop();
    }
    while(!st.empty() and st.top() > a[i]){
      // printf("%lld %lld\n", st.top(), a[i]);
      st.pop();
    }
    st.push(a[i]);
  }
  ans += st.top();
  printf("%lld\n", ans);
  return 0;
}






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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int sa = 0, sb = 0;
        for(int i=0; i<n; i++){
            if(i%2 == 0){
                sa += a[n - i - 1];
            }else{
                sb += a[n - i - 1];
            }
        }
        System.out.println(sa - sb);
    }   
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N, A[101], i, judge=1;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];

        if(A[i]%2==0 && A[i]%3!=0 && A[i]%5!=0){
            judge = 0;
        }
    }

    if(judge == 1){
        cout << "APPROVED" << endl;
    }

    else{
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    int i;
    int x, y, z;
    int ans = 0;

    cin >> n;

    vector<int> a(n), b(n), c(n);

    for (i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }

    for (i = 0; i < n; i++)
    {
        ans += b[a[i] - 1];

        if (a[i] + 1 == a[i + 1])
        {
            ans += c[a[i] - 1];
        }
    }

    cout << ans << endl;
}

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

int main() {
    int N, M, ans = 0;
    cin >> N >> M;
    vector<vector<int>> br(N + 1);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        br[a].push_back(b);
    }

    vector<int> dp(N + 1);

    for(int i = 1; i <= N; ++i) {
        dp[i] = max(dp[i], dp[i - 1]);
        for(int j : br[i])
            dp[j] = max(dp[j], dp[i] + 1);
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 6272
#include <algorithm>
#include <cstdint>

using namespace std;

enum status_t {
  WHITE,
  GRAY,
  BLACK,
};

#define GRAPH_SIZE 101

static uint32_t graph[GRAPH_SIZE][GRAPH_SIZE];
static status_t state[GRAPH_SIZE];
static uint32_t shortest_path[GRAPH_SIZE];

size_t minimum_spanning_tree(size_t num)
{
  size_t minimum_cost = 0;

  for (uint32_t i = 0; i < num; i++) {
    shortest_path[i] = UINT32_MAX;
    state[i] = WHITE;
  }

  shortest_path[0] = 0;
  state[0] = GRAY;

  while (true) {
    uint32_t minimum = UINT32_MAX;
    uint32_t to = 0;
    for (uint32_t j = 0; j < num; j++) {
      if ((shortest_path[j] < minimum) && state[j] != BLACK) {
        minimum = shortest_path[j];
        to = j;
      }
    }

    if (minimum == UINT32_MAX) break;

    state[to] = BLACK;
    minimum_cost += minimum;

    for (uint32_t j = 0; j < num; j++) {
      if (state[j] != BLACK) {
        shortest_path[j] = min(shortest_path[j], graph[to][j]);
      }
    }
  }

  return minimum_cost;
}

#include <iostream>

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

  for (uint32_t i = 0; i < num; i++) {
    for (uint32_t j = 0; j < num; j++) {
      int32_t val;
      cin >> val;
      if (val == -1) {
        graph[i][j] = UINT32_MAX;
      } else {
        graph[i][j] = val;
      }
    }
  }

  cout << minimum_spanning_tree(num) << endl;

  return 0;
}

Measured memory_bytes: 3112
n,m = gets.chomp.split.map(&:to_i)
s_ary = []
m.times do
    s_ary << gets.chomp.split.map(&:to_i)
end
p_ary = gets.chomp.split.map(&:to_i)

count = 0
for i in 0...2**n
    flag = true
    # 店頭消灯
    ary = []
    for j in 0...n
        if ((i >> j) & 1) == 1
            ary << 1
        else
            ary << 0
        end
    end
    # p ary

    on_flag = true
    for j in 0...m
        tmpcount = 0
        # 店頭消灯数を管理
        for k in 1..s_ary[j][0]
            if ary[s_ary[j][k]-1] == 1
                tmpcount += 1
            end
        end
        if tmpcount % 2 != p_ary[j]
            on_flag = false
        end
    end
    if on_flag
        count += 1
    end
    # puts
    # p ary
    # p [tmpcount, count]
end
puts count



Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << '\n';
        return 0;
    }
    cout << ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) << '\n';

    return 0;
}

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

void main_()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll open = 0;
    ll lack_open = 0;
    for (auto ch : S)
    {
        if (ch == '(') {
            open++;
        }
        if (ch == ')') {
            if (open == 0) {
                lack_open++;
            } else {
                open--;
            }
        }
    }

    cout << string(lack_open, '(') << S << string(open, ')') << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.string;
import std.conv;

void main(){
	int[] nums = readln.chomp.map!((c) => [c].to!int).array;
	OP[][] opss = [[OP.PLUS,OP.PLUS,OP.PLUS], [OP.PLUS,OP.PLUS,OP.MINUS],[OP.PLUS,OP.MINUS,OP.PLUS],[OP.PLUS,OP.MINUS,OP.MINUS],[OP.MINUS,OP.MINUS,OP.MINUS],
				[OP.MINUS,OP.MINUS,OP.PLUS],[OP.MINUS,OP.PLUS,OP.PLUS],[OP.MINUS,OP.PLUS,OP.MINUS]];
	auto answers = opss.map!((ops) => calc(ops, nums)).array;
	int idx;
	foreach(int i, ans; answers){
		if(ans == 7){
			idx = i;
		}
	}
	auto answer_str = "";
	foreach(ix, OP op; opss[idx]){
		answer_str ~= nums[ix].to!string;
		switch(op){
			case OP.PLUS:{
				answer_str ~= "+";
				break;
			}
			case OP.MINUS:{
				answer_str ~= "-";
				break;
			}
			default:assert(0);
		}
	}
	answer_str ~= nums[$-1].to!string ~ "=7";
	writeln(answer_str);
}

enum OP{
	PLUS,MINUS
}

int calc(OP[] ops, int[] nums){
	if(!ops.empty){
		switch(ops[0]){
			case OP.PLUS:{
				if(nums.length > 2){
					nums = (nums[0] + nums[1]) ~ nums[2..$];
				}else{
					nums = [nums[0] + nums[1]];
				}
				return calc(ops[1..$], nums);
				
			}
			case OP.MINUS:{
				if(nums.length > 2){
					nums = (nums[0] - nums[1]) ~ nums[2..$];
				}else{
					nums = [nums[0] - nums[1]];
				}
				return calc(ops[1..$], nums);
				
			}
			default:assert(0);
		}
	}else{
		return nums[0];
	}
}

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

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

using namespace std;

int main(void) {
  int N,W;
  cin >> N >> W;
  int maxi = N * 100 + 1, ans = 0;
  vector<int> dp(maxi,INT_MAX), v(N), w(N);
  rep(i,N) cin >> v[i] >> w[i];
  dp[0] = 0;
  rep(i,N) for(int j=maxi-1;j>=0;--j) if( dp[j] != INT_MAX ) {
      dp[j+v[i]] = min(dp[j+v[i]],dp[j]+w[i]);
      if( dp[j+v[i]] <= W ) ans = max(ans,j+v[i]);
    }
  cout << ans << endl;
   return 0;
}



Measured memory_bytes: 3120
S = input()

odd_strp = ['R','U','D']
even_step = ['L', 'U', 'D']

for ix, c in enumerate(S):
    if ix & 1:
        if c in even_step:
            pass
        else:
            print("No")
            exit()
    
    else:
        if c in odd_strp:
            pass
        else:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3060
#include <iostream>

using ll = long long;
using namespace std;

ll d[100001][2]; // root, parent, back_diff

void search_root_diff(ll i) {
  if (d[i][0] == i) return;
  ll p = d[i][0];
  search_root_diff(p);
  d[i][0] = d[p][0];
  d[i][1] += d[p][1];
}

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

  for (ll i = 0; i < N + 1; i++) {
    d[i][0] = i;
    d[i][1] = 0;
  }
  bool ok = true;
  for (ll i = 0; i < M; i++) {
    ll L, R, D;
    cin >> L >> R >> D;
    search_root_diff(L);
    search_root_diff(R);
    if (d[L][0] == d[R][0]) {
      if (d[R][1] - d[L][1] != D) { ok = false; break; }
    }
    ll lp = d[L][0], rp = d[R][0], ld = d[L][1], rd = d[R][1];
    if (ld <= rd - D) {
      d[rp][0] = lp;
      d[rp][1] = ld + D - rd;
      d[R][0] = lp;
      d[R][1] = ld + D;
    } else {
      d[lp][0] = rp;
      d[lp][1] = rd - D - ld;
      d[L][0] = rp;
      d[L][1] = rd - D;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define FF first.first
#define FS first.second
#define S second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e16;
 
ll n, q=1, m, a[N], b[N], f[N], o, k, t, x, y, z, u, h, mx, mn, ans, Ans;
pair<ll,ll> p[N];
string s;
vector<int> v[N];
 
main(){ios_base::sync_with_stdio(false), cin.tie(0);
   	
	cin>>x;
	
	for (ll i=-1000; i<=1000; i++)
		for (ll j=-1000; j<=1000; j++)
			if(i*i*i*i*i-j*j*j*j*j==x){cout<<i<<" "<<j;return 0;}
	
}

Measured memory_bytes: 27076
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := readInt()

	if N == 2 {
		// K = 2
		fmt.Println(1)
		return
	}

	r := int(math.Sqrt(float64(N)))
	// K = N - 1, N
	result := 2
	for K := 2; K <= r; K++ {
		t := N
		for t >= K && t%K == 0 {
			t /= K
		}
		if t%K == 1 {
			result++
		}

		if (N-1)%K == 0 && (N-1)/K > K {
			result++
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>

using namespace std;
typedef long long ll;
#define MAX_X 10000000000LL
vector<ll> prime;
vector<ll> v;
int N;
int ans, ans2;

map<ll, int> mp;

void generate_prime(){
	prime.push_back(2);
	for(ll p = 3; p * p * p <= MAX_X; p+=2){
		bool tf = true;
		for(int j=0; j<prime.size(); j++){
			if(p%prime[j]==0){
				tf = false; break;
			}
			if(prime[j] * prime[j] > p)	break;
		}
		if(tf) prime.push_back(p);
	}
	//cout<<prime.size();
}

int main(){
	generate_prime();
	scanf("%d", &N);
	ll x; 
	for(int i=0; i<N; i++){
		scanf("%lld", &x); 
		ll y = 1;
		int cnt;
		for(int j=0; j<prime.size(); j++){
			if(x%prime[j]!=0)	continue;
			cnt = 0;
			while(x%prime[j]==0){
				cnt++; x/=prime[j];
			}
			cnt=cnt%3;
			for(int k=0; k<cnt; k++){
				y *= prime[j];
			}
		}
		if(x!=1){
			y *= x;
		}
		if(y==1){
			if(mp[1]==0){
				mp[1]++;
				ans++;
			}
			continue;
		}
		if(mp[y]==0)	v.push_back(y);
		mp[y]++;
	}
	for(int i=0; i<v.size(); i++){
		ll now = v[i];
		int cnt;
		ll y = 1;
		for(int j=0; j<prime.size(); j++){
			if(now%prime[j]!=0)	continue;
			cnt = 0;
			while(now%prime[j]==0){
				cnt++; now/=prime[j];
			}
			for(int k=0; k<(3-cnt); k++){
				y*=prime[j];
				y = min(y, MAX_X+1);
			}
		}
		if(now!=1){
			ll sq = sqrt(now);
			if(sq * sq == now){
				y*=sq;
				y = min(y, MAX_X+1);
			}else{
				y*=now; y = min(y, MAX_X+1);
				y*=now; y = min(y, MAX_X+1);
			}
		}
		//cout<<v[i]<<" "<<y<<endl;
		if(mp[y]==0){
			ans+=mp[v[i]];
		}
		else	ans2 += max(mp[v[i]], mp[y]);
	}
	ans = ans + ans2/2;
	printf("%d", ans);
	return 0;
}

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

int main() {
    ll n;
    cin>>n;
    set<string> m;
    rep(i,n){
        string s;
        cin>>s;
        m.insert(s);
    }
    cout<<m.size()<<endl;
}


Measured memory_bytes: 19252
import sys
N = int(input())

min = 99999999
for a in range(1, N):
    b = N - a
    a_sum = sum([int(i) for i in str(a)])
    b_sum = sum([int(i) for i in str(b)])
    if a_sum + b_sum < min:
        a_min = a
        b_min = b
        min = a_sum + b_sum
print(min)


Measured memory_bytes: 3060
defmodule Main do
  def main do
    x =
      IO.read(:line)
      |> String.trim()
      |> String.to_integer()

    100
    |> Stream.unfold(fn a -> {a, trunc(a * 1.01)} end)
    |> Enum.take_while(fn a -> a < x end)
    |> Enum.count()
    |> Integer.to_string()
    |> IO.puts()
  end
end


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

int main(){
  int n;
  cin >> n;
  int sum = 0;
  vector<int> l(n);
  rep(i,n){
    int num;
    cin >> l.at(i);
    sum += l.at(i);
  }
  for(int i=0;i<n;i++){
    if( l.at(i) >= sum - l.at(i) ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {
    static class Solver {
        MyReader mr = new MyReader();

        public void solve() {
            int n = mr.nextInt();
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                int x=  mr.nextInt();
                if(set.contains(x)){
                    System.out.println("NO");
                    return;
                }
                else{
                    set.add(x);
                }
            }

            System.out.println("YES");
        }
    }

    public static void main(String[] args) {
        new Solver().solve();
    }

    static class MyReader {
        BufferedReader br;
        StringTokenizer st;

        MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String res = "";
            try {
                res = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return res;
        }

        Integer[] nextIntArray(int n) {
            Integer[] arr = new Integer[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }

            return arr;
        }

        Long[] nextLongArray(int n) {
            Long[] arr = new Long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }

            return arr;
        }

        String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }

    static void swap(int[] arr, int i, int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

}




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

int main(void){
	bool m[10001];
	int k;
	for(int i=0;i<10001;i++)m[i]=true;
	m[0]=m[1]=false;
	for(int i=2;i<10001;i++){
		if(!m[i])continue;
		for(int j=i*2;j<10001;j+=i){
			m[j]=false;
		}
	}
	while(cin>>k){
		int c=0;
		for(int i=1;i<=k/2;i++){
			if(m[k-i+1]&&m[i])c++;
		}
		c*=2;
		if((k&1) && m[k/2+1])c++;
		cout<<c<<endl;
	}
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, M; cin >> N >> M;
  vector<int> L(M), R(M); REP(i, M) cin >> L[i] >> R[i];

  int l = 1, r = N;
  for (int i = 0; i < M; ++i) {
    l = max(l, L[i]);
    r = min(r, R[i]);
  }

  cout << max(0, r-l+1) << endl;
}

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

int main() {
	string S;
	cin >> S;
	int N = S.size();
	int r = -1, l = -1;
	if (N == 2 && S[0] == S[1]) r = 1, l = 2;
	for (int i = 2;i < N;i++) {
		if (S[i] == S[i - 1] || S[i] == S[i - 2] || S[i - 1] == S[i - 2])
			r = i - 1, l = i + 1;
	}
	cout << r << " " << l << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a; cin>>a;
  if(a[0]=='1')a[0]='9';
  else if(a[0]=='9')a[0]='1';
  if(a[1]=='1')a[1]='9';
  else if(a[1]=='9')a[1]='1';
  if(a[2]=='1')a[2]='9';
  else if(a[2]=='9')a[2]='1';
  cout<<a<<endl;
  return 0;
}

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

typedef long long int LL;
typedef unsigned long long uLL;
typedef pair< int,int > ii;
typedef pair< int,ii > iii;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 100005;
const int MOD = 1e9+7;
const double EPS = 1e-6;
const double PI = acos(-1.0);

set <int> S;

int main( int argc, char const *argv[] ) {
    int n;
    cin >> n;
    while( n-- ) {
        int x;
        cin >> x;
        S.insert( x );
    }
    cout << (int)(S.size()) <<endl;
    return 0;
}



Measured memory_bytes: 256