akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dPCC3
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            int AB = 0;
            int BA = 0;
            int BX = 0;
            int XA = 0;
            int N = int.Parse(Console.ReadLine());
            string[] s = new string[N];
            for (int i = 0; i < N; i++)
            {
                s[i] = Console.ReadLine();
                for (int j = 0; j < s[i].Length - 1; j++)//ABの個数
                {
                    if (s[i][j] == 'A' && s[i][j + 1] == 'B')
                    {
                        AB++;
                    }
                }
                //Console.WriteLine(AB);
                if (s[i].Substring(0, 1) == "B")
                {
                    if (s[i].Substring(s[i].Length - 1, 1) == "A")
                    {
                        BA++;//"BA"
                    }
                    else
                    {
                        BX++;//"BX"
                    }
                }
                else if (s[i].Substring(s[i].Length - 1, 1) == "A")
                {
                    XA++;//"XA"
                }
            }
            //Console.WriteLine(AB+" "+BA+" "+BX+" "+XA);
            if (BA > 0) //BAがあって
            {
                if (BX == 0 && XA == 0)//BAだけの時
                {
                    ans = AB + BA - 1;
                }
                if (BX == 0 && XA > 0)//XAとBA
                {
                    ans = AB + BA;
                }
                if (BX > 0 && XA == 0)//BAとBX
                {
                    ans = AB + BA;
                }
                if (XA > 0 && BX > 0)//XA BA BXがあるとき
                {
                    ans = AB + BA + 1 + Math.Min(XA - 1, BX - 1);
                }
            }
            else // BAがなくて
            {
                if (BX > 0 && XA > 0)
                {
                    ans = AB + Math.Min(XA, BX);
                }
                else
                {
                    ans = AB;
                }
                /*
                if (BX == 0 && XA == 0)//ABだけのとき
                {
                    ans = AB;
                }
                if (BX > 0 && XA == 0)
                {
                    ans = AB;
                }
                if (BX == 0 && XA > 0)
                {
                    ans = AB;
                }
                */
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13232
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a) {
        cout << k << endl;
        return 0;
    }
    if(k <= a + b) {
        cout << a << endl;
    } else {
        cout << a - (k - (a + b)) << endl;
    }
}

Measured memory_bytes: 3636
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    string S; cin >> S;
    int N = S.size();

    int np = 0;
    REP(i,N){
        if (S[i] == 'p') np++;
    }

    int ans = -np + (N / 2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    pll han[31];
    ll y=1;
    rep(i,1,31){
        han[i]={y+1,y*2};
        y*=3;
    }
    int q;cin>>q;
    rep(i,0,q){
        ll a,b,c,d;cin>>a>>b>>c>>d;
        a--;b--;c--;d--;
        ll ans=abs(c-a)+abs(d-b);
        ll yy=y;
        rrep(j,30,1){
            yy/=3;
            //if(j==2)cout<<aa<<" "<<bb<<" "<<cc<<" "<<dd<<endl;
            if(a/yy==c/yy&&(a/yy)%3==1&&abs(b/yy-d/yy)>=2){
                ll aa=a%yy,cc=c%yy;
                Max(ans,abs(b-d)+min(1+aa+1+cc,yy-aa+yy-cc));
            }
            if(b/yy==d/yy&&(b/yy)%3==1&&abs(a/yy-c/yy)>=2){
                ll bb=b%yy,dd=d%yy;
                Max(ans,abs(a-c)+min(1+bb+1+dd,yy-bb+yy-dd));
            }
        }
        cout<<ans<<endl;
    }
}






Measured memory_bytes: 384
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    while(true) {
      val a = scanner.nextInt
      val op = scanner.next
      val b = scanner.nextInt

      op match {
        case "+" => println(a + b)
        case "-" => println(a - b)
        case "*" => println(a * b)
        case "/" => println(a / b)
        case _ => System.exit(0)
      }
    }
  }
}


Measured memory_bytes: 45076
#include<stdio.h>

