akhauriyash/Code-Regression huggingface dataset:
def solve(str_in_arr):
    _year, _month, _day = str_in_arr[0].split("/")
    year, month, day = int(_year), int(_month), int(_day)
    if year < 2020 and month < 5 and day < 31:
        return "Heisei"
    else:
        return "TBD"

      
def main():
    date = [input()]
    print(solve(date))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;

int main(){
	cin>>n>>k;
	cout<<n-k+1<<endl;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define REP(i,n) for(int i=0; i < (n); ++i)
#define SIZE(c) (int) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
#define FWD(i,a,b) for (int i=(a); i<(b); ++i)
#define BCK(i,a,b) for (int i=(a); i>(b); --i)
#define PI 3.14159265358979311600
#define pb push_back
#define mp make_pair
#define st first
#define nd second

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

typedef vector < int > VI;
typedef vector<ll> VL;

typedef long double K;

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

	string s;
	cin >> s;
	string cur[2];
	vector<int> g[2];

	REP(iter, 2) {
		int j = 0;
		while (j < SIZE(s) && s[j] == 'x') ++j;
		g[iter].push_back(j);
		for (int i = j; i < SIZE(s); ++i) {
			cur[iter] += s[i];
			j = i + 1;
			while (j < SIZE(s) && s[j] == 'x') ++j;
			g[iter].push_back(j - i - 1);
			i = j - 1;
		}
		reverse(s.begin(), s.end());
	}
	if (cur[0] != cur[1]) {
		cout << -1 << '\n';
		return 0;
	}
	int result = 0;
	// REP(i, SIZE(g[0])) cout << g[0][i] << ' ' << g[1][i] <<endl;
	REP(i, SIZE(g[0])) result += max(g[0][i], g[1][i]) - min(g[0][i], g[1][i]);
	cout << result/2 << '\n';
	return 0;
}

Measured memory_bytes: 1864
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
int main()
{
    long N,K;
    std::cin >> N >> K;
    std::cout << std::ceil((double)(N-1)/(K-1)) << std::endl;
    return 0;
}

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

long double A,B,H,M;

void input(){
  cin >> A >> B >> H >> M ;
}

void solve(){
  long double H_d,M_d,diff,ans;
  long double pi;
  pi = 2.0*asin(1.0);
  H_d=(M+H*60.0)/720.0*2.0*pi;
  M_d=M/60.0*2.0*pi;
  
  ans=sqrt(pow(A,2)+pow(B,2)-2*A*B*cos(H_d-M_d));
  cout << setprecision(30) << ans << endl;
}

int main(){
  input();
  solve();
  return 0;
}


Measured memory_bytes: 4168
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k;
double p[200010],ans;
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lf",p+i),p[i]=(1.0+p[i])/2.0,p[i]+=p[i-1];
	for(int i=1;i<=n-k+1;i++)
		ans=max(ans,p[i+k-1]-p[i-1]);
	printf("%.12lf\n",ans);
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

P dfs(string s)
{
    if (s == "north")
    {
        return P(0, 1);
    }
    if (s == "west")
    {
        return P(90, 1);
    }
    int len = s.length();
    if (s.substr(0, 4) == "west")
    {
        P p = dfs(s.substr(4, len - 4));
        return P(p.first * 2 + 90, p.second * 2);
    }
    else
    {
        P p = dfs(s.substr(5, len - 5));
        return P(p.first * 2 - 90, p.second * 2);
    }
    return P(-1, -1);
}

// gcd(a, b)
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    string s;
    while (cin >> s, s != "#")
    {
        P p = dfs(s);
        ll g = gcd(p.first, p.second);
        p.first /= g;
        p.second /= g;
        if (p.second == 1)
        {
            cout << p.first << endl;
        }
        else
        {
            cout << p.first << "/" << p.second << endl;
        }
    }
}



Measured memory_bytes: 3152
import sys
import heapq

heap = []
while True:
	input_line = sys.stdin.readline()
	input_line = input_line.strip().split(' ')
	if input_line[0][0] == 'i' :
		heapq.heappush(heap,-int(input_line[1]))
	elif input_line[0][1] == 'x' :
		print(-int(heapq.heappop(heap)))
	else :
		break

Measured memory_bytes: 47240
#include <string.h>
#include <iostream>
#include <vector>
#include <algorithm>

//ツ債計ツ行ツ青板づーツ偲ヲツ督セ
int GetRowCount()
{
	int count;
	std::cin >> count;
	return count;
}


typedef enum{LEFT,DOWN,RIGHT,UP} DIRECTION;

