akhauriyash/Code-Regression huggingface dataset:
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var p = long.Parse(line[1]);
        if (n == 1) { Console.WriteLine(p); goto exit; }
        if (p == 1) { Console.WriteLine(1); goto exit; }
        var rp = (int)Sqrt(p);
        var a = GeneratePrime(rp + 1);
        var ans = getAns(a, n, p);
        Console.WriteLine(ans);
        exit:;
    }
    static long getAns(List<int> a, long n, long p)
    {
        var ans = 1L;
        foreach (var x in a)
        {
            var count = 0;
            if (p < x) break;
            while (true)
                if (p % x == 0) { count++; p /= x; }
                else break;
            ans *= (long)Pow(x, count / n);
        }
        return ans;
    }
    public static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
}

Measured memory_bytes: 21472
import std.stdio, std.algorithm, std.conv, std.string;

void main(){
    while(true){
        ulong[int] sales;
        int[] order;
        int data=readln.chomp.to!int;
        if(data==0)break;
        foreach(_;0..data){
            auto inp=readln.split.map!(to!int);
            int id=inp[0],sale=inp[1],num=inp[2];
            if(id in sales){
                sales[id]+=sale*num;
            }else{
                order~=id;
                sales[id]=sale*num;
            }
        }
        bool na=true;
        foreach(id;order){
            if(sales[id]>=1_000_000){
                id.writeln;
                na=false;
            }
        }
        na&&"NA".writeln;
    }
}

Measured memory_bytes: 1256
n=int(input())
a=list(map(int,input().split()))
cost=[]
cost.append(0)
for i in range(1,n):
    if i==1:
        cost.append(abs(a[i]-a[i-1]))
    else:
        cost.append(min((abs(a[i]-a[i-1])+cost[i-1]),(abs(a[i]-a[i-2])+cost[i-2])))
print(cost[n-1])

