akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<stack>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int MAX = 1000010;
bool prime[MAX+2];




class AOJ2048{
private:
  int a,b;
  vector<int> A,B;
public:
  AOJ2048(int a,int b):a(a),b(b){}
   
 

  vector<int> div(int num){
    vector<int> vec;
    for(int i=2;i<=num/2+1;i++){
      if(num%i == 0){
	vec.pb(i);
	//cout << "pre " << num << endl;
	while(num%i == 0)
	  num = num/i;
	//cout << "after " << num << endl << endl;
	if(num == 1)break;
      }
    }
    if(num != 1)vec.pb(num);
    // rep(i,vec.size()){
    //cout <<"vec = " << vec[i] << endl;
    // }
    return vec;
  }

  void run(){
   
    A = div(a);
    B = div(b);
    ll totalA,totalB;
    totalA = totalB = 0;
    int maxa,maxb;
    maxa=maxb=0;
    rep(i,A.size()){
      if(prime[A[i]]){
	maxa = max(maxa,A[i]);
	totalA += A[i];
      }
      //cout << "a = " << A[i] << endl;
    }    

    rep(i,B.size()){
      if(prime[B[i]]){
      maxb = max(maxb,B[i]);
      totalB += B[i];
      }
    }    
    totalA -= maxa;
    maxa -= totalA;
    totalB -= maxb;
    maxb -= totalB;
    if(maxa > maxb){
      cout << 'a' << endl;
    }
    else cout << 'b' << endl;

  }


};

void eratos(){
  rep(i,MAX+1)prime[i] = false;
  for(int i=3;i<=MAX;i+=2)prime[i] = true;
  prime[2] = true;
  int lim = (int)sqrt((double)MAX)+1;
  for(int i=3;i<=lim;i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<=MAX;j+=i)prime[j] = false;
  }
}

int main(){
  int Aa,Ba;
    eratos();
  
    while(true){
      cin >> Aa >> Ba;
      if(Aa+Ba == 0)break;
      AOJ2048 ans = AOJ2048(Aa,Ba);
      ans.run();
    }
return 0;
}

Measured memory_bytes: 2184
import math
def main():
    N = int(input())
    l = [0] * (N+1)
    x = int(math.sqrt(N)) + 2
    for i in range(1, x):
        for j in range(1, x):
            for k in range(1, x):
                t = i**2 + j**2 + k**2 + i*j + j*k + k*i
                if t <= N:
                    l[t] += 1
    for i in range(1, N+1):
        print(l[i])
main()


Measured memory_bytes: 9296
#include <iostream>
#include <stdio.h>


using namespace std;
int main(){
  int N,M,K;
  cin >> N >> M >> K;
  long long int A[N+1],B[M+1],a[N+1],b[M+1];
  int max=0;
  long long int time=0;
  int maxanum=0;
  A[0]=0;
  B[0]=0;
  a[0]=0;
  b[0]=0;
  int j=M;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    time+=A[i];
    a[i]=time;
  }
  time=0;
  for(int i=1;i<=M;i++){
    cin >> B[i];
    time+=B[i];
    b[i]=time;
  }
  for (int i=0;i <=N ;i++){
    if(a[i]>K)break;
    while (b[j] >K-a[i]){
      j-=1;
    }
    if (max<i+j){
      max=i+j;
    }
  }
  cout << max << endl;


}


Measured memory_bytes: 9816
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

