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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char c;
    cin >> c;
    
    int cnt = 0;
    char d;
    bool ok = true;
    while(cin >> d){
        if( d != '9' ) ok = false;
        cnt++;
    }
    //~ cerr << ok << endl;
    if(ok){
        cout<< (c-'0') + 9*cnt;
    }else cout << (c-'1') + 9*cnt;
    
    cout << '\n';
}


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

int score_function(const vector<int> &t,const vector<vector<int>> &s,const vector<int> &c,const int &d){
    vector<int> last(27);
    int manzoku=0;
    for(int i=1;i<=d;i++){
        manzoku+=s[i][t[i]];
        last[t[i]]=i;
        int sum=0;
        for(int j=1;j<=CONTEST_NUM;j++){
            sum+=c[j]*(i-last[j]);
        }
        manzoku-=sum;
    }
    return manzoku;
}

void set_ans(const vector<int> &t,vector<int> &ans,const int &d){
    for(int i=1;i<=d;i++){
        ans[i]=t[i];
    }
}

int main() {
    int d;cin>>d;
    vector<int> c(27);
    for(int i=1;i<=CONTEST_NUM;i++){
        cin>>c[i];
    }
    vector<vector<int>> s(d+1,vector<int>(27));
    for(int i=1;i<=d;i++){
        for(int j=1;j<=CONTEST_NUM;j++){
            cin>>s[i][j];
        }
    }
    vector<int> t(d+1);
    vector<int> ans(d+1);
    int old_ans=-1000000000;
    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rand26(1,26);
   int k=0;
    while(k<40000){
        for(int i=1;i<=d;i++){
            t[i]=rand26(mt);
        }
        int tmp=score_function(t,s,c,d);
        if(tmp>old_ans){
            set_ans(t,ans,d);
        }
        k++;
    }
    for(int i=1;i<=d;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""

import numpy as np
import sys
from functools import reduce 
""""
import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy
import bisect
"""

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
# 約数を高速で列挙するコード
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse = True)
    return divisors
"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
N = int(input())
A = list(map(int, input().split()))
L = [0]*(N+1)
R = [0]*(N+1)     


# 最大公約数を吐く
def gcd_euclid(a, b):
    if a > b:
        a, b = b, a 
    if a==0:
        return b
    return gcd_euclid(b%a, a)

def main():
    A.sort()
    res = 0
    for i in range(1,N+1):
        L[i] = gcd_euclid(L[i-1], A[i-1])
    for i in range(N-1, 0, -1):
        R[i] = gcd_euclid(R[i+1], A[i])
    
    for i in range(N):
        gcd_now = gcd_euclid(L[i], R[i+1])
        res = max(res, gcd_now)
    print(res)
    
if __name__ == '__main__':
    main()


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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	ll n, k; cin>>n>>k;
	vl a(n); for(auto &e: a) cin>>e;

	ll lo = 0, hi = 1e9;
	while(lo+1<hi){
		ll mid = (lo + hi)/2;
		ll cntr = 0;
		for(auto &e: a) cntr += div_ceil(e, mid) - 1;
		if(cntr>k)
			lo = mid;
		else
			hi = mid;
	}
	cout<<hi<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 4716
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memset((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#define mod 1000000007
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 300005
char s[N]; int n,f[N][7];
void upd(int &x,int y){ x+=y; if (x>=mod) x-=mod; }
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	scanf("%s",s+1); n=strlen(s+1);
	int nk=0,k=1;
	if (s[1]!='0') f[nk][3]=1;
	if (s[1]!='1') f[nk][0]=1;
	rep (i,2,n){
		nk^=1; k^=1; mset(f[nk],0);
		if (s[i]!='0'){ //可以加上1
			upd(f[nk][2],f[k][0]);//0+1-->01
			upd(f[nk][0],f[k][1]);//00+1-->0
			upd(f[nk][3],f[k][2]);//01+1-->1
			upd(f[nk][6],f[k][3]);//1+1-->11
			upd(f[nk][3],f[k][4]);//10+1-->1
			upd(f[nk][4],f[k][5]);//100+1-->10
			upd(f[nk][6],f[k][6]);
		}
		if (s[i]!='1'){ //可以加上0
			upd(f[nk][1],f[k][0]);//0+0-->00
			upd(f[nk][0],f[k][1]);//00+0-->0
			upd(f[nk][0],f[k][2]);//01+0-->0
			upd(f[nk][4],f[k][3]);//1+0-->10
			upd(f[nk][5],f[k][4]);//10+0-->100
			upd(f[nk][4],f[k][5]);//100+0-->10
			upd(f[nk][6],f[k][6]);
		}
	}
	cout<<(f[nk][3]+f[nk][6])%mod<<endl;
	return 0;
}
// sample data:
/*
1??00

2

======
?

1

======
?0101???10???00?1???????????????0????????????1????0

402589311

*/

// rest:
/*
0: 0
1: 00
2: 01
3: 1
4: 10
5: 100
6: all
以上是所有有用的状态.
因为对于任意两个距离不超过2的1最终不可能同时存在,
经过若干次合并后肯定不会有连续三位中出现两个1,
所以没有必要记录这样的状态.
直接转移即可.
*/

/*
If you find any bug in my code or solution, please tell me. Thanks so much.
email: 2411280037@qq.com
*/

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define MOD 1000000007
#define MAX 105
#define MAX_NUM 300001
char s[MAX];
bool isPalindrome(char *s,int len)
{
    int i;
    for(i=0;i<len-1-i;i++)
    {
        if(s[i]!=s[len-1-i]) return false;
    }
    return true;
}
int main()
{
    int n,m,i;
    for(i=0;;i++)
    {
        char cc;
        scanf("%c",&cc);
        if(!('a'<=cc&&cc<='z'))
        {
            break;
        }
        s[i]=cc;
    }
    n=i;
    if(isPalindrome(s,n)&&isPalindrome(s,(n/2))&&isPalindrome((s+(n/2)+1),(n/2)))
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{    int n,m,i,countwa=0,countac=0,a[100005]={0},t;
    scanf("%d %d",&m,&n);
    getchar();
    for(i=0;i<n;i++)
    {   char s[3];
        scanf("%d",&t);
        getchar();
        gets(s);
       if(s[0]=='A'&&s[1]=='C'&&a[t]<100005)countwa+=a[t],a[t]=100005,countac++;

       if(s[0]=='W'&&s[1]=='A')a[t]++;
    }
    printf("%d %d",countac,countwa);

    return 0;
}


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

int main(){
    ll h,w,x,y;
    cin>>h>>w>>x>>y;
    if(h==1){
	if(y==1||y==w)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
    }
    if(w==1){
	if(x==1||x==h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
    }
    if(h*w%2==1&&(x+y)%2==1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 3124
#include <stdio.h>
int main(void){
    int n,m,l,i,j,k;
    scanf("%d %d %d",&n,&m,&l);
    int a[n][m],b[m][l];
    long ans[n][l];
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            ans[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
               ans[i][j]+=a[i][k]*b[k][j]; 
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if(j!=l-1){
                printf("%ld ",ans[i][j]);
            }
            else{
                printf("%ld\n",ans[i][j]);
            }
        }
    }
    return 0;
}


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


int main(){

  int n, k;
  vector<int> v;
  cin >> n;
  cin >> k;

  int p;
  for (int i=0; i!=n; ++i){
    cin >> p;
    v.push_back(p);
  }

  sort(v.begin(), v.end());

  int sum = 0;
  for (int j=0; j!=k; ++j){
    sum += v[j];
  }

  cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3612
def main():
    """
    端の最適解は決定している
        idx= 0~ 1:sumがx以下になるようにがA[ 1]を減らす、それでもx以下にならないならA[ 0]を減らす
        idx=-2~-1:sumがx以下になるようにがA[-2]を減らす、それでもx以下にならないならA[-1]を減らす

        -> 左端は決定しているので右端まで減らす
        -> 右端から行っても減らす数は変わらない
        -> 端から2番目を優先に減らせばどちらでもよい？
    """
    N, x = map(int, input().split())
    A = list(map(int, input().split()))

    ans = f(N, x, A)
    print(ans)


def f(N, x, A):
    ans = 0
    for i in range(1, N):
        s = sum(A[i - 1:i + 1])
        if s > x:
            # 引き過ぎない
            n = min(s - x, A[i])
            A[i] -= n
            ans += n

            s = sum(A[i - 1:i + 1])
            if s > x:
                n = min(s - x, A[i - 1])
                A[i - 1] -= n
                ans += n

    return ans


def WA(N, x, A):
    ans = 0
    for i in range(N // 2):
        s = sum(A[i:i + 2])
        if x <= s:
            n = s - x
            A[i + 1] -= n
            ans += n

            s = sum(A[i:i + 2])
            if x <= s:
                n = s - x
                A[i] -= n
                ans += n

        if i == 0:
            # slice(-2, 0) -> []
            s = sum(A[-2:])
        else:
            s = sum(A[-(i + 2):-i])
        if x <= s:
            n = s - x
            A[-(i + 2)] -= n
            ans += n

            if i == 0:
                s = sum(A[-2:])
            else:
                s = sum(A[-(i + 2):-i])
            if x <= s:
                n = s - x
                A[-(i + 1)] -= n
                ans += n

    return ans

if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define bit(x) (1 << x)
#define par pair<int,int>
#define maxn 200005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

ll N,A[maxn],cont,frec[maxn];
int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;

    for(int i=1;i<=N;i++)
        cin >> A[i] , cont+=frec[A[i]] , frec[A[i]]++;

    for(int i=1;i<=N;i++)
        cout << cont - frec[A[i]]+1 << "\n";



}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void solve()
{
	int a, b;
	cin >> a >> b;
	if (a + b == 15)
	{
		cout << "+" << endl;
	}
	else if (a * b == 15)
	{
		cout << "*" << endl;
	}
	else
	{
		cout << "x" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import numpy as np
N , M , C = map(int,input().split())
B = np.array(list(map(int,input().split())))
A = []
for _ in range(N):
    A.append(list(map(int,input().split())))
A = np.array(A)
cnt = 0

for i in range(N):
    if sum(A[i] * B) + C > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 12496
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 7);

int main(){
  int a, b;cin>>a>>b;
  cout<<((a-b)%2?"IMPOSSIBLE":to_string((a+b)/2))<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();
        BigDecimal x = sc.nextBigDecimal();

        System.out.println(nbCanDivide(a, b, x));
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
//            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }

    //a以上b以下の数でxで割り切れるものの数をf(n)と置くと、
    //f(n) = f(b) - f(a-1)
    BigDecimal nbCanDivide(BigDecimal a, BigDecimal b, BigDecimal x){
//        System.out.println(String.format("%s %s %s", a, b, x));
        return canDivide(b, x).subtract(canDivide(a.subtract(BigDecimal.valueOf(1)), x));
    }
    BigDecimal canDivide(BigDecimal i, BigDecimal x){
//        System.out.println(String.format("%s %s", i, x));
        if(i.compareTo(BigDecimal.valueOf(0)) != -1){
//            System.out.println(((i/x) + 1));
            return i.divide(x, 1).add(BigDecimal.valueOf(1));
        } else {
            return BigDecimal.valueOf(0);
        }
    }

}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}


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

class Program
{
    static Scanner sc = new Scanner();

    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var P = sc.ReadIntArray(N);

        var ans = 0;
        for (int i = 1; i < N - 1; i++)
        {
            if (P[i - 1] < P[i] && P[i] < P[i + 1])
            {
                ans += 1;
            }
            else if (P[i - 1] > P[i] && P[i] > P[i + 1]) {
                ans += 1;
            }
        }

        Console.WriteLine(ans);
    }

    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}

class HashMap<K, V> : Dictionary<K, V> where V : new()
{
    private V DefaltValue = new V();
    public HashMap() { }
    public HashMap(V defaultValue)
    {
        this.DefaltValue = new V();
    }
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v : base[i] = this.DefaltValue;
        }
        set { base[i] = value; }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
    char a[100];
    int n,k;
    scanf("%d%d",&n,&k);
    int i;
    scanf("%s",a+1);
    for(i=1;i<=n;i++)
    {
        if(i==k)
            printf("%c",a[i]+32);
        else
            printf("%c",a[i]);

    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a, b;
    cin>>a>>b;
    if(a <= 5){
        cout<<"0";
    }
    else if(a > 5 && a < 13){
        cout<<b/2;
    }
    else cout<<b;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int n;
long long int a[200010];

bool cansolve(long long int k)
{
	for(int i = 0; i < n; i++){
		int tmp1;
		if(i == 0) tmp1 = lower_bound(a + i, a + i + n, k) - a;
		else tmp1 = lower_bound(a + i, a + i + n, k + a[i - 1]) - a;
		int tmp2 = lower_bound(a + tmp1 + 1, a + i + n, k + a[tmp1]) - a;
		// cout << mid << " " << tmp1 << " " << tmp2 << endl;
		if(a[i + n - 1] - a[tmp2] >= k) return true;
	}
	return false;
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i + n] = a[i];
	}
	for(int i = 1; i < 2 * n; i++){
		a[i] += a[i - 1];
	}
	long long int l = 0, r = a[n - 1];
	while(r - l > 1){
		long long int mid = (l + r) / 2;
		if(cansolve(mid)) l = mid;
		else r = mid;
	}
	cout << l << endl;
}


Measured memory_bytes: 4640
a,b,c,d,e,f = map(int, input().split())
s = [0,0,0,0]
con1 = 0
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
#                 w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w3)
                con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                if con1 <= con2 and w >= 0:
                    con1 = con2
                    s = [x,y,v,w]
                else:
                    continue

ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3]
ans2 = c*s[2] + d*s[3]
print(ans1,ans2)

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

using namespace std;

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	if (h == 1 || w == 1){
		puts("1");
		return 0;
	}
	long long ans = h * 1LL * w;
	ans = (ans + 1)  >> 1;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

Measured memory_bytes: 71960
alp = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
keta = 0
a = 0
answer = ''
while a < n:
    keta += 1
    a += 26**keta
a -= 26**keta
n -= a+1
for i in range(keta-1):
    answer += alp[n // (26 ** (keta-i-1))]
    n = n % (26 ** (keta-i-1))
answer += alp[n % 26]
print(answer)

Measured memory_bytes: 61920
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8],out[20];
char k;
s;
size_t i;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    if(n == 1) {
        putchar(49);
    } else {
        const int sqrtN = sqrt(n);
        ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int a = n / i;
            ans += ((long long)i * (i + a) * (a + 1 - i));
        }
        i = 20;
        do{
            out[--i]=ans%10+'0';
            ans/=10;
        }while(ans);
        write(1,out+i,20-i);
    }
}


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

typedef long long ll;
const ll MOD = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= MOD;
	if(k%2 == 1){
		ret *= x; ret %= MOD;
	}
	return ret;
}
ll f(ll n){
	ll ret = 1;
	for(int i = 1 ; i <= n ; i ++){
		ret *= i;
		ret %= MOD;
	}
	return ret;
}