Measured memory_bytes: 13928
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		int K = scanner.nextInt();
		TreeSet<String> strings = new TreeSet<>();

		for (int i = 0; i < s.length(); i++) {
			for (int j = i + 1; j <= s.length() && j <= i + K; j++) {
				strings.add(s.substring(i, j));
			}
		}
		int i = 0;
		String result = null;
		for (String string : strings) {
			if (++i == K) {
				result = string;
				break;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 27092
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  n <- getLine
  print $ solve n

solve n | odd (length n) = frees + n'
        | otherwise      = frees
 where
  n'    = length [10 ^ (length n - 1), 10 ^ (length n - 1) + 1 .. read n]
  frees = sum (map f [1, 3 .. length n - 1])

f n = 10 ^ (n - 1) * 9


Measured memory_bytes: 1020
#include <stdio.h>
int main(void)
{
	int a[5],b[2],max=0,min=100,cnt,all,i;
	for(cnt=0;cnt<4;cnt++){
		scanf("%d",&a[cnt]);
		if(min>a[cnt]){
			i=cnt;
			min=a[cnt];
		}
	}
	a[i]=0;
	for(cnt=0;cnt<2;cnt++){
		scanf("%d",&b[cnt]);
		if(max<b[cnt]){
			max=b[cnt];
		}
	}
	all=a[0]+a[1]+a[2]+a[3]+max;
	printf("%d\n",all);
	return 0;   
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const int inf = 1e9+7;

int sz = 1e5+5;
vector<ll> bit(sz+1);

int lowbit(int x){
	return x&-x;
}
void add(int x,int w){
	for(int i = x;i<sz;i += lowbit(i)){
		bit[i] += w;
	}
}
ll sum(int x){
	ll ret = 0;
	for(int i = x;i>0;i-=lowbit(i)){
		ret += bit[i];
	}
	return ret;
}
int search_small(int index){
	ll x = sum(index);
	int ok = -1;
	int ng = index;
	while(abs(ok-ng)>1){
		int mid = (ok+ng)/2;
		if(sum(mid)<x)ok = mid;
		else ng = mid;
	}
	return ok;
}
int search_big(int index){
	ll x = sum(index);
	int ok = sz;
	int ng = index;
	while(abs(ok-ng)>1){
		int mid = (ok+ng)/2;
		int count = sum(mid);
		if(count > x)ok = mid;
		else ng = mid;
	}
	return ok;
}
int main(void){
	int N;
	cin >> N;
	vector<ll> a(N+1);
	for(int i=1;i<=N;i++){
		int tmp;
		cin >> tmp;
		a[tmp]= i;
	}
	ll ans = 0;
	
	for(int i=N;i>=1;i--){
		int nowpos = a[i];
		ll s1 = search_small(nowpos);
		ll s2 = search_small(s1);
		ll b1 = search_big(nowpos);
		b1 = min(b1,(ll)N+1);
		ll b2 = search_big(b1);
		b2 = min(b2,(ll)N+1);
		ll cases = 0;
		if(s1!=-1)cases += (s1-s2)*(b1-nowpos);
		if(b1!=N+1)cases += (nowpos - (s1+1))*(b2-b1);
		ans += i*cases;
		add(nowpos,1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

main()
{
  char s[11], u[11];
  int a, b;
  scanf("%s %*s %d %d %s", &s, &a, &b, &u);
  if (strcmp(s, u)) --b;
  else --a;
  printf("%d %d\n", a, b);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
ll a[1010];
int main(){
	cin >> N >> K;
	for(int i=1;i<=N;i++){
		cin >> a[i];
	}
	for(int i=1;i<=N;i++){
		a[i+1]+=a[i];
	}
	vector<ll> vec,nxt;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<=N;j++){
			vec.pb(a[j]-a[i]);
		}
	}
	ll ans = 0ll;
	for(int i=40;i>=0;i--){
		int cnt = 0;
		for(int j=0;j<vec.size();j++){
			if((vec[j]>>i)&1){
				cnt++;
				nxt.pb(vec[j]);
			}
		}
		if(cnt>=K){
			ans |= (1ll<<i);
			swap(vec,nxt);
		}
		nxt.clear();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6256
H, W = map( int, input().split())
if H%3 == 0 or W%3 == 0:
    ans = 0
else:
    ans = min( max((H//3+1)*W, (H//3)*W)- min((H//3+1)*W, (H//3)*W),  max((W//3+1)*H, (W//3)*H)- min((W//3+1)*H, (W//3)*H))
    for i in range(H+1):
        ans = min( ans, max(W*i, (H-i)*(W//2), (H-i)*(W - W//2)) - min(W*i, (H-i)*(W//2), (H-i)*(W - W//2)))
    for j in range(W+1):
        ans = min( ans, max(H*j, (W-j)*(H//2), (W-j)*(H - H//2)) - min(H*j, (W-j)*(H//2), (W-j)*(H - H//2)))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;

using namespace std;


int main(void) {
    int N;
    cin >> N;
    unordered_map<int, vector<int>> times;
    // vector<int> dead_lines;
    set<int> dead_lines;
    unordered_map<int, int> sums;
    // vector<pair<int, int>> BA;
    for (int i = 0; i < N; i++) {
        int ai, bi; cin >> ai >> bi;
        // BA.push_back(make_pair(bi, ai));
        times[bi].push_back(ai);
        if (sums.find(bi) == sums.end()) {
            sums[bi] = ai;
        } else {
            sums[bi] += ai;
        }
        // sums[bi] += ai;
        dead_lines.insert(bi);
        // if (std::find(dead_lines.begin(), dead_lines.end(), bi) == dead_lines.end()) {
        //     dead_lines.push_back(bi);
        // }
    }
    // sort(dead_lines.begin(), dead_lines.end());

    int current = 0;

    for (auto v : dead_lines) {
        if (current + sums[v] > v) {
            cout << "No" << endl;
            return 0;
        } else {
            current += (sums[v]);
            // cout << v << ":" << sums[v] << " " << (times[v].size()) << " - current " << current << endl;
        }
    }
    // cout << current << endl;
    cout << "Yes" << endl;
}

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

int main() {
    string s;
    cin>>s;
    int n=s.size();
    if(n%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i = 0;i < n;i+=2) {
        if(s[i]!='h'||s[i+1]!='i'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int H, W;
	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++) {
			for(int j=0;j<W;j++) printf("#");
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2580
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>

typedef long long ll;
ll N,a,b,ans=1,temp;
int main(){
    scanf("%lld",&N);
    for(int i=1;i<=N;i++){
            ans*=i;
            //printf("1:%lld\n",ans);
            ans=ans%(10*10*10*10*10*10*10*10*10+7);
            //printf("2:%lld\n",ans);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	char ch;
	cin>>ch;
	if(ch=='A')
		cout<<"T";
	else if(ch=='T')
		cout<<"A";
	else if(ch=='G')
		cout<<"C";
	else
		cout<<"G";
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

ll MOD = 1000000007;

vector<ll> comb0(50, 0);
vector<ll> comb1(50, 0);
vector<ll> comb (50, 0);
void calcComb(){
    comb0[0] = 1;
    comb1[0] = 1;
    comb [0] = 2;
    for(int i=1;i<50;i++){
        comb0[i] = comb0[i-1] + comb1[i-1];
        comb1[i] = comb0[i-1];
        comb [i] = comb0[i] + comb1[i];
        comb [i] %= MOD;
        comb0[i] %= MOD;
        comb1[i] %= MOD;
    }
}

int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    calcComb();
    vector<vector<ll>> dp(H+1, vector<ll>(W, 0));
    dp[0][0] = 1;
    for(int i=1;i<=H;i++){
        for(int j=0;j<W;j++){
            ll c0 = 1;
            ll c1 = 1;
            ll c2 = 1;
            if(j-2>=0)   c0 *= (comb[j-2]);
            if(W-j-3>=0) c0 *= (comb[W-j-3]);
            if(j-3>=0)   c1 *= (comb[j-3]);
            if(W-j-3>=0) c1 *= (comb[W-j-3]);
            if(j-2>=0)   c2 *= (comb[j-2]);
            if(W-j-4>=0) c2 *= (comb[W-j-4]);

            if(true)  dp[i][j] += dp[i-1][j]   * c0;
            dp[i][j] %= MOD;
            if(j>0)   dp[i][j] += dp[i-1][j-1] * c1;
            dp[i][j] %= MOD;
            if(j<W-1) dp[i][j] += dp[i-1][j+1] * c2;
            dp[i][j] %= MOD;
        }
    }
    cout<<dp[H][K-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n)cin >>a.at(i);
  rep(i,n) a.at(i)--;
  ll sum = 0;
  rep(i,n)sum+=a.at(i);
  cout << sum << endl;
}


Measured memory_bytes: 3664
#include<cstdio>
using namespace std;

int w, h;
char d[20][25];
bool wasOn[20][20];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int solve(int x, int y) {
  if (x < 0 || y < 0 || x >= w || y >= h) return 0;
  if (d[y][x] == '#') return 0;
  if (wasOn[y][x]) return 0;
  wasOn[y][x] = true;
  int ans = 1;
  for (int i = 0; i < 4; i++) ans += solve(x + dx[i], y + dy[i]);
  return ans;
}

int main() {
  while (1) {
    scanf("%d%d", &w, &h);
    if (w == 0) break;
    for (int i = 0; i < h; i++) scanf("%s", d[i]);
    int x, y;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        wasOn[i][j] = false;
        if (d[i][j] == '@') y = i, x = j;
      }
    }
    printf("%d\n", solve(x, y));
  }
}



Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int n;
vi v;
map<int, int> record;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	v.resize(n);
	rep(i,0,n) {
		cin >> v[i];
		record[v[i]] = i;
	}

	int r = 0;
	vector<bool> visited(n+1, false);

	for(int x = 1; x <= n; ++x) {
		if(visited[x]) continue;

		int y = x;
		int idx = record[y];
		while(y < n + 1 && record[y] >= idx) {
			visited[y] = true;
			idx = record[y];
			y++;
		}
		r = max(r, y - x);
	}

	cout << n - r << endl;
	return 0;
}

Measured memory_bytes: 10496
import scala.io.StdIn.{readLine,readInt}

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val l = readLine.split(" ").map(_.toInt)
    printf("%d %d %d\n",l.min,l.max,l.foldLeft(0.toLong)(_+_))
  }
}

Measured memory_bytes: 49540
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<queue>
#include<set>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair

int n,ng;
char in[4][21];


int main(){
	while(scanf("%d",&n),n){
		rep(i,5)scanf("%s",in[i]);
		ng=0;
		for(int i=0;i<=n;i++)rep(j,5)rep(k,n-i)
		if(in[j][i+k]=='X'&&in[j][k]=='X')ng|=1<<i;
		
		set<pair<int,int> > S;
		priority_queue<pair<int,pair<int,int> > > Q;
		Q.push(mp(-n,mp(1,ng)));
		while(!Q.empty()){
			int cc=Q.top().first,cnt=Q.top().second.first;
			int bit=Q.top().second.second; Q.pop();
			if(S.count(mp(cnt,bit)))continue; S.insert(mp(cnt,bit));
			if(cnt==10){
				 printf("%d\n",-cc); break;
			}
			for(int i=1;i<=n;i++)if(!(bit&1<<i))
			if(!S.count(mp(cnt+1,bit>>i|ng)))Q.push(mp(cc-i,mp(cnt+1,bit>>i|ng)));
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define push_back emplace_back
#define push emplace
#define insert emplace
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	int pre[n+1]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		pre[i+1]=pre[i]+a[i];
	}
	int x=LONGLONG_MAX;
	for(int i=0;i<n;i++){
		x=min(x,abs(pre[n]-2*pre[i+1]));
	}
	cout<<x;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int i, n, m;
	int a, b;
	int num[100] = {0};
	cin >> n >> m;
	for(i = 0; i < m; i++){
		cin >> a >> b;
		num[a]++;
		num[b]++;
	}
	for(i = 1; i <= n; i++){
		cout << num[i] << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]+=1;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}

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

int main() {
  
  int N,K;
  cin >> N >> K;
  
  vector<int> H(N);
  for ( int i = 0; i < N; i ++){
    cin >> H.at(i);
  }
  
  int count = 0;
  
  for ( int i = 0; i < N; i ++){
    if ( K <= H.at(i) ){
      count ++;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 640
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	List<String> taroList = new ArrayList<String>();
	List<String> hanakoList = new ArrayList<String>();

	int n = scan.nextInt();

	for (int i = 0; i < n; i ++) {
		taroList.add(scan.next());
		hanakoList.add(scan.next());	
	}

	int tP = 0;
	int hP = 0;

	for (int i = 0; i < n; i ++) {
		String t = taroList.get(i);
		String h = hanakoList.get(i);
		
		if (t.compareTo(h) > 0) {
			tP += 3;	
		}
		else if (t.compareTo(h) < 0) {
			hP += 3;
		}
		else {
			hP++;
			tP++;
		}
	}
		
	System.out.println(tP + " " + hP); 

}
}

Measured memory_bytes: 20820
<?php
$answer = (int)trim(fgets(STDIN));

define('MAX', 119);
define('MIN', -118);

for ($i = MIN; $i <= MAX; $i++) {
    for ($n = MIN; $n <= MAX; $n++) {
        $check_answer = pow($i, 5) - pow($n, 5);
        if ($answer === $check_answer) {
            echo $i . ' ' . $n;
            break 2;
        }
    }
}

Measured memory_bytes: 16032
#include<stdio.h>
#include<string.h>

int main(){
  char S[200015],T[200015];
  
  scanf("%s",S);
  scanf("%s",T);
  
  int cnt=0;
  
  for(int i=0;i<strlen(S);i++){
   if(S[i]!=T[i])
     cnt++;
  }
  
  printf("%d",cnt);
 return 0;
}

Measured memory_bytes: 2540
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = Math.max(a, b);
        int ans = c + c;
        if (a != b) {
            ans--;
        }
        System.out.println(ans);
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int ans = 0;
  
  for(int j=0; j<N; j++){
    if(vec.at(j) <= K/2){
      ans = ans + vec.at(j)*2;
    }
    else{
      ans = ans + (K - vec.at(j))*2;
    }
  }
   
    cout << ans << endl;
  
}

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();
		int M = scan.nextInt();

		System.out.println(N * (N -1)/2 + M * (M -1)/2);

	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll aend=0,bhead=0,ab=0;
int main()
{
	int n;
	cin>>n;
	string s;
	ll ans=0;
	for(int i=1;i<=n;i++){
		cin>>s;
		int x=s.size();
		for(int j=0;j<x-1;j++){
			if(s[j]=='A'&&s[j+1]=='B')	ans++;
		}
		if(s[0]=='B'&&s[x-1]=='A') ab++;	
		if(s[0]=='B') bhead++;
		if(s[x-1]=='A') aend++;
	}
	aend-=ab;
	bhead-=ab;
	if(aend==0&&bhead==0){
		if(ab==0||ab==1) cout<<ans<<endl;
		else cout<<ans+ab-1<<endl;
	}
	else if(aend==0||bhead==0){
		cout<<ans+ab<<endl;
	}
	else if(aend!=0&&bhead!=0){
		cout<<ans+min(aend,bhead)+ab<<endl;
	}
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            auto r = min(k - j, a[i + 1] - a[i]);
            for (auto c : irange(0L, a.back() - a[i + 1] + 1)) {
                for (auto b : irange(c + 1, c + r + 1)) {
                    auto w = j + b - c;
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, mk + 1)) {
        ans += dp[i][0];
        if (ans >= M) {
            ans -= M;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3972
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) {
      cout << a * b;
    } else {
      cout << -1;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U; typedef pair<int,int > P; typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
	inp();
	return 0;
}
const int  N = 3000;
int o[N][N],g[N][N];
char s[N];
int st[N];
int findM(int *a,int n){
	int cnt=0; a[n]=-1;n++; 
	int wid,cur,ma=0;
	for(int i = 0;i<n;i++){
		while(cnt&&a[st[cnt-1]]>a[i]){
			cur=st[cnt-1],cnt--;
			wid=cnt?i-st[cnt-1]-1:i;
			wid=(a[cur]+1)*(wid+1);
		//	printf("i:%d cur:%d ea:%d\n",i,cur,wid);
			if(wid>ma)
				ma=wid;
		}
		st[cnt]=i;cnt++;
	}
	return ma;
}
void inp(){
	int ma=1;
//	int a[]={2,1,5,6,2,3},n=sizeof(a)/sizeof(n);
//	ma=findM(a,n);
//	printf("%d\n",ma);
	int h,w;scanf("%d%d",&h,&w);
	for(int i = 1;i<=h;i++){ scanf("%s",s);
		for(int j =1;j<=w;j++){ g[i][j]=s[j-1]=='#'; }
	}
	int x;
	for(int i=1;i<=h-1;i++){
		for(int j=1;j<=w-1;j++){
			x=0;
			x=g[i][j]+g[i][j+1]+g[i+1][j]+g[i+1][j+1];
			x=!(x&1);
			if(x&&o[i-1][j]){ o[i][j]=o[i-1][j]+x; }
			else o[i][j]=x;
		}
	}
	ma=max(w,h);
	//ma=0;
	for(int i =1;i<=h-1;i++){
		x=findM(o[i]+1,w-1);
		if(x>ma)
			ma=x;
	}
	printf("%d\n",ma);
}
//at81d.cc by xsthunder at Tue Aug 22 08:29:48 2017


Measured memory_bytes: 49280
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b,n=0;
	cin>>a>>b;
	while(a*n-n+1<b){
		n++;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline split-ints-into-vector))
(defun split-ints-into-vector (string dest-vector &key (offset 0) (key #'identity))
  (declare (string string)
           (function key)
           ((array * (*)) dest-vector)
           ((integer 0 #.most-positive-fixnum) offset))
  (loop with position = 0
        for idx from offset below (length dest-vector)
        do (setf (values (aref dest-vector idx) position)
                 (parse-integer string :start position :junk-allowed t))
           (setf (aref dest-vector idx) (funcall key (aref dest-vector idx)))
        finally (return dest-vector)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (x (read))
         (as (make-array n :element-type 'uint32))
         (table (make-array (list n n) :element-type 'uint32)))
    (split-ints-into-vector (read-line) as)
    (dotimes (i n)
      (let ((min #xffffffff))
        (dotimes (j n)
          (let ((a (aref as (mod (- i j) n))))
            (when (< a min)
              (setf min a))
            (setf (aref table i j) min)))))
    (println
     (loop for j below n
           minimize (+ (* j x)
                       (loop for i below n
                             sum (aref table i j)))))))

#-swank(main)


Measured memory_bytes: 27108
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0 ; i < 3 ; i++){
            a[i] = sc.nextInt();
        }
            Arrays.sort(a);
            System.out.println(a[0] + " " + a[1] + " " + a[2]);
    }
}


Measured memory_bytes: 26432
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int main()
{
    int N, h;
    cin >> N;
    vector<int> Hs(N);
    for(int i = 0; i < N; ++i){
        cin >> h;
        Hs[i] = h;
    }
    int ans = 0;
    int index = 0;
    int zeroCount = 0;
    while(true){
        if(index == N){
            if(zeroCount == N) break;
            index = 0;
            zeroCount = 0;
        }
        if(Hs[index] == 0){
            index++;
            zeroCount++;
            continue;
        }
        if(index != N-1 && Hs[index+1] != 0) ans--;
        Hs[index]--;
        ans++;
        index++;
        // if(count(Hs.begin(), Hs.end(), 0) == N) break;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define INF 10101010

int main()
{
    ll X;
    cin >> X;
    ll count=1;
    ll point=0;
    while(point<X){
        point+=count;
        count++;
    }
    cout << count-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

long long n, m;
vector<pair<int, int>> v;

int solve();

int main() {
  cin >> n >> m;
  v.resize(m);
  for(int i = 0; i < m; ++i) cin >> v[i].se >> v[i].fi;
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

int solve() {
  int now = 0, ans = 0;
  for(int i = 0; i < m; ++i)
    if(v[i].se >= now) {
      now = v[i].fi;
      ++ans;
    }
  return ans;
}

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

int main()
{
  int N;
  cin >> N;
  vector<long> A(N);
  vector<long> B(N);
  
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  long b1MinusBpreN = A.at(0);
  bool isMinus = true;
  for (int i = 1; i < N - 1; i++)
  {
    if (isMinus) b1MinusBpreN -= A.at(i);
    else b1MinusBpreN += A.at(i);
    isMinus = !isMinus;
  }
  B.at(0) = b1MinusBpreN + A.at(N - 1);
  cout << B.at(0) << " ";
  for (int i = 1; i < N; i++)
  {
    B.at(i) = A.at(i - 1) * 2 - B.at(i - 1);
    cout << B.at(i) << " ";
  }
}


Measured memory_bytes: 2816
import sys
a, b, c, d, e, f = map(int, input().split())

m = sys.maxsize
mlist = [1,0,0,0]

for x in range(int(f / (100*a)) + 1):
    for y in range(int((f - 100 * a * x) / 100*b) + 1):
        for z in range(min(int((f - 100* a * x - 100 * b * y) / c), int(((a*x + b*y) * e) / c)) + 1):
            for w in range(min(int((f - 100* a * x - 100 * b * y - c * z) / d), int(((a*x + b*y) * e - c*z) / d)) + 1):
                if (z != 0 or w != 0) and float((a*x + b*y) / (c*z + d*w)) <= m:
                    mlist = [x,y,z,w]
                    m = float((a*x + b*y) / (c*z + d*w))
print(100 * a * mlist[0] + 100 * b * mlist[1] + c * mlist[2] + d * mlist[3], c * mlist[2] + d * mlist[3])

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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 5e5 + 1;
const int INF = 2e9;

struct bitPointUpdateRangeQuery {
    vi bit;
    int n;

    bitPointUpdateRangeQuery() {
        this->n = N - 1;
        bit.assign(N - 1, 0);
    }

    void update(int p, int val) {
        while (p <= n) {
            bit[p] += val;
            p += p & -p;
        }
    }

    int get(int p) {
        int res = 0;
        while (p >= 1) {
            res += bit[p];
            p -= p & -p;
        }
        return res;
    }

    int get(int l, int r) { return get(r) - get(l - 1); }
};

char a[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    bitPointUpdateRangeQuery bit[26];
    int n;
    cin >> n;
    rf(i, 1, n) {
        cin >> a[i];
        bit[a[i] - 'a'].update(i, 1);
    }
    int q;
    cin >> q;
    while (q--) {
        int c;
        cin >> c;
        if (c == 1) {
            int p;
            char t;
            cin >> p >> t;
            bit[a[p] - 'a'].update(p, -1);
            a[p] = t;
            bit[a[p] - 'a'].update(p, 1);
        } else {
            int ans = 0;
            int l, r;
            cin >> l >> r;
            rf(i, 0, 25) {
                if (bit[i].get(l, r) > 0)
                    ans++;
            }
            cout << ans << "\n";
        }
    }
}

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

int main(){

   int n;
   cin>>n;

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

   sort(s,s+n);
   int cnt=1;
   int max=0;
   ans[0]=1;
   

   for(int j=0;j<n;j++){
       if(s[j]==s[j+1]){
           cnt+=1;
       }else{
           if(cnt>max){
               max=cnt;
               for(int i=0;i<j;i++){
                   ans[i]=0;
               }
               ans[j]=1;
           }else if(cnt==max){
               ans[j]=1;
           }
           cnt=1;
       }
   }

   for(int k=0;k<n;k++){
       
       if(ans[k]==1){
           cout<<s[k]<<endl;
       }
   }

return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
 
#define inf 0x3f3f3f3f
#define pi acos(-1)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define EPS 1e-9
template<class T> bool mmin(T &a,T b){return (a>b ?(a=b,true):false);};
template<class T> bool mmax(T &a,T b){return (a<b ?(a=b,true):false);};


int32_t main(){
	
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(n*a,b) << '\n';
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <deque>
#include <tuple>
#include <map> 
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;

int main() {

	int A, B;
	cin >> A >> B;

	cout << A * B << endl;
}

Measured memory_bytes: 3604
from sys import stdin
 
inf = 10**9 + 1

def solve():
    n = int(stdin.readline())
    R = [int(stdin.readline()) for i in range(n)]

    ans = max_profit(n, R)

    print(ans)

def max_profit(n, R):
    max_d = -inf
    min_v = R[0]

    for i in range(1, n):
        max_d = max(max_d, R[i] - min_v)
        min_v = min(min_v, R[i])

    return max_d

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 15632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&b[i]==c[i]){
        }else if(a[i]==b[i]&&b[i]!=c[i]){
            ans++;
        }else if(a[i]!=b[i]&&b[i]==c[i]){
            ans++;
        }else if(a[i]!=b[i]&&b[i]!=c[i]&&a[i]!=c[i]){
            ans=ans+2;
        }else{
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

int main(void){



  long int A,B,K;
  
  scanf("%ld %ld %ld\n",&A,&B,&K);
  
  if(A>=K){
  	printf("%ld %ld\n",A-K,B);
  }else{
  	if(A+B>=K){
    	printf("0 %ld\n",B-(K-A));
    }
    else{
    	printf("0 0\n");	
    }
  
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> pp(M);
  rep(i,M){
    cin >> pp[i].first >> pp[i].second;
  }
  sort(all(pp));
  vector<pair<int,int>> p;
  int tmp = 0;
  rep(i,M){
    if(pp[i].first != tmp){
      p.pb(pp[i]);
    }
    tmp = pp[i].first;
  }
  reverse(all(p));

  int left=1e8;
  int ans = 0;
  rep(i,(int)p.size()){
    if(p[i].second <= left){
      ans++;
      left = min(left,p[i].first);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9
struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator<(const Puzzle &p)const {
    for(int i=0;i<N2;i++){
      if(f[i]==p.f[i])continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool itarget(Puzzle x){
  for(int i=0;i<N2;i++)
    if(x.f[i]!=(i+1))return false;
    return true;
  }

  string bfs(Puzzle a){
    queue<Puzzle>Q;
    map<Puzzle, bool>V;
    Puzzle u, v;
    a.path="";
    Q.push(a);
    V[a]=true;

    while(!Q.empty()){
      u=Q.front(); Q.pop();
      if(itarget(u))return u.path;
      int xx=u.space/N;
      int xy=u.space%N;

      for(int k=0;k<4;k++){
	int yx=xx+dx[k];
	int yy=xy+dy[k];
	if(yx<0 || yy<0 || yx >=N || yy>=N)continue;
	v=u;
	swap(v.f[u.space],v.f[yx*N+yy]);
	v.space=yx*N+yy;
	if(!V[v])
	  {
	    V[v]=true;
	    v.path+=dir[k];
	    Q.push(v);
	  }
      }
    }
    return "unsolvable";
  }
  

int main(){
  Puzzle n;
  for(int i=0;i<N2;i++){
    cin>>n.f[i];
    if(n.f[i]==0){
      n.f[i]=N2;
      n.space=i;
    }
  }
  string ans=bfs(n);
  cout<<ans.size()<<endl;
  
  return 0;
}



Measured memory_bytes: 30564
#include<cstdio>

using namespace std;

int nums[100001];
int availables[] = {6, 6*6, 6*6*6, 6*6*6*6, 6*6*6*6*6, 6*6*6*6*6*6,
                  9, 9*9, 9*9*9, 9*9*9*9, 9*9*9*9*9};


int main() {
    int N;
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) {
        int min = nums[i-1]+1; // if the last is 1-yen withdrawing
        for(size_t x = 0; x < 11; ++x) {
            if(availables[x] <= i && nums[i-availables[x]] < min) {
                    min = nums[i-availables[x]] + 1;
            }
        }
        nums[i] = min;
    }
    printf("%d\n", nums[N]);

    return 0;
}


Measured memory_bytes: 512
//

//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll D, T, S;
    cin >> D >> T >> S;
    yes(S * T >= D);
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
string S;
	cin >> S;
	int ans = 0;
	fx(S.size()) {
		int sum = 0;
		while (x<S.size()&&S[x]=='R') {
			sum++; x++;
		}
		ans = max(ans, sum);
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct rest {
	string name;
	int p;
	int ind;
	bool operator < (const rest& right) const {
		if (name == right.name) {
			return (p < right.p);
		}
		else {
			return (name < right.name);
		}
	}
};

int main(void) {
	int N;
	cin >> N;
	vector<rest> R(N);
	for (int i = 0; i < N; ++i) {
		cin >> R[i].name;
		cin >> R[i].p;
		R[i].p = -R[i].p;
		R[i].ind = i+1;
	}
	sort(R.begin(),R.end());
	for (int i = 0; i < N; ++i) {
		cout << R[i].ind << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int k,n;
    cin>>n>>k;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    sort(all(h));
    reverse(all(h));
    ll ans=h[0]-h[k-1];
    repi(i,1,n-k+1) ans=min(ans,h[i]-h[i+k-1]);
    cout<<ans;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N, M;
	cin >> N >> M;

	int M0 = M;
	int X[40000] = {};
	int Y[10000] = {};
	int dokomade = 0;

	int saidai = sqrt(M);
	for (int i = 2; i < saidai + 1; i++) {
		while (M % i == 0) {
			if (Y[i] == 0) dokomade++;
			Y[i]++;
			X[dokomade] = i;
			M /= i;
		}
	}

	int kotae = 1;

	if (M != 1) {
		dokomade++;
		Y[0]++;
		X[dokomade] = 0;
	}

	if (M0 == 1) co(1);
	else {

		int saidai = 1;

		rep1(i, dokomade) saidai *= (1 + Y[X[i]]);


		for (int i = 0; i < saidai; i++) {
			int kari = 1;

			int karii = i;
			rep(ii, dokomade) {

				if(X[ii + 1] == 0) kari *= pow(M, karii % (1 + Y[X[ii + 1]]));
				else kari *= pow(X[ii + 1], karii % (1 + Y[X[ii + 1]]));
				karii /= (1 + Y[X[ii + 1]]);

			}
			ce(kari);

			if (M0 >= 1ll * N * kari) kotae = max(kotae, kari);
		}


		co(kotae);
	}


	Would you please return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
char s[5];
main(){
	while(~scanf("%s",s)){
		if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') puts("3");
		else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R')) puts("2");
		else if(s[0]=='R'||s[1]=='R'||s[2]=='R') puts("1");
		else puts("0");
	}
}


Measured memory_bytes: 3680
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, x;
	int l[200];

	int pos = 0;
	int count = 1;

	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}

	for (int i = 0; i < n; i++) {
		pos += l[i];

		if (pos <= x) {
			count++;
		}
		else {
			break;
		}
	}

	cout << count << endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    set<string>st;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
}


Measured memory_bytes: 19216
n = int(input())
x = n / 1.08
if int(x) == x:
  ans = int(x)
else:
  x1 = int(x) + 1
  n1 = int((x1) * 1.08)
  if n == n1:
    ans = x1
  else:
    ans = ":("
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

const int INF = 1 << 30;

int n,Ma,Mb;
int dp[45][405][405];
int a[45],b[45],c[45];

int main(){
  cin >> n >> Ma >> Mb;
  fill(dp[0][0],dp[45][0],INF);
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  
  dp[0][0][0] = 0;
/*
  rep(i,10){
    rep(j,10){
      cout << dp[0][i][j];
    }
  }
*/
  for(int i = 0;i < n;i++){
    rep(j,405){
      rep(k,405){
        if(dp[i][j][k] != INF){
          //i個目を選ぶ
          chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
          //i個目を選ばない
          chmin(dp[i+1][j][k],dp[i][j][k]);
        }
      }
    }
  }
  
  int ans = INF;
  
  for(int i = 1; i < 405;i++){
    for(int j = 1; j < 405; j++){
      if(Ma*j==Mb*i) chmin(ans, dp[n][i][j]);
    }
  }
  
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
    
  return 0;
}

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


int main()
{
	int	a[200],n;

	cin >>n;

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

	int c=0;
	while(1)
	{
		for(int i=0;i<n;i++)
		{
			if(a[i]%2==1)
			{
				cout << c;
				return 0;
			}
			a[i]=a[i]/2;
		}
		c++;
	}
	cout << c;

	return 0;
}

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

public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

        int[] cakeList = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

        int ans = 0;
        int total = inpt[0];
        int max = cakeList.Max();
        if(max * 2 >= total) {
            ans = max - (total - max) - 1;
        }        
        Console.WriteLine(ans);

    }

    public class Reader {
        public static bool IsDebug = true;

        private static string Input = @"

100 1
100

        ";

        private static System.IO.StringReader rd;
        public static string ReadLine() {
            if(!IsDebug) {
                return Console.ReadLine();
            }
            if(rd == null) {
                rd = new System.IO.StringReader(Input.Trim());
            }
            return rd.ReadLine();
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 3032