akhauriyash/Code-Regression huggingface dataset:
def check(numbers, threshold):
    
    total = 0
    
    for number in numbers:
        d, m = divmod(number, threshold)
        if m == 0:
            d -= 1
        total += d
    return total
    
def main():
    n, k = map(int, input().rstrip().split(" "))
    
    numbers = list(map(int, input().rstrip().split(" ")))
    
    bottom, top = 1, 2 * (10 ** 9)
    
    while bottom < top:
        #print(bottom, top)
        if check(numbers, (bottom + top )// 2) <= k:
            top = (bottom + top )// 2
        else:
            bottom = ((bottom + top )// 2) + 1
    print(top)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 30960
import sys,os,math
from collections import Counter, defaultdict, deque, OrderedDict
import bisect
from sys import stdin, stdout
from itertools import repeat
import Queue


# sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())


def main():
    n = map(int, raw_input().split())[0]
    G = defaultdict(list)
    bfs = []
    for i in range(n):
        a, b = map(int, raw_input().split())
        b += 100000
        G[a].append(b)
        G[b].append(a)
        bfs.append(a)

    vs = set()
    ans = 0
    for i in bfs:
        if i in vs:
            continue
        x, y = 0, 0
        t = 0
        vs.add(i)
        q = deque()
        q.append(i)
        while q:
            now = q.popleft()
            if now > 100000:
                y += 1
            else:
                x += 1
            for adj in G[now]:
                t += 1
                if adj not in vs:
                    # print adj
                    vs.add(adj)
                    q.append(adj)
        # print x, y, t/2
        ans += x*y - t/2
    print ans




main()


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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 9;
const double eps = 1e-9;

inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}
int n, a[N], x;

int main () {
	boost ();
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		x += (a[i] % 2);
	}	
	if (x % 2) cout << "NO";
	else cout << "YES";

	return 0;
}

                

Measured memory_bytes: 640
def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)

N,K,*a = map(int, open(0).read().split())
m = 1000000007
memf = []
mfappend = memf.append
for x in memfact(N-1,m):
    mfappend(x)
a.sort()
ans = 0
if K == 1:
    print(0)
else:
    for i in range(1,N-K+2):
        ans = (ans + a[-i] * comb(N-i,K-1,m)) % m
    for i in range(1,N-K+2):
        ans = (ans - a[i-1] * comb(N-i,K-1,m)) % m
    print(ans)