int main(){
	ll n,m,k;
	cin >> n >> m >> k;
	ll a,b,c;
	a = (n-1)*n*(n+1)/6; a %= MOD; a *= m; a %= MOD; a *= m; a %= MOD;
	b = (m-1)*m*(m+1)/6; b %= MOD; b *= n; b %= MOD; b *= n; b %= MOD;
	c = f(n*m-2);
	c *= modpow(f(k-2),MOD-2); c %= MOD;
	c *= modpow(f(n*m-k),MOD-2); c %= MOD;
	cout <<((a+b)*c)%MOD << endl;
}

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

typedef long long int ll;
#define ent cout << "\n"
#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define pair < ll, ll > pp
#define f(a, b) for(auto i = a;i < b;i++)
#define rev_f(a, b) for(auto i = b;i >= a;i--)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define st(x) sort(x.begin(), x.end()) 
#define rv(x) reverse(x.begin(), x.end()) 
#define cintc() ll tc;while(tc--) 
#define deb(x) cout << x << "\n";
#define cin(a) ll a; cin >> a;
#define cin2() ll a, b; cin >> a >> b
#define cin3() ll a, b, c; cin >> a >> b >> c
#define cinn(vect, n) def_v vect(n); f(0, n) cin >> vect[i]
#define coutn(vect, n)  f(0, n) {cout << vect[i] << "";} cout << " ";

