akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

int n, m, Q;
int a[55], b[55], c[55], d[55];

vector<int> vec;
int dfs(int p, int x)
{
	if(p == n+1){
		int sum = 0;
		for(int i = 1; i <= Q; i++){
			if(vec[a[i]]+c[i] == vec[b[i]]) sum += d[i];
		}
		return sum;
	}
	int ret = 0;
	vec.push_back(x);
	ret = max(ret, dfs(p+1, x));
	vec.pop_back();
	
	if(x+1 <= m) ret = max(ret, dfs(p, x+1));
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> Q;
	for(int i = 1; i <= Q; i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--, b[i]--;
	}
	
	cout << dfs(1, 1) << endl;
	
	return 0;
}

Measured memory_bytes: 3640
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

s = list(input())
if s[3] == "7":
    s[3] = "8"
ans = ""
for i in range(len(s)):
    ans += s[i]
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ls (p<<1)
#define rs (p<<1|1)
using namespace std;



/*
	需要维护的是
	a[i]区间最大值
	a[i]-i的区间最小值 
*/
#define inf 1000000
#define M 200005
int f[M<<2],laz[M<<2],mx[M<<2];
int n,m;
int res,pos;
void up(int p){
	mx[p]=max(mx[ls],mx[rs]);
	f[p]=min(f[ls],f[rs]);
}
void down(int l,int mid,int r,int p){
	if (laz[p]){
		laz[ls]=laz[rs]=laz[p];
		mx[ls]=mx[rs]=laz[p];
		f[ls]=laz[p]-mid;
		f[rs]=laz[p]-r;
		laz[p]=0;
	}
}
void build(int l,int r,int p){
	if (l==r){
		mx[p]=l;
		f[p]=0;
		return ;
	}
	
	int mid=(l+r)>>1;
	build(l,mid,ls);
	build(mid+1,r,rs);
	up(p);
}
void pt(int l,int r,int p){
	if (l==r){
		printf("%d ",mx[p]);
		return ;
	}
	int mid=(l+r)>>1;
	down(l,mid,r,p);
	pt(l,mid,ls);
	pt(mid+1,r,rs);
	up(p);
}
void qu(int l,int r,int p){
	if (mx[p]<pos)return; 
	if (l==r){
		res=l;
		return; 
	}
	int mid=(l+r)>>1;
	down(l,mid,r,p);
	qu(l,mid,ls);
	if (res)return;
	qu(mid+1,r,rs);
}
int qu(int k){
	res=0;
	pos=k;
	qu(1,m+1,1);
	return res;
}
void upd(int l,int r,int x,int y,int k,int p){
	if (l==x&&r==y){
		laz[p]=k;
		mx[p]=k;
		f[p]=k-r;
		return ;
	}
	int mid=(l+r)>>1;
	down(l,mid,r,p); 
	if (y<=mid){
		upd(l,mid,x,y,k,ls);
	}
	else if (x>mid){
		upd(mid+1,r,x,y,k,rs);
	}
	else{
		upd(l,mid,x,mid,k,ls);
		upd(mid+1,r,mid+1,y,k,rs);
	}
	up(p);
} 
void upd(int l,int r,int k){
	int resl=qu(l);
	int resr=qu(r+1)-1;
//	printf("%d %d\n",resl,resr);
	if (resl<=resr&&resr<=m)upd(1,m+1,resl,resr,k,1);
}
int qu(int l,int r,int x,int y,int p){
	if (l==x&&r==y){
//		printf("%d %d    %d\n",x,y,f[p]);
		return f[p];
	}
	int mid=(l+r)>>1;
	down(l,mid,r,p);
	if (y<=mid)return qu(l,mid,x,y,ls);
	if (x>mid)return qu(mid+1,r,x,y,rs);
	return min(qu(l,mid,x,mid,ls),qu(mid+1,r,mid+1,y,rs));
}
int calc(int i){
	int res=qu(1,m+1,1,m,1); 
	if (res>=m)return -1;
	return res+i;
}
/*
4 4
2 4
1 1
2 3
2 4
*/

int main(){
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	int i,l,r;
	build(1,m+1,1);
	for (i=1;i<=n;i++){
		scanf("%d%d",&l,&r);
		if (r==m){
			upd(l,r,inf);
		}
		else{
			upd(l,r,r+1);
		}
//		pt(1,m+1,1); printf("\n");
		printf("%d\n",calc(i));
	}
	return 0;
} 