typedef struct _BLOCK
{
	int fundmention;
	DIRECTION direct;
	int x,y;

	static bool xPred(struct _BLOCK left,struct _BLOCK right)
	{
		return left.x < right.x;
	}

		static bool yPred(struct _BLOCK left,struct _BLOCK right)
	{
		return left.y < right.y;
	}

} BLOCK;

void GetBoxRect(int rowcount){

	std::vector<BLOCK> blocks;
	BLOCK block;
	memset(&block,0,sizeof(BLOCK));
	blocks.push_back(block);

	for(int i = 0; i < rowcount - 1; i++){
		BLOCK block;
		std::cin >> block.fundmention >> (int &)block.direct;
		blocks.push_back(block);
	}

	for(int i = 1; i < rowcount; i++){
		blocks[i].x = blocks[blocks[i].fundmention].x;
		blocks[i].y = blocks[blocks[i].fundmention].y;
		switch(blocks[i].direct){
			case LEFT:
				blocks[i].x++;
				break;
			case DOWN:
				blocks[i].y++;
				break;
			case RIGHT:
				blocks[i].x--;
				break;
			case UP:
				blocks[i].y--;
				break;
		}
	}

	int w = std::max_element(blocks.begin(),blocks.end(),BLOCK::xPred)->x - std::min_element(blocks.begin(),blocks.end(),BLOCK::xPred)->x + 1;
	int h = std::max_element(blocks.begin(),blocks.end(),BLOCK::yPred)->y - std::min_element(blocks.begin(),blocks.end(),BLOCK::yPred)->y + 1;

	std::cout << w << ' ' << h << std::endl;
}

void A()
{
	int rowcount = GetRowCount();
	while(rowcount != 0){
		GetBoxRect(rowcount);
		rowcount = GetRowCount();
	}
}