func Solve() {
  var N int
  var A []int
  NextInt(&N)
  NextIntVec(&A)
  sort.Ints(A)
  E := make([]bool, 1000001)
  for i := range E { E[i] = true }
  for i, a := range A {
    if 0 < i && A[i - 1] == a { continue }
    for b := 2 * a; b < 1000001; b += a { E[b] = false }
  }
  cnt := 0
  for i, a := range A {
    if 0 < i && A[i - 1] == a { continue }
    if i < N - 1 && A[i + 1] == a { continue }
    if E[a] { cnt++ }
  }
  Write(cnt)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 11096
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, m; cin >> n >> m;
    vector<string> a(n), b(m);
    cin >> a >> b;
    rep(i, n){
        rep(j, n){
            //cout << i << " " << j << endl;
            bool z = true;
            if(i+m > n || j+m > n) continue;
            for(ll k = i; k < m+i; ++k){
                string x = a[k].substr(j, m), y = b[k-i];
                //cout << x << " " << y << endl;
                if(x != y) z = false;
            }
            if(z){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

x,y = map(int,input().split())
a = 0
b = 0

if x >= 2:
    a = comb(x,2)

if y >= 2:
    b = comb(y,2)

print(a+b)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;


int main(){
  int n,m;cin>>n>>m;
  vector<vector<int>> a(n,vector<int>(2));
  rep(i,n)rep(j,2)cin>>a[i][j];
  sort(all(a));

  int64_t ans=0,sum=0;
  rep(i,n){
    sum += a[i][1];
    ans += (int64_t)a[i][0]*a[i][1];
    if(sum>=m){
      ans -= (sum-m)*a[i][0];
      break;
    }
  }
  cout << ans;
}




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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int num = A%B;
	int d = A%B;
	while (num!= 0) {
		num += d;
		num = num%B;
		if (num%B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	if (num == C) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
ls = sorted([tuple(map(int,input().split())) for _ in range(N)])
cnt = 0
ans = 0
for a,b in ls:
    if cnt + b >= M:
        ans += a*(M-cnt)
        break
    cnt += b
    ans += a*b
print(ans)

Measured memory_bytes: 17756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    int c = 0;
    string ans = "No";
    rep(i, n) {
        int x, y;
        cin >>x >> y;
        if(x == y) c++;
        else c = 0;
        if(c >= 3) ans = "Yes";
    }
    cout << ans <<'\n';
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <set>
#include <functional>
#include <cmath>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)

struct State {
  double param;
  string name;
  State(double p, string n):param(p), name(n){}
  bool operator>(const State& a) const {
    return (abs(a.param - param) < EPS) ? name < a.name : param > a.param ;
  }
};

int n;

void solve() {
  set<State, greater<State> > cset;
  rep(i,n) {
    string l;
    int p, a, b, c, d, e, f, s, m;
    cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
    double time = a + b + c + (d + e) * m;
    double income = f * s * m - p;
    double value = (double)income / (double)time;
    cset.insert(State(value, l));
  }
  for (multiset<State>::iterator i = cset.begin(); i != cset.end(); i++) {
    cout<<i->name<<endl;
  }
  cout<<"#"<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector <vector <int>> gr(n);
    forn (i, 0, m) {
        int v, u;
        cin >> v >> u, --v, --u;
        gr[v].pb(u), gr[u].pb(v);
    }
    const int INF = 1e9;
    vector <int> dst(n, INF), par(n, -1);
    deque <int> q = {0};
    dst[0] = 0;
    while (!q.empty()) {
        int v = q.front();
        q.pop_front();
        for (int u : gr[v])
            if (dst[v] + 1 < dst[u]) {
                dst[u] = dst[v] + 1;
                q.pb(u);
                par[u] = v;
            }
    }
    forn (i, 1, n)
        if (par[i] == -1)
            return cout << "No", 0;
    cout << "Yes\n";
    forn (i, 1, n)
        cout << par[i] + 1 << "\n";
    return 0;
}

Measured memory_bytes: 10680
#include<stdio.h>
int main(){
  int n,m,i,j,cards[4][14];
  char a;
 
  for(i = 0;i < 4;i++){
    for(j = 0;j < 14;j++){
      cards[i][j] = 0;
    }
  }
 
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%c%c %d",&a, &a,&m);
      if(a == 'S'){
        cards[0][m] = 1;
      }
      else if(a == 'H'){
    cards[1][m] = 1;
      }
      else if(a == 'C'){
    cards[2][m] = 1;
      }
      else if(a == 'D'){
    cards[3][m] = 1;
      }
  }
  for(i = 0;i < 4;i++){
    for(j = 1;j <= 13;j++){
      if(i == 0 && cards[0][j] == 0){
        printf("S %d\n",j);
      }
      else if(i == 1 && cards[1][j] == 0){
    printf("H %d\n",j);
      }
      else if(i == 2 && cards[2][j] == 0){
    printf("C %d\n",j);
      }
      else if(i == 3 && cards[3][j] == 0){
    printf("D %d\n",j);
      }
    }
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 51;
int n;
int cnt[N][26];
int mcnt[26];
string s, ans;
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        for (int j = 0; j < s.length(); ++j) {
            ++cnt[i][s[j] - 'a'];
        }
    }
    for (int i = 0; i < 26; ++i) {
        mcnt[i] = 1e9;
        for (int j = 0; j < n; ++j) {
            mcnt[i] = min(mcnt[i], cnt[j][i]);
        }
    }
    for (int i = 0; i < 26; ++i) {
        while (mcnt[i]) {
            ans.push_back('a' + i);
            --mcnt[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 
'''
#------------------PYPY FAst I/o--------------------------------#

def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#

#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))

def find_gt(a, x):
    #'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:
        return -1


def main():
    try:
        a,b=In()
        l=list(In())
        n=sum(l)
        if a-n<0:
            print(-1)
        else:
            print(a-n)
            
    except:
        pass
M = 998244353
P = 1000000007

if __name__ == '__main__':
    main()

Measured memory_bytes: 10168
#include<cstdio>
#include<functional>
#include<algorithm>
#include<string.h>
using namespace std;

long long int f(long long int times){
	if(times==0)
		return 1;
	long long int tmpt=1;
	for(int i=1;i<=times;i++)
		tmpt*=2;
	return tmpt;
}

int main(){
	long long int s;
	scanf("%lld", &s);
	long long int tmps=s,ans=0;
	int seat=0;
	while(tmps>0){
		tmps=tmps/10;
		seat++;
	}
	long long int times[20];
	for(int ii=0;ii<15;ii++)
		times[ii]=0;
	times[1]=f(seat-1);
	int curseat=1, curcurseat=1;
	while(curseat<=seat){
		long long int tmp=s%10;		
		curcurseat=1;
		int i=1;
		while(curcurseat<=curseat){
			ans+=(tmp*times[i]);
			tmp*=10;
			curcurseat++;
			if(times[i+1]==0 && i+1<=seat){
				times[i+1]=times[i]/2;
				times[i]=times[i+1];
			}
			i++;
		}	
		curseat++;
		s/=10;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,a.size()){
        cin>>a[i];
    }
    int cnt = 0;
    rep(i,0,a.size()){
        rep(j,i+1,a.size()){
            rep(k,j+1,a.size()){
                if ( a[i] == a[j] || a[j] == a[k] || a[i] == a[k] )continue;
                if ( a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i] ){
                    cnt++;
                }
            }
        }
    }

    cout<<cnt<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3664
package main

import "fmt"

func main() {
	var TakahashiHp, TakahashiForce, AokiHp, AokiForce int
	fmt.Scan(&TakahashiHp, &TakahashiForce, &AokiHp, &AokiForce)

	for {
		AokiHp = AokiHp - TakahashiForce

		if AokiHp <= 0 {
			fmt.Println("Yes")
			return
		}

		TakahashiHp = TakahashiHp - AokiForce

		if TakahashiHp <= 0 {
			fmt.Println("No")
			return
		}
	}
}

Measured memory_bytes: 1756
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
int ary[30][1000006]={0};
#define mp make_pair
signed main(){
    int n,C; cin>>n>>C;
    rep(i,n){
        int a,b,c;cin>>a>>b>>c;
        --c;
        ary[c][a-1]++;
        ary[c][b]--;
    }
    rep(i,30){
        rep(j,100006-1)ary[i][j+1]+=ary[i][j];
    }
    int ans=0;
    rep(j,1000006-1){
        int cnt=0;
        rep(i,30){
            if(ary[i][j]>0)cnt++;;
        }
        if(ans<cnt){
            ans=cnt;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 72320
#include <stdio.h>
#include <string.h>
#include <algorithm>

int N, K;
char A[11][10];
int used[11];
char num[100];
int size, arr[6000];
int ans = 0;

void rec(int k) {
	int length = strlen(num);
	if (k == K) {
		arr[size++] = atoi(num);
		return;
	}
	for (int i = 0; i < N; ++i) {
		if (!used[i]) {
			used[i] = 1;
			strcat(num, A[i]);
			rec(k + 1);
			used[i] = 0;
			num[length] = '\0';
		}
	}
}

void bubbleSort() {
	for (int i = 0; i < size; ++i) {
		for (int j = 1; j < size - i; ++j) {
			if (arr[j - 1] > arr[j]) {
				std::swap(arr[j - 1], arr[j]);
			}
		}
	}
}

int main(void) {
	while (true) {
		scanf("%d%d", &N, &K);
		if (N == 0 && K == 0) { break; }
		for (int i = 0; i < N; ++i) { scanf("%s", &A[i]); }

		for (int i = 0; i < N; ++i) { used[i] = 0; }
		strcpy(num, "");
		size = 0;
		rec(0);
		bubbleSort();
		ans = 0;
		for (int i = 0; i < size; ++i) {
			if (i == 0 || arr[i - 1] != arr[i]) { ans++; }
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2628
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,A,B;
  cin>>N>>A>>B;
  cout<<min(A,B)<<" "<<max(0,A+B-N)<<endl;
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


S = sys.stdin.readline().rstrip()

A = S[::2]
print(A)

Measured memory_bytes: 65132
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;
//abc179

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s') s+="es";
    else s+="s";
    out(s);
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3652
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K,C;
string S;

vector<LL> ans;

void solve(){
	if(N==1){
		if(S[0]=='o') ans.push_back(1);
		return;
	}
	//前から貪欲に詰めたとき、i日目の時点での働ける日にちの最大値
	vector<LL> forward(N,0);
	//後ろから貪欲に詰めたとき、N-1-i日目の時点での働ける日にちの最大値
	vector<LL> backward(N,0);

	int counter_forward = 0;//労働日数のカウンタ
	int counter_backward = 0;//労働日数のカウンタ
	int counter_forward_waittime = C;//間隔調整用カウンタ
	int counter_backward_waittime = C;//間隔調整用カウンタ
	for(int i=0;i<N;i++){
		{
			counter_forward_waittime++;
			if(counter_forward_waittime>=C+1 && S[i]=='o'){
				counter_forward_waittime = 0;
				counter_forward++;
			}
			forward[i] = counter_forward;
		}
		{
			counter_backward_waittime++;
			if(counter_backward_waittime>=C+1 && S[N-1-i]=='o'){
				counter_backward_waittime = 0;
				counter_backward++;
			}
			backward[N-1-i] = counter_backward;
		}
	}

	// for(int i=0;i<N;i++){
	// 	cout << forward[i] << " ";
	// }
	// cout << endl;
	// for(int i=0;i<N;i++){
	// 	cout << backward[i] << " ";
	// }
	// cout << endl;

	if(backward[1]<K && S[0]=='o'){
		ans.push_back(0+1);
	}

	//i日目を労働不可と仮定しても
	//K日以上労働日数を確保できるならば
	//i日目は必ず働く日ではない
	//つまり
	//i日目を労働不可と仮定すると
	//K日未満しか労働日数が確保できないならば
	//i日目は必ず働く日
	C = max(C,1LL);
	multiset<LL> days;
	for(int i=1;i<N;i++){
		//新たな数を追加
		{
			if(i-1>=0 && i+C<N){
				LL sum = forward[i-1] + backward[i+C];
				days.insert(sum);
				// cout << "add:"<< sum << endl;
			}
		}

		LL day = 0;
		if(days.size()>0){
			day = (*(--days.end()));
		}
		if(i+1<N) day = max(day,backward[i+1]);
		if(i-1>=0) day = max(day,forward[i-1]);
		if(day<K){
			if(S[i]=='o') ans.push_back(i+1);
		}

		//不要になった数を削除
		{
			if(i-C>=0 && i+1<N){
				LL sum = forward[i-C] + backward[i+1];
				auto iter = days.lower_bound(sum);
				days.erase(iter);
				// cout << "erase:"<< (*iter) << endl;
			}
		}
		// cout << "i="<<i << endl;
		// for(auto iter=days.begin();iter!=days.end();iter++){
		// 	cout << (*iter) << " ";
		// }
		// cout << endl;
	}
}

int main(){
    cin >> N >> K >> C;
    cin >> S;

    solve();

    for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
    return 0;
}

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

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

using namespace std;

int main(){
  
  char a,b,c;
  cin >> a >> b >> c;
  
  if((a == 'S')&&(b == 'S')&&(c == 'S')){
    cout << "0";
  }else if(((a == 'R')&&(b == 'S')&&(c == 'S'))||((a == 'S')&&(b == 'R')&&(c == 'S'))||((a == 'S')&&(b == 'S')&&(c == 'R'))||((a == 'R')&&(b == 'S')&&(c == 'R'))){
    cout << "1";
  }else if((a == 'R')&&(b == 'R')&&(c =='R')){
    cout << "3";
  }else if(((a == 'S')&&(b == 'R')&&(c == 'R'))||((a == 'R')&&(b == 'R')&&(c == 'S'))){
    cout << "2";
  }else{
    cout << "0";
  }
  
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    ll n, k;
    cin >> n >> k;
    map<ll, ll> mp;
    ll a, b;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        mp[a] += b;
    }
    ll c = 0;
    for (auto x : mp) {
        c += x.second;
        if(c >= k) {
            cout << x.first << std::endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

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


int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  if (a[int(a.size())-1] == b[0] && b[int(b.size())-1] == c[0]) {
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){

  int a, b, t; cin >> a >> b >> t;
  pr((t/a) * b);

  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m;
    cin >> n >> m;
    vt<int> a(n);
    for (int &i : a) cin >> i, i /= 2;

    int mx = *max_element(all(a));

    ll lcm = 1;
    for (int i : a) {
        int r = mx % i;
        int g = i / __gcd(r, i);
        lcm *= g / __gcd((ll)g, lcm);

        if (lcm * mx > m || ~(g * mx / i) & 1 || ~g & 1)
            return cout << 0, 0;
    }

    cout << (m / lcm / mx + 1) / 2;
}


Measured memory_bytes: 3732
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    rep(i, 3){
        if(S[i] == 'R'){
            ans = 1;
            break;
        }
    }
    rep(i, 2){
        if(S[i] == 'R' && S[i+1] == 'R'){
            if(ans < 2){
                ans = 2;
            }else{
                ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3628
N = int(input())

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

flg = 0
for i in range(len(A)):
    if A[i] % 2 == 0:
        if (A[i] % 3 != 0 and A[i] % 5 != 0):
            flg = 1
if flg == 0:
    print("APPROVED")
else:
    print("DENIED")

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(all(a));
    vi b(8,0);
    int c=0;
    rep(i,n){
        if(a[i]<400){
            b[0]++;
        }
        if(400<=a[i]&&a[i]<800){
            b[1]++;
        }
        if(800<=a[i]&&a[i]<1200){
            b[2]++;
        }
        if(1200<=a[i]&&a[i]<1600){
            b[3]++;
        }
        if(1600<=a[i]&&a[i]<2000){
            b[4]++;
        }
        if(2000<=a[i]&&a[i]<2400){
            b[5]++;
        }
        if(2400<=a[i]&&a[i]<2800){
            b[6]++;
        }
        if(2800<=a[i]&&a[i]<3200){
            b[7]++;
        }
        if(3200<=a[i]){
            c++;
        }
    }
    int ans=0;
    rep(i,8){
        if(b[i]>0)ans++;
    }
    if(ans==0){
        cout<<1<<" ";
    }
    else cout<<ans<<" ";
    cout<<ans+c<<endl;
}


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

int N;

int M[110];


int main() {
    int max;
    int sum = 0;
    int min = 10000;
    cin >> N >> max;
    for (int i = 0; i < N; ++i) {
        cin >> M[i];
        if(M[i] < min) min = M[i];
        sum += M[i];
    }
    if(sum == max)  cout << N << endl;
    else cout << (max - sum) / min + N << endl;
    
}


Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

Measured memory_bytes: 3060
dice = input().split()
direction = list(input())
dice2 = []
for i in range(len(direction)):
    dice2 = dice
    if direction[i] == 'E':
        dice = [dice2[3],dice2[1],dice2[0],dice2[5],dice2[4],dice2[2]]
    elif direction[i] == 'N':
        dice = [dice2[1],dice2[5],dice2[2],dice2[3],dice2[0],dice2[4]]
    elif direction[i] == 'S':
        dice = [dice2[4],dice2[0],dice2[2],dice2[3],dice2[5],dice2[1]]
    else:
        dice = [dice2[2],dice2[1],dice2[5],dice2[0],dice2[4],dice2[3]]
print('{0}'.format(int(dice[0]))) 


Measured memory_bytes: 5604
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,x,M=0,m=0;
  cin >> n;
  map<int,int> mp;
  for(int i=0; i<n; i++) {
    cin >> x;
    mp[x/400]++;
  }
  for(auto p:mp) {
    if(p.first<8) {
      M++,m++;
    }
    else {
      M+=p.second;
    }
  }
  m=max(m,1);
  cout << m << " " << M << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;


void solve(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i,N) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if(N & 1){
        ll a = A[N/2];
        ll b = B[N/2];
        cout << b - a + 1 << endl;
    }
    else{
        ll a = A[N/2-1] + A[N/2];
        ll b = B[N/2-1] + B[N/2];
        cout << b - a + 1 << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 6340
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    string s;
    cin >> s;
    string::size_type index;
    index = s.find("C");
    if(index == string::npos){
        cout << "No" << endl;
    } else {
        s = s.substr((int)index);
        // cout << s << endl;
        index = s.find("F");
        if(index == string::npos){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(void)
{
    int l;
    cin >> l;
    
        double a = l/3.0;
        printf("%.6f\n", a*a*a);

    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
f(a,b)char*a,*b;{return*a-*b;}
g(a,b)char*a,*b;{return*b-*a;}
a[99];b[99];
main(){
	gets(a);gets(b);
	qsort(a,strlen(a),1,f);
	qsort(b,strlen(b),1,g);
	puts(strcmp(a,b)<0?"Yes":"No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vi E[111111];
bool used[111111];
bool vis[111111][5];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    ll u,v;cin>>u>>v;
    u--;v--;
    E[u].pb(v);
    //E[v].pb(u);
  }
  ll s,t;cin>>s>>t;
  s--;t--;
  used[s]=true;
  queue<pair<ll,ll>>que;
  que.push(mp(s,0));
  vis[s][0] = true;
  while(!que.empty()){
    ll now,cost;
    tie(now,cost) = que.front();
    que.pop();
    // cout<<now<<endl;
    //if(used[now]){
    //continue;
    //}
    queue<ll>que2;
    que2.push(now);
    for(int i=0;i<3;i++){
      ll r = que2.size();
      
      for(int j=0;j<r;j++){
	ll nx = que2.front();
	que2.pop();
	//	cout<<nx<<" "<<i+1<<" "<<now<<endl;

	//cout<<nx<<" "<<j+1<<" "<<vis[nx][j+1]<<endl;
	for(auto e:E[nx]){
	  if(vis[e][i+1])continue;
	  vis[e][i+1] = true;
	  que2.push(e);
	}
      }
    }

    while(!que2.empty()){
      ll nx = que2.front();
      que2.pop();
      if(nx == t){
	cout<<cost+1<<endl;
	return 0;
      }
      if(used[nx] == false){
	used[nx] = true;
	que.push(mp(nx,cost+1));
      }
    }
  }
  cout<<-1<<endl;
  return 0;
}


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

using namespace std;

const int N = 1e5 + 1;
typedef long long ll;
ll f[N][2];
int a[N], n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	f[0][1] = f[0][0] = 0;
	f[1][0] = a[1] + a[2];
	f[1][1] = - f[1][0];
	for (int i = 2; i <= n - 1; ++i) {
		f[i][0] = max(f[i - 1][0] - a[i] + a[i] + a[i + 1], f[i - 1][1] + a[i] - a[i] + a[i + 1]);
		f[i][1] = max(f[i - 1][0] - a[i] - a[i] - a[i + 1], f[i - 1][1] + a[i] + a[i] - a[i + 1]);
	}
	cout << max(f[n - 1][0], f[n - 1][1]);
	return 0;
}


Measured memory_bytes: 2176
/*
 this->author = Fuad Ashraful Mehmet, CSE-UAP
 Todo:
 lightoj : 1147,1101
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
using namespace std;

const int N=2e5+5;
typedef  long long ll;
int n,m,k;

long double one=1.00;
int a[N];

bool Ok(int mid)
{
      int cnt=0;

      for(int i=1;i<=n;++i)
      {
            cnt+=a[i]/mid;
            if(a[i]%mid==0)cnt-=1;
            
      }

      return cnt<=k;
}// end func

void HalfDead()
{
      cin>>n>>k;
      for(int i=1;i<=n;++i)cin>>a[i];

      int lo=1,hi=1e9+7;
      
      int run=200;
      while(lo<=hi)
      {
            int mid=(lo+hi)>>1;
            if(Ok(mid))
            {
                  hi=mid-1;
            }
            else lo=mid+1;
      }

      int res=lo;
      cout<<res<<endl;
}// end func
int main()
{
     ios_base::sync_with_stdio(0); cin.tie(nullptr);
      int tc=1;
      //cin>>tc;
      //scanf("%d",&tc);
     // cout<<fixed<<setprecision(10);
      while(tc--)
      {
            HalfDead();
      }
      return 0;
}


Measured memory_bytes: 4352
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int main()
{

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//ios_base& scientific (ios_base& str);
    ll n;
    cin >> n;
    vector<ll> indminusele(n);
    vector<ll> eleplusind(n);
    map<ll, ll> mp1;
    map<ll, ll> mp2;
    for (int i = 0; i < n; i++)
    {
        cin >> eleplusind[i];

        indminusele[i] = i + 1 - eleplusind[i];
        if (mp1.find(indminusele[i]) != mp1.end())
            mp1[indminusele[i]]++;
        else
            mp1[indminusele[i]] = 1;

        eleplusind[i] += i + 1;
        if (mp2.find(eleplusind[i]) != mp2.end())
            mp2[eleplusind[i]]++;
        else
            mp2[eleplusind[i]] = 1;
    }
    ll combinations = 0;
    for (auto p : mp1)
    {
        ll key = p.F;
        ll count = p.S;
        if (mp2.find(key) != mp2.end())
        {
            ll temp = mp2[key];
            combinations += temp * count;
        }
    }
    cout << combinations << "\n";
    return 0;
}

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

bldg = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]


for i in range(n):
	b,f,r,v = map(int, input().split())
	#print(b,f,r,v)
	bldg[b-1][f-1][r-1] = bldg[b-1][f-1][r-1] + v

#print(bldg)

for a in range(4):
		for b in range(3):
			for c in range(10):
					print(" " + str(bldg[a][b][c]), end = "")
			print()
		if a != 3:
			for i in range(20):
				print("#", end="")
			print()


Measured memory_bytes: 5632
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  std::vector<int> h(n), dp(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &h[i]);
    if (!i) dp[i] = 0;
    else dp[i] = 2e9;
    for (int j = i - 1; j >= i - k && j >= 0; --j) {
      dp[i] = std::min(dp[i], dp[j] + std::abs(h[i] - h[j]));
    }
  }
  printf("%d\n", dp.back());
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);
  
  sort(S.begin(), S.end());
  
  for (int i = 0; i < N; i++) cout << S.at(i);
  cout << endl;
}

Measured memory_bytes: 256
n,y = gets.chomp.split.map(&:to_i)

set = '-1 -1 -1'

(0..n).each do |a|
  (0..(n-a)).each do |b|
    c = n - a - b
    set = "#{a} #{b} #{c}" if 10000*a + 5000*b + 1000*c == y
    break if set != '-1 -1 -1'
  end
end

puts set


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

#define pow2(x) ((x)*(x))

int main() {
	double x0, y0, x1, y1, X0, Y0, X1, Y1;
	double a1, b1, a2, b2, a3, b3;
	int n;
	cin >> n;
	while(n--) {
		cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
		x0 = (a1 + a2) / 2.0; y0 = (b1 + b2) / 2.0;
		x1 = -(b2 - b1); y1 = (a2 - a1);
		X0 = (a2 + a3) / 2.0; Y0 = (b2 + b3) / 2.0;
		X1 = -(b3 - b2); Y1 = (a3 - a2);
		double s = (Y1*(x0 - X0) - X1*(y0 - Y0)) / (X1*y1 - Y1*x1);
		double p = x0 + s * x1, q = y0 + s * y1;
		double r = sqrt(pow2(p - a1) + pow2(q - b1));
		printf("%.3f %.3f %.3f\n", p, q, r);
	}
	return 0;
}

Measured memory_bytes: 1248
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int h1 = sc.nextInt(),
				m1 = sc.nextInt(),
				s1 = sc.nextInt();
			if (h1 == -1 && m1 == -1 && s1 == -1) break;
			int h = 2, m = 0, s = 0;
			s -= s1;
			if (s < 0)
			{
				s += 60;
				m--;
			}
			m -= m1;
			if (m < 0)
			{
				m += 60;
				h--;
			}
			h -= h1;
			System.out.printf("%02d:%02d:%02d\n", h, m , s);
			h *= 3;
			m *= 3;
			h += m / 60;
			m = m % 60;
			s *= 3;
			m += s / 60;
			s = s % 60;
			System.out.printf("%02d:%02d:%02d\n", h, m , s);
		}
	}
}

Measured memory_bytes: 12000
function Main(input) {
	var idata = input.split(/\n/);
	var N = parseInt(idata[0]);
	var box = [];
	var box2 =[];
	var same = 0;
	var count = 0;
	for(i = 1; i < N+1; i++){
		box[i] = idata[i].split("");
		box[i].sort();
		box2[i]=box[i].toString();
	}
	box2.sort();

	//合ってるか確認
	for(i=1;i<N+1;i++){
		if(box2[i-1]==box2[i]){
			count += 1;
		}else{
			same += count * ( count + 1 ) / 2;
			count = 0;
		}
	}
	console.log(same);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 65320
n = int(input())
f = [list(input().split()) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
print(max(sum(p[j][sum(f[j][x] == "1" and format(i, "010b")[x] == "1" for x in range(10))] for j in range(n)) for i in range(1, 2 ** 10)))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
string s;

int main(){
	cin >> s;
	
	REP(i,0,s.size()-1) if(s[i]==s[i+1]){cout << i+1 << " " << i+2 << endl; return 0;}
	REP(i,0,s.size()-2) if(s[i]==s[i+2]){cout << i+1 << " " << i+3 << endl; return 0;}
	cout << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    int ans = 0;
    rep(i, 0, N)
    {
        cin >> H.at(i);
    }
    bool f;
    rep(i, 0, N)
    {
        f = true;
        rep(j, 0, i)
        {
            if (H.at(j) > H.at(i))
            {
                f = false;
                break;
            }
        }
        if (f)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005;
ll I,O,T,J,L,ans,now;

void doit(ll x){
	if(I<x||J<x||L<x||x<0)return;
	ans=max(ans,x*3+(I-x)/2*2+(J-x)/2*2+(L-x)/2*2);
}

int main(){
	read(I),read(O);
	read(T),read(J),read(L);
	REP(t,10)doit(t),doit(min(J,L)-t);
	ans+=O;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
#define int long long
const int mod=1e9+7;
map<int,int>d;
inline int solve(int x)
{
    if(d[x]!=0)
        return d[x];
    else
    return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main()
{
    d[0]=1;
    d[1]=2; 
    int n;
    cin>>n; 
    int ans=solve(n);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string s;
    cin >> s;
    rep(i, s.size()-1){
        if (s[i] == 'A' && s[i+1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256