akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  vl sa = a;
  sort(all(sa));
  rep(i, n) cout << (a[i] == sa[n - 1] ? sa[n - 2] : sa[n - 1]) << '\n';
}

Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W; cin>>H>>W;
  vector<string> S(H);
  rep(i,0,H) cin>>S[i];
  vii F(H,vi(W,INF));
  priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> Q;
  rep(i,0,H){
    rep(j,0,W){
      if(S[i][j]=='#'){
        F[i][j]=0;
        Q.push(mp(0,mp(i,j)));
      }
    }
  }
  vi P={0,1,0,-1},R={1,0,-1,0};
  while(Q.size()>0){
    int X=Q.top().second.first,Y=Q.top().second.second,Z=Q.top().first;
    Q.pop();
    rep(i,0,4){
      int A=X+P[i],B=Y+R[i];
      if(0<=A&&A<H&&0<=B&&B<W&&F[A][B]>Z+1){
        F[A][B]=Z+1;
        Q.push(mp(Z+1,mp(A,B)));
      }
    }
  }
  int ans=0;
  rep(i,0,H){
    rep(j,0,W) ans=max(ans,F[i][j]);
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 34668
#include <bits/stdc++.h>
using namespace std;
#define N 140000
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
#define MP make_pair

#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++)     
void fastIO(void);

void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);




int main()
{
   ll n;
   cin>>n;
   ll a[n];
   string s;
   rep(j,n){
      a[j]=0;
      cin>>s;
      rep(i,10)
         a[j]+=modpower(13,ll(s[i]-'a'),10e9+7);
   }
   sort(a,a+n);
   map<ll,ll> m;
   set<ll> se;
   rep(i,n){
      //cout<<a[i]<<" ";
      m[a[i]]++;}
  // cout<<endl;
   ll count=0,curr;
   rep(i,n){
      //cout<<se.count(a[i])<<endl;
      if(m[a[i]]>1 && se.count(a[i])==0){
         se.insert(a[i]);
         curr = m[a[i]]*1ll*(m[a[i]]-1);
         curr = curr/2;
         count+=curr;
      }
   }
   cout<<count<<endl;
}























void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}

void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m))%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll n,l;
    cin>>n>>l;
    vector<string> v;
    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        v.pb(s);
    }
    sort(all(v));
    for(auto it:v)cout<<it;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
