akhauriyash/Code-Regression huggingface dataset:
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var min = ToInt64(input[0]);
        var max = ToInt64(input[1]);
        var n = min;
        var result=0;
        while (n <= max)
        {
            result++;
            n *= 2;
        }
        WriteLine(result);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}


//main関数
int main() {
    ll x; cin >> x;

    ll ans = 0, money = 100;

    while(money < x){
        money = money + money / 100;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
N, K = [int(x) for x in input().split()]
S = input()
lst = []
if (S[0] == '0'): lst.append(0)
cnt = 1
for i in range(N-1):
    if (S[i] == S[i+1]):
        cnt += 1
    else:
        lst.append(cnt)
        cnt = 1 
lst.append(cnt)
if (S[-1] == '0'): lst.append(0)
tmp = [0] + lst[:]
ans = 0 if (len(lst) != 1) else lst[0] 
for i in range(len(lst)):
    tmp[i+1] += tmp[i]
if (((len(lst)+1)//2-K) < 1):
    ans = tmp[-1]
else:
    for i in range(0, (len(lst)+1)//2-K):
        l = 2*i
        r = l + 1 + 2*K
        s = tmp[r] - tmp[l]
        if (ans < s):
            ans = s
print(ans)


Measured memory_bytes: 47088
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long K = long.Parse(Console.ReadLine());
            long min = 1;
            for(int i = 0; i < N; i++)
            {
                min = Math.Min(min * 2, min + K);
            }
            Console.WriteLine(min);
        }

    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(ans);

Measured memory_bytes: 27508
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	alice := 0
	bob := 0
	for i := 0; i < n; i += 2 {
		alice += a[i]
		if i+1 < n {
			bob += a[i+1]
		}
	}

	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define Whitebeard ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
    Whitebeard;
    ll a;
    cin>>a;
    a--;
    cout<<(a*(a+1))/2;

    return 0;
}


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

int N, A;

int main(void){
    
    scanf("%d %d", &N, &A);
    vector<int> x(N);
    int sum = 0;
    for(int i = 0; i < N; ++i){
        scanf("%d", &x[i]);
        sum += x[i];
    }
    
    vector<vector<ll>> dp(2501, vector<ll>(51, -1));
    dp[0][0] = 1;
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        for(int s = sum; s >= 0; --s){
            if(x[i] + s > sum) continue;
            for(int c = 0; c < N; ++c){
                if(!~dp[s][c]) continue;
                if(!~dp[x[i] + s][c + 1]) dp[x[i] + s][c + 1] = 0;
                dp[x[i] + s][c + 1] += dp[s][c];
            }
        }
    }
    
    for(int s = 1; s <= sum; ++s) for(int c = 1; c <= N; ++c) if(s % c == 0 && s / c == A && ~dp[s][c]) ans += dp[s][c];
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll mn = 0, mx = 0;
	ll n;
	cin>>n;
	vector<ll> v(n);
	rep(i, n) cin>>v[i];
	rep(i, n){
		if(v[i]<v[mn]) mn = i;
		if(v[i]>v[mx]) mx = i;
	}
	bool neg = false;
	int p = mx;
	if(v[mx]<abs(v[mn])){
		neg = true;
		p = mn;
	}
	vector<P> res(2*n-1);
	rep(i, n) res[i] = P(p, i);
	rep(i, n-1){
		if(!neg) res[i+n] = P(i, i+1);
		else res[i+n] = P(n-i-1, n-i-2);
	}
	cout<<res.size()<<endl;
	rep(i, res.size()){
		cout<<res[i].fst+1<<" "<<res[i].snd+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,a,ans=0;
	cin>>n;
	for(long long i=1;i*i<=n;++i){
		if(n%i==0)
			a=n/i;
	}
	while(a){
		a/=10;
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N, d;
  cin >> N;
  d = 1;
  vector<int> vec(N);
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i=1; i<N; i++) {
    if (vec.at(i) == vec.at(i-1)) {
      continue;
    } else {
      d++;
    }
  }
  cout << d << endl;
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[,] abc = new int[N, 3];
        int[,] DP = new int[N + 1, 3];

        for (int i = 0; i < N; i++)
        {
            abc[i, 0] = cin.nextInt();
            abc[i, 1] = cin.nextInt();
            abc[i, 2] = cin.nextInt();
        }

        for (int i = 1; i < N + 1; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                DP[i, (j + 1) % 3] = Math.Max(DP[i, (j + 1) % 3], DP[i - 1, j] + abc[i - 1, (j + 1) % 3]);
                DP[i, (j + 2) % 3] = Math.Max(DP[i, (j + 2) % 3], DP[i - 1, j] + abc[i - 1, (j + 2) % 3]);
            }
        }

        Console.WriteLine(Math.Max(Math.Max(DP[N, 0], DP[N, 1]), DP[N, 2]));
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 17344
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC, task c, 2020/04/19
//ms, ac
/*
*/

int main(void){
  int64_t N;
  vector<int64_t> worker(200001);
  int64_t temp;

  cin >>N;
  for(int i=0;i<N;i++){
    worker.at(i)=0;
  }

  for(int i=0;i<N-1;i++){
    cin >>temp;
    worker.at(temp-1)++;
  }

  for(int i=0;i<N;i++){
    cout <<worker.at(i) <<endl;
  }
  return 0;
}
/*
*/


Measured memory_bytes: 4660
import sys
input = sys.stdin.readline
MAX = 500000
SENTINEL = 2000000000
L = [0]*(MAX//2 + 2)
R = [0]*(MAX//2 + 2)
cnt = 0

def Merge(A,n,left,mid,right,cnt):
    n1 = mid - left
    n2 = right - mid
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = SENTINEL
    R[n2] = SENTINEL
    L_i = 0
    R_i = 0
    for k in range(left,right):
        cnt += 1
        if L[L_i] <= R[R_i]:
            A[k] = L[L_i]
            L_i += 1
        else:
            A[k] = R[R_i]
            R_i += 1
    return cnt

def MergeSort(A,n,left,right,cnt):
    if left + 1 < right:
        mid = (left + right)//2
        cnt = MergeSort(A,n,left,mid,cnt)
        cnt = MergeSort(A,n,mid,right,cnt)
        cnt = Merge(A,n,left,mid,right,cnt)
    return cnt

if __name__ == "__main__":
    n = int(input())
    array = list(map(int,input().split()))
    cnt = 0
    SENTINEL = 2*10**9
    cnt = MergeSort(array,n,0,n,cnt)
    print(" ".join(map(str,array)))
    print(cnt)



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

public class Main {
	public static void main(String args[]) {
		solve51();
	}

	public static void solve51() {
		Scanner sc = new Scanner(System.in);
		{

			//最初の数字を読み込む
			int n = sc.nextInt();

			//n行分inputを読み込むまで繰り返す
			for (int i = 0; i < n; i++) {

				//数字が入るArrayを作る
				char[] arr = sc.next().toCharArray();

				//ソートして昇順に並べる
				Arrays.sort(arr);

				//昇順に並べた数字をIntに変換する
				int min = Integer.parseInt(new String(arr));
				//System.out.println(min);

				//降順に並べる
				int max = Integer.parseInt(new StringBuffer(new String(arr)).reverse()
						.toString());
				//System.out.println(max);

				//最大値から最小値を引く
				int result = max - min;
				System.out.println(result);

			}
		}

	}

}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll a, b, n;
ll i, j, k;

vector<ll> vv;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    return gcd(b, a % b);
}
int main(){
    scanf("%lld%lld%lld", &a,&b,&n);
    ll aa = gcd(a, b);
    fornum(i,0,aa){
        if(aa%(i+1)==0){
            vv.push_back(aa / (i + 1));
        }
    }
    sort(vv.begin(),vv.end());
    /*fornum(i,0,vv.size()){
        printf("%lld\n", vv[i]);
    }*/
    printf("%lld", vv[vv.size()-n]);

    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	vector<int> freq(26, 0);
	string s;
	cin >> s;
	int n = int(s.size());
	for(int i = 0; i < n; ++i){
		++freq[s[i] - 'a'];
	}
	bool ok = true;
	for(int i = 0; i < 26; ++i){
		ok &= (freq[i] % 2 == 0);
	}
	cout << (ok ? "Yes" : "No" ) << '\n';
	return 0;
}

Measured memory_bytes: 3640
import sys
from itertools import accumulate

def main():
  input=sys.stdin.readline
  n,k=map(int,input().split())
  A=list(map(int,input().split()))
  mod=10**9+7
  dp=[0]*(k+1)
  dp[0]=1
  for a in A:
    dp=list(accumulate(dp))
    #print("accumulated",dp)
    for j,d in enumerate(dp[:k-a],start=a+1):
      dp[j]-=d
    dp=[dpi%mod for dpi in dp]
    #print(dp)
  print(dp[k])
"""
def main():
  dp=[[0]*(k+1) for _ in range(n+1)]
  mod=1000000007
  #i人目までに0個配る方法は1通り
  #for i in range(n+1):
  #  dp[i][0]=1
  for i in range(0,n+1):
    for j in range(0,k+1):
      if i==0 and j==0:
        dp[i][j]=1
        break
      if j==0:
        dp[i][j]=1
        continue
      tmp=dp[i - 1][j] + dp[i][j - 1]
      if tmp>=mod:
        tmp%=mod
      dp[i][j]=tmp
      if j-a[i-1]-1>=0:
        tmp=dp[i][j]-dp[i-1][j-a[i-1]-1]
        if tmp>=mod:
          tmp%=mod
        dp[i][j]=tmp
    #print(dp)   
  print(dp[n][k])"""
main()

Measured memory_bytes: 18432
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll N;
ll A[200000];

int main(){
    cin>>N;
    rep(i,N){
        cin>>A[i];
        A[i]-=i+1;
    }

    sort(A,A+N);

    ll b1,b2,b3;
    if(N%2==0){
        b1=(A[N/2]+A[N/2-1])/2;
        b2=b1-1;
        b3=b1+1;
    }else{
        b1=A[N/2];
        b2=b1-1;
        b3=b1+1;
    }

    ll ans1=0, ans2=0, ans3=0;
    rep(i,N){
        ans1+=abs(A[i]-b1);
        ans2+=abs(A[i]-b2);
        ans3+=abs(A[i]-b3);
    }

    ll ans=min(ans1,min(ans2,ans3));
    cout<<ans<<endl;
}

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

using namespace std;

struct State{
  string s;
  int d;
};

int N,size[10];
map<string,string> mp;
string src,dst,str[10];

int solve(){
  queue<State> Q;
  Q.push((State){src,0});
  set<string> visited;
  visited.insert(src);

  while(!Q.empty()){
    State now = Q.front(); Q.pop();
    string s = now.s;
    if(s == dst) return now.d;
    
    for(int i = 0 ; i < N ; i++){
      string next;
      for(int j = 0 ; j < (int)s.size() ; j++){
        string sub = s.substr(j,size[i]);
        if(sub == str[i]){
          next += mp[str[i]];
          j += size[i]-1;
        }else{
          next += s[j];
        }
      }
      if(next.size() > dst.size()) continue;
      if(!visited.count(next)){
        visited.insert(next);
        Q.push((State){next,now.d+1});
      }
    }
  }
  return -1;
}

int main(){
  while(cin >> N, N){
    for(int i = 0 ; i < N ; i++){
      string b;
      cin >> str[i] >> b;
      mp[str[i]] = b;
      size[i] = str[i].size();
    }
    cin >> src >> dst;
    cout << solve() << endl;
  }
  return 0;
}

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

void rotate(char t[10][10]){
	char tmp[10][10];

	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			tmp[j][7-i] = t[i][j];
		}
	}

	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			t[i][j] = tmp[i][j];
		}
	}
}

