akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int             long long
#define ip(x)           int x; cin>>x;
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define mod             pow(10,9)+7
#define inf             1e18
#define endl			"\n"
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	ip(a);
	ip(b);
	cout << a*b << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

void dijkstra(vector<vi> &M) {
  auto n = M.size();
  vi d(n, INF);
  vector<bool> visited(n, false);
  d[0] = 0;
  while (true) {
    auto minv = INF;
    auto u = -1;
    REP(i, n) {
      if (!visited[i] && d[i] < minv) {
        minv = d[i];
        u = i;
      }
    }
    if (u == -1) break;
    visited[u] = true;
    REP(i, n) {
      if (!visited[i]) {
        d[i] = min(d[i], d[u] + M[u][i]);
      }
    }
  }
  REP(i, n) cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
}

int main() {
  int n;
  cin >> n;
  vector<vi> M(n, vi(n, INF));
  int k, c, u, v;
  REP(i, n) {
    cin >> u >> k;
    REP(j, k) {
      cin >> v >> c;
      M[u][v] = c;
    }
  }
  dijkstra(M);
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        for (int i = 1, j = m + 1; i < j; i++, j--)
            System.out.println(i + " " + j);
        for (int i = m + 2, j = m * 2 + 1; i < j; i++, j--) {
            System.out.println(i + " " + j);
        }
    }

}


Measured memory_bytes: 46008
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() 
{
      ll n,w;
      cin>>n>>w;
      ll wt[n],val[n];
      for(ll i=0; i<n;i++)
      {
        ll a,b;
        cin>>a>>b;
        wt[i]=a;
        val[i]=b;
      }
      
      ll dp[n+1][w+1];
      for(ll i=0; i<=n;i++)
         dp[i][0]=0;
      for(ll i=0; i<=w;i++)
         dp[0][i]=0;
      
      for(ll i=1; i<=n; i++)
      {
        for(ll j=1; j<=w; j++)
        {
            if(wt[i-1]<=j)
             dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
             else
             dp[i][j]=dp[i-1][j];
             
        }
      }
      cout<<dp[n][w]<<endl;
        return 0;
}

Measured memory_bytes: 82436
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <tuple>
#include <stdlib.h>
using namespace std;
typedef long long int ll;

int main()
{
	long long int ans, K, c = 0, k = 0,t = 0;
	bool one = false;
	string S;
	cin >> S >> K;
	string T = S + S;
	for (int i = 0; i < T.size(); i++)
	{
		if (i != 0 && T[i] == T[i - 1])
		{
			T[i] = 'A';
			c++;
		}
	}
	T=S+S+S;
	for (int i = 0; i < T.size(); i++)
	{
		if (i != 0 && T[i] == T[i - 1])
		{
			T[i] = 'A';
			t++;
		}
	}
	T = S;
	if (T[0] != T[T.size() - 1])one = true;
	for (int i = 0; i < T.size(); i++)
	{
		if (i != 0 && T[i] == T[i - 1])
		{
			T[i] = 'A';
			k++;
			if (i == T.size() - 1)one = true;
		}
	}
	if (one) {
		ans = k*K;
	}
	else ans = (K / 2)*c + (K % 2)*k;
	if (t - c == c - k)ans = k + (K - 1)*(t - c);
	if (T.size() == 1)ans = K / 2;
	cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
 
        if( C>A && C<B || C<A && C>B ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
 
    }
 
}

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