typedef vector < ll > def_v;
typedef tuple< ll, ll, ll> def_tuple;
ll mod = 1e9 + 7,cnt = 0;

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

    if(str == "ABC")
        cout << "ARC\n";
    else
        cout << "ABC\n";
    
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main() {
    int a, b;
    cin>>a>>b;
    if(a == b){
        cout << a + b << endl;
    }else if(a > b){
        cout << a + a -1 << endl;
    }else{
        cout << b + b -1 << endl;
    }
}



Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto B = [0L] ~ A;
    long M = N + 1;

    long sum;
    foreach (i; 0 .. M)
        sum += abs(B[i] - B[(i + 1) % M]);
    foreach (i; 0 .. N)
    {
        writeln(sum - abs(B[i] - B[(i + 1) % M]) - abs(B[(i + 1) % M] - B[(i + 2) % M]) + abs(
                B[i] - B[(i + 2) % M]));
    }
}


Measured memory_bytes: 5240
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*3];
		for(int i=0; i<N*3; i++)
			a[i] = sc.nextInt();

		long[] sum1 = new long[N+1];
		PriorityQueue<Integer> q = new PriorityQueue<>();
		for(int i=0; i<N; i++) {
			q.add(a[i]);
			sum1[0] += a[i];
		}
		
		for(int i=0; i<N; i++) {
			q.add(a[N+i]);
			int min = q.poll();
			sum1[i+1] = sum1[i] +a[N+i] -min;
		}
		
		long[] sum2 = new long[N+1];
		q = new PriorityQueue<>(Comparator.reverseOrder());
		for(int i=0; i<N; i++) {
			q.add(a[N*2+i]);
			sum2[N] += a[N*2+i];
		}
		
		for(int i=0; i<N; i++) {
			q.add(a[N*2-1-i]);
			int max = q.poll();
			sum2[N-1-i] = sum2[N-i] +a[N*2-1-i] -max;
		}
		
		long ans = sum1[0]-sum2[0];
		for(int i=0; i<N; i++)
			ans = Math.max(ans, sum1[i+1]-sum2[i+1]);
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 94720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll K;
  cin>>K;
  ll a=7,b=7;
  if (7%K==0){
    cout<<1<<endl;
    return 0;
  }
  for(int i=2;i<=50000000;i++){
    b*=10;
    b%=K;
    a+=b;
    a%=K;
    if(a==0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
     
    int ary_total(int num)
    {
      int total = 0;
      
      do {
        int tmp = num % 10;
        total += tmp;
        num /= 10;
      } while (num > 0);
     
      return total;
    }
     
    int main()
    {
      int n;
      int a, b;
      int i;
      int total = 0;
     
      scanf("%d %d %d", &n, &a, &b);
     
      for (i = 1; i <= n; i++) {
        int ans = ary_total(i);
        if (ans >= a && ans <= b) {
          total += i;
        }
      }
     
      printf("%d\n", total);
     
      return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

ll x, y;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> y;
	
	ll ret = 0;
	if(y <= 0){
		if(x <= y) ret = y - x;
		else if(x < 0) ret = 2 + x - y;
		else if(x <= -y) ret= 1 - x - y;
		else ret = 1 + y + x;
	}else{
		if(x < 0) ret = 1 + x + y + 2 * (max(x, -y) - x);
		else if(x <= y) ret = y - x;
		else ret = 2 - x + y + 2 * (x - min(x, y));
	}
	
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3636
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  int n,m,i,j,t;
  cin>>n;
  int cur=-1;
  t=0;
  for(i=0;i<n;i++)
  {
  	cin>>m;
  	if(m>=cur)
  	{
  		t++;
  		cur=m;
  	}
  }
  cout<<t;
  return 0;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n;
ll x;
ll a[2001];
ll cost[2001][2001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> n >> x;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cost[i][j] = LLONG_MAX;
    }
  }
  for (int i = 0; i < n; i++) cost[i][0] = a[i];
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++) {
      cost[i][j] = min(cost[i][j - 1], a[(i - j + n) % n]);
    }
  }
  for (int i = 0; i < n; i++) {
    ll res = i * x;
    for (int j = 0; j < n; j++) {
      res += cost[j][i];
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}

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

using namespace std;
#define mp make_pair
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;

using t3 = tuple<int,int,int>;

const int maxS = 2500;

int enc(int v, int s){
    // 0 <= s <= maxS, 0 <= v < n
    // 0 ... maxS 
    // maxS+1 ... 2*maxS + 1
    return v*(maxS+1) + s;
}

pii dec(int idx){
    int v = idx/(maxS+1);
    int s = idx%(maxS+1);
    return {v,s};
}

vector<vector<t3>> g;
vi cr;
vi T;

vl sp; //shortes path to i in [0,n-1]
int nMrk; // number of cities visited

class Dijkstra{
public:
    static vl solve(int s, int target = -1){
        //g[v] = list of (u,w) , where v->u with weight w.
        int n = (maxS+1)*cr.size();

        assert(s >= 0 && s < n);

        vl dist(n, -1);
        vector<bool> used(n, false);
        set<pair<ll,int>> S;
        S.insert(mp(0, s));
        
        while(!S.empty()){
            auto min_data = *S.begin();
            S.erase(S.begin());

            ll min_dist = min_data.first;
            int v = min_data.second;
            dist[v] = min_dist;
            used[v] = true;

            int vc,vs;
            auto pp = dec(v);
            vc = pp.first; vs = pp.second;
            if(sp[vc] == -1){
                sp[vc] = min_dist;
                nMrk++;
            }
            if(nMrk == sp.size()) break;

            // buy silver from gold
            int u = enc(vc, min(maxS, vs + cr[vc]));
            int uw = T[vc];

            if((!used[u]) && (dist[u] == -1 || dist[v]+uw < dist[u])){
                if(dist[u] != -1) S.erase({dist[u],u});
                dist[u] = dist[v] + uw;
                S.insert({dist[u],u});
            }
            // travel
            for(auto u_data : g[vc]){
                int uc = get<0>(u_data);
                int us = get<1>(u_data);                
                int w = get<2>(u_data);
                if(us > vs) continue;
                us = vs - us;
                int u = enc(uc, us);
                if(used[u]) continue;

                if(dist[u] == -1 || (dist[v]+w < dist[u])){
                    if(dist[u] != -1) S.erase({dist[u],u});
                    dist[u] = dist[v] + w;
                    S.insert({dist[u],u});
                }
            }
        }
        return dist;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, i, j, u, v, s0, w, s;
    cin >> n >> m >> s0;

    g.resize(n, vector<t3>());    
    for(i=0;i<m;i++){
        cin >> u >> v >> s >> w;
        u--;v--;
        g[u].push_back({v,s,w});
        g[v].push_back({u,s,w});
    }

    cr.resize(n);
    T.resize(n);
    for(i=0;i<n;i++){
        cin >> cr[i] >> T[i];
    }

    sp = vl(n, -1);
    nMrk = 0;

    int v0 = enc(0, min(s0,maxS));
    Dijkstra::solve(v0);

    for(i=1;i<n;i++)
        cout << sp[i] << "\n";

    return 0;
}

Measured memory_bytes: 7568
#include<stdio.h>

int main(){

  char a = '#';
  char A = '.';
  int i,j;
  int b[300][300];
  int x,y;
  
  while(1){
    scanf("%d%d",&x,&y);
  
  if (x ==0 && y ==0){
    break;
  }
    
  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
      
      if( i==0 || i ==x-1 || j==0 || j==y-1) printf("%c",a);
      else printf("%c",A);
      
    }printf("\n");
  }
  printf("\n");
  }

  return 0;
}

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