Measured memory_bytes: 14444
#include<bits/stdc++.h>
#define R register int 
#define ll long long
#define inf 2147483647
using namespace std;
const int N=500000;
int n,m,ans;
int gi(){
    R x=0,k=1;char c=getchar();
    while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')k=-1,c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*k;
}
int main(){
	n=gi(),m=gi();
	for(R i=1;i*i<=m;++i){
		if(m%i)continue;
		if(m/i>=n)ans=max(ans,i);
		if(i*i!=m){
			if(i>=n)ans=max(ans,m/i);
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL fac(LL a, LL mod){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(mod>0&&ans>mod)ans%=mod;}return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
LL ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
LL scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}

LL N,u,v,A[NUM],B[NUM],U[NUM],V[NUM],costu[NUM],costv[NUM];

void bfs(LL ver,LL* q,LL* cost){
  LL i,n=0,k=1,pre[NUM],last[N+1];
  FOR(i,1,N+1)last[i]=-1;
  FOR(i,0,2*N-2)pre[i]=last[A[i]],last[A[i]]=i;
  q[n++]=ver,cost[ver]=1;
  while(n<N){
    for(i=last[ver];i+1;i=pre[i])if(cost[B[i]]==0)q[n++]=B[i],cost[B[i]]=cost[ver]+1;
    ver=q[k++];
  }
}

int main(){
  LL i,n,ans;
  scanf("%lld%lld%lld",&N,&u,&v);
	FOR(i,0,N-1)scanf("%lld%lld",&A[i],&B[i]);
	FOR(i,0,N-1)A[N-1+i]=B[i],B[N-1+i]=A[i];
  bfs(u,U,costu);bfs(v,V,costv);
  FOR(i,0,N)if(costv[V[N-1-i]]>costu[V[N-1-i]]){
    printf("%lld\n",costv[V[N-1-i]]-2);
    return 0;
  }
  
  //printf("%lld\n",ans);
	//return 0;
}


Measured memory_bytes: 11136
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    n = _i()

    ans = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 72752
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Get lines from standard input.
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split("\n");

var number_of_datasets = lines.shift();

for (var dataset = 0; dataset < number_of_datasets; dataset++)
{
var value = "NO"; 
var values = lines[dataset].split(" ");

var a = parseInt(values[0]);
var b = parseInt(values[1]);
var c = parseInt(values[2]);

if ((a*a) + (b*b) === (c*c))
{
value = "YES";
}
if ((a*a) + (c*c) === (b*b))
{
value = "YES";
}
if ((c*c) + (b*b) === (a*a))
{
value = "YES";
}

console.log(value);
}

Measured memory_bytes: 17716
#include <cstdio>

typedef unsigned long long ull;

const int MAXN = 2 * 1e5;

int main() {
    int n;
    std::scanf("%d", &n);
    static int arr[MAXN + 5];
    for (int i = 1; i <= n; i++) {
        std::scanf("%d", &arr[i]);
    }

    ull cnt = 0;
    for (int i = 2; i <= n; i++) {
        if (arr[i] < arr[i - 1]) {
            cnt += arr[i - 1] - arr[i];
            arr[i] = arr[i - 1];
        }
    }

    std::printf("%llu\n", cnt);

    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int c = abs(a - b);
	if (c % 2 == 0) {
		cout << (a + b) / 2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
}


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

int main(){
  int a,b,c; cin>>a>>b>>c;
  int ans = 0;
  for(int n=a;n<=min(b,c);++n){
    if(c%n==0){++ans;}
  }
  cout << ans <<"\n";
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];
ll L[100005];
ll R[100005];

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

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

    L[0] = A[0];
    FOR(i, N, 1) {
        L[i] = gcd(L[i - 1], A[i]);
    }
    R[N - 1] = A[N - 1];
    for (ll i = N - 2; i >= 0; --i) {
        R[i] = gcd(R[i + 1], A[i]);
    }

    ll ans = std::max(R[1], L[N - 2]);
    for (ll i = 1; i < N - 1; ++i) {
        ans = std::max(ans, gcd(L[i - 1], R[i + 1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b;

int are(int a){
    return a * (a + 1) / 2; 
}

signed main(){
    io();

    cin>>a>>b;
    int c=b-a-1;
    cout<<are(c)-a<<endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
    int sum=0;
   vector<pair<int,int>> a(5);
   for(int i=0;i<5;i++){
       cin>>a.at(i).second;
       a.at(i).first=(1000-a.at(i).second)%10;
       sum+=a.at(i).first+a.at(i).second;
    }
    sort(a.begin(),a.end());
    sum-=a.at(4).first;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int L[210];
int main(){
	int n=gi();
	for(int i=1;i<=n+n;++i)L[i]=gi();
	std::sort(L+1,L+n+n+1);
	int ans=0;
	for(int i=1;i<=n+n;i+=2)ans+=L[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    int d, a;
    double x = 0, y = 0;

    int angle = 90;
    while (true)
    {
        scanf("%d,%d", &d, &a);
        if (d == 0 && a == 0)
            break;
        x = x + d * cos(angle * M_PI / 180);
        y = y + d * sin(angle * M_PI / 180);

        angle -= a;
    }
    cout << (int)x << endl;
    cout << (int)y << endl;
    return 0;
}


Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define rep(i,n); for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}



int main(){
  int n,m;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cin>>m;
  rep(i,m){
    string t;
    cin >> t;
    mp[t]--;
  }  
  int ans=0;
  for(auto& k : mp){
    int s = k.second;
    if(s>ans) ans =s;
  }

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


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

int pow_10 (int b) {
  int c = 1;
  for (int i = 0; i < b; ++i) {
    c = c * 10;
  }
  return c;
} //aのb乗

bool good_number (int N, unsigned int K, const vector<int> &bad_number) {
  bool check = true;
  for (unsigned int i = 0; i < K; ++i) {
    if (N == bad_number[i]) {
       check = false;
       break;
    }
  }
  return check;
}

vector<int> itov (int N) {
  int m = N;
  int k = 0;
  vector<int> v;
  while (m > 0) {
    k = m % 10;
    m = m / 10;
    v.insert(v.begin(), k);
  }
  return v;
}

int rounded_up (int N, int k) {
  vector<int> numbers = itov (N);
  int result = 0;
  for (int i = 1; i <= k; ++i) {
    result += numbers[i - 1] * pow_10 (numbers.size() - i);
  }
  result += pow_10 (numbers.size() - k);
  return result;
}

int vtoi (vector<int> v) {
    int result = 0;
    for (int i = 1; i <= v.size(); ++i){
      result += v[i-1] * pow_10 (v.size() - i);
    }
    return result;
}

int pay_money (int N, unsigned int K, const vector<int> &bad_number) {
  //cout << N << endl;
  vector<int> numbers = itov (N);
  //cout << vtoi (numbers) << endl;
  int i = 0;
  while (i < numbers.size()) {
    //cout << vtoi (numbers) << endl;
    if (good_number(numbers[i], K, bad_number) == true) {
      ++i;
    }
    else {
      int k = numbers[i];
      while (k != 10) {
        ++k;
        if (good_number(k, K, bad_number)) {
          //cout << "A" << endl;
          numbers[i] = k;
          int m = vtoi (numbers);
          //cout << pow_10 (numbers.size() - i - 1) << endl;
          m = m / pow_10 (numbers.size() - i - 1);
          //cout << m << endl;
          m = m * pow_10 (numbers.size() - i - 1);
          numbers = itov (m);
          ++i;
          break;
        }
      }
      if (k == 10) {
        //cout << "A" << endl;
        N = rounded_up(N, numbers.size() - 1);
        numbers = itov(N);
        i = 0;
      }
    }
  }

  return vtoi (numbers);
}

int main(){
  int N;
  unsigned int K;
  cin >> N >> K;
  int a;
  vector <int> D;
  for (unsigned int i = 0; i < K; ++i){
    cin >> a;
    D.push_back(a);
  }

  cout << pay_money(N, K, D) << endl;

  return 0;
}


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

int main(void){
    long long N,K;
    string S,result;
    cin >> N >> S >> K;
    char tmp = S[K - 1];
    for (int i = 0; i < S.size(); i++){
        if(S[i] != tmp){
            S[i] = '*';
        }
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
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++) {
            int next = sc.nextInt();
            a[next - 1] = i+1;
        }

        for (int i = 0; i < n; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println();
	}
}


Measured memory_bytes: 62136
#include <stdio.h>

int main(void) {
	int N, D, X, A[100];
	scanf("%d%d%d", &N, &D, &X);
	for (int i = 0;i < N;i++) {
		scanf("%d", &A[i]);
	}

	int day[100], eat[100];
	for (int i = 0;i < N;i++) {
		day[i] = 1;
		eat[i] = 0;
	}

	for (int i = 1;i <= D;i++) {
		for (int j = 0;j < N;j++) {
			if (day[j] == i) {
				eat[j]++;
				day[j] += A[j];
			}
		}
	}

	int eat_all = X;
	for (int i = 0;i < N;i++) {
		eat_all += eat[i];
	}

	printf("%d\n", eat_all);

	return 0;
}

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

using namespace std;

int main(void){
  int n; cin >> n;
  char s[n];
  rep(i,n) cin >> s[i];
  int ans = 0;
  for(int i = 1; i < n-1; i++){
    if(s[i-1] == 'A' && s[i] == 'B' && s[i+1] == 'C'){
      ans++;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << b * 2 - a << endl;
    return 0;
}

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back


int main(){
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    
    else cout << "ABC" << endl;
}

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

int main(){
  int n,m;cin>>n>>m;
  long long sum=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    int x;cin>>x;
    sum+=x;a[i]=x;
  }
  
  sort(a.begin(),a.end(),greater<int>());
  
  if((double)a[m-1]>=(double)sum/(4*m))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;

class Class3
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');

        for (int i = 0; i < input.Length; i++)
        {
            if ("0".Equals(input[i]))
            {
                Console.WriteLine((i+1));
                break;
            }
        }
    }
}


Measured memory_bytes: 25764
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
	ll n;
	ll ans = 1e18;
	cin >> n;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		ll j = n / i;
		ans = i+ j -2;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<pair<pair<string,int>,int>>v(n);
  for (int i=0;i<n;i++)
  {
  	string s;
  	int p;
  	cin>>s>>p;
  	v[i]={{s,-p},i+1};
  	
  	
  }
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
    cout<<v[i].second<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int L;
ll A[200000];
ll dp[200001][5];

int main() {
    cin >> L;
    rep(i,L) cin >> A[i];
    vector<vector<ll>> dp(L+1, vector<ll>(5, linf));
    dp[0][0] = 0;
    rep(i,L) {
        ll m = dp[i][0];
        dp[i+1][0] = dp[i][0] + A[i];

        m = min(m, dp[i][1]);
        if (A[i] == 0) dp[i+1][1] = m+2;
        else if (A[i]%2) dp[i+1][1] = m+1;
        else dp[i+1][1] = m;

        m = min(m, dp[i][2]);
        dp[i+1][2] = m + (A[i]%2==0);

        m = min(m, dp[i][3]);
        if (A[i] == 0) dp[i+1][3] = m+2;
        else if (A[i]%2) dp[i+1][3] = m+1;
        else dp[i+1][3] = m;

        m = min(m, dp[i][4]);
        dp[i+1][4] = m + A[i];
    }
    ll ans = linf;
    rep(i,5) ans = min(ans, dp[L][i]);
    cout << ans << endl;
}

Measured memory_bytes: 17536
using System;

namespace Atcoder
{
    class Program
    //ABC126 C - Dice and Coin
    {
        private static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ');
            var n = double.Parse(nk[0]);
            var k = int.Parse(nk[1]);
            double ans = 0.0;
            for (var i = 1; i <= n; i++)
            {
                if (i >= k)
                {
                    ans += 1/n;
                }
                else
                {
                    var temp = i * 2;
                    var count = 1;
                    while (temp < k)
                    {
                        temp = temp * 2;
                        count++;
                    }
                    ans += (1 / n) * Math.Pow(0.5, count);
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

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

		for(int i = 0;i < chars.length;i++) {
			if(Character.isUpperCase(chars[i])) {
				chars[i] = Character.toLowerCase(chars[i]);
			} else if (Character.isLowerCase(chars[i])) {
				chars[i] = Character.toUpperCase(chars[i]);
			}
			System.out.print(chars[i]);
		}
		System.out.println();

	}
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"


template <typename T, typename K> struct P {
	T a; K b;
};

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
vector <P <ll, ll> >prime_factorize( ll N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
int main( void ){
	// initialize();
	int N;
	cin >> N;
	cout << N*N*N << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}

/*
 * @fn eratosthenes
 * @brief O(NloglogN)~=(N)
 * @param N: その数まで
 * @return 0 or 1 の配列 (boolは都合が悪い)
 */
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

/*
 * @fn prime_factorize
 * @brief O(√N): 素因数分解
 * @param N: 素因数分解する数
 * @return vec: (a: 素数, b: 個数)
 */
vector <P <ll, ll> >prime_factorize( ll N ){
	vector <P <ll, ll> > vec;
	int lim = sqrt( N ) + 1;
	rep( i, 2, N + 1 ){
		if (i >= lim){
			vec.push_back( P <ll, ll>{N, 1} );
			break;
		}
		if (N % i == 0){
			vec.push_back( P <ll, ll>{i, 0} );
			while(N % i == 0){
				N /= i;
				vec.back().b++;
			}
		}
	}
	return vec;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
N,K,Q = map(int, input().split())  
A = dict(zip(range(1,N+1),[0]*N))

for i in range(Q):
    A[int(input())] += 1

for j in range(1,N+1):
    if (K-Q+A[j] >= 1):
        print('Yes')
    else:
        print('No')

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

int main(){
    int n;
    static int a[200000];
    cin >> n;
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    set<int> sm, ng;
    for(int i=0;i<n;++i){
        bool flg = false;
        for(int s: sm) if(a[i] % s == 0){ flg = true; break; }
        if(flg || ng.count(a[i]) > 0) continue;

        if(a[i] < 1000) sm.insert(a[i]);
        else for(int j=1;a[i]*j<=1000000;++j) ng.insert(a[i]*j);
        if(i+1 == n || a[i] != a[i+1]) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 34520
N, K = map(int, input().split())
mod = 10**9+7
S = T = 0
for i in range(K):
    S = (S+i  )%mod
    T = (T+N-i)%mod
ans = 0
for k in range(K, N+2):
    ans += T-S+1
    ans %= mod
    S = (S+k  )%mod
    T = (T+N-k)%mod
print(ans)

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

int main()
{
	long long x, n;
	cin >> x;
	n = 100;
	for (int i = 1; i <= 100000; i++) {
		n *= 1.01;
		if (n >= x) {
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

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;
}

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  ll A, B, N;
  cin >> A >> B >> N;

  ll i = min(N, B - 1);
  ll res = (A * i / B) - A * (i / B);

  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = sorted([ii() for _ in range(N)])

print(sum(A) - A[-1]//2)

Measured memory_bytes: 3064
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(M)]

ans = []
for a, b in AB:
    dist = 10 ** 9
    goal = -1
    for i, cd in enumerate(CD):
        c, d = cd
        di = abs(a-c)+abs(b-d)
        if di < dist:
            goal = i + 1
            dist = di
    ans.append(goal)

print(*ans, sep="\n")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
  
int main(){
  string s,t;
  cin>>s>>t;
  if (t.substr(0,t.size()-1) == s){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int count = 0;
		
		for(int i = A; i <= B; i++) {
			String As = new Integer(i).toString();
			StringBuffer Asb = new StringBuffer(As);
			String AsbR = Asb.reverse().toString();
			if(As.equals(AsbR)) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 38356
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[200][20000];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    vector<ll> v(N), w(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> v[i] >> w[i];
    }
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 0; j <= W; j++)
        {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j - w[i] >= 0)
            {
                chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= W; i++)
    {
        chmax(ans, dp[N][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11224
n, u, v = map(int, input().split())
V = [ [] for _ in range(n + 1) ]
for _ in range(n - 1):
    a, b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)

import collections

def bfs(x):
    X = [ -1 ] * (n + 1)
    q = collections.deque([ (x, 0) ])
    X[x] = 0
    while q:
        node, dist = q.popleft()
        for dst in V[node]:
            if X[dst] == -1:
                X[dst] = dist + 1
                q.append((dst, dist + 1))
    return X

T = bfs(u)
A = bfs(v)

ans = 0
for i in range(1, len(T)):
    if T[i] < A[i]:
        ans = max(ans, A[i] - 1)
print(ans)

Measured memory_bytes: 65772
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[100005],b[100005],c[100005],dp[100005][3];
int main(){
cin>>n;
for(int k=1;k<=n;k++)
    cin>>a[k]>>b[k]>>c[k];
dp[1][1]=a[1];
dp[1][2]=b[1];
dp[1][3]=c[1];
for(int k=2;k<=n;k++){
  dp[k][1]=max(dp[k-1][2],dp[k-1][3])+a[k];
  dp[k][2]=max(dp[k-1][1],dp[k-1][3])+b[k];
  dp[k][3]=max(dp[k-1][1],dp[k-1][2])+c[k];
}
cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
return 0;
}


Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static StreamReader sr;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var AB = Sarray();
            var A = AB[0];
            var B = AB[1];
            var ans = primefactorize(Gcd(A, B)).Distinct().Count() + 1;
            WriteLine(ans);
            //Out.Flush();
        }
        static long Gcd(long x, long y) => 0 == y ? x : Gcd(y, x % y);
        static List<long> primefactorize(long n)
        {
            var primes = new List<long>();
            for (long i = 2; i * i <= n; ++i)
            {
                while (n % i == 0)
                {
                    primes.Add(i);
                    n /= i;
                }
            }
            if (n != 1) primes.Add(n);
            return primes;
        }
    }
}

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

int a[102400], n, c;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		if(a[i] < i && a[a[i]]==i) ++c;
	}
	printf("%d\n", c);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cout<<elem;}cerr<<endl;}

const llong inf=1e18;

template<class Type_k,class Type_p>
Type_p mod_pow(long long n,Type_k k,Type_p p){//n^k(mod p).
	if(k==0) return 1;
	long long res=mod_pow(n*n%p,k/2,p);
	if(k&1) res=res*n%p;
	return res;
}

//解説参考. 解法1.
int main(){
	int n,k;
	cin>>n>>k;
	
	vector<llong> a(n);
	int cnt=0;//負の数.
	REP(i,n){
		cin>>a[i];
		if(a[i]<0) cnt++;
	}
	
	if(cnt==n and k%2==1){//全て負かつkが奇数.
		//debug("debug");
		sort(ALL(a),greater<int>());
		//line(a);
		llong ans=1;
		REP(i,k) ans=ans*(MOD+a[i])%MOD;
		cout<<ans<<endl;
		return 0;
	}
	
	auto f=[](int x,int y){
		return abs(x)>abs(y);
	};
	sort(ALL(a),f);
	//line(a);
	
	llong sum=1;
	cnt=0;
	REP(i,k){
		sum=sum*a[i]%MOD;
		if(a[i]<0) cnt++;
	}
	
	if(cnt%2==0 or sum==0 or k==n){//非負の場合またはk=nの場合.
		cout<<(MOD+sum)%MOD<<endl;
		return 0;
	}
	
	llong pl,pr,ml,mr;
	pl=pr=ml=mr=inf;
	REP(i,k){
		if(a[i]<0) ml=a[i];
		else pl=a[i];
	}
	for(int i=n-1;i>=k;--i){
		if(a[i]<0) mr=a[i];
		else pr=a[i];
	}
	
	if(ml==inf or pr==inf) sum=sum*mod_pow(pl,MOD-2,MOD)%MOD*(MOD+mr)%MOD;
	else if(pl==inf or mr==inf) sum=sum*mod_pow(MOD+ml,MOD-2,MOD)%MOD*pr%MOD;
	else{
		//pr/ml>=mr/pl.
		if(pr*pl>=mr*ml) sum=sum*mod_pow(MOD+ml,MOD-2,MOD)%MOD*pr%MOD;
		else sum=sum*mod_pow(pl,MOD-2,MOD)%MOD*(MOD+mr)%MOD;
	}
	
	cout<<(MOD+sum)%MOD<<endl;
}

Measured memory_bytes: 4784
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

// ModInt
// region
class ModInt(x: Long) {

    companion object {
        const val MOD = 1000000007L
        //const val MOD = 998244353L
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

val fac = mutableListOf<ModInt>()
val invfac = mutableListOf<ModInt>()

fun fact(n: Long, b: Boolean): ModInt {
    if (fac.count() == 0) {
        fac.add(ModInt(1))
        invfac.add(ModInt(1))
    }
    while (fac.count() <= n) {
        fac.add(fac.last() * ModInt(fac.count().toLong()))
        invfac.add(fac.last().inv())
    }
    return if (b) {
        fac[n.toInt()]
    } else {
        invfac[n.toInt()]
    }
}

fun comb(n: Long, k: Long): ModInt {
    return fact(n, true) * fact(k, false) * fact(n - k, false)
}

fun comb2(n: Long, k: Long): ModInt {
    var ans = ModInt(1)
    for (i in 0 until k) {
        ans = ans * ModInt(n - i) / ModInt(k - i)
    }
    return ans
}
// endregion

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextInt()
    var num = 1
    var ans = ModInt(0)
    while (num * 3 <= s) {
        ans += comb(s - 2 * num - 1L, num - 1L)
        num++
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 38200
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	map<string, int>a;
	int len = 0, freq = 0;
	string s;
	while (cin>>s) {
		a[s]++;
		if (len < s.length())len = s.length();
		if (freq < a[s])freq = a[s];
	}
	for (auto it = a.begin(); it != a.end(); it++) {
		if (freq == it->second)cout << it->first << " ";
	}
	for (map<string, int>::iterator it = a.begin(); it != a.end(); it++) {
		if (len == it->first.length())cout << it->first << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include <iostream> // std::cin
#include <string> // std::string
#include <cstdio> // puts

std::string S;

inline bool check1()
{
    return S[0]=='A';
}

inline bool check2()
{
    int cnt=0;
    int len = S.length();
    for (int i=2;i<=len-2;++i)
    {
        if (S[i]=='C')  ++ cnt;
    }
    return cnt == 1;
}

inline bool check3()
{
   for (int i=0;i<S.length();++i)
   {
        if (S[i]>'A'&&S[i]<='Z'&&S[i]!='C')
            return false;
   }
   return true;
}

inline bool check_tot()
{
    return check1()&&check2()&&check3();
}
int main()
{
    std::cin>>S;
    check_tot()?puts("AC"):puts("WA");
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,string> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{
  ll n,k,sum(0);
  cin>>n>>k;
  vi v(n);
  rep(i,n){
  cin>>v[i];
  sum+=v[i];
  }
  sort(all(v),greater<int>());
   for(int i=0 ; i<min(n,k) ; i++)
   {
       sum-=v[i];
   }
cout<<sum;
go;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int i,j,k;
	int n,b,f,r,v;
	int a[4][3][10] = {0};

	scanf("%d", &n);

	for(i = 0; i < n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);

		a[b-1][f-1][r-1] += v;

		if(a[b-1][f-1][r-1] <= 0)
		{
			a[b-1][f-1][r-1] = 0;
		}
	}

	for(i =0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			
			for(k = 0; k < 10; k++)
			{
				printf(" ");
				printf("%d",a[i][j][k]);
			}

			printf("\n");
		} 
		
		if(i == 3)
		{
			break;
		}else
		{
			for(j = 0; j < 20; j++)
			{
				printf("#");
			}
		}
		printf("\n");
		
	}
	
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int f(const int d) {
	if (d < 10) return d;
	else return d % 10 + f(d / 10);
}

int main() {
	int n; std::cin >> n;
	if (n % f(n) == 0) std::cout << "Yes\n";
	else std::cout << "No\n";
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = sorted([list(map(int, input().split())) for _ in range(n)])
cost = 0
for i in range(n):
    cost += a[i][0] * min(m, a[i][1])
    m -= min(m, a[i][1])
    if m == 0:
        break
print(cost)


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

int main(){
    int n;
    cin >> n;
    int F[50];
    F[0]=1;
    F[1]=1;
    
    for(int i=2; i<=n; i++){
        F[i] = F[i-1] + F[i-2];
    }
    
    cout << F[n] << endl;
    
    return 0;
}

Measured memory_bytes: 3048
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,k,t;
	while(cin>>n>>k,n){
		int s[100]={0};
		rep(i,n+1)rep(j,k)cin>>t,s[j]+=i?-t:t;
		rep(i,k)if(s[i]<0){
			cout<<"No"<<endl; goto N;
		}
		cout<<"Yes"<<endl;
		N:;
	}
	return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <map>
#include <stdio.h>

int main(void)
{
	std::map<std::string,int> words;
	char word[33];
	while(~scanf("%s",word))
	{
		if(words.find(word)==words.end())
			words[word]=0;
		words[word]++;
	}

	int max=0;
	std::string mode,longest;
	for(std::map<std::string,int>::iterator it = words.begin(); it != words.end(); it++)
	{
		if(it->second > max)
		{
			max = it->second;
			mode = it->first;
		}
		if(it->first.size() > longest.size())
		{
			longest = it->first;
		}
	}
	std::cout << mode << " " << longest << std::endl;
	return 0;
}

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

using namespace std;

int main(void)
{
    const long long MOD = 1e+9 + 7;

    int N = 0; cin >> N;

    vector<long long> a(N);

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

    long long result = 0;

    int bit = 0;

    for(int d = 0; d < 60; d++) {
        for(int i = 0; i < N; i++) {
            if(a[i] & (1ll << d)) {
                bit++;
            }
        }
        result += ((long long)bit * (N - bit) % MOD) * ((1ll << d) % MOD) % MOD;
        result %= MOD;
        bit = 0;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 2560
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1
        
max_value = max(Dic.values())

max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_value]
max_k_list = sorted(max_k_list)

print(*max_k_list, sep="\n")

Measured memory_bytes: 34012
n=int(input())
p=[[0]*51 for _ in range(51)]
for _ in range(n):
    a=float(input())
    a*=10**9
    a=round(a)
    cnt2,cnt5=0,0
    while a%2==0:
        a//=2
        cnt2+=1
    while a%5==0:
        a//=5
        cnt5+=1
    p[cnt2][cnt5]+=1
ans=0
for i in range(51):
    for j in range(51):
        for k in range(51):
            for l in range(51):
                if k>=18-i and l>=18-j:
                    if i==k and j==l:
                        ans+=p[i][j]*(p[i][j]-1)
                    else:
                        ans+=p[i][j]*p[k][l]
print(ans//2)

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

int main() {
    int n,k;
    cin >> n >> k;
    if(n%2==1){
        if((n/2+1)>=k){
            cout << "YES";
        }
        else{
            cout << "NO";
        }
    }
    else{
        if((n/2)>=k){
            cout << "YES";
        }
        else{
            cout << "NO";
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
int r(){int x;cin>>x;return x;}
void solve() 
{   
    priority_queue<int>pq;
    int n,m;cin>>n>>m;
    REP(i,n)pq.push(r());
    REP(i,m){
        int x=pq.top();pq.pop();
        pq.push(x/2);
    }
    ll ans=0;
    while(!pq.empty())ans+=pq.top(),pq.pop();
    cout<<ans<<endl;
}

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


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

}
 

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

using namespace std;

const int N = 1e5 + 7;

int u, v, n, m, d[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        cin >> u >> v;
        d[u]++;
        d[v]++;
    }
    for (int i = 1; i <= n; i++)
        if (d[i] & 1){
            cout << "NO";
            return 0;
        }
    cout << "YES";
}


Measured memory_bytes: 768
n=input()
a,b=map(int,raw_input().split())
c,d=map(int,raw_input().split())
a,b,c,d=a-1,b-1,c-1,d-1
minInt=1e20
for w in range(1,n+1):
    xa,ya=a%w,a/w
    xb,yb=b%w,b/w
    xc,yc=c%w,c/w
    xd,yd=d%w,d/w
    dist=abs(xa-xb)+abs(ya-yb)+abs(xc-xd)+abs(yc-yd)
    minInt=min(minInt,dist)
print minInt

Measured memory_bytes: 4288
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  int i;
  int ans = 0;
  for(i=0;i<n;i++){
    cin >> a[i];
    if(i>=1 && a[i]==a[i-1]){
      ans++;
      a[i]=-1;
    }
  }
  cout << ans << endl;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    A--; B--;
    vector<int> v = {14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    if(v[A] > v[B]) {
        cout << "Alice" << endl;
    } else if(v[A] == v[B]) {
        cout << "Draw" << endl;
    } else {
        cout << "Bob" << endl;
    }
}


Measured memory_bytes: 764
a=input().split(" ")
ans=0
x=0
for i in range(1,int(a[0])):
	for j in range(1,int(a[0])):
		ans=(i*2)+(j*4)
		if ans==int(a[1]) and i+j==int(a[0]):
			x=x+1
if int(a[0])*4==int(a[1]):
	x=x+1
if int(a[0])*2==int(a[1]):
	x=x+1
if x>=1:
	print("Yes")
elif x==0:
	print("No")
		
		

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

int reverse(int n){
  int r = 0;
  
  for(int i = 4; i >= 0; i--){
    r += n % 10*pow(10, i);
    n /= 10;
  }
  
  return r;
}

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
    
  for(int i = A; i <= B; i++){
    int n = reverse(i);
    if(i == n){
      ans++;
    }
  } 
 
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#define MAX 1024
int main(void){
  char s[MAX],t[MAX];
  int n,m,h;
  int i;
  while(scanf("%s",s),strcmp(s,"-")!=0){
      n=strlen(s);
      scanf("%d",&m);
      for(i=0;i<m;i++){
          scanf("%d",&h);
          memcpy(t+n-h,s,   h);
          memcpy(t,     s+h,n-h);
          memcpy(s,     t,  n);
      }
      printf("%s\n",s);
  }
  return 0;  
}


Measured memory_bytes: 2076
#include <bitset>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;

  int a[4] = {s[0] - '0', s[1] - '0', s[2] - '0', s[3] - '0'};

  for (int i = 0; i < (1 << 3); ++i) {
    bitset<3> b(i);
    int t = a[0];
    string u(1, s[0]);
    for (int j = 0; j < 3; ++j) {
      if (b.test(j)) {
        t += a[j + 1];
        u += "+" + string(1, s[j + 1]);
      } else {
        t -= a[j + 1];
        u += "-" + string(1, s[j + 1]);
      }
    }
    if (t == 7) {
      printf("%s\n", (u + "=7").c_str());
      return 0;
    }
  }
}


Measured memory_bytes: 3128
import java.time.Year;
import java.util.*;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    // input
    static int n;
    static ArrayList<Integer> h;

    /**
     * input
     */
    static void input(){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        h = new ArrayList<Integer>();

        for(int i=0;i<n;i++){
            h.add(sc.nextInt());
        }
        sc.close();
    }
 
    // global
    static int ans;

    static void rec(){
        int m = Collections.max(h);

        if (m == 0) {
            return;
        } else {
            int prev = -1;
            for(int i=0;i<n;i++){
                if (h.get(i) == m) {
                    if (prev != m) {
                        ans ++;
                    }
                    h.set(i, h.get(i) - 1);
                    prev = m;
                } else {
                    prev = h.get(i);
                }
            }
            rec();
        }

    }

    /**
     * solver
     */
    static void solve(){
        rec();
        System.out.println(ans);
    }


    public static void main(String args[]) {

        input();

        solve();
    }
}


Measured memory_bytes: 23764