int main(){
    int n, m;
    cin >> n >> m;
    cout << (n==m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int l = S.length();

		if(l == 7) {
			if(S.equals("keyence")) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
			System.exit(0);
		}
		List<String> list = new ArrayList<String>();
		int k = l - 7;
		String[]s = new String[l];
		for(int i = 0; i < l; i++) {
			s[i] = S.substring(i, i + 1);
		}
		for(int i = 0; i < l - k; i++) {
			int a = i;
			int b = k + i;
			String t = "";
			for(int j = 0; j < l; j++) {
				if(j < a || j >= b) {
					t += s[j];
				}
			}
			if(t.equals("keyence")) {
				System.out.println("YES");
				System.exit(0);
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 25172
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>


using namespace std;
#define INF 1000000005
int main()
{
int n;
std::cin >> n;
int cx,cy,eh;

std::vector<std::vector<int>> q;


for(int i = 0; i < n; i++){
    int tx,ty,th;
    std::cin >> tx >> ty >> th;
    std::vector<int> temp;
    temp.push_back(tx);
    temp.push_back(ty);
    temp.push_back(th);
    q.push_back(temp);
}
int flag = 0;
int it;
for(int i = 0; i < n; i++){
    if(q[i][2] != 0){
        it = i;
        break;
    }
}
for(int i = 0; i <= 100; i++){
    flag = 0;
    int max;
    for(int j = 0; j <= 100; j++){
        flag = 0;
        max = q[it][2] + abs(q[it][0] - i) + abs(q[it][1] - j);
        for(int k = 0; k < n; k++){
            if(q[k][2] !=  std::max(max - abs(i - q[k][0]) - abs(j - q[k][1]),0)){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            cx = i;
            cy = j;
            eh = max;
            break;
        }
    }
   if(flag == 0){
        break;
    }
}

std::cout << cx << " " << cy << " " << eh << std::endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    string S;
    cin >> S;
    cout << bitset<6>(S).count() << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        mut n: usize,
        k: usize,
    }

    solve(n, k);
}

fn solve(mut n: usize, k: usize) {
    let mut cnt = 0;
    loop {
        if n <= 1 {
            println!("{}", cnt + n);
            break;
        }

        cnt += 1;
        n = n / k;
    }
}


Measured memory_bytes: 2156
import java.util.Scanner;

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

		a = new int[8][8];
		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 8; j++) {
				String str = sc.next();
				for (int k = 0; k < 8; k++) {
					a[j][k] = str.charAt(k) - '0';
				}
			}
			int x = sc.nextInt();
			int y = sc.nextInt();
			bomb(a, y - 1, x - 1);
			System.out.println("Data " + (i + 1) + ":");
			for (int j = 0; j < 8; j++) {
				for (int k = 0; k < 8; k++) {
					System.out.print(a[j][k]);
				}
				System.out.println();
			}
		}
	}

	public static void bomb(int a[][], int i, int j) {
		if (0 <= i && i < 8 && 0 <= j && j < 8 && a[i][j] == 1) {
			a[i][j] = 0;
			bomb(a, i - 3, j);
			bomb(a, i - 2, j);
			bomb(a, i - 1, j);
			bomb(a, i + 1, j);
			bomb(a, i + 2, j);
			bomb(a, i + 3, j);
			bomb(a, i, j - 3);
			bomb(a, i, j - 2);
			bomb(a, i, j - 1);
			bomb(a, i, j + 1);
			bomb(a, i, j + 2);
			bomb(a, i, j + 3);
		}
	}
}

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

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    int j_N=y+r;
    int j_S=y-r;
    int j_W=x-r;
    int j_E=x+r;

    if (j_N>H || j_S<0 || 
    j_W<0 || j_E>W)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3120
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

using mint = modint998244353;

vector<mint> ten_pow, ones;

struct S {
    int size;
    mint val;
};

S op (S l, S r) {
    return {l.size + r.size, l.val * ten_pow[r.size] + r.val};
}

S e() { return {0, 0}; };

using F = int;

S mapping(F f, S x) {
    if (f == 0) return x;
    return {x.size, f * ones[x.size]};
}

F composition(F f, F g) {
    if (f == 0) return g;
    else return f;
}

F id() { return 0; }

int main() {
    int n, q;
    cin >> n >> q;
    ten_pow.resize(n+1);
    ones.resize(n+1);
    ten_pow[0] = 1;
    for (int i = 1; i <= n; ++i) {
        ten_pow[i] = ten_pow[i-1] * 10;
        ones[i] = ones[i-1] + ten_pow[i-1];
    }
    vector<S> a(n, S{1, 1});
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        seg.apply(l, r+1, d);
        cout << seg.all_prod().val.val() << '\n';
    }
}

Measured memory_bytes: 11368
# ABC162 C

import math