int main()
{
	A();

	return 0;
}

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,k;
	cin>>n>>k;
	vector<bool> haveSnack(n, 0);
	for (int i = 0; i < k; i++){
		int d;
		cin>>d;
		for (int j = 0; j < d; j++){
			int temp;
			cin>>temp;
			temp--;
			haveSnack[temp] = 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (!haveSnack[i]){
			ans++;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

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

int main(){
  int n,dp[100010];
  cin>>n;
  dp[0]=0;
  for(int i=1;i<=100000;i++){
    dp[i]=1e9;
    int power=1;
    while(power<=i){
      dp[i]=min(dp[i],dp[i-power]+1);
      power*=6;
    }
    int power2=1;
    while(power2<=i){
      dp[i]=min(dp[i],dp[i-power2]+1);
      power2*=9;
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s[3];
    rp(i,3) cin >> s[i];
    rp(i,3) cout << (char)(s[i][0]+(int)('A'-'a'));
    cout <<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
inline long long qr()
{
	long long x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while (ch<='9'&&ch>='0')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
inline long long mul(long long x,long long y)
{
	int ans=0;
	while(y)
	{
		if(y&1)
		ans=(ans+x)%mod;
		y>>=1;
		x=(x+x)%mod;
	}
	return ans;
}
int n;
const int maxn=2e5+10;
long long a[maxn];
long long b[maxn];
long long ans;
int main()
{
	n=qr();
	for(register int i=1;i<=n;i++)
	{
		a[i]=qr();
		b[i]=(b[i]+b[i-1]+a[i]);
	}
	for(register int i=1;i<n;i++)
	{
		ans=(ans+mul(a[i],b[n]-b[i])%mod)%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6720
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s=sc.next();
		//String t= sc.next();
		int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0;
		long count1=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		/*for(int i=0;i<3;i++) {
			if(s.substring(i,i+1).equals(t.substring(i,i+1))) {
				count++;
			}
		}*/

		/*if(n<=9&&m<=9) {
			System.out.println(n*m);
		}else {
			System.out.println(-1);
		}*/

		System.out.println(n*n);
	}
}




Measured memory_bytes: 23380
import math
import itertools

N = int(input())

pos = list()

for i in range(N):
    pos.append(tuple(map(int, input().split())))

dists = dict()
for i in range(N):
    for j in range(i+1, N):
        dists[(i, j)] = math.sqrt(
            (pos[i][0]-pos[j][0])**2+(pos[i][1]-pos[j][1])**2)

total = 0
num = 0

for i in itertools.permutations(range(N)):
    num += 1
    pre = None
    for j in i:
        if pre is None:
            pre = j
            continue
        if pre > j:
            f = j
            t = pre
        else:
            t = j
            f = pre
        total += dists[(f, t)]

print(total/num)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main(void)
{
	int m[10] = { 0 }, x;

	for (int i = 0; i < 10; i++) {
		cin >> m[i];
		for (int j = i; j > 0; j--) {
			if (m[j] > m[j - 1]) { x = m[j]; m[j] = m[j - 1]; m[j - 1] = x; }
		}
	}
	for (int i = 0; i < 3; i++) {
		printf("%d\n", m[i]);
	}
}

Measured memory_bytes: 1148
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int a, b, k;
string s;
int main() {
	cin >> a >> b >> k;
	for (int i = a; i <= min(a + k - 1, b); i++) {
		cout << i << '\n';
	}
	for (int i = max(min(a + k - 1, b) + 1, b - k + 1); i <= b; i++) {
		cout << i << '\n';
	}
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int r,g,b,i,j,ans=0,n;
int main()
{
	scanf("%d%d%d%d",&r,&g,&b,&n);
	for(i=0;i*r<=n;i++)
	{
		for(j=0;j*g<=n-i*r;j++)
		{
			if((n-i*r-j*g)%b==0)ans++;	
		}	
	}	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= print . solve

solve :: [Int] -> Int
solve [h,w]
  | h == 1 || w == 1 = 1
  | otherwise = uncurry (+) $ (h*w) `divMod` 2

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 380
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  	string s;
  	cin >> s;
  	int memo,ans = 1e9;
  
  	rep(i,0,s.size()-2){
      	memo = 0;
     	rep(j,0,3){
        	memo += (int)(s[j+i] - '0')*pow(10,2-j);
        }
      	ans = min(ans, abs(753 - memo));
      
    }
  
  	cout << ans << endl;
  
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
 
    int N;
    bool flag = true;
    cin >> N;
    string S;
    cin >> S;
    
    
    if(N%2) flag = false;
    else{
        for(int i = 0; i < N/2; i++){
        if(S[i] != S[N/2+i])
            flag = false;
        }
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll e=1000000007;
long long int me(long long int x,long long int n,long long int M)
{
 long long int result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(__int128)(result*x)%M;
        x=(__int128)(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modInverse(ll A,ll B,ll M)
{
    ll k=B*(M-2);
    return me(A,k,M);
}
int main()
{
    
  ll n,k;
  
  cin>>n;cin>>k;
  ll dp[k+5]={0};
  ll i;
  ll seeta=0;
  i=k;
  while(i>=1)
  {
      ll sum=0;ll i1=2;
      ll j=i*i1;
      
      while(j<=k)
      {
         
          
          sum=(sum%e + dp[j]%e)%e ; 
          
          i1++;
           j=i*i1;
      }
      ll sum1 = k/i;
      ll ram = me(sum1,n,e);
      
      dp[i] = (ram - sum + e )%e;
      
      seeta=( seeta%e + (i%e*dp[i]%e)%e )%e  ;
      
      i--;
  }
    cout<<seeta;
    return 0;
}

Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i,N) for (int i = 0; i < N; i++)
#define llong long long

llong N;
vector<llong> H;

int main() {
    cin >> N; H.resize(N);
    rep(i,N) cin >> H[i];
    vector<llong> counter(N);
    counter[0] = 0;
    rep(i,N-1) {
        if (H[i] >= H[i+1]) counter[i+1] = counter[i]+1;
        else counter[i+1] = 0;
    }
    cout << *max_element(counter.begin(), counter.end()) << endl;
    return 0;

}

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

const int MOD = static_cast<int>(1e9 + 7);

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

    string S;
    cin >> S;
    unsigned long n = S.size();
    long long dp[100001][4] = {};  // { all, A, AB, ABC }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 4; ++j) {
            dp[i + 1][j] += dp[i][j] * (S[i] ==  '?' ? 3 : 1);
            dp[i + 1][j] %= MOD;
            if (j < 3 && (S[i] ==  '?' || S[i] == "ABC"[j] )) {
                dp[i + 1][j + 1] += dp[i][j];
                dp[i + 1][j + 1] %=  MOD;
            }
        }
    }

    cout << dp[n][3] << '\n';

    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>

int main()
{
    int i, j, k;

    //Input
    int n, m, l;
    scanf("%d%d%d", &n, &m, &l);
    int A[n][m], B[m][l];
    for( i = 0; i < n; ++i )
        for( j = 0; j < m; ++j )
            scanf("%d", &A[i][j]);
    for( i = 0; i < m; ++i )
        for( j = 0; j < l; ++j )
            scanf("%d", &B[i][j]);

    //Processing
    long int C[n][l];
    for( i = 0; i < n; ++i )
        for( j = 0; j < l; ++j )
            C[i][j] = 0;
    for( i = 0; i < n; ++i )
        for( j = 0; j < l; ++j )
            for( k = 0; k < m; ++k )
                C[i][j] += A[i][k] * B[k][j];

    //Output
    for( i = 0; i < n; ++i ){
        for( j = 0; j < l; ++j ){
            printf("%ld", C[i][j]);
            if( j != l-1 ) printf(" ");
        }
        printf("\n");
    }

    return 0;
}

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

ll f(ll a) {
    ll cnt1 = (a+1)/2;
    ll ans = cnt1%2;
    if (a%2 == 0) ans ^= a;
    return ans;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = f(b) ^ f(a-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
struct node {
  int id;
  int cap;
  struct node *next;
};
struct node **list;
int **flow, *visit, *delta, *prev, reached;
void Insert(int, int);
void Init(int);
int Maxflow(int, int, int);
int main(void)
{
  int i, x, y, v, e, s, t, maxflow = 0;
  scanf("%d %d %d", &x, &y, &e);
  v = x + y + 2;
  list = (struct node**)malloc(sizeof(struct node*) * v);
  flow = (int**)malloc(sizeof(int*) * v);
  visit = (int*)malloc(sizeof(int) * v);
  delta = (int*)malloc(sizeof(int) * v);
  prev = (int*)malloc(sizeof(int) * v);
  for (i = 0; i < v; i++) {
    list[i] = NULL;
    flow[i] = (int*)calloc(v, sizeof(int));
  }
  for (i = 0; i < e; i++) {
    scanf("%d %d", &s, &t);
    Insert(0, s + 1);
    Insert(x + t + 1, v - 1);
    Insert(s + 1, x + t + 1);
  }
  while (Init(v), Maxflow(0, v - 1, v)) {
    int n = v - 1;
    do {
      flow[prev[n]][n] += delta[v-1];
      flow[n][prev[n]] -= delta[v-1];
      n = prev[n];
    } while(n);
    maxflow += delta[v-1];
  }
  printf("%d\n", maxflow);
  for (i = 0; i < v; i++) {
    free(list[i]);
    free(flow[i]);
  }
  free(list);
  free(flow);
  free(visit);
  free(delta);
  free(prev);
}
void Insert(int a, int b)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->cap = 1;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->id = a;
  p->cap = 0;
  p->next = list[b];
  list[b] = p;
}
void Init(int size)
{
  int i;
  for (i = 0; i < size; i++) {
    visit[i] = 0;
    delta[i] = INT_MAX;
    prev[i] = -1;
  }
  reached = 0;
}
int Maxflow(int s, int t, int size)
{
  struct node *n;
  visit[s] = 1;
  if (s == t) return 1;
  for (n = list[s]; n != NULL; n = n->next) {
    int v = n->id;
    if (!visit[v] && flow[s][v] < n->cap) {
      prev[v] = s;
      delta[v] = MIN(delta[s], n->cap - flow[s][v]);
      reached = Maxflow(v, size - 1, size);
      if (reached) break;
    }
  }
  return reached;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
int N;
vi P{3,5,7};
int func(int K){
  if(K>N)
    return 0;
  int ret=0;
  rep(i,0,3){
    int X=K*10+P[i];
    ret+=func(X);
    }
  string S=to_string(K);
  set<char> X;
  rep(i,0,S.size())
    X.insert(S[i]);
  if(X.size()==3)
    ret++;
  return ret;
  }
signed main(){
  cin>>N;
  int ans=func(0);
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

def find(x):
    if p[x] == x:
        return x
    else:
        p[x] = find(p[x])
        return p[x]

def unite(x, y):
    px, py = find(x), find(y)
    p[px] = py

n, q = map(int, input().split())
p = list(range(n))
for _ in range(q):
    c, x, y = map(int, input().split())
    if c == 0:
        unite(x, y)
    else:
        print(1 if find(x) == find(y) else 0)


Measured memory_bytes: 13116
/*
 * d.cc: 
 */

#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() {
  string s, p;
  cin >> s >> p;

  int sn = s.size(), pn = p.size();

  for (int i = 0; i < sn; i++) {
    bool ok = true;
    for (int j = 0; j < pn; j++)
      if (s[(i + j) % sn] != p[j]) {
	ok = false;
	break;
      }
    if (ok) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    string s,t,u;
    cin >> s;
    int q;
    cin >> q;
    int flag= 0;
    rep(i,q){
        int a,f;
        char c;
        cin >> a;
        if(a==1) flag++;
        else{
            cin >> f >> c;
            if((f+flag)%2==1) t += c;//先頭に追加
            else u += c; //末尾に追加
        }
    }
    reverse(t.begin(),t.end());
    string ans = t+s+u;
    if(flag%2) reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
 
  bool ONAJI = false;
 for  (int i = 0; i < 3; i++) {
   if  ( S.at(i) == S.at(i+1) ) 
     ONAJI = true;
   } 
  
    if(ONAJI == true){
   cout << "Bad" << endl;
    }
  else {
   cout << "Good" << endl;  
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  REP(i, n) REP(j, m) {
    cin >> a[i][j];
    a[i][j]--;
  }
  bool ng[m];
  REP(i, m) ng[i] = false;
  int ans = n;
  REP(k, m) {
    int cnt[m];
    REP(i, m) cnt[i] = 0;
    REP(i, n) {
      bool next = false;
      REP(j, m) {
        if (next) continue;
        if (!ng[a[i][j]]) {
          cnt[a[i][j]]++;
          next = true;
        }
      }
    }
    int mx = 0;
    REP(i, m) {
      if (cnt[mx] < cnt[i]) mx = i;
    }
    ans = min(ans, cnt[mx]);
    ng[mx] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
const int INF = 1e9;
int m[3000];

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	x--;
	y--;
	rep(i, n)rep(j, n) {
		if (i == j)continue;
		int k = min(abs(j - i), min(abs(x - i) + abs(y - j) + 1,abs(i-y)+abs(j-x)+1));
		k--;
		m[k]++;
	}
	rep(i, n-1) {
		cout << m[i] / 2 << endl;
	}
	return 0;
	
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int N = (int)1e5+77;
const int inf = (int) 1e9+77;
const ll mod = (ll) 998244353;
const ld pi = acos(-1);

ll n, W, w[101], v[101], dp[101][N];

int main() {
    fast;
    cin >> n >> W;
    for1(i, n) cin >> w[i] >> v[i];
    for1(i, n) {
        forn(j, W + 1) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j - w[i] >= 0)dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }
    ll ans = 0;
    forn(i, W + 1) ans = max(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int money = 1e9;
  for(int i = 0; i < X + Y; i++) {
    money = min(money, (i*2*C)+max(0, X-i)*A+max(0, Y-i)*B);
  }
  cout << money << endl;

  return 0;
}


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

int I;
int O;
int T;
int J;
int L;
int S;
int Z;
long long int solve1(){
	int ti = I;
	int tj = J;
	int tl = L;
	long long int ans = 0;
	ans += O;
	ans += (L / 2) * 2;
	L %= 2;
	ans += (J / 2) * 2;
	J %= 2;
	ans += (I / 2) * 2;
	I %= 2;
	if (I&&J&&L){
		ans += 3;
	}
	I = ti;
	J = tj;
	L = tl;
	return ans;
}
int main(){
	cin >> I >> O >> T >> J >> L >> S >> Z;
	long long int ans = 0;
	for (int i = 0; i < 5; i++){
		ans = max(ans, solve1()+3*i);
		I--;
		J--;
		L--;
		if (I >= 0 && J >= 0 && L >= 0){

		}
		else{
			break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

s = input().rstrip()
ans = []
for ch in s:
    if ch == "0":
        ans.append("0")
    elif ch == "1":
        ans.append("1")
    else:
        if len(ans) > 0:
            ans.pop()
print("".join([item for item in ans]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6


 
int main(){
	fast;
	int n;
	cin>>n;
	bool flag=0;
	for(int i=0; i<n; i++){
	    int x;
	    cin>>x;
	    if(x%2==0){
	        if((x%3)!=0 && (x%5)!=0){ flag=1;}
	    }
	}
	if(!flag) cout<<"APPROVED";
	else cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX  500
#define HANI (1<<21)
#define WHITE  0
#define GRAY  1
#define BLACK  2

int n;
int A[MAX][MAX];

int main(){
  int i,j,e;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      A[i][j] = (e==-1) ? HANI : e;
    }
  }
  
  printf("%d\n",prim());

  return 0;
}

int prim(){
  int i,v,u,min,q[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    q[i] = HANI;
    p[i] = -1;
    color[i] = WHITE;
  }

  q[0] = 0;

  while(1){
    min = HANI;
    u = -1;
    for(i=0;i<n;i++){
      if(min > q[i] && color[i] != BLACK){
        u = i;
        min = q[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && A[u][v] != HANI){
        if(q[v] > A[u][v]){
          q[v] = A[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for(i = 0;i < n;i++){
    if(p[i] != -1){
      sum += A[i][p[i]];
    }
  }

  return sum;
}




Measured memory_bytes: 2040
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull  unsigned long long
#define ll long long int
#define ull unsigned long long 
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl vector< long long>v(n);
#define mii unordered_map<ll,ll>
double pi = 2*acos(0.0);
#define mod 1000000007

ll power(ll a,ll b){ ll res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}

 int main()
 {
       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
       ll tst;
       tst=1;
       //cin>>tst;
       while(tst--)
       {
         string s1,s2;
         cin>>s1>>s2;
         ll ans=0;
         for(int i=0;i<s1.length();i++)
         {
                   if(s1[i]!=s2[i])
                   ans++;
         }
         cout<<ans<<endl;
            
       }
 }

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
typedef pair<long long int, long long int> P;

vector<int> E[210000];

P func(int pos, int pre){
    P ret = P(pos, -1);
    for(int to : E[pos]){
        if(to != pre){
            P p = func(to, pos);
            if(p.second > ret.second){
                ret = p;
            }
        }
    }
    ret.second += 1;
    return ret;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    P p = func(1, -1);
    p = func(p.first, -1);
    if(p.second % 3 == 1){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s;

	cout<<s[0]<<strlen(s)-2<<s[strlen(s)-1]<<endl;



}


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

#define endl '\n'
#define endt '\t'
#define ends ' '
#define die(x) return cout << x << endl, 0;
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << '[' << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 924844033; 

////////////////////////

const int MAXN = 64;

int BigPower(ll a) {
	int b = -1;
	while (a) b++, a >>= 1;
	return b;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	#ifdef LOCAL
	ifstream cin("sample.in");
	#endif

	ll a, b; cin >> a >> b;
	int p = MAXN - 1;
	while (p >= 0 && (a >> p) == (b >> p)) p--;
	if (p == -1) die(1);
	ll c = 1LL << p;
	a &= (c << 1) - 1, b &= (c << 1) - 1;
	b = (1LL << (BigPower(b - c) + 1)) - 1;
	if (b < a) cout << (c + b - a + 1) + (c - a) << endl;
	else cout << ((c << 1) - 1) - a + 1 << endl;

	return 0;
}


Measured memory_bytes: 3660
/**
*   @Author : MeGA
*   @InitTime :02/08/20 16:09:01
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif

     ios::sync_with_stdio(false);
     cin.tie(0);
      int n;
      cin>>n;
      int x=(n%100);
      int y=(n/100);
      if((x==0|| x>12) && (y==0 || y>12)){
        cout<<"NA";
      }else if(x>12 ||x==0){
         cout<<"MMYY";
      }else if(y>12||y==0){
        cout<<"YYMM";
      }else{
        cout<<"AMBIGUOUS";
      }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c;
    int water = 0;

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

    if(b +c < a){
        printf("0\n");
    }else{
        printf("%d\n", b+c-a);
    }

    return 0;
}

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

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a > b) swap(a,b);
    if (b > c) swap(b,c);
    
    // a <= b <= c
    
    int count = 0;
    
    if ((c-b)% 2 == 0 && (c-a)%2 == 0){
        count += (c-b)/2 + (c-a)/2;
    }
    else if ((c-b)%2 == 1 && (c-a)%2 == 1){
         count += (c-b)/2 + (c-a)/2 + 1;
    }
    else {
       count += (c-b)/2 + (c-a)/2 + 2;
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n[256] = {0}, i;
	char s[1200], *t;

	for (;;) {
		t = fgets(s, 1200, stdin);
		if (t == NULL) break;
		for (i = 0; s[i] != '\0'; i++) {
			n[s[i]]++;
		}
	}
	for (i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a' + i, n['a' + i] + n['A' + i]);
	}

	return 0;
}



Measured memory_bytes: 2036
#include <stdio.h>

int main(void){
    int n,q, dig;
    
    while (scanf("%d", &n), n!=-1){
        dig = 0;
        q=0;
        while (n){
            q += n%4;
            q *= 10;
            n /= 4;
            dig++;
        }
        q /= 10;
        if (dig){
            while (dig--){
                printf("%d", q%10);
                q /= 10;
            }
        } else printf("0");
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 1032
package main
import "fmt"
import "sort"

func main(){
    // Your code here!
    var n int
    fmt.Scan(&n)
    
    arr := make([]int, n)
    for i := 0; i < n; i++{
        fmt.Scan(&arr[i])
    }
    
    sort.Ints(arr)
    fmt.Println(arr[n-1] - arr[0])
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long f(int a){
  if (a < 0) return 0;
  return 1LL * a * (a - 1) / 2;
}
int main() {
  double l;
  cin >> l;
  l /= 3;
  cout << fixed << setprecision(12) << l * l * l << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 10010;

vector< long long > v;


int main(){
	long long n , sum = 0 , mn , mx  ,a , b;
	cin >> n;
	mn = n + 1;
	for(long long i = 1;i * i <= n;i++){
		if(n % i == 0){
			v.push_back(i);
			if(i * i != n)
				v.push_back(n / i);
		}
	}
	for(int i = 0 ;i < (int)v.size();i++){
		v[i]--;
		if(v[i] == 0) continue;
		if(n % v[i] == (n / v[i]))
			sum += v[i];
	}
	cout << sum << endl;
    return 0;
} 

Measured memory_bytes: 384
#include <stdio.h>

void swap(int *a, int *b)
{
	*a += *b;
	*b = *a - *b;
	*a -= *b;
}

int main(void)
{
	int x, y, z;
	int n;
	int r;
	int i;
	
	while (1){
		scanf("%d %d %d", &x, &y, &z);
		
		if (x == 0 && y == 0 && z == 0){
			break;
		}
		
		if (x > y){
			swap(&x, &y);
		}
		if (y > z){
			swap(&y, &z);
		}
		
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d", &r);
			if (x * x + y * y < 4 * r * r){
				printf("OK\n");
			}
			else {
				printf("NA\n");
			}
		}
	}
	
	return (0);
}

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

int main(){
	int n,m;
	int t[100000],x[100000],p[100];
	int sum=0;
	cin>>n;
	for (int i = 0; i < n; i++){
		cin>>t[i];
		sum+=t[i];
	}

	cin>>m;
	for (int i = 0; i < m; i++){
		cin>>p[i]>>x[i];
	}

	for (int i = 0; i < m; i++){
		cout<<sum-t[p[i]-1]+x[i]<<endl;
	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void ryuka(int64_t &a1,int64_t &a2){
	int64_t n = a1;
  	a1 = a2;
  	a2 += n;
} 
 
int main() {
  int N;
  cin >> N;
  int64_t a1,a2;
  a1 = 2;
  a2 = 1;
  if(N != 1){
    for(int i=0;i<N-1;i++){
      ryuka(a1,a2);
    }
  } 
  cout << a2 << endl;
}

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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


int main()
{
  ul n,x[100];
  cin >> n;

  for (ul i=0;i<n;i++) cin>>x[i];

  ul cs,ms=INT64_MAX;
  for (ul i=1;i<=100;i++) {
    cs=0;
    for (ul j=0;j<n;j++) cs += (i-x[j])*(i-x[j]);
    ms=cs<ms?cs:ms;
  }

  cout << ms << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(size_t i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(size_t i = 0; i < n; i++)
#define asort(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.begin(), a.end(), greater<int>())
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 

int32_t main()
{
    fast_io;
    int n, k;
    cin >> n >> k;
    vi a(n);
    c(a, n);
    vi dp(n);
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i = 2; i < n; i++)
    {
        int m = INT_MAX;
        for(int j = 1; j <= k && j <= i; j++)
        {
            if(dp[i-j] + abs(a[i]- a[i-j]) < m)
                m = dp[i-j] + abs(a[i]- a[i-j]);
        }
        dp[i] = m;    
    }
    cout << dp[n-1];

    return 0;
}

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

using namespace std;

int main(){
    int n,w,ans = 0;
    cin >> n >> w;

    vector<pair<int,int>> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i].first >> v[i].second;
    }

    int dp[n][w+1];
    memset(dp,0,sizeof(dp));

    dp[0][v[0].second] = v[0].first;


    for(int i = 1; i < n; i++){
        dp[i][v[i].second] = v[i].first;
        for(int j = 0; j < w+1; j++){
            if(dp[i-1][j] != 0){
                dp[i][j] = max(dp[i-1][j],dp[i][j]);
                if(v[i].second + j <= w){
                    dp[i][j+v[i].second] = max(dp[i-1][j] + v[i].first,dp[i][j+v[i].second]);
                }
            }
        }
    }

    for(int i = 0; i <= w; i++){
        ans = max(ans,dp[n-1][i]);
    }

    cout << ans << "\n";
}



Measured memory_bytes: 7024
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<intt>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return (n*fact(n-1))%mod;
}

void go()
{
#ifndef ONLINE_JUDGE
  freopen("IN.txt","r",stdin);
  freopen("OUT.txt","w",stdout);
  #endif
}

int main(){
	go();
	fast_io
  string s;cin>>s;
  if(s.back()=='s'){
    //s.erase(s.begin()+s.size()-1);
    s+='e';
    s+='s';
  }
  else
    s+='s';
  cout << s <<"\n";
}





































Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

double EPS = 1.0e-08;

int main() {
  int N; cin>>N;
  vector<double> a(N);
  REP(i,N) cin>>a[i];
  int sum = 0;
  REP(i,N) sum += a[i];
  int ans = 0;
  int min = 100	* 100 *	100 + 10;
  REP(i,N) {
    double d = abs(a[i]*N-sum);
    if(d < min) {
      ans = i;
      min = d;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    int z[m];
    for(int i=0;i<m;i++)
        cin>>z[i];
    sort(z,z+m);
    int j;
    for(j=0;j<m;j++)
        if(z[j]>x)break;
    if(j<m-j)cout<<j;
    else cout<<m-j;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <cmath>
#include <numeric>
struct unique_factorization_element {
    std::uint32_t prime;
    std::uint8_t pow;
};
//std::ostream& operator<< (std::ostream& os, const unique_factorization_element& e)
//{
//    os << e.prime << '^' << std::uint16_t(e.pow);
//    return os;
//}
std::vector<unique_factorization_element> unique_factorization(std::uint64_t n)
{
    std::vector<unique_factorization_element> re;
    re.reserve(20);
    const std::uint32_t lim = std::sqrt(n);
    auto calc_pow = [&n](std::uint32_t prime){
        std::uint8_t re = 0;
        while(!(n % prime)){
            n /= prime;
            ++re;
        }
        return re;
    };
    if(const auto pow = calc_pow(2)) re.push_back({std::uint32_t(2), pow});
    for(std::uint32_t i = 3; i < lim; i += 2){
        if(const auto pow = calc_pow(i)) re.push_back({i, pow});
    }
    re.shrink_to_fit();
    return re;
}
template <class Container, class T, class BinaryOperation>
T accumulate(Container&& c, T init, BinaryOperation&& binary_op)
{
    return std::accumulate(std::begin(c), std::end(c), init, std::forward<BinaryOperation>(binary_op));
}
int main()
{
    std::uint64_t N, P;
    std::cin >> N >> P;
    if(1 == N){
        std::cout << P << std::endl;
        return 0;
    } else if(1 == P){
        std::cout << '1' << std::endl;
        return 0;
    }
    const auto unique_factorization_elements = unique_factorization(P);
    const auto re = accumulate(unique_factorization_elements, std::uint64_t(1), [N](auto prev, const auto& e){
        const std::uint8_t new_pow = e.pow / N;
        for(std::uint8_t i = 0; i < new_pow; ++i) prev *= e.prime;
        return prev;
    });
    std::cout << re << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  map<ll,ll> ma;
  rep(i,0,n){
    ll a;
    cin>>a;
    ma[a]++;
  }
  ll m;
  cin>>m;
  rep(i,0,m){
    ll a;
    cin>>a;
    if(ma[a]>0){
      ma[a]--;
    }
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int N;
vector<int> s;

int f(int n){
    int ng = 0-1, ok = N;
    while(ok - ng > 1){
        int mid = (ng + ok)/2;
        (s[mid] >= n ? ok : ng) = mid;
    }
    return ok;
}

signed main(){
    cin >> N;
    s = vector<int>(N);
    rep(i,N) cin >> s[i];
    int Q; cin >> Q;

    int ans = 0;
    while(Q--){
        int t; cin >> t;
        ans += !!(f(t+1) - f(t));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3504
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

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

	int m = *max_element(a.begin(), a.end());
	int val = MOD;
	int r = 0;
	
	for(int i = 0; i < n; ++i) {
		if( m == a[i] ) continue;
		
		else if( val > abs(m / 2 - a[i]) ) {
			val = abs(m / 2 - a[i]);
			r = a[i];
		}
	}
	
	cout << m << " " << r << endl;
	
	return 0;
}


Measured memory_bytes: 640
n = gets.to_i

def f(n, acc)
  [3, 5, 7].each do |i|
    j = acc*10 + i
    if j <= n
      yield j
      f(n, j) { |k| yield k }
    end
  end
end

count = 0
f(n, 0) { |i|
  if i.to_s.chars.uniq.size == 3
    count += 1
  end
}
puts count


Measured memory_bytes: 1788
import itertools
N,K=map(int,input().split())
S=input()
gr=itertools.groupby(S)
li=[] if S[0]=='1' else [0]
for key,group in gr:
    li.append(len(list(group)))
res=0
cum=[0]*(len(li)+1)
for i in range(len(li)):
    cum[i+1]=cum[i]+li[i]
for i in range(0,len(li),2):
    r=i+2*K+1
    if r>=len(cum):
        r=len(cum)-1
    res=max(res,cum[r]-cum[i])
print(res)

Measured memory_bytes: 46172
#include<stdio.h>
int main(){
  int n,i,ans=0;
  char s[2];
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%c",&s[0]);
    if(s[0]=='Y')ans++;
  }
  puts(ans>0?"Four":"Three");
  return 0;
}

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

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

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

  if (c >= a && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256