int main(void){
	char t[10][10];

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

	for(int i=1;i<=3;i++){
		cout<<90*i<<endl;
		rotate(t);
		for(int j=0;j<8;j++){
			cout<<t[j]<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<string> S(N);
  int A=0; int W=0; int T=0; int R=0;
  for(int i=0; i<N; i++){
    cin>>S.at(i);
    if(S.at(i)=="AC")
      A++;
    else if(S.at(i)=="WA")
      W++;
    else if(S.at(i)=="TLE")
      T++;
    else R++;
  }
  cout<<"AC x "<<A<<endl;
  cout<<"WA x "<<W<<endl;
  cout<<"TLE x "<<T<<endl;
  cout<<"RE x "<<R<<endl;
}
    

Measured memory_bytes: 6412
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  ll maxi,ac,ad,bc;
  maxi=b*d;
  ac=a*c;
  maxi=max(maxi,ac);
  ad=a*d;
  maxi=max(maxi,ad);
  bc=b*c;
  maxi=max(maxi,bc);


  if(maxi<0){
  if(a<=0 && b>=0){
    maxi=0;
  }
  if(c<=0 && d>=0){
    maxi=0;
  }

}
cout << maxi << endl;
  }


Measured memory_bytes: 3632
def main():
    X = int(input())
    if X >= 1800:
        print(1)
        exit()
    l = [6,8,10,12,14,16,18]

    for i, v in enumerate(l):
        if X < v *100:
            print(8-i)
            exit()
if __name__ == "__main__":
    main()

Measured memory_bytes: 9164
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; 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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (b-a == c-b){ cout << "YES" <<endl; }
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

ll v[maxn+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, k; cin >> n >> k;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  int ans, pas;
  for (ans = pas = (1<<30); pas > 0; pas /= 2) {
    if (ans-pas <= 0) continue;
    z = ans-pas;
    ll now = 0;
    for (i = 1; i <= n; i++) now += 1LL*(v[i]+z-1)/z - 1;
    if (now <= k) ans -= pas;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 5208
#include <iostream>
#define SWAP(a,b) (a ^= b,b = a ^ b,a ^= b)

typedef unsigned int uint;
typedef long long ll; 
using namespace std;

uint solve(uint a, uint b) {
  if (a % b == 0) return b;
  else solve(b, a % b); 
}

int main() {
  uint  a, b, r;
  while (cin >> a >> b) {
    if (a < b) SWAP(a, b); 
    r = solve(a, b); 
    cout << r << " " << (ll)a * (ll)b / r << endl;
  }
  return 0;
}

Measured memory_bytes: 0
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    ll n,m;
    fi>>n>>m;
    auto Div = [&](ll a,ll b,ll c,ll d)
    {
        ll num = n - 1;
        while (b --)
            num /= a;
        while (d --)
            num /= c;
        return !num;
    };
    ll ans = 1e18;
    auto f = [&](ll k)
    {
        ll rudi = pow(n,1.0 / k);
        for (ll i = max(1ll,rudi - 1);i <= min(n,rudi + 1);++i)
            for (ll frudi = 0;frudi <= k;++frudi)
                if (Div(i,frudi,i + 1,k - frudi))
                    ans = min(ans,(k - 1) * m + i * frudi + (i + 1) * (k - frudi));
    };
    for (ll t = 1;t <= 50;++t)
        f(t);
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}




Measured memory_bytes: 256
def solve(xyhs):
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            cand = None
            for x, y, h in filter(lambda xyh: xyh[2] > 0, xyhs):
                t = h + abs(x - cx) + abs(y - cy)
                if cand is None:
                    cand = t
                elif cand != t:
                    break
            else:
                for x, y, h in filter(lambda xyh: xyh[2] == 0, xyhs):
                    if abs(x - cx) + abs(y - cy) < cand:
                        break
                else:
                    return cx, cy, cand

    return -1, -1, -1


n = int(input())
xyhs = tuple(tuple(map(int, input().split())) for _ in range(n))

print(*solve(xyhs))


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int one = 0;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        if(tmp == 1){
            one = i;
        }
    }
    if(N <= K)cout << 1 << endl;
    else{
        if((N-K)%(K-1)==0)cout << 1 + (N-K)/(K-1) << endl;
        else cout << 2 + (N-K)/(K-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

const int N=2e5+5;

ll n,d,a,x[N],pre[N],ans;

pair<ll,ll>p[N];

int main()
{
    cin >> n >> d >> a;
    for (int i=0;i<n;i++)
    {
        cin >> p[i].F>> p[i].S;
    }
    sort(p,p+n);
    for (int i=0;i<n;i++)
    {
        x[i]=p[i].F;
    }
    for (int i=0;i<n;i++)
    {
        if (i>0)pre[i]+=pre[i-1];
        p[i].S+=pre[i];
        if (p[i].S<=0)continue;
        int to=upper_bound(x,x+n,x[i]+(2*d))-x;
        pre[i]-=a*(p[i].S/a+(p[i].S%a!=0));
        pre[to]+=a*(p[i].S/a+(p[i].S%a!=0));
        ans+=(p[i].S/a)+(p[i].S%a!=0);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6528
//12252024832524
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; 

typedef long long LL;
const int MAXN = 10005;

LL Read()
{
	LL x = 0,f = 1;char c = getchar();
	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
	return x * f;
}
void Put1(LL x)
{
	if(x > 9) Put1(x/10);
	putchar(x%10^48);
}
void Put(LL x,char c = -1)
{
	if(x < 0) putchar('-'),x = -x;
	Put1(x);
	if(c >= 0) putchar(c);
}
template <typename T>T Max(T x,T y){return x > y ? x : y;}
template <typename T>T Min(T x,T y){return x < y ? x : y;}
template <typename T>T Abs(T x){return x < 0 ? -x : x;}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	LL a = Read(),b = Read(),n = Read();
	LL ans;
	if(n >= b-1) ans = b-1;
	else ans = n;
	Put(a * ans / b - a * (ans / b));
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i=0; i<3; i++){
	if(s.at(i)=='1'){
    	count++;
    }
  }    	
  cout << count << endl;  	  
}

Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

struct Point {
    double x;
    double y;
};

void koch(int n, Point a, Point b) {
    if (n == 0) return;

    Point s, u, t;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
}

int
main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    Point a, b;
    
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  vector<bool> v;
  rep(i, n){
    if(s1.at(i) == s2.at(i)){
      v.push_back(false);
    }else{
      v.push_back(true);
      i++;
    }
  }
  mint ans;
  rep(i, v.size()){
    if(i == 0){
      if(v.at(i) == false) ans = 3;
      else ans = 6;
    }else{
      if(v.at(i) == false){
        if(v.at(i-1) == false) ans *= 2;
      }else{
        if(v.at(i-1) == false) ans *= 2;
        else ans *= 3;
      }
    }
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> sorted(n); // pref -> list of years
  unordered_map<int, int> map; // city -> pref
  unordered_map<int, int> birth; // city -> year
  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    sorted[p - 1].emplace_back(y);
    map[i] = p - 1;
    birth[i] = y;
  }
  for (int i = 0; i < n; i++) {
    sort(sorted[i].begin(), sorted[i].end());
  }
  for (int i = 0; i < m; i++) {
    int p = map[i];
    int y = birth[i];

    const vector<int>& cities = sorted[p];

    int l = 0;
    int r = cities.size() - 1;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (cities[mid] < y) {
        l = mid + 1;
      } else if (cities[mid] > y) {
        r = mid - 1;
      } else {
        printf("%06d%06d\n", p + 1, mid + 1);
        break;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 15176
import math
import itertools
import sys
s = input()
cnt = 0
for i in range(3):
    if(s[i] == 'R'):
        cnt += 1
if(cnt == 1 or cnt == 3):
    print(cnt)
elif(cnt == 0):
    print(0)
else:
    if(s[1] == 'R'):
        print(2)
    else:
        print(1)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  
  ll num_500 = x / 500;
  x = x % 500;

  ans += num_500 * 1000;

  ll num_5 = x / 5;

  ans += num_5 * 5;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{

	public static void main(String[] args){
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		//??????????????°??????
		int n = scan.nextInt();
		String strTcard = "";
		String strHcard = "";
		int Tscore = 0;
		int Hscore = 0;

		for(int i = 0; i < n; i++){

			strTcard = scan.next();
			strHcard = scan.next();
			//????????????????????°????????????

			//???????????????????????????
			int resultNum = strTcard.compareTo(strHcard);

			if(resultNum == 0 ){
				Tscore += 1;
				Hscore += 1;
			}else if(0 < resultNum){
				Tscore += 3;
			}else{
				Hscore += 3;
			}

		}
		scan.close();
		System.out.println(Tscore + " " + Hscore);
	}
}

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

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i ,n) cin >> h[i];
    vector<int> dp(n,-1);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;++i){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

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

void solve(vector<int> a){
	b.push_back(a[0]);
	c.push_back(0);
	for(int i = 1; i < 10; i++){
		if(a[i] - b[b.size() - 1] > 0 && a[i] - c[c.size() - 1] > 0){
			if(a[i] - b[b.size() - 1] < a[i] - c[c.size() - 1]){
				b.push_back(a[i]);
			}else{
				c.push_back(a[i]);
			}
		}else if(a[i] - b[b.size() - 1] > 0 && a[i] - c[c.size() - 1] < 0){
			b.push_back(a[i]);
		}else if(a[i] - b[b.size() - 1] < 0 && a[i] - c[c.size() - 1] > 0){
			c.push_back(a[i]);
		}else{
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			cin >> a[j];
		}
		solve(a);
	}
}

Measured memory_bytes: 1208
S = input()
flag = False
if S.count('keyence') > 0:
    flag = True
else:
    key = 'keyence'
    i = 0
    while key[i] == S[i]:
        i += 1
    if key[i:] == S[-(7-i):]:
        flag = True
print('YES' if flag else 'NO')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

int main()
{
    long n;
    cin >> n;

    vector<long> a(n);
    rep(i,n){
      long ai;
      cin >> ai;
      a.at(i) = ai;
    }

    rvt(a);

    long long ans=0;
    long before = a.at(0);
    long cnt=1;

    for(int i=1; i<n; i++){
      ans+=before;
      cnt++;
      if(cnt>=n) break;

      if(i!=1) {
        ans+=before;
        cnt++;
        if(cnt>=n) break;
      }

      before = a.at(i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 4812
n = int(input())
list = []
ans = 0
i = 1
while i <= n:
    if i % 15 == 0:
        list.append(i)
    elif i % 5 == 0:
        list.append(i)
    elif i % 3 ==0:
        list.append(i)
    else:
        ans += i
    i += 1
print(ans)

Measured memory_bytes: 27232
#include <iostream>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long

using namespace std;

int main() {
    fast_io;

    ll n, a, b;

    cin >> n >> a >> b;

    cout << n / (a + b) * a + min(n % (a + b), a) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll x=n/3,y=n/5,z=n/15;
    x=3*(x*(x+1))/2;
    y=5*(y*(y+1))/2;
    z=15*(z*(z+1))/2;
    ll w=(n*(n+1))/2;
    cout<<w-(x+y-z);
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
vector<llint> vec[100005];
vector<pair<llint, llint> > vec2;
priority_queue<llint, vector<llint>, greater<llint> > Q;

int main(void)
{
	cin >> n >> k;
	llint t, d;
	for(int i = 1; i <= n; i++){
		cin >> t >> d;
		vec[t].push_back(d);
	}
	for(int i = 1; i <= n; i++) sort(vec[i].rbegin(), vec[i].rend());
	
	for(int i = 1; i <= n; i++){
		if(vec[i].size()) vec2.push_back(make_pair(vec[i][0], i));
	}
	sort(vec2.rbegin(), vec2.rend());
	
	llint ans = 0, tmp = 0, sum = 0;
	for(llint i = 0; i < min((llint)vec2.size(), k); i++){
		int p = vec2[i].second;
		tmp += vec[p][0];
		for(int j = 1; j < vec[p].size(); j++){
			if((int)Q.size()+i+1 < k || Q.size() == 0 || Q.top() < vec[p][j]){
				Q.push(vec[p][j]);
				sum += vec[p][j];
			}
		}
		while((int)Q.size()+i+1 > k){
			sum -= Q.top();
			Q.pop();
		}
		if((int)Q.size()+i+1 < k) continue;
		ans = max(ans, tmp + sum + (i+1)*(i+1));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 7924
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string a,b,c; cin >> a >> b >> c;
    cout << (char)(a[0]-'a'+'A') << (char)(b[0]-'a'+'A')  << (char)(c[0]-'a'+'A') <<endl; return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,L,x=0,y=LINF;cin>>N>>L;
  std::vector<int> v(2*N+5,0),used(2*N+5,0);
  typedef pair<int,int> P;
  std::vector<P> lr(N+1);
  map<int,int> m;
  for(int i=0;i<N;i++){
    int l,r;cin>>l>>r;m[l]=m[r]=0;
    lr[i]=P(l,r);
  }
  int cnt=0;
  for(auto &p:m)p.second=cnt++;
  for(int i=0;i<N;i++)lr[i]=P(m[lr[i].first],m[lr[i].second]);
  L=m[L];
  lr[N]=P(LINF,LINF);
  sort(lr.begin(),lr.end());
  int nownum=0,nowpo=0;
  priority_queue<int> que;
  while(nowpo<L){
    while(lr[nownum].first<=nowpo)que.push(lr[nownum++].second);
    nowpo=que.top();que.pop();
    x++;
  }
  for(int i=0;i<N;i++)v[lr[i].first]++,v[lr[i].second]--;
  for(int i=0;i<L+4;i++)v[i+1]+=v[i];
  for(int i=0;i<L;i++)y=min(y,v[i]);
  cout<<x<<" "<<N-y+1<<endl;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1000000007;

inline bool check(int mask){
	vector<int> vec;
	while(mask){
		vec.push_back(mask&1);
		mask >>= 1;
	}
	for(int i = 1; i < vec.size(); i++){
		if(vec[i] && vec[i - 1])return false;
	}
	return true;
}

inline int getNext(int pos, int mask){
	if(mask&(1<<pos))return pos + 1;
	if(pos == 0)return 0; pos--;
	if(mask&(1<<pos))return pos;
	return pos + 1;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int H, W, K;
	cin>>H>>W>>K;
	int dp[H + 1][W];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for(int h = 1; h <= H; h++){
		for(int mask = 0; mask < (1<<(W - 1)); mask++){
			if(!check(mask))continue;
			for(int pos = 0; pos < W; pos++){
				int npos = getNext(pos, mask);
				dp[h][npos] += dp[h - 1][pos];
				if(dp[h][npos] >= mod)dp[h][npos] -= mod;
			}
		}
	}
	cout<<dp[H][K - 1]<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	int c;
	double d;
	
	cin >> a >> b;
	
	c = (a + b) / 2;
	
	d = (double)(a + b) / 2.0;
	
	if (c < d){
		c++;
	}
	
	cout << c << "\n";
	
	return (0);
}


Measured memory_bytes: 256
n=int(input())
x=[-1]*(10**7+5)
x[0]=0
x[1]=1
i=2
while i<=10**7+1:
    j=2*i
    if x[i]==-1:
        x[i]=i
        while j<=10**7+1:
            if x[j]==-1:x[j]=i
            j+=i
    i+=1
def f(k):
    if k==1:
        return 1

    z=[]
    p=x[k]
    m=1
    ans=1
    while k>=2:
        k=k//p
        if p==x[k]:
            m+=1
        else:
            z.append(m)
            m=1
            p=x[k]

    for i in range(len(z)):
        ans*=z[i]+1
    return ans
s=0
for i in range(1,n+1):
    s+=i*f(i)
print(s)



Measured memory_bytes: 152692
#include <algorithm>
#include <list>
#include <iostream>
#include <vector>
 
#define unless(cond) if (!(cond))
 
using namespace std;
 
typedef long long int lli;
typedef unsigned long long ull;
 
int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
 
  int n;
  while (cin >> n) {
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    list<int> x;
    for (int i = 0; i < n; ++i) {
      if (x.size() % 2) x.push_front(a[i]);
      else x.push_back(a[i]);
    }
    if (n % 2) reverse(x.begin(), x.end());
    bool f = false;
    for (auto i = x.begin(); i != x.end(); ++i) {
      if (f) cout << ' ';
      f = true;
      cout << *i;
    }
    cout << endl;
  }
  
  return 0;
}


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

int main(){
        int c1,c5,c10,c50,c100,c500,x;

        cin>>c1>>c5>>c10>>c50>>c100>>c500;

        x=c1+(5*c5)+(10*c10)+(50*c50)+(100*c100)+(500*c500);

        if(x>=1000) cout<<1<<endl;
                else cout<<0<<endl;

        return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;
#define INF 1000000000

struct el {
    bool occ = false;
    int m;
    el(int a) {
        m=a;
    }
    bool ifOcc() {
        return occ;
    }
};

map<int,int> MI;
unordered_set<int> SI;

int main(){


    int n,a,b,c;
    cin>>n;
    unordered_set<int>::iterator it;
    map<int,int>::iterator im;
    while(n--) {
        cin>>a;
        b = a-1;
        c = a+1;

        /////////////////////////
        it = SI.find(a);


        im = MI.find(a);
        if(im == MI.end()) {
                MI.insert(make_pair(a, 1));
        } else {
                MI.at(a)++;
        }
        if(it == SI.end() ) {
            SI.insert(a);
        }

        ////////////////////////////////////
        im = MI.find(b);
        if(im == MI.end()) {
                MI.insert(make_pair(b, 1));
        } else {
                MI.at(b)++;
        }
        ///////////////////////////////////////

        im = MI.find(c);
        if(im == MI.end()) {
                MI.insert(make_pair(c, 1));
        } else {
                MI.at(c)++;
        }
    }
    int big = -1;
    for (auto it = SI.begin(); it != SI.end(); ++it) {
      if(MI.find(*it)->second > big) {
        big =MI.find(*it)->second;
        im = MI.find(*it);
      }

    }

    cout<<im->second<<'\n';

  return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    string c; cin >> c;
    vi rc(n+1),wc(n+1);
    rep(i,n) if(c[i] == 'R') rc[i]++;
    rep(i,n) if(c[i] == 'W') wc[i]++;
    vi rs(n+1),ws(n+1);
    RREP(i,1,n+1) rs[i-1] = rs[i] + rc[i-1];
    rep(i,n) ws[i+1] = ws[i] + wc[i];

    int ans = min(rs[0], ws[n]);
    rep(i,n+1){
        ans = min(ans, max(rs[i], ws[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6772
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

struct solve {
  explicit solve(const vec<ull> &A) : A(A) { cout << exec(0, 1) << endl; }
  ull exec(ull depth, ull acc) {
    if (depth == A.size()) {
      return (acc & 1) ? 0 : 1;
    } else {
      return exec(depth + 1, acc * A[depth]) +
             exec(depth + 1, acc * (A[depth] - 1)) +
             exec(depth + 1, acc * (A[depth] + 1));
    }
  }
  vec<ull> A;
};

int main() {
  ull N;
  cin >> N;
  vec<ull> A(N);
  REP(i, N) cin >> A[i];
  solve res(A);
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
  int N, M;
  scanf("%d %d", &N, &M);
  
  int food[M];
  for(int i=0; i<M; i++){
    food[i]=0;  
  }
  
  int count;
  for(int i=0; i<N; i++){
    scanf("%d",&count);
    for(int j=0; j < count; j++){
      int buf;
      scanf("%d", &buf);
      //printf("%d %d %d\n", buf, j, count);
      food[buf-1]+=1;
    }
  
  }/*
   for(int i=0; i<M; i++){
    printf("%d ",food[i]);  
  }
  printf("\n");
*/
  int kaburi=0;
  for(int i=0; i<M; i++){
  	if(food[i]>=N)
      kaburi++;
  }
   
  printf("%d", kaburi);

}

Measured memory_bytes: 128
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

x_arr = []

x_arr << a_arr.map.with_index do |a, i|
  sign = (i % 2 == 0 ? 1 : -1)
  sign * a
end.inject(:+) / 2

a_arr[0..-2].each_with_index do |a, i|
  x_arr << a - x_arr[i]
end

puts x_arr.map{|x| (x * 2).to_s }.join(" ")


Measured memory_bytes: 18436
#include <bits/stdc++.h>
using namespace std;
bitset <4000003> ans;
int main(int argc, char const *argv[])
{
	int n, tot = 0;
	cin>>n;
	ans.set(0);
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin>>x;
		tot+=x;
		ans = (ans | (ans << x));
	}
	for (int i = 0; i <= tot; ++i)
	{
		if(ans[i] && 2*i >= tot)
		{
			cout<<i<<"\n";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2176
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val ac = mutableSetOf<String>()
    val wa = mutableMapOf<String, Int>()

    repeat(m) {
        val (p, s) = readLine()!!.split(" ")
        if (ac.contains(p)) return@repeat

        if (s == "WA") {
            wa[p] = wa.get(p)?.plus(1) ?: 1
        }
        if (s == "AC") {
            ac.add(p)
        }
    }

    var waCnt = 0
    wa.forEach {
        if (ac.contains(it.key)) waCnt += it.value
    }

    println("${ac.size} $waCnt")
}

Measured memory_bytes: 62764
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n;
    cin >> n;
    vec<int> v(n), sorted(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        sorted[i] = v[i];
    }

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

    auto l = sorted[n / 2 - 1];
    auto r = sorted[n / 2];

    for (auto e : v)
    {
        if (e <= l)
        {
            cout << r << endl;
        }
        else
        {
            cout << l << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3712
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
int f[26];
int cnt[26];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    for (int i = 0; i < 26; i++) {
        f[i] = 1e9;
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        memset(cnt, 0, sizeof cnt);
        string s;
        cin >> s;
        for (char& c : s) {
            cnt[c - 'a']++;
        }
        for (int j = 0; j < 26; j++) {
            f[j] = min(f[j], cnt[j]);
        }

    }
    string ans;
    for (int i = 0; i < 26; i++) {
        ans += string(f[i], (char)('a' + i));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256