typedef long long ll; 
int main(){
  ll n,m,a=0,d=0;cin>>n;
  if(n==2||n==3){d=1;}
 while(d==0){
  m=n;
  for(ll i=2;i*i<=n;i++){
    m=n;
    if((i+1)*(i+1)>n){if(m%i!=0){d=1;}}
    if(m%i==0){i=n;}
  }
   n++;
 }
  n--;
  if(n==1||n==2){n++;}
  cout << n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int L,R;cin>>L>>R;
  	if(R-L>=2019){
      	cout<<0<<endl;
      	return 0;
    }
    L%=2019;R%=2019;
    if(L>=R){
        cout<<0<<endl;
        return 0;
    }
    int ans=INF;
    for(int i=L;i<R;i++){
        for(int j=i+1;j<=R;j++){
            chmin(ans,i*j%2019);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let s: String = read();
    let (l, r) = s.split_at(3);
    let (_, k) = r.split_at(1);
    println!("{}8{}", l, k);
}


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































int main () {
double t1 = clock();

    int64_t N;
    cin >> N;
    
    vector<int64_t> A(N), B(N), C(N);

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int64_t count = 0;

    for (int i = 0; i < N; i++) {
        auto C_low = lower_bound(C.begin(), C.end(), B[i] + 1); // >= B[i] + 1 になる最小のインデックス
        auto A_upp = upper_bound(A.begin(), A.end(), B[i] - 1); // > B[i] - 1 になる最小のインデックス
        count += distance(C_low, C.end()) * distance(A.begin(), A_upp);
        // cout << distance(A.begin(), A_upp) << " ";
        // cout << distance(C_low, C.end()) << " ";
        // cout << count << endl;
    }

    cout << count << endl;
    double t2 = clock();
    // cout << ((t2 - t1) / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 5672
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n;
    cin>>n;
    vector<int>pos(n+1);
    
    for(int i =1 ; i <=n ; i++ ) {
        int tmp;
        cin>>tmp;
        pos[tmp] = i;
    }
    
    int last = 0 , ans = 0 , cnt = 0;
    
    for(int i =1 ; i <= n ; i++ ) {
        
        if(pos[i] > last) {
            cnt++;
            ans = max(ans , cnt);
        }
        else cnt = 1;
        last = pos[i];
    }
    cout<<n-ans<<'\n';
    return 0;
    
    
}

Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
class Main{

    static class MinCut{
        class Edge{
            int to,rev;
            long cap;
            Edge(int to,long cap,int rev){this.to=to;this.cap=cap;this.rev=rev;}
        }
        List<Edge> edges[];
        int[] itr;
        int[] level;
        void add_edge(int from,int to,long cap){
            edges[from].add(new Edge(to,cap,edges[to].size()));
            edges[to].add(new Edge(from, 0, edges[from].size()-1));
        }
        // dinic法
        // itr, bfs + dfs
        MinCut(int N){
            edges = new ArrayList[N];
            itr = new int[N];
            level = new int[N];
            for(int i=0;i<N;++i)edges[i] = new ArrayList<>();
        }
        private void bfs(int s){
            Deque<Integer> que = new ArrayDeque<>();
            que.add(s);
            Arrays.fill(level, -1);
            level[s]=0;
            while(!que.isEmpty()){
                int v = que.poll();
                for(Edge e : edges[v]){
                    if(level[e.to]<0 && e.cap>0){
                        level[e.to]=level[v]+1;
                        que.add(e.to);
                    }
                }
            }
        }

        private long dfs(int s,int t,long f){
            if(s==t)return f;
            while(itr[s]<edges[s].size()){
                Edge e = edges[s].get(itr[s]);
                if(e.cap>0 && level[e.to]>level[s]){
                    long d = dfs(e.to, t, Math.min(f, e.cap));
                    if(d>0){
                        e.cap-=d;
                        edges[e.to].get(e.rev).cap+=d;
                        return d;
                    }
                }
                ++itr[s];
            }
            return 0;
        }

        long mincut(int s,int t){
            long res =0;
            while(true){
                bfs(s);
                Arrays.fill(itr, 0);
                boolean flag=false;
                while(true){
                    long d = dfs(s,t,Long.MAX_VALUE/10000);
                    if(d>0)flag=true;
                    if(d==0)break;
                    res+=d;
                }
                if(!flag)return res;
            }
        }

    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long[] a = new long[N+1];
        for(int i=1;i<=N;++i)a[i]=scan.nextLong();
        long max = 0;
        for(int i=1;i<=N;++i)if(a[i]>0)max+=a[i];
        MinCut mc = new MinCut(2*N+2);
        for(int i=1;i<=N;++i){
            for(int j=i;j<=N;j+=i)mc.add_edge(j,i+N,Integer.MAX_VALUE);
            mc.add_edge(0,i,(a[i]>0 ? a[i]:0));
            mc.add_edge(N+i, 2*N+1, (a[i]<=0 ? -a[i]:0));
        }
        System.out.println(max - mc.mincut(0,2*N+1));


    }
}

Measured memory_bytes: 22736
#include<stdio.h>
#include<algorithm>
using namespace std;
struct node {
	int a, b;
	bool operator<(const node& p)const {
		return a < p.a;
	}
}A[100005];
int main() {
	int N; scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &A[i].a);
		A[i].b = i;
	}
	sort(A + 1, A + N+1);
	for (int i = 1; i <= N; i++)
		printf("%d ", A[i].b);
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> count(N);
    vector<vector<int>> list(N);
    vector<pair<int, int>> bridge;
    for (int i = 0; i < M; i++)
    {
        int p, q;
        cin >> p >> q;
        p--, q--;
        list[p].push_back(q), list[q].push_back(p);
        count[p]++, count[q]++;
        bridge.push_back(make_pair(p, q));
    }
    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        vector<bool> arrived(N, false); //訪問済みかどうか
        queue<int> que;                 //訪問予定
        int number = 1;                 //何箇所訪れたか

        que.push(0);
        arrived[0] = true;
        while (!que.empty())
        {
            int now = que.front();
            que.pop();
            for (int j = 0; j < count[now]; j++)
            {
                int search = list[now][j];
                auto tmp = make_pair(min(now, search), max(now, search));
                if (tmp == bridge[i])
                    continue;
                if (!arrived[search]) //未訪問
                {
                    arrived[search] = true;
                    que.push(search);
                    number++;
                }
            }
        }
        if (number != N)
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Cryptography;

namespace ABC176
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(" ");
            long[] A = new long[input.Length];
            for(var i = 0; i < N; i++)
            {
                A[i] = long.Parse(input[i]);
            }

            long cnt = 0;

            for(var i = 1; i < N; i++)
            {
                if (A[i] < A[i-1])
                {
                    long dif =  A[i-1] - A[i];
                    cnt += dif;
                    A[i] = A[i-1];
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


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

int findSumOfDigits(int n){
 int sum = 0;
  while(n > 0){
   sum += n%10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
   int sum = findSumOfDigits(n);
    if(n%sum == 0){
      cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


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

int main(){
    int Q;
    cin>>Q;
    int c[100],a[100],n[100];
    for(int i=0;i<Q;i++){
        int ans=0;
        int MIN=1e9;
        cin>>c[i]>>a[i]>>n[i];
        if(c[i]&&a[i]&&n[i]){
            MIN=min(c[i],min(a[i],n[i]));
            ans+=MIN;
            c[i]-=MIN;
            a[i]-=MIN;
            n[i]-=MIN;
        }
        if(c[i]==0) cout<<ans<<endl;
        else if(a[i]==0) cout<<ans+c[i]/3<<endl;
        else cout<<ans+min(c[i]/2,a[i])+(c[i]-2*min(c[i]/2,a[i]))/3<<endl;
    }

}


Measured memory_bytes: 3136
# coding: utf-8
N = int(input())
H = list(map(int, input().split()))
l = []
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        l.append(cnt)
        cnt = 0
l.append(cnt)
print(max(l))

Measured memory_bytes: 15020
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

int a[100100];
vector<int> v;

int main(void){
	int n,i,j,c,ans=-INF;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<2; ++i){
		for(j=1; j*j<=a[i]; ++j){
			if(a[i]%j){
				continue;
			}
			v.push_back(j);
			v.push_back(a[i]/j);
		}
	}
	for(j=(v.l_ength()-1); j>=0; --j){
		c = 0;
		for(i=0; i<n; ++i){
			if(a[i]%v[j]){
				continue;
			}
			++c;
		}
		if(c>n-2){
			ans = max(ans,v[j]);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n; cin >>n;
  vector<int>v(n);
  map<int,int>a;
  map<int,int>b;
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(a.count(v[i]))a.at(v[i])++;
      else a[v[i]]=1;
    }else{
      if(b.count(v[i]))b.at(v[i])++;
      else b[v[i]]=1;
    }
  }
  int dai_a=0;
  int dai_ai;
  auto begin=a.begin(),end=a.end();
  for(auto iter=begin;iter!=end;iter++){
    if(dai_a<iter->second){
      dai_a=iter->second;
      dai_ai=iter->first;
    }
  }
  int dai_b=0;
  int dai_bi;
  auto c=b.begin(),d=b.end();
  for(auto iter=c;iter!=d;iter++){
    if(dai_b<iter->second){
      dai_b=iter->second;
      dai_bi=iter->first;
    }
  }
  int kotae=0;
  if(dai_ai!=dai_bi){
    kotae=n-dai_a-dai_b;
    cout<<kotae<<endl;
    return 0;
  }else{
    if(dai_a+dai_b==n){
      kotae=n-dai_a;
      cout<<kotae<<endl;
      return 0;
    }else{
      int dai_b2=0;
      auto c=b.begin(),d=b.end();
      for(auto iter=c;iter!=d;iter++){
        if(dai_bi!=iter->first)dai_b2=max(dai_b2,iter->second);
      }
      int dai_a2=0;
      auto begin=a.begin(),end=a.end();
      for(auto iter=begin;iter!=end;iter++){
      if(dai_ai!=iter->first)dai_a2=max(dai_a2,iter->second);
      }
      if(dai_a+dai_b2>=dai_a2+dai_b){
        kotae=n-dai_a-dai_b2;
        cout<<kotae<<endl;
        return 0;
      }else{
        kotae=n-dai_a2-dai_b;
        cout<<kotae<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main(){
	int N,M,C,b[20]={},a[20][20]={},ans=0,count=0;
	cin>>N>>M>>C;
	for(int i=0;i<M;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<N;i++)
	{
		count=0;
		for(int j=0;j<M;j++)
		{
			cin>>a[i][j];
			count+=a[i][j]*b[j];
		}
		if(count+C>0)ans++;
	}
	cout<<ans;
	return 0;
	}

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

using namespace std;

int main(){
  int counter = 0;//カウンタ初期化
  int N;  //要素数
  cin >> N;

  //ループ脱出フラグ。falseで初期化
  bool finish = false;

  vector<int> p(N);

  //以下奇数が出てこない限りループ
  //全ての要素に対して
  //2で割れるか確かめる
  //奇数が出てきた段階でループを出る

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

  while(true){
	  for (int i = 0; i < N; i++){ //多分ここが問題。参照渡しと変数自体に代入する違いがわからん
    	if(p[i]%2){
        finish = true;
        break;
    	}
    	p[i] /= 2;//全部割れたら全要素に2で割った数を代入
      }
    if(finish){
      break;
    }
    counter++;
  }

  cout << counter << endl;
}


Measured memory_bytes: 256
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s=input()
ans=0
l1=['SRR','RRS']
if s.count('R')==0:
    ans=0
elif s.count('R')==1:
    ans=1
elif s.count('R')==3:
    ans=3
else:
    if s in l1:
        ans=2
    else:
        ans=1
print(ans)

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

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    int list[n];
    list[0] = 0;
    int i,ans = 0;
    bool a = false;
    for(i = 0;i < n ;i++){
        if(s.at(i) == 'A'){
              a = true;
              list[i+1] = list[i];
        }
        else if(s.at(i) == 'C' && a == true){              
            list[i+1] = list[i] + 1;
            a = false;
            }
        else{
            a = false;
            list[i+1] = list[i];
        }
    }
    for(i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        int ans = list[r] - list[l];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
/*
 * Princess's Marriage
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2019
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {
  ll n, m;
  while (cin >> n >> m, n | m) {
    vpi d(n);
    REP(i, n){
      cin >> d[i].second >> d[i].first;
    }
    RSORT(d);
    ll cost = 0;
    REP(i, n){
      if (m > 0) {
        m -= d[i].second;
        if(m < 0) {
          cost -= m * d[i].first;
        }
      } else {
        cost += d[i].second * d[i].first;
      }
    }
    cout << cost << endl;
  }
}

Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String string;
		
		int n, p, stone, now;
		while(true){
			string = reader.readLine();
			n = Integer.valueOf(string.split(" ")[0]);
			stone = p = Integer.valueOf(string.split(" ")[1]);
			if((n | p) == 0) break;
			
			int mayors[] = new int[n];
			now = 0;
			while(true){
				if(stone > 0){
					++mayors[now];
					--stone;
				}else if(stone == 0){
					stone = mayors[now];
					mayors[now] = 0;
				}
				if(stone == 0 && mayors[now] == p){
					break;
				}
				
				now++;
				if(now == n) now = 0;
			}
			System.out.println(now);
		}
		reader.close();
	}
}

Measured memory_bytes: 25532
#include <iostream>
#include <string>

using namespace std;


int main()
{
	string s;
	cin >> s;
	string atcg[] = { "A","T","C","G" };
	int answer = 0;
	int start = -1;
	int len = 0;
	bool j = false;

	for (int i = 0; i < s.length(); i++) {
		j = false;
		for (int n = 0; n < 4; n++) {
			if (s.substr(i, 1) == atcg[n]) {
				j = true; break;
			}
		}
		if (j) {
			if (start >= 0) {
				len++;
			}
			else {
				len = 1; start = i;
			}
		}
		else {
			if (answer < len) answer = len;
			start = -1; len = 0;
		}
	}

	if (answer < len) answer = len;


	cout << answer << endl;

    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int n; 
    ll k;
    cin >> n >> k;
    ll sum=0;
    vector<ll>cnt(100000);
    rep(i, 0, n){
        int a, b;
        cin >> a >> b;
        a--;
        cnt[a] += b;
    }
    rep(i, 0, 100000){
        sum += cnt[i];
        if(sum >= k){
            cout << i+1 << endl;
            return 0;
        }
    }
}

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

using namespace std;

int main() {
  vector<int> A(4);
  while(cin >> A[0]) {
    for(int i = 0; i < 3; i++) {
      if(A[i] >= A[i+1]) swap(A[i], A[i+1]);
      else break;
    }
  }
  for(int i = 3; i > 0; i--) {
    cout << A[i] << endl;
  }
  return 0;
}


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

double calcSide(double a, double b, double l, double m){
  double side;
  double x, y;
  x = fabs(l - a);
  y = fabs(m - b);
  side = sqrt(x * x + y * y);
  return side;
}

double calcArea(double AB, double AC, double BC){
  double Area;
  double s = (AB + AC + BC) / 2;
  Area = sqrt(s * (s - AB) * (s - AC) * (s - BC));
  return Area;
}

int main(){
  double ax, ay, bx, by, cx, cy, px, py;;
  double ABC, APB, APC, BPC;
  double AB, AC, BC, AP, BP, CP;
  
  while(cin >> ax >> ay >> bx >> by >> cx >> cy >> px >> py){
    
    AB = calcSide(ax, ay, bx, by);
    AC = calcSide(ax, ay, cx, cy);
    BC = calcSide(bx, by, cx, cy);

    AP = calcSide(ax, ay, px, py);
    BP = calcSide(bx, by, px, py);
    CP = calcSide(cx, cy, px, py);

    ABC = calcArea(AB, AC, BC);
    APB = calcArea(AP, AB, BP);
    APC = calcArea(AP, AC, CP);
    BPC = calcArea(BP, BC, CP);

    if(fabs(APB + APC + BPC - ABC) < 0.000000001) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int count(int,int);



int main (){

	int i,j;
	int h,w;
	int count;
	cin >>h>>w;
	char input;
	vector<vector<char>> data(h+2,vector<char>(w+2));
	vector<vector<char>> out(h+2,vector<char>(w+2));



	//s all 0==================
	i=0;
	while (i<h+2) {
		j=0;
		while (j<w+2) {

			data.at(i).at(j)=0;
			j++;
		}
		i++;
	}
	//g----------------------


	//s 代入=================
	i=1;
	while (i<=h) {
		j=1;
		while (j<=w) {
			cin>>input;
			data.at(i).at(j)=input;	
			j++;
		}
		i++;
	}
	//g---------------------
	//judge==========
	i=1;
	while (i<=h) {

		j=1;
		while (j<=w) {

			if (data.at(i).at(j)=='.') {
					count=0;

	if (data.at(i+1).at(j+1)=='#') count++;
	if (data.at(i-1).at(j-1)=='#') count++;
	if (data.at(i-1).at(j+1)=='#') count++;
	if (data.at(i+1).at(j-1)=='#') count++;
	if (data.at(i-1).at(j)=='#') count++;
	if (data.at(i+1).at(j)=='#') count++;
	if (data.at(i).at(j-1)=='#') count++;
	if (data.at(i).at(j+1)=='#') count++;

				out.at(i).at(j)='0'+count;//cast
			}else
			{
				out.at(i).at(j)='#';
			}
			j++;
		}
		i++;
	}
	//---------------------------

	//output
	i=1;
	while (i<=h) {
		j=1;
		while (j<=w) {

			cout<<out.at(i).at(j);
			
			j++;
		}
		cout<<endl;
		i++;
	}

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
if(n%10==2|| n%10==4||n%10==5||n%10==7||n%10==9)
    cout<<"hon";
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
        cout<<"pon";
    else
        cout<<"bon";
}


Measured memory_bytes: 3600
import math
import sys
input = sys.stdin.readline

def Euclid_dist(tpl1, tpl2):
    if len(tpl1) != len(tpl2): raise TypeError("The length differs between tpl1 and tpl2")
    sum = 0
    for i in range(len(tpl1)):
        sum += pow(tpl1[i]-tpl2[i], 2)
    return math.sqrt(sum)

N, D = map(int,input().split())
li_X = [list(map(int, input().split())) for _ in range(N)]
count = 0
for i in range(N):
    for j in range(i+1, N):
        if Euclid_dist(li_X[i], li_X[j]).is_integer():
            count += 1
print(count)


Measured memory_bytes: 3064
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ld a; cin >> a;
    long double b;cin >> b;
    ld ret = b *a;
    cout << ll(ret) << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 2e3+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;

int n,m;


int main()
{
	char s[5];
	scanf("%s",s+1);
	for(int i=1;i<4;i++)
	{
		if(s[i] == s[i+1])
		{
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
	return 0;
}


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

using namespace std;
long long a,z=1,ans;
string s[100009];
int main()
{
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	
	sort(s,s+a);

	for(int i=1;i<a;i++){
		if(s[i]==s[i-1])z++;
		else{
			ans=ans+(z*(z-1))/2;
			z=1;	
		}
	}
	ans=ans+(z*(z-1))/2;
	cout<<ans;
}

Measured memory_bytes: 7296
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	v := scanNums(n)
	fmt.Printf("%d\n", solve(v))
}

type NumGroup struct {
	Count      map[int]NumGroupNum //それぞれのグループに属する数の個数
	SortedNums NumGroupNums        //グループに属する数をcountの大きい順に並べたもの
}
type NumGroupNum struct {
	Num   int
	Count int
}

func MinCount(numLength int, grpa, grpb *NumGroup) (minCount, minA, minB int) {
	minCount = -1
	minA = -1
	minB = -1

	numsA := grpa.SortedNums
	numsB := grpb.SortedNums
	for i := 0; i < numsA.Len(); i++ {
		numA := numsA[i]
	B:
		for j := 0; j < numsB.Len(); j++ {
			numB := numsB[j]
			if numA.Num == numB.Num {
				continue B
			} else {
				c := numLength - numA.Count - numB.Count
				if minCount < 0 {
					minCount = c
					minA = numA.Num
					minB = numB.Num
					return
				}
			}
		}
	}
	return
}

//sortのための実装
type NumGroupNums []NumGroupNum

func (a NumGroupNums) Len() int {
	return len(a)
}

func (a NumGroupNums) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a NumGroupNums) Less(i, j int) bool {
	return a[i].Count < a[j].Count
}

func NewNumGroup(count map[int]int) *NumGroup {
	g := NumGroup{}
	gcnt := make(map[int]NumGroupNum)
	nums := make(NumGroupNums, 0)
	for k, v := range count {
		n := NumGroupNum{
			Num: k, Count: v,
		}
		gcnt[k] = n
		nums = append(nums, n)
	}
	g.Count = gcnt

	//sort
	sort.Sort(sort.Reverse(nums))
	g.SortedNums = nums

	return &g
}

//偶数個の要素をもつslice vについて
//v[i] = v[i+2], v[i]の数字の種類は2種類のみをみたすようにするとき、数を変えたいとき、
//最小の操作数を求める
//3 1 3 2 -> 1を2に変えるだけなので、1
//105 119 105 119 105 119 -> 1回も変える必要がないので0
//1 1 1 1 -> 1を2回変える必要があるので、2
func solve(v []int) (count int) {
	debug("#solve args->%v\n", v)
	n := len(v)
	half := n / 2
	seta := make(map[int]int)
	setb := make(map[int]int)
	//順番に分ける
	for i := 0; i < n; i = i + 2 {
		seta[v[i]] += 1
		setb[v[i+1]] += 1
	}

	grpa := NewNumGroup(seta)
	grpb := NewNumGroup(setb)

	//debug("seta=%v\n", seta)
	//debug("setb=%v\n", setb)

	//両方同じ数字
	if len(seta) == 1 && len(setb) == 1 {
		if v[0] == v[1] {
			count = half
			return
		} else {
			count = 0
			return
		}
	}

	minCount, minA, minB := MinCount(n, grpa, grpb)
	minCount1, minA1, minB1 := MinCount(n, grpb, grpa)

	if minCount < minCount1 {
		debug("0:a, b = %d %d\n", minA, minB)
		return minCount
	} else {
		debug("1:a, b = %d %d\n", minA1, minB1)
		return minCount1
	}
}

var rdr = bufio.NewReaderSize(os.Stdin, 100000)

/**
 * 長い文字列はfmt.Scanfだと時間がかかる
 */
func readLine() (string, error) {
	buf := make([]byte, 0, 100000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			return "", e
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf), nil
}

/**
 * １行に空白区切りで数字を読み込み
 */
func scanNums(len int) (nums []int) {
	nums = make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&nums[i])
	}
	return
}

const DEBUG_ENABLE = false

func debug(format string, a ...interface{}) (n int, err error) {
	if DEBUG_ENABLE {
		return fmt.Fprintf(os.Stdout, format, a...)
	} else {
		return 0, nil
	}
}


Measured memory_bytes: 15488
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val s2 = readLine.split(" ").head.split("").sorted.mkString
    val t2 = readLine.split(" ").head.split("").sorted.reverse.mkString
    val ans = s2 < t2
    println(if(ans) "Yes" else "No")
  }
}


Measured memory_bytes: 25404
n = int(input());

S = [];
H = [];
C = [];
D = [];
for i in range(0,n):
    a = list(map(str, input().split()));
    if a[0] == 'S':
        S.append(a[1]);
    if a[0] == 'H':
        H.append(a[1]);
    if a[0] == 'C':
        C.append(a[1]);
    if a[0] == 'D':
        D.append(a[1]);
s = [int(s) for s in S];
h = [int(s) for s in H];
c = [int(s) for s in C];
d = [int(s) for s in D];

s.sort();
h.sort();
c.sort();
d.sort();
s.append(0);
h.append(0);
c.append(0);
d.append(0);

q = 0;
for j in range(1,14):
    if s[q] != j:
        print('S', j);
    if s[q] == j:
        q += 1;
    
q = 0;
for k in range(1,14):
    if h[q] != k:
        print('H', k);
    if h[q] == k:
        q += 1;
    
q = 0;
for m in range(1,14):
    if c[q] != m:
        print('C', m);
    if c[q] == m:
        q += 1;
    
q = 0;
for o in range(1,14):
    if d[q] != o:
        print('D', o);
    if d[q] == o:
        q += 1;


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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;

template<typename T>void chmin(T &a,T b){a=min(a,b);}
template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    string s;int K,N;
    cin>>s>>K;
    N=s.size();
    vector<int> a(s.size());
    for(int i=0;i<N;i++)
        a[i]=s[i]-'a';
    for(int i=0;i<N;i++){
        if(a[i]==0)continue;
        else if(26-a[i]<=K){
            s[i]='a';
            K-=26-a[i];
            a[i]=0;
        }
    }
    if(K>0){
        int ch=K%26;
        a[N-1]=(a[N-1]+ch)%26;
        s[N-1]='a'+a[N-1];
    }
    cout<<s<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

vector<string> ans={"KIHBR", "AKIHBR", "KIHABR", "KIHBAR", "KIHBRA", "AKIHABR", "AKIHBAR", "AKIHBRA", "KIHABAR", "KIHABRA", "KIHBARA", "AKIHABAR", "AKIHABRA", "AKIHBARA", "KIHABARA", "AKIHABARA"};

int main(){
    string s; cin>>s;
    for(int i=0; i<16; i++){
        if(s==ans[i]){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K, i;
  cin >> A >> B >> C >> K;
  i=0;
  if (B>A){
    i=i;
    if (C>B){
      i=i;
    }
    else if (B>=C && C*2>B){
      i=i+1;
    }
    else if (B>=C*2 && C*2*2>B){
      i=i+2;
    }
    else if (B>=C*2*2 && C*2*2*2>B){
      i=i+3;
    }
  }
  else if (B<=A && B*2>A){
    i=i+1;
    if (C>B*2){
      i=i;
    }
    else if (B*2>=C && C*2>B*2){
      i=i+1;
    }
    else if (B*2>=C*2 && C*2*2>B*2){
      i=i+2;
    }
    else if (B*2>=C*2*2 && C*2*2*2>B*2){
      i=i+3;
    }
    else if (B*2>=C*2*2*2 && C*2*2*2*2>B*2){
      i=i+4;
    }
  }
  else if (A>=B*2 && B*2*2>A){
    i=i+2;
    if (C>B*2*2){
      i=i;
    }
    else if (B*2*2>=C && C*2>B*2*2){
      i=i+1;
    }
    else if (B*2*2>=C*2 && C*2*2>B*2*2){
      i=i+2;
    }
    else if (B*2*2>=C*2*2 && C*2*2*2>B*2*2){
      i=i+3;
    }
    else if (B*2*2>=C*2*2*2 && C*2*2*2*2>B*2*2){
      i=i+4;
    }
    else if (B*2*2>=C*2*2*2*2 && C*2*2*2*2*2>B*2*2){
      i=i+5;
    }
  }
  else if (A>=B*2*2 && B*2*2*2>A){
    i=i+3;
    if (C*2>B*2*2*2){
      i=i+1;
    }
    else if (B*2*2*2>=C*2 && C*2*2>B*2*2*2){
      i=i+2;
    }
    else if (B*2*2*2>=C*2*2 && C*2*2*2>B*2*2*2){
      i=i+3;
    }
    else if (B*2*2*2>=C*2*2*2 && C*2*2*2*2>B*2*2*2){
      i=i+4;
    }
    else if (B*2*2*2>=C*2*2*2*2 && C*2*2*2*2*2>B*2*2*2){
      i=i+5;
    }
    else if (B*2*2*2>=C*2*2*2*2*2 && C*2*2*2*2*2*2>B*2*2*2){
      i=i+6;
    }
  }
  
  if (K>=i){
    cout << "Yes" << endl;
  }
  else if (K<i){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();

        if (k % 2 != 0) {
            System.out.println((k + 1) / 2 * ((k + 1) / 2 - 1));
        } else {
            System.out.println(k / 2 * (k / 2));
        }

    }
}






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


int main() {
	int a, b; std::cin >> a >> b;
	std::cout << std::max(0, a - 2 * b) << std::endl;
}

Measured memory_bytes: 888
n = int(input())
A = list(map(int, input().split()))
ans = float('inf')
# 各Aiを見ていく時 iが奇数、偶数どちらの時の和を負の数にするか
for case in range(2):
    count = 0  # 操作回数
    sum_a = 0  # Ai までの数の和
    up = case  # 和を正整数にするか
    for a in A:
        sum_a += a
        diff = 0  # a をどの程度操作するか。
        if up:  # 正整数であるべき
            if sum_a < 1:  # 1未満の数(0か負数)
                diff = 1 - sum_a
        else:  # 負整数であるべき
            if -1 < sum_a:  # -1より大きい数(0か正整数)
                diff = -1 - sum_a
        sum_a += diff  # Ai までの和に操作後の値を適用する
        count += abs(diff)  # 操作回数を加算する
        up ^= 1  # 次回は今回とは逆の符号にする
    ans = min(count, ans)  # 最小操作回数を更新
print(ans)


Measured memory_bytes: 14332
#include<bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using vl=vector<ll>;
using vp=vector<pll>;
const ll INF=1e18;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    cout<<s;
    if(s.back()=='s') cout<<'e';
    cout<<'s';
    return 0;
}

Measured memory_bytes: 3620
A, B, C = map(int, input().split())
K = int(input())

def solve(A, B, C, K):
    while (A >= B):
        B *= 2
        K -= 1
        if K < 0:
            print("No")
            return
    
    while (B >= C):
        C *= 2
        K -= 1
        if K < 0:
            print("No")
            return
    
    print("Yes")
    return

solve(A, B, C, K)

Measured memory_bytes: 9124
#include<iostream>

using namespace std;

int func(int n)
{
  int sum = 0;
  while(n > 0){
    sum += n%10;
    n = n/10;
  }
  return sum;
}

int main(){

  int N,A,B;
  int sum = 0;
  cin >> N >> A >> B;
  for(int i=1;i<=N;i++)
  {
    if(func(i) >= A && func(i) <= B)
    {
      sum += i;
    }
  }

  cout << sum << endl;

  return 0;
}

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

a = list(map(int, input().split()))
b = []
for i in range(n):
    if a[i] % 2 == 0:
        b.append(a[i])

for i in range(len(b)):
    if b[i] % 3 != 0 and b[i] % 5 != 0:
        print('DENIED')
        exit()

print('APPROVED')

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<pair<int, int>> p(n);
  int ans = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    ans -= b;
    p[i] = make_pair(a, b);
  }
  sort(all(p), [](auto x, auto y) { return x.first + x.second > y.first + y.second; });

  int cnt = 0;
  for (auto x : p) {
    if (cnt % 2 == 0) ans += x.first + x.second;
    cnt++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import fractions

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

if N == 1:
    print(abs(X - x[0]))
    exit()

distance_to_x0 = abs(X-x[0])
distance_to_x1 = abs(X-x[1])
candidate = fractions.gcd(distance_to_x0, distance_to_x1)

for x_i in x:
    distance = abs(X-x_i)
    candidate = fractions.gcd(candidate, distance)

print(candidate)


Measured memory_bytes: 16240
h,w = map(int,input().split())
data_t = []
for _ in range(h):
    list_ = str(input())
    data_t.append(list_)

""" data preparation """
data = []
datamaplt = []
datamaprt = []
datamaplb = []
datamaprb = []

data.append([])
datamaplt.append([])
datamaprt.append([])
datamaplb.append([])
datamaprb.append([])
for _ in range(w+2):
    data[0].append(10**9)
    datamaplt[0].append(10**9)
    datamaprt[0].append(10**9)
    datamaplb[0].append(10**9)
    datamaprb[0].append(10**9)

for i in range(h):
    data.append([])
    data[i+1].append(10**9)
    datamaplt.append([])
    datamaplt[i+1].append(10**9)
    datamaprt.append([])
    datamaprt[i+1].append(10**9)
    datamaplb.append([])
    datamaplb[i+1].append(10**9)
    datamaprb.append([])
    datamaprb[i+1].append(10**9)
    for  j in range(w):
        if data_t[i][j] == "#":
            data[1+i].append(1)
        else:
            data[1+i].append(0)
        datamaplt[1+i].append(0)
        datamaprt[1+i].append(0)
        datamaplb[1+i].append(0)
        datamaprb[1+i].append(0)
    data[i+1].append(10**9)
    datamaplt[i+1].append(10**9)
    datamaprt[i+1].append(10**9)
    datamaplb[i+1].append(10**9)
    datamaprb[i+1].append(10**9)

data.append([])
datamaplt.append([])
datamaprt.append([])
datamaplb.append([])
datamaprb.append([])
for _ in range(w+2):
    data[h+1].append(10**9)
    datamaplt[h+1].append(10**9)
    datamaprt[h+1].append(10**9)
    datamaplb[h+1].append(10**9)
    datamaprb[h+1].append(10**9)

""" data preparation """




for i in range(h):
    for  j in range(w):
        ii = i+1
        jj = j+1
        if data[ii][jj] == 0:
            fromtop = datamaplt[ii-1][jj]+1
            fromleft = datamaplt[ii][jj-1]+1
            datamaplt[ii][jj] = min(fromtop,fromleft)

    for  j in range(w-1,-1,-1):
        ii = i+1
        jj = j+1
        if data[ii][jj] == 0:
            fromtop = datamaprt[ii-1][jj]+1
            fromright = datamaprt[ii][jj+1]+1
            datamaprt[ii][jj] = min(fromtop,fromright)

for i in range(h-1,-1,-1):
    for  j in range(w):
        ii = i+1
        jj = j+1
        if data[ii][jj] == 0:
            frombottom = datamaplb[ii+1][jj]+1
            fromleft = datamaplb[ii][jj-1]+1
            datamaplb[ii][jj] = min(frombottom,fromleft)

    for  j in range(w-1,-1,-1):
        ii = i+1
        jj = j+1
        if data[ii][jj] == 0:
            frombottom = datamaprb[ii+1][jj]+1
            fromright = datamaprb[ii][jj+1]+1
            datamaprb[ii][jj] = min(fromright,frombottom)
            
ans = 0  
for i in range(h):
    for  j in range(w):
        ii = i+1
        jj = j+1
        min_temp = min(datamaplt[ii][jj],datamaprt[ii][jj],datamaplb[ii][jj],datamaprb[ii][jj])
        if min_temp > ans:
            ans =  min_temp
            
print(ans)


Measured memory_bytes: 98012
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int a[105];
int main()
{
    int n;
    scanf("%d",&n);
    int i;
    a[0]=0;
    for(i=1; i<=n; i++)
    {
        int x;
        scanf("%d",&x);
        a[i]=a[i-1]+x;
    }
    int t=1;
    int min1=105;
    while(t<n)
    {
        if(abs(a[n]-2*a[t])<=min1)
        {
            min1=abs(a[n]-2*a[t]);

        }t++;


    }
    printf("%d\n",min1);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int a[101][101], b[101], c[101];
    int i, j;
    int n, m;
 
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    }
    for (j = 0; j < m; j++) scanf("%d", &b[j]);
 
    for (i = 0; i < n; i++) {
        c[i] = 0;
        for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
    }
 
    for (i = 0; i < n; i++) {
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
map<ll,ll> m;
void solve()
{
	ll n;
	cin>>n;
	ll x=100;
	ll y;
	for(ll i=0;i<=1000000;i++)
	{
		if(x>=n)
		{
			cout<<(i)<<endl;
			break;
		}
		y=(x/100);
		x+=y;
	}

}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 3636