int main (void){

  int a,b,sum=0;
  a=1,b=1;

  while(a<=9){
  sum=a*b;
  printf("%dx%d=%d\n",a,b,sum);
  b++;
  if(b>9){
    a++;
    b=1;
  }
  }
  return 0;
}

Measured memory_bytes: 524
#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>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
   int n = 1;
   int N;
   cin >> N;
   vector<int> v(N);
   vector<int> p(N);
   vector<int> q(N);

   rep(i, N){
      cin >> p[i];
   }
   rep(i, N){
      cin >> q[i];
   }
   
   iota(v.begin(), v.end(), 1);
   int a, b;
   do {
      /*cout << n++ << ":";
      for (int i = 0; i < v.size(); i++) {
         cout << " " << v[i];
      }
      cout << "\n";*/
      n++;
      if(p == v){
         a = n;
      }
      if(q == v){
         b = n;
      }
   }while (next_permutation(v.begin(), v.end()));
   cout << abs(b - a) << endl;
   /*do{

      for(int i = 0; i < N; i++){

      }

   }while(next_permutation(v.begin(), v.end()));

   rep(i, v.size()){
      cout << v[i] << endl;
   }*/
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    ll a, b; cin >> a >> b;
    rep(1,b+1){
        if(a*i%b == 0){
            cout << a*i << endl;
            return 0;
        }
    }
}
/*

*/


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

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

int main(){
	long h[101];
	int n;
	while( cin >> n, n ){
		rep(i,n+1)  cin >> h[i];
		int i=0;
		for( ; i<n; i++ ){
			long dif = (i<=1 ? h[3]-h[2] : h[1]-h[0]);
			int j=0;
			for(; j<n; j++){
				if( j==i ) continue;
				if( j+1==i ){
					if( j+2<=n && h[j+2]-h[j]!=dif ){
						break;
					}
				}else{
					if( h[j+1]-h[j] != dif ){
						break;
					}
				}
			}
			if( j == n ){
				cout << h[i] << endl;
				break;
			}
		}
		if( i == n )
			cout << h[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0017
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) break;
                for (int i = 1 ; i <= 26 ; i++)
                {
                    string res = string.Join("", line.Select(x => ('a' <= x && x <= 'z') ? (char)((x - 'a' + i) % 26 + 'a') : x));
                    if (res.Contains("the") || res.Contains("this") || res.Contains("that"))
                    {
                        Console.WriteLine(res);
                        break;
                    }
                }
            }
        }
    }

}



Measured memory_bytes: 14112
N,A,B = map(int, input().split())

if abs(A-B)%2 == 0:
	print(abs(A-B)//2)
else:
	ans = min(
		A-1 + (B-A-1)//2 +1,
		N-B + (B-A-1)//2 +1
	)
	print(ans)

Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define mod(x) ((x % MOD) + MOD) % MOD
#define int long long int
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define rrep(i, a, n) for(int i = n-1; i >= a; --i)

using namespace std;

typedef pair<int,int> P;

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


signed main()
{
  int N;
  cin >> N;
  vector< vector<int> > A(2, vector<int>(N));
  rep(i, 0, N) {
    cin >> A[0][i];
  }
  rep(i, 0, N) {
    cin >> A[1][i];
  }

  rep(i, 1, N) {
    A[0][i] += A[0][i-1];
  }
  rrep(i, 0, N-1) {
    A[1][i] += A[1][i+1];
  }


  int ans = 0;
  rep(i, 0, N) {
    ans = max(ans, A[0][i] + A[1][i]);
  }

  cout << ans << endl;

  return 0;
}


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


int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    k--;
    s[k] = tolower(s[k]);
    cout << s;
}

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

using namespace std;

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

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> a(h, vector<bool>(w, true));
    string s;
    for(int i=0;i<h;++i) {
        cin >> s;
        for(int j=0;j<w;++j) if(s[j] == '#') a[i][j] = false;
    }

    vector<vector<ll>> dp(h, vector<ll>(w, 0));
    dp[0][0] = 1;
    for(int i=0;i<h;++i) {
        for(int j=0;j<w;++j) {
            if(dp[i][j]) {
                if(i != h-1 && a[i+1][j]) (dp[i+1][j] += dp[i][j]) %= MOD;
                if(j != w-1 && a[i][j+1]) (dp[i][j+1] += dp[i][j]) %= MOD;
            }
        }
    }

    cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 8320