def main():
    k = int(input())

    res = []

    for i in range(1, k+1):
        for j in range(1, k+1):
            for l in range(1, k+1):
                gcd = math.gcd(i, j)
                if gcd==1:
                    res.append(1)
                else:
                    res.append(math.gcd(gcd ,l))
    
    print(sum(res))

def gcd3(a, b, c):
    ans = math.gcd(math.gcd(a, b), c)
    
    return ans

if __name__ == '__main__':
    main()

Measured memory_bytes: 71660
main(n,r,x,y,z,l,w){
  for(;~scanf("%d",&n),n;printf("%d\n",r))
    for(r=0;n;n--){
      scanf("%d%d%d%d",&x,&y,&z,&w),l=x+y+z;
      if(l<=60&&w<=2)r+=600;
      else if(l<=80&&w<=5)r+=800;
      else if(l<=100&&w<=10)r+=1000;
      else if(l<=120&&w<=15)r+=1200;
      else if(l<=140&&w<=20)r+=1400;
      else if(l<=160&&w<=25)r+=1600;
    }
  return 0;
}

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

using namespace std;

int main(void){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(a <= k){
        ans += a;
        k -= a;
    }else{
        ans += k;
        k = 0;
    }
    if(b <= k){
        k -= b;
    }else{
        k = 0;
    }
    ans -= k;
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define zero(dp) memset(dp,0,sizeof(dp))
#define pb emplace_back
using namespace std;
int32_t main(){
/*
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
*/
ios
int t=1;
//cin>>t;
while(t--)
{
	int n;cin>>n;
	int W;cin>>W;
	int w[n],v[n];
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	int dp[n][W+1];
	zero(dp);
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=W;j++)
			dp[i][j]=-1;
	}
	dp[0][w[0]]=v[0];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=W;j++)
		{
			if(dp[i-1][j]!=-1 and j+w[i]<=W)
				dp[i][j+w[i]]=dp[i-1][j]+v[i];
		}
		for(int j=0;j<=W;j++)
			dp[i][j]=max(dp[i-1][j],dp[i][j]);
	}
	int ans=0;
	for(int i=0;i<=W;i++)
		ans=max(ans,dp[n-1][i]);
	cout<<ans;
}
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  long long int r;
  scanf("%lld", &r);
  
  std::cerr << "Answer:" << std::endl;
  std::cout << r*r << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    string s;
    cin >> s;
    unordered_map<char, int> mp;
    int n = s.size();
    for(int i = 0; i < n; i++){
        mp[s[i]]++;
    }

    char max_word;
    // for(auto x : mp){
    //     cout << x.first << endl;
    //     if(freq <= x.second){
    //         freq = x.second;
    //         max_word = x.first;
    //     }
    // }

    int ans = 105;
    for(auto &x : mp){
        //ある文字について，最大区間だけ変換が必要になる
        char word = x.first;
        int max_dist = 0;
        int r = 0;
        for(int l = 0; l < n; l++){
            while(r < n && s[r] != word){
                r++;
            }
            max_dist = max(max_dist, r-l);
            if(l == r) r++;
        }

        x.second = max_dist;
    }

    for(auto &x : mp){
        // cout << x.first << ", max: " << x.second << endl;
        ans = min(ans, x.second);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

n = int(input())
if n == 1:
    print(0)
    exit()
dic = {}
for i in range(2,n+1):
    l = prime_factor(i)
    for x in l:
        if x in dic:
            dic[x] += 1
        else:
            dic[x] = 1
a,b,c,d,e = 0,0,0,0,0
for x in dic.values():
    if x >= 74:
        e += 1
    elif x >= 24:
        d += 1
    elif x >= 14:
        c += 1
    elif x >= 4:
        b += 1
    elif x >= 2:
        a += 1
ans = e #75
ans += (d + e) * (a + b + c) + (d + e) * (d + e - 1) #25*3
ans += (d + e + c) * b + (d + e + c) * (d + e + c- 1) #15*5
f = b + c + d + e
ans += f * (f - 1) // 2 * a + f * (f - 1) * (f - 2) // 2  #5*5*3
print(ans) 

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
struct UnionFind{
	int par[210],rank[210];
	void init(){
		for(int i=0;i<210;i++){par[i]=i;rank[i]=0;}
	}
	int find(int x){
		if(par[x]==x)return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x==y)return;
		if(rank[x]>rank[y])par[y]=x;
		else{
			par[x]=y;
			if(rank[x]==rank[y])rank[y]++;
		}
		return;
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
}uf;
struct edge{
	int from,to,cost;
	edge(){}
	edge(int from,int to,int cost):from(from),to(to),cost(cost){}
	bool operator < (const edge& a) const{
		return cost < a.cost;
	}
};
int n,m,k;
vector<edge> A,B;
int cost,use_a_max,use_a_min,use;
void check(int x){
	uf.init();
	int p = 0,q = 0;
	cost = 0;
	use_a_max = 0;
	use = 0;
	while(p<A.size()||q<B.size()){
		edge e;
		bool flag = false;
		if(p==A.size())e = B[q++];
		else if(q==B.size()){
			e = A[p++];
			flag = true;
		}else{
			if(A[p].cost+x<=B[q].cost){
				e = A[p++];
				flag = true;
			}else e = B[q++];
		}
		if(!uf.same(e.from,e.to)){
			uf.unite(e.from,e.to);
			cost += e.cost;
			if(flag)use_a_max++;
			use++;
		}
	}
	uf.init();
	p = 0,q = 0;
	cost = 0;
	use_a_min = 0;
	use = 0;
	while(p<A.size()||q<B.size()){
		edge e;
		bool flag = false;
		if(p==A.size())e = B[q++];
		else if(q==B.size()){
			e = A[p++];
			flag = true;
		}else{
			if(A[p].cost+x<B[q].cost){
				e = A[p++];
				flag = true;
			}else e = B[q++];
		}
		if(!uf.same(e.from,e.to)){
			uf.unite(e.from,e.to);
			cost += e.cost;
			if(flag)use_a_min++;
			use++;
		}
	}
	return;
}
bool solve(){
	cin >> n >> m >> k;
	if(n==0&&m==0&&k==0)return false;
	A.clear();
	B.clear();
	for(int i=0;i<m;i++){
		int u,v,c;
		char l;
		cin >> u >> v >> c >> l;
		if(l=='A')A.pb(edge(u,v,c));
		else B.pb(edge(u,v,c));
	}
	sort(all(A));
	sort(all(B));
	for(int i=-105;i<=105;i++){
		check(i);
		//cout << i << ' ' << use_a_min << ' ' << use_a_max << ' ' << cost << endl;
		if(use_a_min<=k&&k<=use_a_max&&use==n-1){
			printf("%d\n",cost+i*use_a_min-i*k);
			return true;
		}
	}
	printf("-1\n");
	return true;
}
int main(){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3128
N = int(input())
arr = list(map(int, input().split()))

money = 1000
kabu = 0

for i in range(N-1):
    if arr[i] < arr[i+1]:
        buy = money//arr[i]
        kabu += buy
        money -= buy*arr[i]

    if arr[i] > arr[i+1]:
        money += kabu*arr[i]
        kabu = 0


print(money+kabu*arr[-1])


Measured memory_bytes: 61732
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	int x[105];
	for(int i=1;i<n+1;i++){
		cin >> x[i];
	}
	int ans = 0;
	int d = 0;
	for(int i=1;i<n+1;i++){
		d = min(2*x[i],abs(k-x[i])*2);
		ans += d;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
print(" ".join(map(str,l)))
def insertionSort(a, n):#配列aを挿入ソートで並び替える(昇順）
    for i in range(1,n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]#a[i]の位置に詰めていく処理
            j -= 1
        a[j+1] = v
        print(" ".join(map(str,a)))#１行ごとに出力
insertionSort(l,n)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

ll modP(ll x, ll y, ll MOD)
{
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
 
 ll a,b,c,k; 
 cin>>a>>b>>c>>k; 
 

 while(b<=a) 
 {
     b*=2; 
     ans++;
 }
while(c<=b) 
{
    c*=2; 
    ans++;
}

  if(ans<=k) 
  {
cout<<"Yes";
  }
  else 
  cout<<"No";
    //cout << ans << "\n";
}int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
   
    for (int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}





Measured memory_bytes: 3612
import math
import pprint
import fractions
import collections
import itertools
N,M,Q=map(int,input().split())
req=[list(map(int,input().split())) for _ in range(Q)]
seq=list(range(1,M+1))
l=list(itertools.combinations_with_replacement(seq,N))
#print(l)
score=0
maxscore=0
buf=[]
for i in range(len(l)):
    score=0
    buf=list(l[i])
    for j in range(Q):
        left,right,dist,num=map(int,req[j])
        left=left-1
        right=right-1
        if buf[right]-buf[left]==dist:
            score=score+num
    maxscore=max(score,maxscore)
print(maxscore)







Measured memory_bytes: 90628
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll n, m;
ll a[200010];
ll seg[800000];
ll sum[200010];
vector<ll> vt;
ll getidx(ll x)
{
	return lower_bound(vt.begin(), vt.end(), x) - vt.begin();
}
ll update(ll pos, ll val, ll node, ll x, ll y)
{
	if (pos < x || y < pos)return seg[node];
	if (x == y)return seg[node] += val;
	ll mid = (x + y) / 2;
	return seg[node] = update(pos, val, node * 2, x, mid) + update(pos, val, node * 2 + 1, mid + 1, y);
}
ll query(ll lo, ll hi, ll node, ll x, ll y)
{
	if (hi < x || y < lo)return 0;
	if (lo <= x&&y <= hi)return seg[node];
	ll mid = (x + y) / 2;
	return query(lo, hi, node * 2, x, mid) + query(lo, hi, node * 2 + 1, mid + 1, y);
}
int main()
{
	scanf("%lld %lld", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		a[i] -= m;
	}
	for (int i = 1; i <= n; i++)
	{
		sum[i] = a[i]+sum[i-1];
		vt.push_back(sum[i]);
	}
	sort(vt.begin(), vt.end());
	vt.erase(unique(vt.begin(), vt.end()), vt.end());
	ll dap = 0;
	for (int i = n; i>=1; i--)
	{
		ll t = getidx(-a[i]+sum[i]);
		dap += query(t, vt.size(), 1, 0, vt.size());
		update(getidx(sum[i]), 1, 1, 0, vt.size());
		if (a[i] >= 0)dap++;
	}
	printf("%lld", dap);
}

Measured memory_bytes: 11248
class Combination:
    def __init__(self, n, mod):
        fact = [0]*(n+1)
        ifact = [0]*(n+1)
        fact[0] = 1
        for i in range(1, n+1):
            fact[i] = (fact[i-1]*i) % mod
        # 1/n!を逆元で求める
        ifact[n] = pow(fact[n], mod-2, mod)
        for i in range(n, 0, -1):
            ifact[i-1] = (ifact[i]*i) % mod

        self.n = n
        self.mod = mod
        self.fact = fact
        self.ifact = ifact

    def choose(self, n, r):
        if r < 0 or r > n:
            return 0
        ret = (self.fact[n]*self.ifact[r]) % self.mod
        return (ret*self.ifact[n-r]) % self.mod


n = int(input())
*a, = map(int, input().split())
indices = [-1]*n
l, r = 0, 0
for i in range(n+1):
    if indices[a[i]-1] != -1:
        l = indices[a[i]-1]
        r = i
        break
    indices[a[i]-1] = i

MOD = 10**9+7
c = Combination(n+2, MOD)
for i in range(1, n+2):
    ans = c.choose(n+1, i) - c.choose(l+n-r, i-1)
    ans = (ans+MOD) % MOD
    print(ans)


Measured memory_bytes: 60652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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; }


/* ACL */

//using namespace atcoder;

int main(){
    string S;
    cin >> S;
    int cnt =0;
    rep(i,S.size()){
        cnt += (int(S[i])-48);
    }
    
    if(cnt % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
x,y = map(int,input().split())
ans = 0
for i in range(x):
  f = 2 * i + 4 * (x - i)
  if f == y:
    ans = 1
if x*2 == y:
  ans = 1
if ans == 1:
  print('Yes')
else:
  print('No')

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

int main() {
  int A, B; cin >> A >> B;
  if (A % 3 == B % 3 && A % 3 != 0) {
    cout << "Impossible" << endl;
  }
  else cout << "Possible" << endl;
  return 0;
}

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

int main() {
  int valueA = 0, valueB=0;
  
  cin >> valueA >> valueB;
  
  if( ((valueA * valueB) % 2) == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <cstdio>

using namespace std;

#define MAX_N 200000

class union_find
{
private:
    int par[MAX_N];
    int tree_rank[MAX_N];
    int set_num;
public:
    union_find(int n); // const
    int find(int x);
    void unite(int x, int y);
    bool same(int x, int y);
    int get_number_of_cluster();
    int* get_par();
    int* get_tree_rank();
};

union_find::union_find(int n){
    set_num = n;
    for (int i = 0 ; i < n ; i++){
        par[i] = i;
        tree_rank[i] = 0;
    }
}

int union_find::find(int x){
    if (par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void union_find::unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x==y) return;

    if(tree_rank[x] < tree_rank[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if (tree_rank[x] == tree_rank[y]) tree_rank[x]++;
    }
}

bool union_find::same(int x, int y){
    return find(x) == find(y);
}

int union_find::get_number_of_cluster(){
    int *memo = (int*)malloc(set_num * sizeof(int));
    memset(memo, 0, set_num * sizeof(int));
    int ret = 0;
    for (int i = 0; i < set_num; i++){
        if (memo[find(i)] == 0){
            ret++;
            memo[find(i)] = 1;
        }
    }
    free(memo);
    return ret;
}

int* union_find::get_par(){
    return par;
}

int* union_find::get_tree_rank(){
    return tree_rank;
}

int main(){
    int N,M, x,y,z;
    scanf("%d %d", &N, &M);
    union_find number_set(N);
    for (int i=0; i<M; i++){
        scanf("%d %d %d", &x, &y, &z);
        if (! number_set.same(x-1, y-1)){
            number_set.unite(x-1, y-1);
        }
    }
    printf("%d\r\n", number_set.get_number_of_cluster());
    fflush(stdout);
}


Measured memory_bytes: 1408
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int res;
vector <vector <int> >mylist(100000);
vector <bool> visited(100000);
int dfs(LL i,LL cnt){
    visited[i]=true;
    int ret=cnt;
    debug(i);
    REP(j,mylist[i].size()){
        if(visited[mylist[i][j]==false] && mylist[i][j]==2)
        {visited[2]=true;
        return cnt;
        }
        else if(visited[mylist[i][j]]==false){
            ret = min(ret , dfs(mylist[i][j],cnt+1));
        }
    }
    return ret;
}

void solve(long long N, std::vector<long long> a){
    if(find(ALL(a), 2)==a.end())cout<<-1<<endl;
    else{
        REP(i,N){
            mylist[i].PB(a[i]);
            visited[i]=false;
        }
        int cnt=0;
        int pos=1;
        while(cnt<=100000){
            cnt++;
            pos=a[pos-1];
            if(pos==2)break;
        }
        if(pos==2)cout<<cnt<<endl;
        else cout<<-1<<endl;
        // int res=dfs(1,1);
        // if(visited[2]) cout<<res<<endl;
        // else cout<<-1<<endl;
    }
    // int cnt=0
    // while()
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 6528
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int, readline().split())
uvs = list(map(int,read().split()))

links = [dict() for _ in range(n+1)]
it = iter(uvs)
for u,v,s in zip(it,it,it):
    links[u][v] = s
    links[v][u] = s

def dfs(root, init):
    nums = [0] * (n+1)
    depth = [-1] * (n+1)
    parent = [-1] * (n+1)

    nums[root] = init
    depth[root] = 0
    stack = [root]
    while(stack):
        next = []
        while(stack):
            i = stack.pop()
            for j,s_ij in links[i].items():
                if(j == parent[i]):
                    continue

                num_j = s_ij - nums[i]
                if(depth[j] != -1)&(nums[j] != num_j):
                    loop_len = depth[j] + depth[i] + 1
                    if(loop_len%2 == 0):
                        print(0)
                        exit()
                    else:
                        num_j = nums[j] + num_j
                        if(num_j % 2 ==1):
                            print(0)
                            exit()
                        return (False, nums,depth,j,num_j//2)
                elif(depth[j] == -1):
                    depth[j] = depth[i] + 1
                    nums[j] = num_j
                    parent[j] = i
                    next.append(j)
        stack = next[::]

    return(True, nums,depth,0,0)

flag,nums,depth,root,init = dfs(1,0)

if(flag==False):
    flag2,nums,depth,root,init = dfs(root,init)
    if(flag2==False):
        print(0)
    else:
        if(min(nums[1:]) < 1):
            print(0)
        else:
            print(1)
    exit()

even = []
odd = []
for i in range(1,n+1):
    if(depth[i]%2==0):
        even.append(nums[i])
    else:
        odd.append(nums[i])

min0 = min(even)
min1 = min(odd)

ans = 1 + (min0-1) + (min1-1)
print(max(0,ans))

Measured memory_bytes: 142568
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int p[10];
  int i;
  for(i=0;i<n;i++) scanf("%d",p+i);
  int sum=0;
  int max=0;
  for(i=0;i<n;i++){
    sum+=p[i];
    if(max<p[i]) max=p[i];
  }
  printf("%d\n",sum-max+max/2);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);

    let mut students: Vec<(i64, i64)> = vec![];
    for _ in 0..n{
        let line = read_as_vec::<i64>();
        students.push((line[0], line[1]));
    }

    let mut checkpoints: Vec<(i64, i64)> = vec![];

    for _ in 0..m{
        let line = read_as_vec::<i64>();
        checkpoints.push((line[0], line[1]));
    }

    for student in students{
        let mut cur_min = 1_000_000_000;
        let mut ans = 0;
        for (i, &cp) in checkpoints.iter().enumerate(){
            if cur_min > (cp.0 - student.0).abs() + (cp.1 - student.1).abs(){
                cur_min = (cp.0 - student.0).abs() + (cp.1 - student.1).abs();
                ans = i;
            }
        }
        println!("{}", ans+1);
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> P){
    int now_min = INF;
    int ans = 0;

    REP(i, N) {
        ans += P[i] <= now_min;
        now_min = min(now_min, (int)P[i]);
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int a[100005];
int main() {
	string s;
	int t=0;
	cin>>s;
	FORD(i,s.size()-1,0) {
		if(s[i]=='L')t=i; //4 2
		//RRLRL 3 1 2
		else a[t-((t-i)&1)]++;
	}
	FOR(i,0,s.size()) {
		if(s[i]=='R')t=i; //0 1 3
		//RRLRL 2 4
		else a[t+((i-t)&1)]++;
	}
	FOR(i,0,s.size()) cout<<a[i]<<" ";
	return 0;
}


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



int main(){
    int x,y,i,n,a;
    cin>>x>>n;
    map<int,int>mp;
    for(i=0;i<n;i++){
        cin>>a;
        mp[a]++;
    }
    i=x;
    while(mp[i]==1){
        i--;
    }
    y=x;
    while(mp[y]==1)y++;
    if(abs(x-i)<=abs(x-y))cout<<i;
    else cout<<y;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int n,i;
  cin >> n;
  int l[n];
  int max=0,sum=0;
  repd(i,0,n){cin >> l[i];}
  repd(i,0,n){
      if(max < l[i]){max = l[i];}
      sum+=l[i];
      }
  sum -= max;
  if(max < sum){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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






vector<vector<ll>> g;
vector<bool> used;
vector<vector<ll>> ans;
ll t;

void dfs(ll v){
    used[v] = true;
    ans[v][0] = ++t;
    for(auto &x : g[v]){
        if(!used[x])dfs(x);
    }
    ans[v][1] = ++t;
}


int main() {
    ll n;
    cin >> n;
    g.resize(n);
    REP(i, n){
        ll u, k;
        cin >> u >> k;
        u--;
        REP(j, k){
            ll v;
            cin >> v;
            v--;
            if(v >= 0) g[u].push_back(v);
        }
    }
    
    used.assign(n, false);
    ans.resize(n, vector<ll>(2));
    REP(i, n) if(!used[i]) dfs(i);
    REP(i, n){
        cout << i + 1 << " " << ans[i][0] << " " << ans[i][1] << endl;
    }
}



Measured memory_bytes: 3108
def main():
	n = int(input())
	h = list(map(int,input().split()))

	sum_h = sum(h)%(10**9 + 7)
	ans = 0
	for i in h:
		i = i%(10**9 + 7)
		sum_h -= i
		ans += i*sum_h

	print(ans%(10**9 + 7))
	

	

if __name__ == '__main__':
	main()

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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, n) for (int i = 0; i < (n); i++)
#define dFOR(i, a, b) for (int i = (b)-1; i >= a; i--)
#define dF0R(i, n) for (int i = (n)-1; i >= 0; i--)

#define print(x) cout << x << '\n';
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define finish(x) return cout << x << '\n', 0;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;


int N,K;
int h[100001];
int dp[100001];

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> K;

    FOR (i,1,N+1) cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    FOR (i,3,N+1) {
        dp[i] = 1e9;
        FOR(j,1,K+1) {
            if (i - j < 1) break;
            dp[i] = min(dp[i],abs(h[i] - h[i - j]) + dp[i -j]);
        }
    }
    finish(dp[N]);






    return 0;
}


Measured memory_bytes: 1152
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    string s; cin>>s;
    ll a=s.size();
    if(s[a-1]=='s'){
        cout<<s<<"es"<<endl;
    }
    else{
        cout<<s<<'s'<<endl;
    }
}











Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0002
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "";
            int[] term;
            List<int> answer = new List<int>();
            while ((s = Console.ReadLine()) != null)
            {
                term = s.Split(' ').Select(int.Parse).ToArray();
                int i = term.Sum();
                answer.Add(i.ToString().Length);
            }
            foreach (int item in answer)
            {
                Console.WriteLine(item);
            }
        }
    }
}



Measured memory_bytes: 16388
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
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; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll r; cin >> r;
    cout << 3*r*r << endstr;
    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b-c>=0){
    cout << "delicious" << endl;
  }else if(a+b>=c){
    cout <<"safe"<<endl;
  }else{
    cout <<"dangerous"<< endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
int n;

int solve(vector<int> a){
	int ret = 0;
	rep(i, n){
		int c;
		c = ((n - 1) & i) == i ? 1 : 0;
		ret += c * a[i];
		ret %= 2;
	}

	return ret;
}

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


	cin >> n;

	string s;
	cin >> s;

	bool have_one = false;
	vector<int> a(n);
	rep(i, n) {
		a[i] = s[i] - '1';
		if(a[i] == 1) have_one = true;
	}

	if(have_one){
		rep(i, n){
			if(a[i] == 2) a[i] = 0;
		}
	}else{
		rep(i, n){
			if(a[i] == 2) a[i] = 1;
		}
	}

	int ans = solve(a);
	if(!have_one) ans *= 2;
	
	cout << ans << endl;
}


Measured memory_bytes: 9116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String word = sc.next();


		int current =0;
		int max = 0;
		for (int i = 0; i < word.length(); ++i) {
			char c = word.charAt(i);
			if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
				++current;
			}
			else
			{
				max = Math.max(max, current);
				current = 0;
			}
		}
		max = Math.max(max, current);
		System.out.println(max);

	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    REP(i, N) {
        ll tmp;
        cin >> tmp;
        if(tmp % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
        ans += tmp;
    }
    if(ans == N) {
        cout << "first" << endl;
        return 0;
    }
    if(ans % 2 == 1) {
        cout << "first" << endl;
    } else {
        cout << "second" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

bool num[1000000] = { false };

void primNumberCheck(){
    num[2] = true;//?\???°?????????????????????????????????2???????????§???????????????

    int i, j, k;
    for (i = 3; i <= 1000000; i += 2)//2????????°???????????????
    {
        k = 0;
        for (j = 3; j <= sqrt((double)i); j += 2)//?????????i??\??????i????´???°??????????????\??????i????´???°??¨?????????????????§????????????
        {
            if (i%j == 0)
            {
                k = 1;
                break;
            }
        }
        if (k == 0)
        {
            num[i] = true;
        }
    }
}

int main()
{
    primNumberCheck();

    int n;
    
    while (cin>>n)
    {
        int result = 0;
        for (int i = 0; i <= n; i++)
        {
            if (num[i] == true)result++;
        }
        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 2136