akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;

    lint T = 1, A = 1;
    FOR(i, 0, N) {
        lint t, a;
        cin >> t >> a;
        // k * t >= T, a * t >= A
        lint K = max((A - 1) / a, (T - 1) / t) + 1;
        T = K * t;A = K * a;
    }
    cout << (A + T) << endl;
    return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main() {
    ll n,m;
    cin>>n>>m;
    if(n==1||m==1){
        cout<<1;
        return 0;
    }
    ll temp=(n*m);
    if((temp)%2==1)cout<<(temp)/2+1;
    else cout<<(temp)/2;
}



Measured memory_bytes: 3568
n = int(input())
nowt, nowx, nowy = 0, 0, 0
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())
    dift, difxy = t - nowt, abs(x - nowx) + abs(y - nowy)
    if dift < difxy or dift&1 != difxy&1:
        ans = 'No'
print(ans)

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

bits = []
for i in range(n):
  bit = int(input().replace(" ", ""), 2)
  bits.append(bit)
p = [[int(item) for item in input().split()] for _ in range(n)]

ans = - 10**9
for i in range(1,2**10):
  val = 0
  for j,mise in enumerate(p):
    val += mise[bin(i & bits[j]).count("1")]
  ans = max(ans, val)
print(ans)

Measured memory_bytes: 3064
#65
#ALDS1_2_B
n=int(input())
*a,=list(map(int,input().split()))
flag=0

for i in range(n):
    m=i
    for j in range(i,n):
        if a[m]>a[j]:m=j
    
    if i!=m:
        a[m],a[i]=a[i],a[m]
        flag+=1

print(*a)
print(flag)
        


Measured memory_bytes: 5604
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 16:39:29 2018