#include<stdio.h>

int main(void){
	int x = 0;
	int y = 0;
	int a = 0;
	int b = 0;
	
	scanf("%d %d", &a, &b);

	if (a == b) {

		x = a + b;
	}
	else {
		if (a > b) {
			x = a;
			a--;
			y = a;
		}
		else {
			x = b;
			b--;
			y = b;
		}
	}
	x = x + y;
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 128
N, K = map(int,input().split())
A = list(map(int, input().split()))
dic = {1:0}
now = 1
flag = 0
T = 0
log = [1]
for i in range(K):
  now = A[now-1]
  #print(i+1,now)
  if now in dic:
    flag=1
    T=i+1-dic[now]
    log = log[dic[now]:]
    break
  dic[now] = i+1
  log.append(now)
if flag!=1:
  print(now)
else:
  print(log[(K-dic[now])%T])

Measured memory_bytes: 32376
#include<iostream>
using namespace std;
long long n,m,d,res,b[101],a;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for (int i=1;i<=m;i++){
        cin>>d;
        for (int j=1;j<=d;j++){
            cin>>a;
            if (b[a]==0)res++;
            b[a]=1;
        }
    }
    cout<<n-res;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;


main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int h, w, k;
    cin >> h >> w >> k;
    string arr[h];
    vector<vector<int>> vec(h);
    vector<int> tmp;

    for(int i = 0; i < h; i++){
        cin >> arr[i];
        string &s = arr[i];
        for(int j = 0; j < w; j++)  if(s[j] == '#') vec[i].push_back(j);
    }

    int cur = 1;
    int res[h][w];
    int i = 0, n = h, m = w;
    while(i < h and vec[i].size() == 0)   i++;
    int ii = i;
    for(; i < h; i++){
        if(vec[i].size() == 0){
            for(int j = 0; j < m; j++){
                res[i][j] = res[i-1][j];
            }
            continue;
        }

        for(int j = 0; j <= vec[i][0]; j++)    res[i][j] = cur;
        for(int l = 0; l < (vec[i].size() - 1); l++){
            for(int j = vec[i][l]; j < vec[i][l + 1]; j++)  res[i][j] = cur;
            cur++;
        }
        for(int j = m - 1; j >= vec[i].back(); j--)  res[i][j] = cur;
        cur++;
    }


    for(int i = ii - 1; i >= 0; i--){
        for(int j = 0; j < m; j++)  res[i][j] = res[i + 1][j];
    }

    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < m; j++){
            cout << res[i][j] << " ";
        }
        cout << "\n";
    }
}

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

namespace Q3
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');

            double W = double.Parse(strs[0]);
            double H = double.Parse(strs[1]);
            double x = double.Parse(strs[2]);
            double y = double.Parse(strs[3]);
            bool OK = false;
            if (x * 2 == W && y * 2 == H)
            {
                OK = true;
            }
            double menseki = W * H / 2.0;
            Console.WriteLine(menseki + " " + (OK ? 1 : 0));
        }
    }
}


Measured memory_bytes: 13140
N,M,NR = map(int,input().split())

R = list(map(lambda x: int(x) - 1 ,input().split()))

import numpy as np
from scipy.sparse.csgraph import floyd_warshall

G = np.zeros((N,N))

for _ in range(M):
  a,b,c = map(int,input().split())
  G[a-1,b-1] = c

floyd_warshall(G, directed=False, overwrite=True)

def it2():
  from itertools import permutations
  for p in permutations(R):
    pp = iter(p)
    next(pp)
    yield sum(G[a,b] for a,b in zip(p,pp))

print(int(min(it2())))

