akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++)
			a[i] = sc.nextInt();
		Arrays.sort(a, Collections.reverseOrder());
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0)
				alice += a[i];
			else
				bob += a[i];
		}
		System.out.println(alice - bob);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N, x;
    cin >> N >> x;

    ll a[N];
    for(int i=0; i<N; i++) cin >> a[i];

    ll ans = 0;
    for(int i=1; i<N; i++){
        ll sum = a[i] + a[i-1];
        if(sum <= x) continue;

        ll d = sum - x;
        ans += d;
        if(a[i] >= d) a[i] -= d;
        else{
            a[i-1] -= (d-a[i]);
            a[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){


	int A, B, X; std::cin >> A >> B >> X;
	if(A <= X && X <= A + B)std::cout << "YES";
	else std::cout << "NO";


	return 0;
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin >> x;
    ll ans=(x/11)*2;
    if(x%11>6)      ans+=2;
    else if(x%11>0) ans+=1;
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main(void) {
	char a[100], b[100];
	int count = 0;
	int i;
	//vector<char> a, b;

	cin >> a;

	for ( i = 0; a[i] != '\0'; i++){}
	int length = i - 1;
	for (int j = 0 ;j != i; j++) {
		b[j] = a[(i - 1) - j];
	}
	for (int i = 0; ; i++) {
		if (a[i] != b[i])
			count++;
		if (i == length / 2)
			break;
	}
	cout << count << endl;

	return 0;
}

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

#define N 100010
int n, m;
int pre[N], sze[N];
int find(int x) {
	return pre[x] == 0 ? x : pre[x] = find(pre[x]);
}
void join(int x, int y) {
	x = find(x), y = find(y);
	if (x != y) {
		if (sze[x] > sze[y]) {
			swap(x, y);
		}	
		pre[x] = y;
		sze[y] += sze[x];
	}
}

int main() {
	while (scanf("%d%d", &n, &m) != EOF) {
		for (int i = 1; i <= n; ++i) {
			pre[i] = 0;
			sze[i] = 1;
		}
		for (int i = 1, u, v, w; i <= m; ++i) {
			scanf("%d%d%d", &u, &v, &w);
			join(u, v);
		}
		int res = 0;
		for (int i = 1; i <= n; ++i) {
			if (find(i) == i) {
				++res;
			}
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, q; cin>>n>>q;
    string s; cin>>s;

    vector<int> sum(n+10, 0);
    for(int i=0; i<n; i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            if(i == 0){
                sum[0] = sum[1] = 1;
            }
            else{
                sum[i] = sum[i-1] + 1;
                sum[i+1] = sum[i];
            }
            i++;
        }
        else{
            if(i == 0){
                sum[0] = 0;
            }
            else{
                sum[i] = sum[i-1];
            }
        }
    }

    while(q--){
        int a, b; cin>>a>>b;
        a--, b--;
                
        int ans;
        if(a == 0){
            ans = sum[b];
        }
        else{
            ans = sum[b] - sum[a-1];
        }
        if(b+1<n && s[b] == 'A' && s[b+1] == 'C') ans--;
        
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
/*
Author：Owen_Q
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int maxn = 1e7+5;
 
vector<int> col;
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen(".txt","r",stdin);
    string s;
    int k;
    cin >> s >> k;
    col.clear();
    int len = s.size();
    int num = 1;
    char c = s[0];
    int sum = 0;
    for(int i=1;i<len;i++)
    {
        if(s[i]==c)
            num++;
        else
        {
            col.push_back(num);
            sum += num/2;
            num = 1;
            c = s[i];
        }
    }
    col.push_back(num);
    int siz = col.size();
    if(siz==1)
    {
        cout << (ll)(len)*(ll)(k)/2LL << "\n";
    }
    else if(s[0]==s[len-1])
    {
        sum -= col[0]/2;
        cout << (ll)(sum)*(ll)(k) + (ll)(col[0]/2) + (ll)(col[siz-1]/2) + (ll)((col[0]+col[siz-1])/2) * (ll)(k-1);
    }
    else
    {
        sum += col[siz-1]/2;
        cout << (ll)(sum)*(ll)(k) << "\n";
    }
    return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    int n,total_even(0);  cin >> n;
    vector<int> v(n);
    bool ev(true);
    rep(i,n){
        cin >> v[i];
        if(v[i]%2==0){
            total_even++;
            ev = false;
        }
    }

    int ans(pow(3,n));

    if(ev){
        ans--;
    }else{
        ans -= pow(2,total_even);
    }

    cout << ans << endl;

    return 0;
}

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

template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int n,k,c;cin>>n>>k>>c;
  string s;cin>>s;
  vector<int> v(n,0);
  int cnt=0;
  for(int i=n-1;i>=0;i--){
    if(s[i]=='o'){
      cnt++;
      v[i]=cnt;
      i-=c;
    }
  }
  for(int i=n-1;i>0;i--)chmax(v[i-1],v[i]);
  int now=0;
  for(int i=0;i<n;i++){
    if(i<n-1){
      if(s[i]=='o'){
        if(v[i+1]+now<k)cout<<i+1<<" ";
        now++;
        i+=c;
      }
    }
    else{
      if(s[i]=='o'&&now<k)cout<<i+1;
    }
  }
  cout<<endl;
}


Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v(5);
  int a;
  for (int i=0; i<5; i++) {
    cin >> v.at(i);
    if (v.at(i) == 0) {
      a = i;
    }
  }
  cout << a+1;
}

Measured memory_bytes: 3568
function main()
	n = parse(readline())
	a = parse.(split(readline()))
	min = 999999999
	for i in 1:n
		check = 0
		q = 2
		while a[i]%q ==0
			check = check+1
			q = q*2
		end
		if check < min
			min = check
		end
	end
	print(min)
end


main()

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

int main(){
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    
    if(s==u) cout<<a-1<<" "<<b<<endl;
    else if(t==u) cout<<a<<" "<<b-1<<endl;
    
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

#ifdef LOCAL
  #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> mp;

  REP(i, n) {
    uint num;
    scanf("%u", &num);
    mp[num]++;
  }

  int ans = 0;
  for(auto &m : mp) {
    if(m.second % 2 == 1) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 4864
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = 1; i <= test_cases; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {
    void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int a = in.nextInt();
        out.println(n * n - a);
    }
}


class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

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

 main() {
int n;
cin >>n;
vector<int>a(n);
int che =0;
for(int i=0;i<n;i++){
  cin >>a.at(i);
  che+=a.at(i);
}
sort(a.begin(),a.end());
if(che%10==0){
  bool chea =true;
for(int i=0;i<n;i++){
  if(a.at(i)%10!=0){
    che-=a.at(i);
    chea =false;
    break;
  }
}
if(chea){
  cout <<0 <<endl;
}
else{
cout <<che <<endl;
}
}
else{
  cout <<che <<endl;
}
 }




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define yzh 2333333
#define bql 2147483647
using namespace std;
int a[10],k;
int main()
{
  for (int i=1;i<=5;i++)
       cin>>a[i];
  cin>>k;
  for (int i=1;i<=4;i++)
	   for (int j=i+1;j<=5;j++)
    if (abs(a[i]-a[j])>k)
    {
      cout<<":(\n";
			return 0;
    }

  cout<<"Yay!\n";
  return 0;
}


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

bool f(int x) {
    if (x < 2) return false;
    if (x == 2) return true;
    if (x%2 == 0) return false;

    double y = sqrt(x);
    for (int i = 3; i <= y; i += 2) {
        if (x%i == 0) return false;
    }
    return true;
}

int main() {
    int x;
    cin >> x;
    for (int i = x;; i++) {
        if (f(i)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
 		
int main() {

int N,Y;
cin>>N>>Y;
	int h=-1,i=-1,j=-1;
	for(int x=0;x<=Y/10000;x++){
		for(int y=0;y<=Y/5000;y++){
          if(N-x-y<0){break;}
			if(x*10000+y*5000+(N-x-y)*1000==Y){
				h=x;
				i=y;
				j=N-x-y;
				x=Y;y=Y;
			}
		}
	}
	cout<<h<<' '<<i<<' '<<j<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

int main() {
	int N, i,H,MAX=0,ans=0;
	cin >> N;
	REP(i, N) {
		cin >> H;
		if (MAX <= H)
			ans++;
		MAX = max(MAX, H);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
 int64_t sum=0;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum+=a[i]*a[j];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()


int main(){
  ll N;
  P ru,lu,rd,ld;
  cin >> N;
  rep(i,N){
    ll x,y;
    cin >> x >> y;
    if(i==0){
      ru=P(x,y);
      lu=P(x,y);
      rd=P(x,y);
      ld=P(x,y);
    }else{
      if(ru.first+ru.second<x+y){
        ru=P(x,y);
      }
      if(ld.first+ld.second>x+y){
        ld=P(x,y);
      }
      if(-lu.first+lu.second<-x+y){
        lu=P(x,y);
      }
      if(-rd.first+rd.second>-x+y){
        rd=P(x,y);
      }
    }
  }
  cout << max(abs(ru.first-ld.first)+abs(ru.second-ld.second),abs(lu.first-rd.first)+abs(lu.second-rd.second)) << endl;
}

Measured memory_bytes: 3560
//~raam
//~created : Jul 17, 2020 - 6.55.06 PM IST

using namespace std;
#include "bits/stdc++.h"

#define ll long long

const int mod = 1e9 + 7;
const int mxN = 1005;
int n, m;
int dp[mxN][mxN];
char s[mxN][mxN];

int find(int i, int j){
   if(i < 0 || j < 0 || i >= n || j >= m || s[i][j] == '#'){
      return 0;
   }
   if(i == 0 && j == 0){
      return 1;
   }
   if(dp[i][j] != -1){
      return dp[i][j];
   }
   return dp[i][j] = (find(i - 1, j) % mod + find(i, j - 1) % mod) % mod;
}
void solve(){
   cin >> n >> m;
   for(int i = 0; i < n; ++i){
     for(int j = 0; j < m; ++j){
     	cin >> s[i][j];	
     }
   }
   memset(dp, -1, sizeof(dp));
   find(n - 1, m - 1);
   cout << (dp[n - 1][m - 1] == -1 ? 0 : dp[n - 1][m - 1]);
}

int main(){

   ios_base::sync_with_stdio(0);
   cin.tie(0);

   int t; t=1;
   while(t--)solve();
}


Measured memory_bytes: 8652
fun main(args: Array<String>) {
  val (r, D, x2000) = readInts()
  var x = x2000.toLong()
  for (i in 1..10) {
    x = x * r - D
    println(x)
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 36336
<?php
list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
$checked = [];
$i = 0;
while (!isset($cheked[$i])) {
    $cheked[$i] = true;
    $i = ($i + $a) % $b;
    if ($i == $c) {
        echo 'YES'.PHP_EOL;
        exit;
    }
}
echo 'NO'.PHP_EOL;


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

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (int i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vii vector<int>
#define vvl vector<vector<ll>>
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;
ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ceel(ll a,ll b){if(a%b==0) return a/b;else return a/b+1;}


#define MAX_SIZE 1005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
            for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
    for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}
        


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};



//---------VIPUL SHARMA----------\\


void solve(){
    string n;
    cin>>n;
    if(n[sz(n)-1]!='s')cout<<n<<"s"<<nl;
    else cout<<n<<"es"<<nl;


}



int main(){
    //vector<int> primes;
    //Sieve(primes);

    fast
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }
    
    return 0;
}










Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long;


int main()
{
    int N;
    ll A[200010],B[200010];
    cin>>N;
    rep(i,N){
        cin>>A[i]>>B[i];
    }
    sort(A,A+N);
    sort(B,B+N);
    if(N%2==0){
        ll min = (A[N/2]+A[N/2-1]);
        ll max = (B[N/2]+B[N/2-1]);
        cout << max-min+1 << endl;
    }else{
        cout << B[N/2]-A[N/2]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 6760
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=0,m=0;
        if(scan.hasNext())
            n=scan.nextInt();
        if(scan.hasNext())
            m=scan.nextInt();
        if(n==m){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;

  int a = X/(Y+Z);
  if(X < ((Y+Z)*a) + Z){
   cout << a - 1 << endl;;
  }else{
    cout << a << endl;
  }
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

if N <= K:
    print(min(K-N, N))
# elif K == 1:
#     print(0)
else:
    print(min(N % K, K - N % K))
    # a = N // K
    # b = ceil(N / K)
    # c = N % K
    # print(a, b, c)
    # print(abs(c-K), abs(c))

    # x = N // (N - K)
    # y = x + 1
    # z = x - 1
    # print(x, y, z)
    # a = N - x * (N-K)
    # b = N - y * (N-K)
    # c = N - z * (N-K)
    # print(a, b, c)
    # ans = min(abs(a), abs(b), abs(c))
    # print(ans)

# if N >= K:
#     ans = min(abs(a), abs(b))
# # K > N:
# else:
#     ans = min(K-N, N)
# print(ans)


Measured memory_bytes: 5200
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        double[] p = new double[N];
        for (int i = 0; i < p.length; i++) {
            p[i] = sc.nextDouble();
        }

        double[] dp = new double[N + 1];
        // dp[i] stores probability to get i heads, N - i tails
        // We implicitly store, with how many coins can we achieve this outcome
        // But really, we just go through all the coins and transition
        // the current heads to the new state, of using 1 more coin.
        dp[0] = 1;
        for (int coin = 0; coin < N; coin++) {
            for (int heads = N; heads >= 0; heads--) {
                // We must go downwards, because at each position,
                // we must rely on the answer for a smaller problem, then
                // update us!
                // In order to preserve this # heads, it's harder
                dp[heads] *= (1 - p[coin]);

                // There's a new way to reach this
                if (heads > 0) {
                    dp[heads] += dp[heads - 1] * p[coin];
                }
            }
        }
        double sum = 0;
        for (int heads = N / 2 + 1; heads <= N; heads++) {
            sum += dp[heads];
        }
        out.println(sum);
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

        double nextDouble() throws IOException { return Double.parseDouble(next()); }

        int nextInt() throws IOException { return Integer.parseInt(next()); }

        long nextLong() throws IOException { return Long.parseLong(next()); }
    }
}

Measured memory_bytes: 24916
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
#define INF 100000000
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();

main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
    int tc=1;
    // tc=in();
    while(tc--){
        go();
    }
    return 0;
}

void go(){
    int n=in();
    cout<<(n+1)/2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int idx=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C') idx=1;
		if(idx && s[i]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
int main(){
	int a,b;
	cin>>a>>b;
	if ((a+b)%2==0)
		cout<<(a+b)/2<<endl;
	else
		cout<<"IMPOSSIBLE"<<endl;
}
	

Measured memory_bytes: 256
/* HARDWORK IS THE KEY TO SUCCESS.
       RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
    #include <bits/stdc++.h>
    #define pragma
    using namespace std;
    #define ll long long
    #define ld long double
    #define T ll t = 1; cin>>t; while(t--)
    #define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
    #define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
    #define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
    #define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
    #define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
    #define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
    #define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
    #define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
    #define F first
    #define S second
    #define I insert
    #define pb push_back
    #define ppb pop_back
    #define AISORT sort(a,a+n)
    #define ADSORT sort(a,a+n,greater<ll>())
    #define VISORT sort(x.begin(),x.end())
    #define VDSORT sort(x.begin(),x.end(),greater<ll>())

    const ll maxs = 1e5+3;
    const ll maxs1 = 1e3+4;
    const ll mod = 1e9 + 7;

    //MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

    //POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

    //MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
    bool vis[maxs];
    vector<ll>graph[maxs];
    //ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
    //ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES


    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
      ll n,m;
        cin >> n >> m;
        if(n < 2 && m < 2)
        {
            cout << 0 ;
            return 0;
        }
            
        ll ans = n * (n - 1) / 2;
        ll ANS = m * (m - 1) / 2;
        cout << ans + ANS;
    }


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; ++i)
  {
    cout << s[i] << t[i];
  }
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main()
{
  uint64_t N, X;
  cin >> N >> X;
  vector<uint64_t> v;
  v.reserve(100001);
  v.push_back(X);
  for (auto i = 0; i < N; i++) {
    uint64_t x;
    scanf("%lu", &x);
    v.push_back(x);
  }
  sort(begin(v), end(v));
  vector<uint64_t> distance;
  for (auto i = 1; i < v.size(); i++) {
    distance.push_back(v[i] - v[i - 1]);
  }
  sort(begin(distance), end(distance));
  uint64_t n {distance[0]};
  for (auto i = 0; i < distance.size(); i++) {
    n = __gcd(n, distance[i]);
  }
  cout << n << endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll s, c;
  cin >> s >> c;

  if (s >= c) {
    cout << c / 2 << endl;
    return 0;
  }
  ll cnt = s;
  ll n   = c - (s * 2);
  cnt += (n / 4);
  cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    D, X = map(int, input().split())
    S = [int(input()) for _ in range(N)]

    result = 0
    for s in S:
        result += len(range(1, D + 1, s))
    print(result + X)


if __name__ == "__main__":
    main()


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

int main(){
 int n,m;
cin >> n >> m;
vector<int> vec(n,0);
vector<int> are(n,0);
vector<vector<int> > miti(m,vector<int>(2));
 
for (int i=0;i<n;i++){
	cin >> vec.at(i);
	}
for (int i=0;i<m;i++){
      for(int j=0;j<2;j++){
        cin >> miti.at(i).at(j);
      }
	}
    for (int i=0;i<m;i++){
    int a,b;
    a = miti.at(i).at(0)-1;
    b = miti.at(i).at(1)-1;
	are.at(a)= max(vec.at(b),are.at(a));
    are.at(b)= max(vec.at(a),are.at(b));
	}
  int output=0;
  for (int i=0;i<n;i++){
  if(vec.at(i)>are.at(i)){
  		output ++;
  		}
	}
  cout << output << endl;
}

Measured memory_bytes: 9524
# coding: utf-8
n = int(input())
t_p = 0
h_p = 0

for _ in range(n):
    t_w, h_w = input().split()
    if t_w > h_w:
        t_p += 3
    elif h_w > t_w:
        h_p += 3
    else:
        t_p += 1
        h_p += 1
        
print(t_p, h_p)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, X, T;
    cin >> N >> X >> T;
    prints()((N + X - 1) / X * T);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

long long nzero_cnt(string N, int K) {
    int L = N.size();

    vector <vector<vector<long long>>> dp(L + 1, vector<vector<long long>>(K + 1, vector<long long>(2)));
    //dp[i桁番目まで確定][非ゼロの個数][N未満確定]
    dp[0][0][0] = 1;
    for (int i = 0; i < L; i++) {
        for (int j = 0; j <= K; j++) {
            for (int k = 0; k < 2; k++) {
                for (int d = 0; d <= (k ? 9 : N[i] - '0'); d++) {
                    if (j == K && d != 0) continue;
                    int temp = 0;
                    if (d != 0)temp = 1;
                    //cout << d<<" ";

                    dp[i + 1][j+temp][k || (d < N[i]-'0')] += dp[i][j][k];
                }
                //cout << endl;
            }
        }
    }
    /*
    for (int i = 0; i <= L; i++) {
        for (int j = 0; j <= K; j++) {
            for (int k = 0; k < 2; k++)
                printf("dp[%d][%d][%d]=%lld ", i, j, k, dp[i][j][k]);
        }
        cout << endl;
    }
    */
    return dp[L][K][1] + dp[L][K][0];
}

int main() {
    string  N;
    int K;
    cin >> N >> K;

    
    cout << nzero_cnt(N,K) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


const int MOD = 1e9+7;
class matrixExponentiation{
	public : 
	vector<vector<int>> multiply(vector<vector<int>>a ,vector<vector<int>> b , int n)
	{
		int M=1e9+7;
		vector<vector<int>>c(n,vector<int>(n));
		for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			for(int ic=0,jr=0;ic<n && jr<n;ic++,jr++)
			{
				c[i][j]+=a[i][ic] * b[jr][j];
				c[i][j]%=M;                            /*      MOD Should be taken care of     */
			}
		}
		return c;
	}
	vector<vector<int>> solve(vector<vector<int>>mat,int p)
	{
		int n=mat.size();
		vector<vector<int>>a(n,vector<int>(n));
		for(int i=0;i<n;i++)a[i][i]=1;
		while( p )
		{
			if( p & 1 )
			{
				a=multiply( a , mat , n);
			}
			mat=multiply( mat , mat , n);
			p>>=1;
		}
		return a;
	}
};

int32_t main()
{
	IOS
	int n , k ; cin >> n >> k;
	vector<vector<int>>a(n,vector<int>(n));
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	cin>>a[i][j];
	
	matrixExponentiation Mxp;
	a = Mxp.solve(a,k);
	
	int ans = 0;
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	ans+=a[i][j],ans%=MOD;
	
	cout << ans << endl;
	
	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    string S;
    cin >> S;
    vector<int> vec(3, 0);
    rep(i, S.size()) {if (S[i] == 'a') vec[0] += 1; if (S[i] == 'b') vec[1] += 1; if (S[i] == 'c') vec[2] += 1;}
    if (vec[0] == vec[1] && vec[0] == vec[2]) {cout << "YES" << endl; return 0;}
    rep(i, 3) if (vec[i % 3] == vec[(i + 1) % 3] && vec[i % 3] == vec[(i + 2) % 3] + 1) {cout << "YES" << endl; return 0;}
    rep(i, 3) if (vec[i % 3] == vec[(i + 1) % 3] + 1 && vec[i % 3] == vec[(i + 2) % 3] + 1) {cout << "YES" << endl; return 0;}
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3732
n=int(input())
a=[]
for i in range(n):
    s=input()
    k=[]
    for i in range(10):
        k.append(s[i])
    k.sort()
    p="".join(k)
    a.append(p)
a.sort()
bef=a[0]
cnt=0
sum=0
for i in range(n):
    if bef==a[i]:
        cnt+=1
    else:
        sum+=(cnt*(cnt-1)//2)
        cnt=1
        bef=a[i]
    if i==n-1:
        sum+=(cnt*(cnt-1)//2)
print(sum)


Measured memory_bytes: 10640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {   
    string s;
    cin >> s;
    if (s.size() == 3) reverse(s.begin(), s.end());
    cout << s << endl;
}




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

int main()
{
    int k, s;
    int x, y, z;
    int ans = 0;

    cin >> k >> s;

    for (x = 0; x <= k; x++) {
        for (y = 0; y <= k; y++) {
            if (s - (x + y) <= k && s - (x + y) >= 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;
    
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	string ans = "";
	while (N != 0) {
		if (N % 2 != 0) {
			N--;
			ans = "1" + ans;
		}
		else ans = "0" + ans;
		N /= -2;
	}

	if (ans == "") ans = "0";

	cout << ans << endl;
	return 0;
}


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

using namespace std; 
int main()
{
	int n,c=1,owo=0;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	for(int i=0;i<n;i++)
	{
		if(c != v[i])
			owo++;
		c++;
	}
	if(owo <=2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	
	return 0;		
}




Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)
ans = 0
 
n.times {|i|
    ans += b[a[i] - 1]
    if (a[i] + 1 == a[i + 1]) then ans += c[a[i] - 1] end
}

puts ans

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

int main()
{
    int a, b;
    cin >> a >> b;

    const int n = 100;
    bool f;

    cout << "100 100" << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i < 50) f = (i * j % 2 && --a > 0 ? true : false);
            else f = (i * j % 2 && --b > 0 ? false : true);
            cout << (f ? '.' : '#');
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// solv_D.cpp : 
//

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;


ull N, K;


const ll mod = 1E9 + 7;

ll my_plus(ll a, ll b) {
    return (a % mod + b % mod) % mod;
}


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

    ll k;
    ll ans = 0;
    ll num;
 
    for (k = K; k <= N+1; k++) {
        num = k * (N -k) +  k  + 1;
        
        ans = my_plus(ans, num);
    }

    cout << ans << endl;
}



Measured memory_bytes: 3232
import sys
input = sys.stdin.readline

S=list(input()[:-1])
Q=int(input()[:-1])
f=0
back=[]
forward=[]

for _ in range(Q):
    q=input().split()
    if int(q[0])==1:
        f = (f+1)%2
    if int(q[0])==2:
        if int(q[1])==1:
            if f==0:
                forward.append(q[2])
            else:
                back.append(q[2])
        else:
            if f==0:
                back.append(q[2])
            else:
                forward.append(q[2])

if f==0:
    print("".join(forward[::-1]+S+back))
else:
    print("".join((forward[::-1]+S+back)[::-1]))

Measured memory_bytes: 75068
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int[] a = new int[3];
		int[] b = new int[2];
		for(int i = 0; i <3; i++) a[i] = in.nextInt();
		for(int j = 0; j <2; j++) b[j] = in.nextInt();
		Arrays.sort(a);
		Arrays.sort(b);

		System.out.println(a[0] + b[0] - 50);
	}

	
}

Measured memory_bytes: 26320
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        //scanner.nextLine();
        int k = scanner.nextInt();
        //scanner.nextLine();

        if(k == 1) {
            System.out.println(0);
        } else {
            System.out.println(n - k);
        }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
  int i,j,n,key,k,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");

  for(i=1;i<n;i++){
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    for(k=0;k<n;k++){
      if(k>0)printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2136
#include<stdio.h>
int main(){
	int H,W;
	for(int i=0;i<300;i++){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

bool cmp(P a,P b) {
    return a.second < b.second;
}

int main() {
    int n;
    cin >> n;
    vector<P> robots(n);
    rep(i,n) {
        ll x,l,a,b;
        cin >> x >> l;
        a = x-l; b = x+l;
        robots[i] = {a,b};
    }
    sort(robots.begin(),robots.end(),cmp);
    ll ans = 0,now = -1e9;
    for(P p : robots) {
        if(now <= p.first) {
            ans++;
            now = p.second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
s = input()
k = int(input())
one_cnt = 0

for i in range(len(s)):
  if s[i] == '1':
    one_cnt += 1
  else:
    break

if k <= one_cnt:
  print(1)
  exit()

for i in range(len(s)):
  if s[i] != '1':
    print(s[i])
    exit()

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n;
    std::cin >> n;

    if (n % 2) {
        std::cout << 0 << std::endl;
    } else {
        i64 a = 10, ret = 0;
        while (a <= n) {
            ret += n / a;
            a *= 5;
        }
        std::cout << ret << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
import collections
c = collections.Counter(a)
li = []
ans = 0
for v,num in  c.items():
    li.append((v,num))
ll = sorted(li,key=lambda x: x[1],reverse=True)

for i in range(k,len(ll)):
    #print(ll[i][1])
    ans += ll[i][1]

print(ans)

Measured memory_bytes: 44352
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve2(N, a) ? YES : NO);
    }

    /**
     * Petr解を参考: https://atcoder.jp/contests/agc035/submissions/6371518
     * PairやArrayListを使わないので実装量が少なくて済む
     */
    private static boolean solve2(int N, int[] a) {
        Arrays.sort(a);

        if (N%3 != 0) {
            if (a[0] == 0 && a[N-1] == 0) return true;

            return false;
        }

        int p = N/3;
        if (a[0] == 0 && a[p-1] == 0 && a[p] == a[N-1]) return true;
        if (a[0] == a[p-1] && a[p] == a[2*p-1] && a[2*p] == a[N-1] && (a[0] ^ a[p] ^ a[2*p]) == 0) return true;

        return false;
    }
}

Measured memory_bytes: 50320
#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(){
    ll x;
    cin >> x;
    ll now = 100;
    ll i = 0;
    while(now < x){
        now += now/100;
        i++;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 3632
n = int(input())
S = list(input() for i in range(n))
alpha = "abcdefghijklmnopqrstuvwxyz"
B = [[0]*n for i in range(26)]
for i in range(n):
    s = S[i]
    for c in s:
        p = alpha.index(c)
        B[p][i] += 1
for i in range(26):
    for j in range(min(B[i])):
        print(alpha[i],end="")
print()

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

int main() {

	int N;
	long long C = 0;

	cin >> N;
	vector<int> A(N);
	vector<int> B(N);

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		B[i] = A[i];
	}

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


	if (B[N - 1] == B[N - 2])
	{
		for (int i = 0; i < N; i++)
		{
			cout << B[N-1]<<endl;
		}
	}
	else {
		for (int i = 0; i < N; i++)
		{
			if (A[i] == B[N - 1])
			{
				cout << B[N - 2] << endl;;
			}
			else {
				cout << B[N - 1]<<endl;
			}
		}

	}

}

Measured memory_bytes: 3200