@author: Yuya
"""



A, B = map(int, input().split())

S = list(input())

S_A = "".join(list(S[0:A]))
S_B = "".join(list(S[A]))
S_C = "".join(list(S[A+1:A+B+1]))

if str.isnumeric(S_A) and S_B == "-" and str.isnumeric(S_C):
    print("Yes")
else:
    print("No")

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

int main(){
    int A, B, K;
	cin >> A >> B >> K;

    int count = 0;
    for( int i=min(A,B) ; i > 0; i-- ){
       if( (A%i == 0) && (B%i == 0) ){
           count++;
           if( count == K ){
               cout << i << endl;
               return 0;
           }
       }
    }

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[110][12];
int p[110][12];
int n;
int main(void) {
    while(cin >> n) {
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < 10; ++j)
                cin >> f[i][j];
        }
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < 11; ++j)
                cin >> p[i][j];
        }
        int ma = -INT_MAX;
        for(int i = 1; i < (1 << 10); ++i) {
            int ans[11];
            for(int j = 0; j < 10; ++j) ans[j] = (i >> j) & 1;
            int cnt = 0;
            for(int j = 0; j < n; ++j) {
                int t = 0;
                for(int k = 0; k < 10; ++k)
                    if(ans[k] & f[j][k]) ++t;
                cnt += p[j][t];
            }
            ma = max(ma, cnt);
        }
        cout << ma << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int a[3];
  int ret;
  int i,j;
  int tmp;
  
  ret=scanf("%d%d%d", &a[0], &a[1], &a[2]);
  for (i=0; i<2; ++i){
    for (j=2; j>i; --j){
      if (a[j-1]>a[j]){
        tmp=a[j];
        a[j]=a[j-1];
        a[j-1]=tmp;
      }
    }
  }
  if ((a[0]==5 && a[1]==5)&&(a[2]==7)){
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 128
n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)
p1 = 0
p2 = 0
p3 = 0
pi = 0
n.times do |i|
	d = (x[i] - y[i]).abs
	p1 += d
	p2 += d ** 2
	p3 += d ** 3
	pi = d if pi <d
end
puts p1
puts p2 ** (1 / 2.0)
puts p3 ** (1 / 3.0)
puts pi



Measured memory_bytes: 6956
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  map<ll, ll> m;
  vector<Pll> X(0);
  for(int i = 0; i < N; i++){
    ll A;
    cin >> A;
    if(!m.count(A)){
      m[A] = X.size();
      X.push_back(Pll(A, 1));
    }
    else{
      X.at(m.at(A)).second++;
    }
  }
  sort(ALL(X), greater<Pll>());
  ll x = 0;
  for(int i = 0; i < X.size(); i++){
    if(X.at(i).second <= 1) continue;
    
    if(x == 0){
      if(X.at(i).second <= 3){
        x = X.at(i).first;
      }
      else{
        cout << X.at(i).first * X.at(i).first << endl;
        return 0;
      }
    }
    else{
      cout << x * X.at(i).first << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 8048
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF 1001001001001001001
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 1, n)
		if (s[i] == s[i - 1])ans++;
	cout << n - ans << endl;
}


Measured memory_bytes: 3752
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var likes = new int[nm[1]];
            for (var i = 0; i < nm[0]; i++)
            {
                var ka = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                for (var j = 1; j < ka.Length; j++)
                {
                    likes[ka[j] - 1]++;
                }
            }
            Console.WriteLine(likes.Where(x => x == nm[0]).Count());
        }
    }
}


Measured memory_bytes: 13396
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

char ss[110][110];
int main()
{
  ll h, w;
  scanf("%lld%lld", &h, &w);
  for (int i = 0; i < h; i++)
  {
    scanf("%s", ss[i]);
  }

  for (int i = 0; i < w + 2; i++)
  {
    putchar('#');
  }
  puts("");
  for (int i = 0; i < h; i++)
  {
    putchar('#');
    printf("%s", ss[i]);
    putchar('#');
    puts("");
  }
  for (int i = 0; i < w + 2; i++)
  {
    putchar('#');
  }
  puts("");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string s, t;
  cin >> s >> t;
  
  int i, j = 0;
  
  while(i < 3){
    if(s.at(i) == t.at(i)){
      j++;
    }
    i++;
  }
  
  cout << j << endl;
}
    

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

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	long pow(long a,long n) {
		long r=1;
		for(;n>0;n>>=1,a=a*a%MOD)if(n%2==1)r=r*a%MOD;
		return r;
	}
	
	final long MOD=(long)1e9+7;
	
	int N=(int)1e6;
	long[] fac=new long[N];
	long[] inv=new long[N];
	long[] ifac=new long[N];
	{
		fac[0]=fac[1]=inv[0]=inv[1]=ifac[0]=ifac[1]=1;
		for(int i=2;i<fac.length;++i) {
			fac[i]=i*fac[i-1]%MOD;
			inv[i]=MOD-inv[(int)(MOD%i)]*(MOD/i)%MOD;
			ifac[i]=inv[i]*ifac[i-1]%MOD;
		}
	}
	
	long comb(int n,int k) {
//		long ret=1;
//		for(long i=n;i>=n-k+1;--i)ret=ret*i%MOD;
//		for(int i=1;i<=k;++i)ret=ret*inv[i]%MOD;
//		return ret;
		return fac[n]*ifac[k]%MOD*ifac[n-k]%MOD;
	}
	
	//最終的な分布がa_iになったとする。
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int Q=sc.nextInt();
		long[] d=new long[K];
		long[] n=new long[Q];
		long[] x=new long[Q];
		long[] m=new long[Q];
		for(int i=0;i<K;++i) {
			d[i]=sc.nextLong();
		}
		for(int i=0;i<Q;++i) {
			n[i]=sc.nextLong();
			x[i]=sc.nextLong();
			m[i]=sc.nextLong();
		}
		
		PrintWriter pw=new PrintWriter(System.out);
		for(int q=0;q<Q;++q) {
			long[] sum=new long[K];
			for(int i=0;i<K;++i) {
				long add=d[i]%m[q];
				if(add==0)add=m[q];
				sum[i]=(i>0?sum[i-1]:0)+add;
			}
			long all=sum[K-1];
			long first=x[q];
			long last=x[q]+sum[(int)((n[q]-2)%K)]+all*((n[q]-2)/K);//i=mK+j項目はx+all*(i/K)
			long ans=(last/m[q]*m[q]-first/m[q]*m[q])/m[q];
			pw.println(n[q]-1-ans);
		}
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 116296
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int n, k, p[1000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> p[i];
	sort(p, p + n);
	int cnt = 0;
	for(int i = 0; i < k; i++) cnt += p[i];
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3620
import sys
readline = sys.stdin.readline
X, Y = map(int, readline().split())
res = 0
C = [0, 300000, 200000, 100000]
if X == Y == 1:
    res += 400000

if X > 3:
    X = 0
if Y > 3:
    Y = 0
res += C[X]
res += C[Y]
print(res)

Measured memory_bytes: 38384
/* Includes */
#include <stdio.h>

/* Prototypes */
char SwitchWord(char val);

/* Valuables */
char list_input[1200];
char list_output[1200];
char list_moji[2][26] = {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'},
                         {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}};

/* Main */

int main ()
{
    for (int i = 0; i < 1200; i++) {
        scanf("%[^\n]s", &list_input[i]);
    }

    for (int i = 0; i < 1200; i++) {
        list_output[i] = SwitchWord(list_input[i]);
    }

    for (int i = 0; list_output[i] != '\0'; i++) {
        printf("%c", list_output[i]);
    }
    printf("\n");
}

/* Sub */
char SwitchWord(char input)
{
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 26; j++) {
            if (input == list_moji[i][j]) {
                if (i == 0) {
                    return list_moji[1][j];
                }
                else {
                    return list_moji[0][j];
                }
            }
            else {
                /* NOP */
            }
        }
    }
    return input;
}


Measured memory_bytes: 2052
n,m= map(int,input().split())
A = list(map(int,input().split()))
cost = [0,2,5,5,4,5,6,3,7,6]
dp =[-1]*10010
dp[0]=0
for i in range(1,n+1):
    for a in A:
        if i - cost[a] >= 0:
            dp[i] = max(dp[i],a+dp[i-cost[a]]*10)
print(dp[n])

Measured memory_bytes: 14388
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long k = in.nextLong();

            TreeMap<Long, Long> map = new TreeMap<>();
            for (int i = 0; i < n; i++) {
                long a = in.nextInt();
                long b = in.nextInt();

                if (map.containsKey(a)) {
                    map.put(a, map.get(a) + b);
                } else {
                    map.put(a, b);
                }
            }

            Set<Long> set = map.keySet();
            long sum = 0;
            for (long x : set) {
                sum += map.get(x);
                if (sum >= k) {
                    out.println(x);
                    return;
                }
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d;
    cin>>n>>d;
    int ans=0;
    while(n--)
    {
        long long int x,y;
        cin>>x>>y;
        double temp = (double)d;
        x*=x;
        y*=y;
        x=(double)x;
        y=(double)y;
        //cout<<fixed<<sqrt(x+y)<<" "<<temp<<"\n";
        if(sqrt(x+y)<= temp)
        ans++;
        
    }
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 3692
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5;
LL a[maxn+3]={0}, b[maxn+3]={0}, c[maxn+3]={0};
int main()
{
    LL sum = 0;
    int n, m;
    scanf("%d%d%lld",&n,&m,&a[1]);
    for(int i=2; i<=n; ++i)
    {
        scanf("%lld",&a[i]);
        if(a[i] > a[i-1])
        {
            sum += a[i]-a[i-1];
            b[a[i-1]+1] += a[i-1]+1;
            b[a[i]+1] -= a[i-1]+1;
            ++c[a[i-1]+1];
            --c[a[i]+1];
        }
        else
        {
            sum += m-a[i-1]+a[i];
            b[a[i-1]+1] += a[i-1]+1;
            ++c[a[i-1]+1];
            b[1] -= m-a[i-1]-1;
            ++c[1];
            b[a[i]+1] += m-a[i-1]-1;
            --c[a[i]+1];
        }
    }
    for(int i=1; i<=m; ++i)
        b[i] += b[i-1], c[i] += c[i-1];
    LL ans = 0;
    for(int i=1; i<=m; ++i)
        ans = max(ans,i*1LL*c[i]-b[i]);
    printf("%lld\n",sum-ans);
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
    // Your code here!
   int a,b,c,d=0,i;
   
   scanf("%d %d %d",&a,&b,&c);
   
   d = a*c-b;
   printf("%d\n",d);
   for(i=0;i<9;i++){
       d =  a*d-b;
       printf("%d\n",d);
   }
   return 0;
}


Measured memory_bytes: 128
n,m,x=gets.chomp.split.map(&:to_i)
xx = x
array = gets.chomp.split.map(&:to_i)
cost=0
costs = []
while x < n do
  x +=1
  if array.include?(x)
    cost += 1
  end
end
costs << cost
cost = 0
while xx > 0 do
  xx -=1
  if array.include?(xx)
    cost += 1
  end
end
costs << cost
puts costs.min


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp73 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int L = st[1];

            string[] S = new string[N];

            for (int i = 0; i < N; i++) {
                S[i] = Console.ReadLine();
            }

            Array.Sort(S);

            Console.WriteLine(string.Join("", S));
        }
    }
}


Measured memory_bytes: 13536
float x,y,s,t,u,v,a,b,c;main(){for(;~scanf("%*d%f%f%f%f%f%f"+!!c*3,&x,&y,&s,&t,&u,&v);printf("%.3f %.3f %.3f\n",t,s,hypot(t-x,s-y)))c=x*x+y*y,a=c-s*s-t*t,b=c-u*u-v*v,s-=x,t-=y,u-=x,v-=y,c=s*v-t*u,t=(t*b-a*v)/2/c,s=(a*u-s*b)/2/c;}

Measured memory_bytes: 0
from collections import Counter

n = int(input())
sl = list(input() for _ in range(n))

cnt = Counter(sl)
# print('cnt:', cnt)
maxNum = max(cnt.values())
# print('maxNum:', maxNum)

ans = []
for k, v in cnt.items():
    if v == maxNum:
        ans.append(k)

ans.sort()
print('\n'.join(ans))

Measured memory_bytes: 35960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int a,b;
    cin >>a>>b;
    if (a>b) rep(i,a) cout <<b;
    else rep(i,b) cout <<a;
}

Measured memory_bytes: 256
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, ans, be[10005], ed[10005], now, has[2][2];
string s[10005];
const int g[2][2] = {
    {4, 1},
    {3, 2}};
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> s[i];
        while ((now = s[i].find("AB")) < s[i].length())
        {
            ++ans;
            s[i][now] = s[i][now + 1] = 'G';
        }
        if (s[i].front() == 'B')
        {
            be[i] = 1;
        }
        if (s[i].back() == 'A')
        {
            ed[i] = 1;
        }
        ++has[be[i]][ed[i]];
    }
    while (has[0][1] || has[1][1])
    {
        if (has[0][1])
        {
            --has[0][1];
            while (has[1][1])
            {
                ++ans;
                --has[1][1];
            }
            if (has[1][0])
            {
                ++ans;
                --has[1][0];
            }
        }
        if (has[1][1])
        {
            --has[1][1];
            while (has[1][1])
            {
                ++ans;
                --has[1][1];
            }
            if (has[1][0])
            {
                ++ans;
                --has[1][0];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    string s;
    rep(i, 0, h) {
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < int(Y);++(X))
#define rrep(X,Y) for (int (X) = int(Y-1);(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){
  int i,j,k;
  double d,t,ta,tb,da,db,ia,ib;
  cin>>t>>d>>ta>>tb>>da>>db;
  vector<double> res;
  for(ia=0;ia<=d;ia+=da){
    for(ib=0;ia+ib<=d;ib+=db){
      if(ia+ib)res.pb(abs(t-(ia*ta+ib*tb)/(ia+ib)));
    }
  }sort(all(res));
  printf("%.5f\n",res[0]);
  return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i<b; i++)
#define dep(i,a,b) for(int i = a-1; i>=b; i--)
#define makeUnique(vec) sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin())
#define LOG_vec(vec, sep) for (int fl = 0; fl < vec.size(); fl++) { cout << vec[fl]<< sep; } cout << "\n";
#define LOG_ints(vec, sep) for (int fl = 0; fl < MAXSIZE; fl++) { cout << vec[fl]<< sep; } cout << "\n"
#define all(x) (x).begin(), (x).end()
#define ll long long
#define LSB(i) ((i) & -(i))
#define vvi vector<vector<int>>
#define vi vector<int>
#define MAXSIZE 100000000
using namespace std;

int main(){
	int sum = 0;
	rep(i, 0, 2) {
		int N;
		cin >> N;
		rep(j, 0, N) {
			sum += j;
		}
	}
	cout << sum;
}

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

int main(){
    string str;
    int cc=0;
    cin >> str;
    
    for(int i=0;i<str.length();i++){
        if(i!=0 && str[i]!=str[i-1])    cc++;
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

# 1 ✕ 1 (int)
X = int(input().rstrip())

for a in range(-300, 300):
    for b in range(-300, 300):
        if a ** 5 - b ** 5 == X:
            print(str(a) + " " + str(b))
            sys.exit()


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    string S;
    cin >> S;
    if(S.size()%2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, S.size()/2) {
        if(S[2*i] != 'h' || S[2*i+1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
     }
     cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
int main() {
  int in(N); int in(K);

  vector<bool> dp(1e5+1, true); // dp[i] = i枚で渡されたときに先手が勝つか
  dp[0] = false;
  vi A(N);
  rep(i, N)
    cin >> A[i];

  rep(k, K+1) {
    dp[k] = false;
    rep(i, N) {
      if (k - A[i] >= 0 && dp[k-A[i]] == false)
        dp[k] = true;
    }
  }
  cout << (dp[K] ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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 namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    vi p(n+1), c(n+1);
    repf(i, n) cin >> p[i];
    repf(i, n) cin >> c[i];
    ll ans = -1*(1LL<<60);
    // 全てのマスを始点として試す
    repf(i, n){
        vi stepScore(n+1, 0);
        vi chk(n+1, 0);
        ll score = 0, step = 0;
        ll pos = p[i];
        while(chk[pos] == 0 && step < k){
            chk[pos] = 1;
            score += c[pos];
            step++;
            stepScore[step] = max(stepScore[step-1], score);
            pos = p[pos];
            chmax(ans, score);
        }
        // 1周に必要な操作 => step
        // 1周で稼げるスコア = score
        if(step < k){
            ll pp = k/step;
            ll qq = k%step;
            ll ans1 = score*pp;
            ans1 += stepScore[qq];
            ll ans2 = score*(pp-1);
            ans2 += stepScore[step];
            chmax(ans, max(ans1, ans2));
        }
        else chmax(ans, score);
    }

    cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
#define x first
#define y second
#define ii pair<int, int>
#define INF int(1e9)
#define LL long long int 
#define vi vector<LL>

using namespace std;

LL n, k;

bool check(LL v, vi &coef, vi &dif){

    LL s = 0;

    //coef[i]*dif[i]>v, ou coef[i] = v/dif[i], onde temos que minimizar v

    for(int i = 0; i<n; i++){
        if(coef[i]*dif[i]>v)
            s+=coef[i] - (v/dif[i]);
    }

    return s<=k;
}
int main () {

    cin >> n >> k;

    vi coef(n), dif(n);

    for(int i=0; i<n; i++) cin >> coef[i];
    for(int i=0; i<n; i++) cin >> dif[i];

    sort(coef.begin(), coef.end());
    sort(dif.begin(), dif.end());
    reverse(dif.begin(), dif.end());

    LL l = 0, r = 1000000000010;

    for(int i=0; i<50; i++){
        LL mid = (l+r)/2;
        if(check(mid, coef, dif))
            r = mid;
        else l = mid+1;
    }

    if(check(min(r, l), coef, dif))
        cout << min(r, l) << endl;
    else cout << max(r, l) << endl;
    return 0;
}

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll fac(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}



int main() {
	int x; cin >> x;
	int num=x/100;
	if(num*5>=x%100) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
n, _ = gets.to_s.split.map{|t|t.to_i}
h    = [0] + gets.to_s.split.map{|t|t.to_i}

ans = [1] * (n+1)
ans[0] = 0

$<.each do |line|
  
  a, b = line.to_s.split
  a, b = a.to_i, b.to_i
  
  ans[a] = 0 if h[a] <= h[b]
  ans[b] = 0 if h[a] >= h[b]
end

puts ans.sum

Measured memory_bytes: 23420
#include<iostream>
#include<vector>
#include<math.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	long long int a;
	double b;
	cin>>a>>b;
	long long int c = round(b*100);
	a*=c;
	cout<<a/100<<endl;

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=1; i<50000; i++){
    if(i*108<(N+1)*100 && i*108>=N*100){
      ans=i;
      break;
    }
  }
  if(ans==0) cout << ":(" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def putsd(str)
  puts str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

a = inputs[0][0]
b = inputs[0][1]

# body
if $debugFlag
  pd a
  pd b
end

nn = b - a - 1
tl = nn*(nn+1)/2

puts tl - a

Measured memory_bytes: 1788
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,A;
int main() {
	cin>>N>>A;

	cout<<N*N-A<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int[] x = new int[N];

            for (int i =0;i <N; i++)
            {
                x[i] = i;
            }

            Array.Sort(A,x);

            for(int i = 0; i < N; i++)
            {
                if (i == N - 1)
                {
                    Console.Write(x[i] + 1);
                }
                else
                {
                    Console.Write(x[i] + 1 + " ");
                }
            }
                
        }
    }
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n, k, q;
		cin >> n >> k >> q;
		vector<int> cnt(n);
		for(int i=0; i < q; i++){
			int a;
			cin >> a;
			cnt[a-1]++;
		}
		for(int i=0; i < n; i++){
			if(k-q+cnt[i] <= 0){
				cout << "No" << "\n";
			}else{
				cout << "Yes" << "\n";
				
			}
		}
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1024
import sys
input = lambda: sys.stdin.readline().rstrip()
tdlist = lambda i, j, value=0: [[value] * j for _ in range(i)]

n, w = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]
dp = tdlist(n+10, w+10)

for i, (weight, value) in enumerate(items):
    for j in range(w+1):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j + weight <= w:
            dp[i+1][j+weight] = max(dp[i+1][j+weight], dp[i][j] + value)

print(dp[n][w])

Measured memory_bytes: 120856
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
#define tm tadsadaagsd
#define next nqweqweeqeqe
#define er erase
#define int ll

using namespace std;
//using namespace __gnu_pbds;

//template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 40, T = 4 * N, logN = (int)log2(N) + 2, inf = 1e9 + 7, sx[4] = {1, -1, 0, 0}, sy[4] = {0, 0, 1, -1};

int n, m, r, l, e, o, z, ts, id, mx, mn = inf, w;
int a[N];
ll f;

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

void boos()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int bp (int x, int y) {
	if (y == 0) return 1;
	if (y % 2 == 1) return bp(x, y - 1) * x;
	else
    {
		int asd = bp(x, y / 2);
		return asd * asd;
	}
}

main()
{
    int x, y;
    setprecision(9);
    //freop();
    boos();
    cin >> n >> m;
    if (n > m) n %= m;
    cout << min(n, m - n);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,w;
	cin>>n>>w;
	ll a[2][n+1],b[n+1][w+1];
	for(ll i = 1;i < n+1;i++)
		cin>>a[0][i]>>a[1][i];
	for(ll i = 0;i < n+1;i++)
	{
		for(ll j = 0;j <w+1;j++)
		{
			if(i==0 || j == 0)
				b[i][j] = 0;	
			else if(j < a[0][i])
				b[i][j] = b[i-1][j];
			else
				b[i][j] = max((a[1][i]+b[i-1][j-a[0][i]]),b[i-1][j]);
		}
	}
	cout<<b[n][w]<<endl;
			
	
	return 0;
}


Measured memory_bytes: 82424
#include<stdio.h>
#define M 10000
#define NIL -1

typedef struct{
  int parent,left,right;
}Node;

Node T[M];
int n,D[M], H[M];

void setDepth(int a,int b){
  if(a == NIL)return;
  D[a] = b;
  setDepth(T[a].left,b+1);
  setDepth(T[a].right,b+1);
}

int setHeight(int a){
  int h1 = 0;
  int h2 = 0;
  if(T[a].left != NIL)
    h1 = setHeight(T[a].left)+1;
  if(T[a].right != NIL)
    h2 = setHeight(T[a].right)+1;
  if(h1>h2)
    {
      H[a]=h1;
    }
  else
    {
      H[a]= h2;
    }
  return H[a];
}
int gSibling(int s)
{
  if(T[s].parent == NIL)return NIL;
  if(T[T[s].parent].left != s && T[T[s].parent].left != NIL)
    return T[T[s].parent].left;
  if(T[T[s].parent].right != s && T[T[s].parent].right != NIL)
    return T[T[s].parent].right;

  return NIL;
}
int main()
{
  int i,j,v,l,r,deg,root = 0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      T[i].parent = NIL;
    }
  for(i = 0;i<n;i++)
    {
      scanf("%d %d %d",&v,&l,&r);
      T[v].left = l;
      T[v].right = r;
      if(l != NIL)T[l].parent = v;
      if(r != NIL)T[r].parent = v;
    }

  for(i = 0;i<n;i++)
    {
      if(T[i].parent == NIL)root = i;
    }

  setDepth(root, 0);
  setHeight(root);

  for(i = 0;i<n;i++)
    {
      printf("node %d: ", i);
      printf("parent = %d, ", T[i].parent);
      printf("sibling = %d, ",gSibling(i));
      deg = 0;
      if(T[i].left != NIL)deg++;
      if(T[i].right != NIL)deg++;
      printf("degree = %d, ",deg);
      printf("depth = %d, ",D[i]);
      printf("height = %d, ",H[i]);

      if(T[i].parent == NIL){
	printf("root\n");
      }
      else if(T[i].left == NIL && T[i].right == NIL)
	{
	  printf("leaf\n");
	}
      else 
	{
	  printf("internal node\n");
	}
    }
  return 0;
}

Measured memory_bytes: 624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int n,i,ans,temp = 0;
		String str;
		str = bf.readLine();
		n = Integer.parseInt(str);
		str = bf.readLine();
		for(i = 0;i < n;++i) {
			if(str.charAt(i) == '.') {
				temp++;
			}
		}
		ans = temp;
		for(i = 0;i < n;++i) {
			if(str.charAt(i) == '.') {
				temp--;
			} else {
				temp++;
			}
			ans = Math.min(ans, temp);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28280
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var cnt = new long[5];
            for (int i = 0; i < N; i++)
            {
                var input = Read();
                if (input[0] == 'M') cnt[0]++;
                else if (input[0] == 'A') cnt[1]++;
                else if (input[0] == 'R') cnt[2]++;
                else if (input[0] == 'C') cnt[3]++;
                else if (input[0] == 'H') cnt[4]++;
            }
            var ans = 0L;
            for (int i = 0; i < 5; i++)
            {
                for (int j = i + 1; j < 5; j++)
                {
                    for (int k = j + 1; k < 5; k++)
                    {
                        ans += cnt[i] * cnt[j] * cnt[k];
                    }
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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


int main()
{
   int m,n;
   cin>>m>>n;
   map<int,int>p;
   p[m]=1,p[n]=1;
   for(int i=1;i<=3;i++)
    if(p[i]==0) cout<<i;
    return 0;
}


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

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

    tx -= sx;
    ty -= sy;

    string s;
    for (int i = 0; i < ty; i++) s += 'U';
    for (int i = 0; i < tx; i++) s += 'R';
    for (int i = 0; i < ty; i++) s += 'D';
    for (int i = 0; i < tx; i++) s += 'L';
    s += 'L';
    for (int i = 0; i < ty + 1; i++) s += 'U';
    for (int i = 0; i < tx + 1; i++) s += 'R';
    s += 'D';
    s += 'R';
    for (int i = 0; i < ty + 1; i++) s += 'D';
    for (int i = 0; i < tx + 1; i++) s += 'L';
    s += 'U';

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  int sum = 700;
  rep(i, s.size()) {
    if(s[i] == 'o') {
      sum += 100;
    }
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, cur;
    ll sum = 0;
    cin >> n;
    for(ll i = 1; i <= n; i = cur + 1) {
    	cur = n/(n/i);
    	ll up = ((n/i) * ((n/i) + 1))/2;
    	sum += ((cur - i + 1)*(i + cur))/2 * up;
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}

unsigned GetDigit(unsigned num){
    return log10(num)+1;
}
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}



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

ll a,b,c,ans = 0,x;
cin >> a >> b >> c;

if(c < b) ans = (ll)floorl(a*c/b);
else ans = (ll)floor(a*(b-1)/b);
cout << ans << endl;

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3664
package main

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

func main() {
	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	m := []string{"M", "A", "R", "C", "H"}
	N := p.NextInt()
	ns := make([]int, 5)
	for i := 0; i < N; i++ {
		s := string(p.Next()[0])
		for k, v := range m {
			if s == v {
				ns[k]++
			}
		}
	}

	res := 0
	for i := 0; i < 3; i++ {
		for j := i + 1; j < 4; j++ {
			for k := j + 1; k < 5; k++ {
				res += ns[i] * ns[k] * ns[j]
			}
		}
	}
	fmt.Println(res)

}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    if(S.back() == 's') cout << S << "es" << endl;
    else cout << S << "s" << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    scanner.nextLine();
    String str = scanner.next();
    int n_r  =0;
    int[] s = new int[n];
    int ans = 0;
    for(int i = 0; i< n; i++){
      if(str.charAt(i) == 'W'){
        s[i] = 0;
      }else{
        s[i] = 1;
        n_r += 1;
      }
    }

    for(int i = 0; i< n_r; i++){
      if(s[i] == 0){
        ans ++;
      }

    }
    System.out.println(ans);
   
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 41972
a,b,c = map(int,input().split())
n = int(input())
num = 0
while True:
    if a >= b:
        b *= 2
        num += 1
    elif b >= c:
        c *= 2
        num += 1
    elif a < b < c:
        break
if num <= n:
    print('Yes')
else:
    print('No')

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * n * n << ln;
    return 0;
}


Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    if(log2(N)==(int)log2(N)) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        cout << 1 << " " << 2 << endl;
        cout << 2 << " " << 3 << endl;
        cout << 3 << " " << N+1 << endl;
        cout << N+1 << " " << N+2 << endl;
        cout << N+2 << " " << N+3 << endl;
        int p=4;
        while(p<N){
            cout << 1+N << " " << p << endl;
            cout << p << " " << p+1 << endl;
            cout << 1+N << " " << p+1+N << endl;
            cout << p+N << " " << p+N+1 << endl;
            p+=2;
        }
        if(p==N){
            int ans=log2(p);
            ans=pow(2,ans);
            cout << p << " " << ans << endl;
            ans=ans^1^p;
            ans+=N;
            if(ans==3+N) cout << 3 << " " << p+N << endl;
            else cout << ans << " " << p+N << endl;
        }
    }
}

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

int main(){
    int a,b,k;  cin>>a>>b>>k;
    
    int count=0;;
    for(int i=min(a,b);i>0;i--){
        if(a%i==0 && b%i==0)++count;

        if(count==k){
            cout<<i<<endl;
            break;
        }
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a;
	int counter;
	int counter2;
	int kari;
	bool hantei;
	while (true) {
		cin >> a;
		if (a == 0) {
			break;
		}
		counter = 0;
		for (int i = a; i > 4;) {
			kari = i;
			counter2 = 0;
			hantei = false;
			while(kari / 5 != 0) {
				if (kari % 5 != 0) {
					break;
				}
				kari /= 5;
				counter2++;
				hantei = true;
			}
			if (hantei) {
				//cout << i << " " << counter2 << endl;
				counter += counter2;
				i -= 5;
			} else {
				i -= (kari % 5);
			}
		}
		cout << counter << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1; i<10; i++)
    {
        if(i==n)
        {
            cout<<cnt+1<<endl;
            return 0;
        }
        else
        {
            cnt++;
        }
    }
    if(n<100)
    {
        cout<<cnt<<endl;
        return 0;
    }
    for(int i=100; i<1000; i++)
    {
        if(i==n)
        {
            cout<<cnt+1<<endl;
            return 0;
        }
        else
        {
            cnt++;
        }
    }
    if(n<10000)
    {
        cout<<cnt<<endl;
        return 0;
    }
    for(int i=10000; i<100000; i++)
    {
        if(i==n)
        {
            cout<<cnt+1<<endl;
            return 0;
        }
        else
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256