Measured memory_bytes: 17892
a = gets.chomp
ans = 0
gu = 0
a.size.times do |i|
  if (gu == 0)
    gu += 1
    ans -= 1 if a[i] == "p"
  else
    if(a[i] == "g")
      ans += 1
      gu -= 1
    else
      gu -= 1
    end
  end  
end
puts ans

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

int main() {
    int n;
    int m;
    cin >> n >> m;
    vector<std::pair<int, int>> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i].first >> a[i].second;
    }

    vector<int> v(n);
    for (int i = 1; i <= n; i++) {
        v[i - 1] = i;
    }

    int sum = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            if (std::find_if(a.begin(), a.end(), [&](const auto& x) {
                    if ((x.first == v[i] || x.first == v[i + 1]) &&
                        (x.second == v[i] || x.second == v[i + 1]))
                        return true;
                    else
                        return false;
                }) == a.end())
                goto LAST;
        }
        sum++;
    LAST:
        continue;
    } while (std::next_permutation(v.begin() + 1, v.end()));

    cout << sum << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 200005;

ll N, K;
vector<ll> a, cycle;
bitset<MX> vis;

void solve() {
    cin >> N >> K;
    a.resize(N);
    for (int i = 0; i < N; i++) {
		cin >> a[i];
		a[i]--;
	}
	
    vis.reset();
    ll cur = 0, cnt = 0;
    while (!vis[cur]) {
		if (cnt == K) {
			cout << cur + 1;
			return;
		}
		vis[cur] = 1;
		cur = a[cur];
		cnt++;
	}
	
	vis.reset();
	while (!vis[cur]) {
		if (cnt == K) {
			cout << cur + 1;
			return;
		}
		cycle.push_back(cur);
		vis[cur] = 1;
		cur = a[cur];
		cnt++;
	}
	
	K -= cnt;
    
    // cout << cycle.size() << "\n";
    cout << cycle[K % cycle.size()] + 1;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 5848
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
int x[100010], y[100010];
vector<int> X[100010], Y[100010];
bool visited[100010];
map<P, int> mp;
int ans = 0;

set<int> stX, stY;
set<P> st;
int cnt = 0;
void search(int x, int y) {
    if (cnt >= 2000000) return;
    cnt++;
    if (visited[mp[{x, y}]]) return;
    stX.insert(x);
    stY.insert(y);
    st.insert({x, y});
    visited[mp[{x, y}]] = true;
    for(auto to: X[y]){
        search(to, y);
    }
    for(auto to: Y[x]) {
        search(x, to);
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) {
        cin >> x[i] >> y[i];
        X[y[i]].push_back(x[i]);
        Y[x[i]].push_back(y[i]);
        mp[{x[i], y[i]}] = i;
    }
    int ans = 0;
    rep(i, N) {
        if (cnt >= 2000000) {
            cout << 0 << endl;
            return 0;
        }
        if (visited[i]) continue;
        search(x[i], y[i]);
        ans += stX.size() * stY.size() - st.size();
        st.clear();
        stX.clear();
        stY.clear();
    }
    cout<< ans << endl;

    return 0;
}


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

int IsPalindrome(const char* str);
int main(void)
{
	int cnt=0;
	char str[101];
	while(scanf("%s", str)!=EOF)
	{
		if(IsPalindrome(str))cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

int IsPalindrome(const char* str)
{
	const char* l = str;
	const char* r = str+(strlen(str)-1);
	while(r-l>1)
	{
		if((*l++)!=(*r--))
			return 0;
	}
	return (*l)==(*r);
}

Measured memory_bytes: 548
#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>;

const ll INF = 1LL << 60;

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


int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    ll dp[n+10];
    rep(i, n) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4568
/*
	AOJ_0506: String
*/
#include	<iostream>
#include	<string>
#include	<algorithm>

using namespace std;

string itos(int);
string operation(string);

int main(void) {
	int n;
	string str, buff;

	while (1) {
		cin >> n;
		if (n == 0) { break; }

		cin >> str;
		for (int i = 0; i < n; i++) {
			buff = operation(str);
			if (str == buff) {
				break;
			}
			str = buff;
		}
		cout << str << endl;
	}
}

string itos(int val) {
	string result;

	if (val == 0) {
		result = "0";
	} else {
		while (val > 0) {
			result += (val % 10) + '0';
			val /= 10;
		}
		reverse(result.begin(), result.end());
	}

	return result;
}

string operation(string str) {
	string result;
	char ch_buff = 0;
	int count_buff = -1;

	string::iterator it = str.begin();
	while (it != str.end()) {
		if (*it != ch_buff) {
			if (count_buff != -1) {
				result += itos(count_buff) + ch_buff;
			}
			count_buff = 1;
			ch_buff = *it;
		} else {
			count_buff++;
		}
		it++;
	}
	result += itos(count_buff) + ch_buff;

	return result;
}

Measured memory_bytes: 1340
x = input()

cnt = 0

while len(x) - 1 > cnt:
    if x[cnt] == 'S' and x[cnt+1] == 'T':
        x = x[:cnt] + x[cnt+2:]
        cnt = max(0, cnt - 1)
    else:
        cnt += 1

print(len(x))


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

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

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N;
    cin >> N;
    vl H(N);
    REP(i,N)cin >> H[i];
    H[0] = max(1LL,H[0]-1LL);

    for(int i=1;i<N;i++){
        if(H[i]<H[i-1]){
            cout << "No" << endl;
            return 0;
        }

        if(H[i]==H[i-1])continue;

        H[i] = max(1LL,H[i]-1);
    }

    cout << "Yes" << endl;
    return 0;

}



Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
 
H,W=map(int, sys.stdin.readline().split())
S=[ sys.stdin.readline().strip() for _ in range(H) ]
 
D=[(1,0),(-1,0),(0,1),(0,-1)]
 
def bfs(start):
    Visit={}
    q=deque()
    q.append(start)
    Visit[start]=1
    L=defaultdict(lambda: float("inf"))    #距離
    L[start]=0
 
    while q:
        fro_x,fro_y=q.popleft()
        for dx,dy in D:
            to_x=fro_x+dx
            to_y=fro_y+dy
            if 0<=to_x<H and 0<=to_y<W:
                if S[to_x][to_y]=="." and (to_x,to_y) not in Visit:
                    Visit[to_x,to_y]=1
                    L[(to_x,to_y)]=min(L[(to_x,to_y)],L[(fro_x,fro_y)]+1)
                    q.append((to_x,to_y))
    if len(L.values())==0:
        return 0
    else:
        return max(L.values())
 
ans=0
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            ans=max(ans,bfs((h,w)))
 
print ans

Measured memory_bytes: 34280
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
long long a[18][18];
long long n;
long long f[18][1<<16];
long long dp[1<<16];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	long long cst=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<1<<(i-1);j++)
		{
			cst=0;
			for(int k=1;k<i;k++)
			{
				cst+=a[k][i]*(1&(j>>(k-1)));
			}
			f[i][j|(1<<(i-1))]=f[i-1][j]+cst;
			f[i][j]=f[i-1][j];
		}
	}
	for(int i=0;i<(1<<(n));i++)
	{
		dp[i]=f[n][i];
	}
	for(int i=1;i<(1<<n);i++)
	{
		for(int j=i;j>0;j=(j-1)&i)
		{
			dp[i]=max(dp[i],dp[i^j]+dp[j]);
		}
	}
	/*
	for(int i=0;i<(1<<(n));i++)
	{
		cout<<i<<":"<<dp[i]<<endl;
	}
	*/
	cout<<dp[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements <=num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//Sort(v);
//v.erase(unique(all(v)),v.end());
//It keeps unique elements in sorted order....
//#define int long long int
void solve(){
	ll k,n;
	cin>>k>>n;
	vl vec(n);
	cin>>vec;
	vl no;
	for(int i=1;i<n;i++) no.pb(vec[i]-vec[i-1]);
	no.pb(k-vec[n-1]+vec[0]);
	Sort(no);
	ll sum=0;
	for(int i=0;i<n-1;i++) sum+=no[i];
	cout<<sum<<endl;
 
 
}
 
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
} 