int main() {
  int n, i, l, r, ans = 0;
  cin >> n;
  
  for(i = 0; i < n; i++){
    cin >> l >> r;
    ans += r - l + 1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

use std::collections::HashMap;
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut a = HashMap::new();
    let mut mx = 0;
    for _ in 0..n {
        let s: String = sc.cin();
        let c = if a.contains_key(&s) {
            a.get(&s).unwrap() + 1
        } else {
            1
        };
        if c > mx {
            mx = c;
        }
        a.insert(s, c);
    }
    let mut ans = vec![];
    for (k, &v) in a.iter() {
        if v == mx {
            ans.push(k);
        }
    }
    ans.sort();
    for a in ans.iter() {
        put!(a);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 20408
#include <cstdio>
#include <set>
#include <functional>
using namespace std;

typedef pair<int, int> Pair;

int n;
int q;
int num[1000001];
set<Pair, greater<Pair> > rank;

int main() {
  scanf("%d%d", &n, &q);
  for (int i=0; i<q; i++) {
    int a, v;
    scanf("%d%d", &a, &v);
    rank.erase(Pair(num[a], -a));
    num[a] += v;
    rank.insert(Pair(num[a], -a));
    printf("%2$d %1$d\n", rank.begin()->first, -rank.begin()->second);
  }
}

Measured memory_bytes: 10992
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
#include<regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	string S, T;
	cin >> S >> T;

	int ls = S.size();
	int lt = T.size();

	if (ls < lt) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	string ans("UNRESTORABLE");

	for (int i = 0; i <= ls - lt; i++) {

		string X(S); // Sのi～i+lt-1文字目までをTで置き換えた文字列
		for (int j = 0; j < lt; j++) {
			X[i + j] = T[j];
		}

		bool check = true;
		for (int j = 0; j < ls && check == true; j++) {
			if (S[j] != '?' && S[j] != X[j]) check = false;
		}

		
		if (check == true) ans = X;
	}




	for (int i = 0; i < ans.size(); i++) {
		if (ans[i] == '?') cout << 'a';
		else cout << ans[i];
	}


	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = 0
for i in range(n):
    score = i + 1
    times = 0
    while score < k:
        times += 1
        score *= 2
    if times == 0:
        p += 1 / n
    else:
        p += 0.5 ** times / n
print(p)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int total = 0;
	if(s[0] == 'o') total++;
	if(s[1] == 'o') total++;
	if(s[2] == 'o') total++;
	cout << total * 100 + 700 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <vector>
#include <queue>

template <class Cap, bool isDirect>
class MaxFlow {
    struct Edge {
        int from, to;
        Cap cap;
        int rev;
        Edge(int from, int to, Cap cap, int rev)
            : from(from), to(to), cap(cap), rev(rev){};
    };

    class Graph {
    public:
        int size;
        std::vector<std::vector<Edge>> path;

        explicit Graph(int N = 0) : size(N), path(size) {}
        void span(int u, int v, Cap cap, int rev) {
            path[u].push_back(Edge(u, v, cap, rev));
        }
        std::vector<Edge>& operator[](int v) { return path[v]; }
    };

private:
    Graph graph;
    std::vector<int> dist, iter;

    void bfs(int s) {
        std::fill(dist.begin(), dist.end(), -1);
        dist[s] = 0;
        std::queue<int> que;
        que.push(s);

        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (const auto& e : graph[v]) {
                if (e.cap > 0 && dist[e.to] < 0) {
                    dist[e.to] = dist[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int g, Cap f) {
        if (v == g) return f;

        // iterで事前にどこまで探索したかをセーブ
        for (int& itr = iter[v]; itr < graph[v].size(); ++itr) {
            auto e = graph[v][itr];
            if (e.cap > 0 && dist[v] < dist[e.to]) {
                Cap df = dfs(e.to, g, std::min(f, e.cap));

                // 流せるなら流す
                if (df > 0) {
                    graph[v][itr].cap -= df;
                    graph[e.to][e.rev].cap += df;
                    return df;
                }
            }
        }
        return 0;
    }

public:
    explicit MaxFlow(int size)
        : graph(size), dist(size, -1), iter(size) {}

    void span(int u, int v, Cap cap) {
        graph.span(u, v, cap, graph[v].size());
        graph.span(v, u, (isDirect ? 0 : cap), graph[u].size() - 1);
    }

    Cap exec(int s, int g) {
        const Cap INF = std::numeric_limits<Cap>::max();

        Cap ret = 0;
        while (true) {
            bfs(s);
            if (dist[g] < 0) return ret;

            std::fill(iter.begin(), iter.end(), 0);
            Cap flow;
            while (true) {
                flow = dfs(s, g, INF);
                if (flow == 0) break;
                ret += flow;
            }
        }
    }
};

int main() {
    int N, M;
    std::cin >> N >> M;

    MaxFlow<int, true> mf(N);
    for (int i = 0; i < M; ++i) {
        int u, v, c;
        std::cin >> u >> v >> c;
        mf.span(u, v, c);
    }

    std::cout << mf.exec(0, N - 1) << std::endl;
    return 0;
}



Measured memory_bytes: 3156