Measured memory_bytes: 9856
//using class
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

class Point{
  public: //以下、外部からaccess可能
  double x,y; //member
  
  Point(double xx,double yy){ //コンストラクタ
    x = xx;
    y = yy;
  }
};

double getDistance(Point p1, Point p2){
  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

int main(){
  Point p1(0,0), p2(0,0); //変数宣言
  //コンストラクタによって座標指定して初期化
  
  cin >> p1.x >> p1.y >> p2.x >> p2.y; //public access可
  
  printf ("%lf", getDistance(p1, p2) );
  
  return 0;
}


Measured memory_bytes: 3220
n, x = map(int, raw_input().split())


def solve(a, b):
    if a > b:return solve(b, a)
    if b % a == 0:
        return (2 * (b / a) - 1) * a
    return 2 * a * (b / a) + solve(a, b % a)

print solve(x, n-x) + n


Measured memory_bytes: 2692
#include <iostream>
using namespace std;
int main()
{   int a,b,x;
    cin>>a>>b>>x;
    if((x-a)>=0)
    {
        if(b>=(x-a))
        {
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    
    return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast

    ll i,j,n,m;
    string a,b;
    cin >> a;
    cin >> b;
    n = a.size();
    m = b.size();
    ll dp[n+1][m+1] = {{0}};
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++){
            dp[i][j] = 0;
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans = "";
    i = n;
    j = m;
    while(dp[i][j]){
        while(dp[i][j]==dp[i-1][j]){
            i--;
        }
        while(dp[i][j]==dp[i][j-1]){
            j--;
        }
        if(dp[i][j]==dp[i-1][j]+1){
            ans = a[i-1] + ans;
            i--;
            j--;
        }
        else{
            ans = b[j-1] + ans;
            i--;
            j--;
        }
    }
    cout << ans << endl;
}

//    cout << fixed << setprecision(12);


Measured memory_bytes: 73972
import numpy as np

s = input().split()
L=int(s[0])
R=int(s[1])
m=2019
count=0
if R-L>2019:
    m=0
else:
    for j in range(L,R+1):
        for i in range(L,j):
            d=(i*j) % 2019
            m=min(d,m)
print(m)

Measured memory_bytes: 12392
#pragma GCC optimize(2)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
#include <sstream>
#include <ctime>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mes(a, b) memset((a), (b), sizeof (a))
#define IosF ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;

struct Point{
    double x, y;
    Point(double a = 0, double b = 0) : x(a), y(b) {};
};

typedef Point Vector;
inline Vector operator + (Vector A, Vector B) {return Vector(A.x + B.x, A.y + B.y);}
inline Vector operator - (Vector A, Vector B) {return Vector(A.x - B.x, A.y - B.y);}
inline Vector operator * (Vector A, double x) {return Vector(A.x * x, A.y * x);}
inline Vector operator / (Vector A, double x) {return Vector(A.x / x, A.y / x);}
inline double Dot(Vector A, Vector B) {return A.x * B.x + A.y * B.y;} //向量点乘
inline double Len(Vector A) {return sqrt(Dot(A, A));}
inline double Ang(Vector A, Vector B) {return acos(Dot(A, B) / Len(A) / Len(B));} //向量夹角
inline double Cro(Vector A, Vector B) {return A.x * B.y - A.y * B.x;} //向量叉乘
inline double Area(Vector A, Vector B) {return Cro(A, B) * 0.5;} //组成三角形面积
inline Vector Rotate(Vector A, double rad) {return Vector(A.x * cos(rad) - A.y * sin(rad), A.x * sin(rad) + A.y * cos(rad));} //向量逆时针旋转角度rad
inline Vector Normal(Vector A) {double len = Len(A); return Vector(-A.y / len, A.x / len);}//求向量A的单位法线

typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int M = 0x3f3f3f3f;
const int inf = 0x7fffffff;
const int mod = 9901;
const double PI = acos(-1);

inline void Solve() {
    int n;
    cin >> n;
    int x = 1000;
    int num = 0;
    while ( num < n ) {
        num += x;
    }
    cout << (num - n) << endl;
}

int main() {
    IosF;
    Solve();
    return 0;
}


Measured memory_bytes: 3220
import numpy as np


def main():
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    graph = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)

    hs.insert(0, 0)
    hs_arr = np.array(hs)
    ans = 0
    for i, node in enumerate(graph[1:], start=1):
        if np.all(hs[i] > hs_arr[node]):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

#define rr register
#define int long long
#define MAXN 1000010

using namespace std;

int X,Y,A,B,C;

int a[MAXN],b[MAXN],c[MAXN];
int d[MAXN],cnt;

bool cmp(int x, int y){
	return x > y;
}

signed main(void){
	cin >> X >> Y >> A >> B >> C;
	for (int i = 1; i <= A; ++i) {
		cin >> a[i];
	}
	for(int i = 1; i <= B; ++i) {
		cin >> b[i];
	}
	for (int i = 1; i <= C; ++i) {
		cin >> c[i];
	}
	
	sort(a+1,a+1+A);
	sort(b+1,b+1+B);
	sort(c+1,c+1+C,cmp);
	
	for (int i = A - X + 1; i <= A; ++i) {
		d[++cnt] = a[i];
	}
	for (int i = B - Y + 1; i <= B; ++i) {
		d[++cnt] = b[i];
	}
	sort(d + 1, d + 1 + cnt);
	int pt = 1;
	for (int i = 1; i <= cnt; ++i) {
		if (pt > C) {
			break;
		}
		if (c[pt] < d[i]) {
			break;
		}
		++pt;
	}
	int ans = 0;
	for (int i = 1; i <= pt - 1; ++i) {
		ans += c[i];
	}
	for (int i = pt; i <= cnt; ++i) {
		ans += d[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11904
private val scanner = java.util.Scanner(System.`in`)
 
private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()
 
fun main(args: Array<String>) {
    val S = readLine()!!.map { it == 'B' }.toTypedArray()
    val size = S.size
 
    val sum = Array(size) { 0L }
    for (i in 0 until size) sum[i] += (if (S[i]) 1 else 0) + (if (i == 0) 0 else sum[i - 1])
 
    var count = 0L
    for (i in 0 until S.size) if (!S[i]) count += sum[i]
 
    println(count)
}

Measured memory_bytes: 39496
#include <iostream>

using namespace std;

int binary_search(int elements[], int n, int key)
{
	int left = 0, right = n, center;
	while (left <= right)
	{
		center = (left + right) / 2;
		if (elements[center] < key) {
			left = center + 1;
		}
		else if (elements[center] > key) {
			right = center - 1;
		}
		else {
			return 1;
		}
	}
	return 0;
}

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

	int n, q, count = 0;
	int S[100000];

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> S[i];

	cin >> q;
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		count += binary_search(S, n, t);
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1584
#include<cstdio>
#include<cctype>
const int N=100007,P=1000000007;
int a[N],deg[N],vis[N],pre[N],cnt[N],f[N];
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
int add(int a,int b){return a+=b-P,a+(a>>31&P);}
int mul(int a,int b){return 1ll*a*b%P;}
int main()
{
    int n=read(),ans=1;
    for(int i=1;i<=n;++i) ++deg[a[i]=read()];
    for(int i=1;i<=n;++i)
    {
	if(deg[i]>2) return puts("0"),0;
	if(deg[i]<2||vis[i]) continue;
	//for(int p=i;!vis[p];vis[p]=1,pre[a[p]]=p,p=a[p]) if(vis[p]) return puts("0"),0;
	int p=i;
	do
	{
	    if(vis[p]) { printf("0\n"); return 0; }
	    vis[p]=1,pre[a[p]]=p,p=a[p];
	}while(p!=i);
    }
    for(int i=1,p,l1,l2;i<=n;++i)
	if(!deg[i])
	{
	    for(p=i,l1=0,l2=0;!vis[p];p=a[p]) vis[p]=1,++l1;
	    do ++l2,p=pre[p]; while(deg[p]^2);
	    if(l1<l2) ans=add(ans,ans); else if(l1>l2) return puts("0"),0;
	}
    for(int i=1;i<=n;++i)
	if(!vis[i])
	{
	    int p=i,l=0;
	    do ++l,p=a[p],vis[p]=1; while(p^i);
	    ++cnt[l];
	}
    for(int i=1;i<=n;ans=mul(ans,f[cnt[i++]]))
    {
	f[0]=1,f[1]=1+(i^1&&i&1);
	for(int j=2;j<=cnt[i];++j) f[j]=add(mul(i,mul(j-1,f[j-2])),mul(f[1],f[j-1]));
    }
    printf("%d",ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include <numeric>
using namespace std;
using ll = long long;
int main(){
  ll N;
  vector<ll> L;
  cin>>N;
  for(int i=0;i<N;++i){
    ll tmp;
    cin>>tmp;
    L.push_back(tmp);
  }
  ll a=accumulate(L.begin(),L.end(),0)-*max_element(L.begin(),L.end());
  if(a>*max_element(L.begin(),L.end())){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

#define IPS 1e-10

double area(int deg) {
    return sin((double)deg / 180 * M_PI);
}

int main() {
    int m, n;
    while (cin >> m, m) {
        int deg, remain = 360;
        double a1 = 0, a2 = 0;
        while (--m) {
            cin >> deg;
            remain -= deg;
            a1 += area(deg);
        }
        a1 += area(remain);

        remain = 360;
        cin >> n;
        while (--n) {
            cin >> deg;
            remain -= deg;
            a2 += area(deg);
        }
        a2 += area(remain);

        if (abs(a1-a2) < IPS) {
            cout << "0" << endl;
        }
        else if (a1 > a2) {
            cout << "1" << endl;
        }
        else {
            cout << "2" << endl;
        }

    }
    return 0;
}

Measured memory_bytes: 1188
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if(n <= k){
        cout << n * x << endl;
    } else {
        cout << k * x + (n - k) * y << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;

int main()
{
  flash
  ll n;
  cin>>n;

  string s;
  cin>>s;

  int cu[n][3]={{0}};

  if(s[n-1]=='R')
    cu[n-1][0]++;
  else if(s[n-1]=='G')
    cu[n-1][1]++;
  else
    cu[n-1][2]++;


  for(int i=n-2;i>=0;i--){
    if(s[i]=='R')
      cu[i][0]++;
    else if(s[i]=='G')
      cu[i][1]++;
    else if(s[i]=='B')
      cu[i][2]++;

      cu[i][0]+=cu[i+1][0];
      cu[i][1]+=cu[i+1][1];
      cu[i][2]+=cu[i+1][2];


  }

  // cout<<cu[2+1][2]<<"sfs";
  //   for(int j=0;j<n;j++){
  //     cout<<cu[j][0]<<" "<<cu[j][1]<<" "<<cu[j][2]<<"\n";
  //   }
    ll ans=0;
    for(int i=0;i+2<n;i++){
      for(int j=i+1;j+1<n;j++){

        if(s[i]!=s[j]){
      //    cout<<i<<" "<<j<<"\n";
          if((j+j-i)<n){
          if(s[j+j-i]!=s[i] && s[j+j-i]!=s[j] )
            ans--;}
        //    cout<<ans<<"\n";
          int a=0,b=0,c=0;

          if(s[i]=='R' || s[j]=='R')
            a=1;
           if(s[i]=='G' || s[j]=='G')
            b=1;
            if(s[i]=='B' || s[j]=='B')
            c=1;
          // cout<<a<<" "<<b<<" "<<c<<"\n";
          if(a==0)
            ans+=cu[j+1][0];
          if(b==0)
            ans+=cu[j+1][1];
          if(c==0)
            ans+=cu[j+1][2];
          //  cout<<ans<<"\n";
        }

      }
    }

    cout<<ans<<"\n";




}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A*B<=C*D) {
    cout << C*D;
  }
  else if (A*B>C*D) {
    cout << A*B;
  }
}

Measured memory_bytes: 256
import math
N,D = map(int,input().split())
X = [list(map(int, input().split())) for i in range(N)]
count = 0
for i in range(N):
    for j in range(i+1,N):
        n = 0
        for k in range(D):
            n = n + (X[i][k]-X[j][k])**2
        n = math.sqrt(n)
        if n.is_integer():
            count += 1
print(count)


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

int main() {
  int N;
  cin >> N;
  int result;
  bool flag = false;
  for (int i = N; i > 0; i--) {
  	int tmp = i * 1.08;
    if (tmp == N) {
      flag = true;
      result = i;
      break;
    } else if (tmp < N) {
      break;
    }
  }
  if (flag) {
    cout << result << endl;
  } else {
  	cout << ":(" << endl;
  } 
}


Measured memory_bytes: 256
#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++)

int main() {
  string s; 
  cin >> s;
  
  long ch=0;
  long co=0;
  rep(i,s.size()){
    if(s.at(i)=='W'){
      ch+=i+1;
      co++;
    }
  }
  cout<<ch-co*(co+1)/2<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	if (l % d == 0) {
		cout << r / d - l / d + 1 << endl;
	}
	else cout << r / d - l / d << endl;
	return 0;
}

Measured memory_bytes: 3616
///*
#include<iostream>
using namespace std;

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (a != b && b != c && c != a) {
		cout << "3";
	}
	else if (a == b && b != c && c != a) {
		cout << "2";
	}
	else if (a != b && b == c && c != a) {
		cout << "2";
	}
	else if (a != b && b != c && c == a) {
		cout << "2";
	}
	else {
		cout << "1";
	}

	return 0;
}
//*/

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-27
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    int group_num = -1;
    for (int i = 1; i <= N; ++i) {
        if(i * (i-1) == 2 * N){
            group_num = i;
            break;
        }
    }

    if(group_num == -1){
        if(N == 1){
            cout << "Yes\n2\n1 1\n1 1\n";
        }else{
            cout << "No" << "\n";
        }
        return 0;
    }

    cout << "Yes" << "\n";
    cout << group_num << "\n";

    vector<int> group[100000];
    int a = 1;
    for (int i = 0; i < group_num; ++i) {
        cout << group_num-1;
        for (int j = 0; j < i; ++j) {
            group[i].push_back(group[i-1][i-1]);
            cout << " " << group[j][i-1] ;
        }
        for (int j = i; j < group_num - 1; ++j) {
            cout << " " << a;
            group[i].push_back(a++);
        }
        cout << "\n";
    }

    return 0;
}


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

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned long ul;

int sumdigit(int x) {
  int res = 0;
  for(auto c : to_string(x)) {
    res += (c-'0');
  }
  return res;
}

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

  int ans = numeric_limits<int>::max();
  for(int x=1; x<=n/2;x++){
    ans = min(ans, sumdigit(x)+sumdigit(n-x));
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+5;
ll dp[N];
ll a[N];
int k;
ll solve(int i)
{
  if(i<=1)
return 0;
else if(dp[i]!=-1)
return dp[i];
ll ans=INT_MAX;
for(int j=1;j<=min(k,i-1);j++)
ans=min(abs(a[i]-a[i-j])+solve(i-j),ans);
return dp[i]=ans;
}
int main()
{
  int n;
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i],dp[i]=-1;
a[0]=INT_MAX;
cout<<solve(n)<<endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,string> mypair;

int main(void){
int n,m;
cin>>n;
string a,b;
vector<mypair> ans;
priority_queue<string> q;
for(int i=0;i<n;i++){
	cin>>a;
	q.push(a);
}

a=q.top();
q.pop();
int c=1;
while(!q.empty()){
	b=q.top();
	q.pop();
	if(a==b){
		c++;
	}else{
		ans.push_back(mypair(c,a));
		c=1;
		a=b;
	}
}
ans.push_back(mypair(c,a));
cin>>m;
for(int i=0;i<m;i++){
	cin>>b;
	for(int j=0;j<ans.size();j++){
		if(ans[j].second==b){
			ans[j].first--;
			break;
		}
	}
}
int d=0;
for(int i=0;i<ans.size();i++){
	d=max(ans[i].first,d);

}
cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int time = in.nextInt();
			int[] t = in.nextIntArray(n);
			long sum = 0;
			Deque<Time> st = new ArrayDeque<Time>();

			for (int i = 0; i < n; i++) {
				int from = t[i];
				int to =  t[i] + time;
				if (st.isEmpty()) {
					st.push(new Time(from, to));
				} else {
					Time timez = st.peek();
					if (timez.to >= from) {
						st.remove();
						st.push(new Time(timez.from, to));
					} else {
						st.push(new Time(from, to));
					}
				}
			}

			while (!st.isEmpty()) {
				Time timez = st.pop();
				sum += timez.calcTime();
			}

			out.println(sum);
		}
	}
	static class Time {
		int from;
		int to;

		Time(int from, int to) {
			this.from = from;
			this.to = to;
		}

		long calcTime() {
			return this.to - this.from;
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 47576
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Battle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);

  int h0 = (c + b - 1) / b;
  int h1 = (a + d - 1) / d;

  if (h0 <= h1) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 3164
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class Point{
public:
  int x;
  int y;
  Point(int _x,int _y) : x(_x),y(_y) {}
  bool operator<(const int h) const{
    return y < h;
  }

  bool operator==(const Point& p) const {
    return (x == p.x && y == p.y);
  }
};

bool comp_x(const Point& p1,const Point& p2) {
  if(p1.x != p2.x){
    return p1.x < p2.x;
  }else{
    return p1.y < p2.y;
  }
}

bool comp_y(const Point& p1,const Point& p2) {
  if(p1.y != p2.y){
    return p1.y < p2.y;
  }else{
    return p1.x < p2.x;
  }
}

int compute_distance(const Point& p1,const Point& p2) {
  return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
}

int main(){
  int total_points;
  while(~scanf("%d",&total_points)){

    vector<Point> points_sort_by_x;
    vector<Point> points_sort_by_y;
    
    for(int i=0;i<total_points;i++){
      int x;
      int y;
      cin >> x >> y;
      points_sort_by_x.push_back(Point(x,y));
      points_sort_by_y.push_back(Point(x,y));
    }
    
    int res = INF;
    sort(points_sort_by_x.begin(),points_sort_by_x.end(),comp_x);
    sort(points_sort_by_y.begin(),points_sort_by_y.end(),comp_y);
    
    for(int i=0;i+1<points_sort_by_x.size();i++){
      res = min(compute_distance(points_sort_by_x[i],points_sort_by_x[i+1]),res);
      int y_idx = lower_bound(points_sort_by_y.begin(),points_sort_by_y.end(),points_sort_by_x[i].y) - points_sort_by_y.begin();

      for(int j=y_idx;j<points_sort_by_y.size();j++){
        if(points_sort_by_y[j] == points_sort_by_x[i]){
          if(j > 0) {
            res = min(compute_distance(points_sort_by_x[i],points_sort_by_y[j-1]),res);
          }
          if(j < points_sort_by_y.size() - 1){
            res = min(compute_distance(points_sort_by_x[i],points_sort_by_y[j+1]),res);
          }

          break;
        }
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll dectobin(ll n,ll p[])
{
    ll i=0 ;
    while(n!=0)
    {
        p[i]=n%2 ;
        n/=2 ;
        i++ ;
    }
    return(i-1) ;
}
ll binarySearchCount(ll arr[], ll n, ll key) 
{ 
    ll left = 0; 
    ll right = n - 1; 
  
    ll count = 0; 
  
    while (left <= right) { 
        int mid = (right + left) / 2; 
  
        // Check if middle element is 
        // less than or equal to key 
        if (arr[mid] < key) { 
  
            // At least (mid + 1) elements are there 
            // whose values are less than 
            // or equal to key 
            count = mid + 1; 
            left = mid + 1; 
        } 
  
        // If key is smaller, ignore right half 
        else
            right = mid - 1; 
    } 
  
    return count; 
} 
void printDivisors(ll n,ll k) 
{  ll temp=1  ;
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                {
                	if(i<=k && i>temp)
                	temp=i ;
				}
  
            else // Otherwise print both 
                
                {
                if(i<=k && i>temp)
                	temp=i ;
                if(n/i<=k && n/i>temp)
                temp=n/i ;
				}
        } 
    }
	cout<<n/temp<<"\n" ;
	return ; 
} 

int main(int argc, char** argv)
{   sws ;

// tcase
{   
  ll n,k ;
  cin>>n>>k ;
  ll h[n],val[n] ;
  forn(i,n)
  {
  cin>>h[i] ;
  val[i]=1e9+7;
  }
  val[0]=0 ;
  val[1]=abs(h[1]-h[0]) ;
 // cout<<val[0]<<" "<<val[1]<<" ";
  for(int i=2;i<n;i++ )
  { for(int j=i-1;j>=0&&j>=i-k;j--)
  	{
	  val[i]=min(val[i],val[j]+abs(h[i]-h[j])) ;
	 // cout<<val[i]<<"\n";
    }
    //cout<<val[i]<<" ";
  }
  cout<<val[n-1]<<"\n";
}
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
int a[30], b[30], n;
char s[100];
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < 26; ++i) a[i] = 100;
	for (int i = 0; i < n; ++i) {
		memset(b, 0, sizeof(b));
		scanf("%s", s);
		for (int i = 0; s[i]; ++i) b[s[i] - 'a']++;
		for (int i = 0; i < 26; ++i) a[i] = min(a[i], b[i]);
	}
	for (int i = 0; i < 26; ++i) {
		while (a[i]) {
			a[i]--;
			putchar(i + 'a');
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int cnt = 0;
  while (b <= a) {
    b *= 2;
    cnt++;
  }
  while (c <= b) {
    c *= 2;
    cnt++;
  }
  if (cnt <= k) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3564
INF = 10 ** 15


def bellman_ford(v, G):
    ret = [INF] * len(G)
    ret[v] = 0

    for _ in range(len(G) - 1):
        for u, g in enumerate(G):
            for w, l in g:
                if not ret[u] == INF and ret[w] > ret[u] + l:
                    ret[w] = ret[u] + l

    for _ in range(len(G)):
        for u, g in enumerate(G):
            for w, l in g:
                if not ret[u] == INF and ret[w] > ret[u] + l:
                    ret[w] = -INF

    return ret


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

ans = bellman_ford(0, G)[-1]
print('inf' if ans == -INF else -ans)


Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

INF = 10 ** 10

n = int(input())
# 貰うDPだと0へのアクセスが、配るDPだとn+1へのアクセスが必要になる
h = [INF] + list(map(int, input().split())) + [INF]
dp = [INF] + [INF] * n + [INF]
dp[1] = 0

def chmin(dp_table, index, value):
    if dp_table[index] > value:
        dp_table[index] = value

# 再帰(DFS) (メモ化あり: テーブル使用)
def dfs(i):
    if i == 0:
        return INF
    if i == 1:
        return 0
    if dp[i] != INF:
        return dp[i]

    ans = INF
    prev_cost = dfs(i-1)
    if ans > prev_cost + abs(h[i] - h[i-1]):
        ans = prev_cost + abs(h[i] - h[i-1])
    prev_cost = dfs(i-2)
    if ans > prev_cost + abs(h[i] - h[i-2]):
        ans = prev_cost + abs(h[i] - h[i-2])

    dp[i] = ans
    return dp[i]

print(dfs(n))


Measured memory_bytes: 124448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <map>


using namespace std;

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector< vector<int> > mat;

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 solve() {
  int a,b,c;
  cin>>a>>b>>c;
  if (a + b + c >= 22) {
    cout << "bust";
  } else {
    cout <<"win";
  }
  cout << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a,b, c = map(int, input().split())

    if abs(a-b) <abs(a-c):
        print("A")
    else:
        print("B")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll x;
  cin >> x;
  cout << "ABC" << x << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3604
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
total = a[0]
index = 1
cnt = 0
for i in range(N - 2):
    if cnt == 2:
        index += 1
        cnt = 0
    total += a[index]
    cnt += 1

print(total)

Measured memory_bytes: 31452
N = int(input())
S,T = input().split()

num_s = 0
num_t = 0
for i in range(2*N):
    if i%2 == 0:
        c = S[num_s]
        print(c,end="")
        num_s += 1
    else:
        c = T[num_t]
        print(c,end="")
        num_t += 1

Measured memory_bytes: 3060
n,k,c = map(int,input().split())
sl = list(input())

# 前貪欲
ansl = []
before = -float("inf")
for idx,s in enumerate(sl):
    if s == "o" and before + c < idx:
        before = idx
        ansl.append(idx)

if len(ansl) > k:
    print()
    exit()
# 後貪欲
ansl2 = []
before = -float("inf")
for idx,s in enumerate(sl[::-1]):
    if s == "o" and before + c < idx:
        before = idx
        ansl2.append(n-idx-1)

for a in sorted(list(set(ansl) & set(ansl2))):
    print(a+1)


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

ans = 0
if A >= B:
    #ひたすらたたく
    ans = 1 + K
else:
    #1円で増えるビスケットの枚数が2枚以下なら、たたいたほうがいい
    if B - A <= 2:
        ans = 1 + K
    else:
        #まずA枚にする
        k = K - (A - 1)
        if k < 2:
            ans = 1 + K
        else:
            #A枚を1円にかえて、1円をB枚に変える
            k -= 2 
            ans = B
            #残った手順でひたすらA枚を1円に、1円をB枚にする
            ans += (k // 2) * (B - A)
            ans += k % 2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'

#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#endif

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int t=1;
    //cin>>t;
    while(t--){
    	string s;cin>>s;
    	if(s.back()=='s')s+="es";
    	else s+='s';
    	cout<<s;
    }
}


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

int main() {

    string s;
    cin >> s;
    s += "R";
    int n = s.size();

    vector< int > r(n + 1, 0), l(n + 1, 0), ans(n);
    for(int i = 1; i <= n; i++) {
        r[i] = r[i - 1] + (s[i - 1] == 'R');
        l[i] = l[i - 1] + (s[i - 1] == 'L');
    }

    int mid = 0, st = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'L' && s[i - 1] == 'R') mid = i;
        if(s[i] == 'R' && s[i - 1] == 'L') {
            int w = (mid - st + 1);
            int l = (w / 2), r = w - l - 1;
            ans[mid - 1] = l + (i - mid) / 2, ans[mid] = r + ((i - mid) - ((i - mid) / 2));
            st = i;
        } else ans[i] = 0;
    }

    for(int i = 0; i < n - 2; i++) {
        cout << ans[i] << " ";
    }
    cout << ans[n - 2] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int MAX_N = 110;
char map[MAX_N][MAX_N];
int m, n;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

void dfs(int x, int y, char ch) {
    map[x][y] = '.';
    
    for (int i = 0; i < 4; i++) {
        int nx = x+dx[i], ny = y+dy[i];
        if (nx >= 0 && nx < m && ny >= 0 && ny < n && map[nx][ny] == ch) dfs(nx, ny, ch);
    }
}

int main() {
    while (cin >> m >> n) {
        if (m == 0 && n == 0) break;
        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++)
                cin >> map[i][j];
        int res = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (map[i][j] != '.') {
                    dfs(i, j, map[i][j]);
                    res++;
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)



int main(){
    int n,t;cin>>n>>t;
    int a[n];rep(i,n)cin>>a[i];
    int cur=a[0];
    multiset<int> ms;
    rep(i,n-1){
        if(a[i]>a[i-1])continue;
        ms.insert(a[i-1]-cur);
        if(cur>a[i])cur=a[i];
    }
    ms.insert(a[n-1]-cur);
    int ans=1;
    auto it=ms.end();
    --it;
    int mval=(*it);
    while(it!=ms.begin()){
        if(*(--it)!=mval)break;
        else ++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2944
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int r, g;
	cin >> r >> g;
	int ans = g * 2 - r;
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    // 整数の入力
    string S ;
    int N, K;
    cin >> N >> K ;
    cin >> S ;
    if(S[K-1] == 'A'){
        S[K-1] = 'a';
    }
    else if(S[K-1] == 'B'){
        S[K-1] = 'b';
    }
    else{
        S[K-1] = 'c';
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string move1,move2,move3,move4;
    move3 += "LU";
    move4 += "RD";
    REP(i,ty - sy){
        move1 += "U";
        move3 += "U";
        move2 += "D";
        move4 += "D";
    }
    REP(i,tx - sx){
        move1 += "R";
        move3 += "R";
        move2 += "L";
        move4 += "L";
    }
    move3 += "RD";
    move4 += "LU";
    cout << move1 + move2 + move3 + move4 << endl;
}

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




int main()
{
int n, a;
cin >> n >> a;
int l = a;
int r = a+n-1;

int eat;
if(r<=0) eat = r;
else if(l >= 0)eat = l;
else eat = 0;

int ans = (r+l)*(r-l+1)/2-eat;

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



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<max(0LL,(n-2)*(b-a)+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int N;
  ll K;
  cin >> N >> K;

  ll num[100010] = {};

  REP(i, N) {
    int a, b;
    cin >> a >> b;
    num[a] += b;
  }

  ll total = 0;
  REP(i, 100010) {
    total += num[i];
    if (total >= K) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1024