Measured memory_bytes: 3956
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;
bool vis[100100];

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> to(n+1);
    vector<int> par(n+1);
    rep(i,m) {
        int a, b; cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    } 
    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        auto x = q.front(); q.pop();
        vis[x] = true;
        //cout << "x : " << x << endl;
        for (auto nx: to[x]) {
            if (vis[nx]) continue;
            else {
                //cout << "nx : " << nx << endl;
                par[nx] = x;
                vis[nx] = true;
                q.push(nx);
            }            
        }
    }
    for (int i = 1; i<n; ++i) {
        if (!vis[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i<n; ++i) {
        cout << (par[i]+1) << endl;
    }
    return 0;
}






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

int main(){
	int n,w,h,x[100001] = {},y[100001] = {};
	cin >> n >> w >> h;
	for(int i = 0;i < n;i++){
		int a,b,c;
		cin >> a >> b >> c;
		x[max(0,b - c)]++;
		x[min(h,b + c)]--;
		y[max(0,a - c)]++;
		y[min(w,a + c)]--;
	}
	bool fx = true,fy = true;
	for(int i = 0;i < h;i++){
		x[i + 1] += x[i];
		if(x[i] <= 0) fx = false;
	}
	for(int i = 0;i < w;i++){
		y[i + 1] += y[i];
		if(y[i] <= 0) fy = false;
	}
	if(fx || fy) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3868
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

x = ri()
if x == 0:
    print(1)
elif x == 1:
    print(0)


Measured memory_bytes: 67940
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = n - 1 - x; i >= 0; i--)

int main() {
    ull a = 100;
    ull X;
    cin >> X;
    for (int i = 0; true; i++) {
        if (a >= X) {
            printf("%d",i);
            return 0;
        }
        a *= 1.01;
    }
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod 1000000007

int main()
{
    ll n;
    cin >> n;
    ll dp[n][3];
    for(ll i = 0; i < n;i++)
    {
        ll a,b,c;
        cin >> a >> b >> c;
        if(i == 0)
        {
            dp[0][0] = a;
            dp[0][1] = b;
            dp[0][2] = c;
        }
        else
        {
            dp[i][0] = a + max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = b + max(dp[i-1][0],dp[i-1][2]);
            dp[i][2] = c + max(dp[i-1][0],dp[i-1][1]);
        }
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]), dp[n-1][2]) << "\n";
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	set<int> mochi;
	rep(i, n){
		int d;
		cin >> d;
		mochi.insert(d);
	}
	cout << mochi.size() << endl;
}

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

public class ABC
{
    //          long[] sp = Console.ReadLine().Split().Select(long .Parse).ToArray();
    //          int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
    //          int N =  int.Parse(Console.ReadLine());
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        Console.WriteLine(N * N * N);
    }

}

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

int main(){

  int N;
  cin >> N;

  int nuki;
  int komi;
  nuki = (int)(N / 1.08);
  komi = (int)(nuki * 1.08);
  if(komi != N){
    nuki = nuki +  1;
    komi = (int)(nuki * 1.08);
    if(komi != N){
      cout << ":(";
    }
    else{
      cout << nuki;
    }
  }
  else{
    cout << nuki;
  }
  return 0;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxabs = 1e9;

const int maxn = 510;

int N, M, n, m;

int ans[maxn + 5][maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d%d%d", &N, &M, &n, &m);
	if (N % n == 0 && M % m == 0)
	{
		puts("No");
		return 0;
	}
	int pos = (maxabs - 1) / (n * m - 1);
	int neg = -pos * (n * m - 1) - 1;
	REP(i, 0, N)
		REP(j, 0, M)
			if (i % n == n - 1 && j % m == m - 1)
				ans[i][j] = neg;
			else ans[i][j] = pos;
	puts("Yes");
	REP(i, 0, N)
	{
		REP(j, 0, M) printf("%d ", ans[i][j]);
		printf("\n");
	}
	return 0;
}


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

struct Node {
    int parent;
    int rank;
};

vector<Node> v;

void initialize(int n);

int find_set(int x);

void unite(int x, int y);

void disp(vector<Node> v);

bool same(int x, int y);

void initialize(int n) {
    for (int i=0; i<n; i++) {
        Node nd = {i, 0};
        v.push_back(nd);
    }
}

int find_set(int x) {
    if (v[x].parent == x) {
        return x;
    } else {
        return v[x].parent = find_set(v[x].parent);
    }
}

void unite(int x, int y) {
    x = find_set(x);
    y = find_set(y);
    if (x == y) return;

    if (v[x].rank < v[y].rank) {
        v[x].parent = y;
    } else {
        v[y].parent = x;
        if (v[x].rank == v[y].rank) {
            v[x].rank++;
        }
    }
}

void disp(vector<Node> v) {
    for (int i=0; i<v.size(); i++) {
        cout << v[i].parent << endl;
    }
}

bool same(int x, int y) {
    return find_set(x) == find_set(y);
}

int main () {
    int n, q;
    int com, x, y;
    cin >> n >> q;
    initialize(n);
    for (int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if (com == 0) {
            unite(x, y);
        } else {
            if (same(x, y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1344
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最大公約数 - 取得
int
fGetGcd(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	int liWork;

	// ユークリッドの互除法
	if (piVal1 < piVal2) {
		liWork = piVal1;
		piVal1 = piVal2;
		piVal2 = liWork;
	}
	while (piVal2 > 0) {
		liWork = piVal1 % piVal2;
		piVal1 = piVal2;
		piVal2 = liWork;
	}

	return piVal1;
}

// 実行メイン
int
fMain(
)
{
	char lc1Buf[1024];

	// 座標 - 取得
	int liSx, liSy, liEx, liEy;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d%d%d", &liSx, &liSy, &liEx, &liEy);
	int liW = abs(liSx - liEx);
	if (liW == 0) {
		return 0;
	}
	int liH = abs(liSy - liEy);
	if (liH == 0) {
		return 0;
	}

	// 最大公約数 - 取得
	int liGcd = fGetGcd(liW, liH);
	liW /= liGcd;
	liH /= liGcd;

	return (liW + liH - 1) * liGcd;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	if (liRet == 0) {
		sprintf(lc1Buf, "Yes\n");
	}
	else {
		sprintf(lc1Buf, "No\n");
	}
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=500010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int a,b,c,x,y;
signed main()
{
    a=read(), b=read(), c=read(), x=read(), y=read();
    if(2*c>a+b)
    {
        printf("%lld\n",x*a+y*b);
    }
    else
    {
        int qwq=min(x,y)*2*c;
        int g=min(x,y);
        x-=g, y-=g;
        if(x)
        {
            printf("%lld\n",qwq+x*min(a,c*2));
        }
        else{
            printf("%lld\n",qwq+y*min(b,c*2));
        }
    }
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

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

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a=0;
  char s;
  for(int i=0;i<4 ;i++){
    cin >>s;
    if(s=='+'){
		a++;
    }else{
		a--;
    }
  }	
  cout <<a<<endl;
  
   return 0;
}


Measured memory_bytes: 256
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        if a[n-1] == 0:
            ans = 0
        else:
            ans = -1
        break

print(ans)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(double, n);
  cout << setprecision(20);
  out(ceil(n / 2) / n);
}


Measured memory_bytes: 256
#coding:utf-8
N,M  = map(int,input().split())
A = list(map(int,input().split()))
b = 0
c = [0,2,5,5,4,5,6,3,7,6]
bagS = [[] for i in range(N+1)]

def check2(A,B):

    if len(A) > len(B):
        return A
    elif len(A) < len(B):
        return B
    for a,b in zip(A,B):
        if  a- b > 0:
            return A
        elif a-b < 0:
            return B
    return A


while b != N:

    for a in A:
        if b+ c[a] <= N:
  
            bagS[b+c[a]] = check2(bagS[b+c[a]],sorted((bagS[b]+[a]),reverse=True))

    for i in range(b+1,N+1):
        if bagS[i]:
            b = i
            break
p = 0
for i in bagS[N]:
    p = p*10+i
print(p)



Measured memory_bytes: 252424
#include <iostream>

using namespace std;

int main (void)
{
    int n;
    cin >> n;

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

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

    for (int i = 1; i < n - 1; i++) {
        a[i] = a[i-1] + a[i];
    }

    long x = a[0];
    long y = total - x;
    long ans = abs(x - y);
    for (int i = 1; i < n - 1; i++) {
        x = a[i];
        y = total - x;
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
//STAY AT HOME

signed _main(){
  int N; cin >> N;
  v<int> b(N),ans;
  rep(i,N){
    cin >> b[i];
    b[i]--;
  }
  while(!b.empty()){
    bool ok=false;
    for(int i=b.size()-1;i>=0;i--){
      if(i==b[i]){
        ans.push_back(i);
        b.erase(b.begin()+i);
        ok=true;
        break;
      }
    }
    if(!ok){
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(ans.begin(),ans.end());
  fore(i,ans) cout << i+1 << endl;
  return 0;
}


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

int main() {
    int64_t N, K;
    cin >> N >> K;
    N = N % K;
    if (N > K/2) cout << K-N << endl;
    else cout << N << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
char query[129];
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int decode(int x){return x<10?x+48:(x<36?x+87:x+29);}
static inline int ask(void){printf("? %s\n",query);fflush(stdout);return IN();}
int main(void)
{
  int l=0,len=0,mid=0,r=0,total=0,diff[62];char pw[129];
  rep(i,62){rep(j,128){query[j]=decode(i);}query[128]=0;diff[i]=128-ask();total+=diff[i];}
  rep(i,62)
  {
    if(len==0){len=diff[i];rep(j,diff[i])pw[j]=decode(i);}
    else
    {
      l=0;
      rep(k,diff[i])
      {
        r=len;
        while(l<r)
        {
          mid=(l+r+1)/2;
          rep(j,mid)query[j]=pw[j];
          rep(j,diff[i]-k)query[mid+j]=decode(i);
          query[mid+diff[i]-k]=0;
          if(ask()==total-mid-diff[i]+k)l=mid;else r=mid-1;
        }
        len++;rep(j,len-l){pw[len-j]=pw[len-j-1];}pw[l]=decode(i);
      }
    }
  }
  pw[len]=0;printf("! %s\n",pw);return fflush(stdout),0;
}

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

int main() {
  int n;
  scanf("%d", &n);

  vector<long long> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  // 最初の数を負の数にして、最小の操作数を求める
  // 正の数である場合は、-1に操作してから最小の操作数を求める
  bool f = true;
  long long ans_1 = 0LL;
  long long sum = 0LL;
  for (int i = 0; i < n; i++) {
    sum += a.at(i);
    if (f) {
      if (sum >= 0) {
        while (sum >= 0) {
          sum--;
          ans_1++;
        }
      }
      f = false;
    } else {
      if (sum <= 0) {
        while (sum <= 0) {
          sum++;
          ans_1++;
        }
      }
      f = true;
    }
  }

  // 最初の数を正の数にして、最小の操作数を求める
  // 負の数である場合は、+1に操作してから最小の操作数を求める
  f = false;
  long long ans_2 = 0LL;
  sum = 0LL;
  for (int i = 0; i < n; i++) {
    sum += a.at(i);
    if (f) {
      if (sum >= 0) {
        while (sum >= 0) {
          sum--;
          ans_2++;
        }
      }
      f = false;
    } else {
      if (sum <= 0) {
        while (sum <= 0) {
          sum++;
          ans_2++;
        }
      }
      f = true;
    }
  }
  
  printf("%lld", min(ans_1, ans_2));
}

Measured memory_bytes: 1024