akhauriyash/Code-Regression huggingface dataset:
#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>;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//無限大
const ll INF = 1LL << 60;


//------------------------------------------------
int main() {

    //main
    int N;
    cin >> N;
    int ans[N];
    rep(i,N) ans[i] = 0;
    int Ai;
    rep(j,N-1){
        cin >> Ai;
        ans[Ai-1] ++;
    };

    rep(i,N) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 4412
import numpy as np

n,m,x = map(int,input().split())
seen = []
ans = 10**7

for i in range(n):
  seen.append(list(map(int,input().split())))
  
for i in range(2**n):
  temp = 0
  base = np.zeros(m)
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        base[k] += seen[j][k+1]
      temp += seen[j][0]
 
  if (np.min(np.where(base >= x,1,0)) == 1) and (ans > temp):
    ans = temp
    
if ans == 10**7:
  ans = -1
  
print(ans)

Measured memory_bytes: 27164
#include<stdio.h>
double crossProduct(double *t,double *s){
	return t[0]*s[1]-t[1]*s[0];
}
int main(){
	double a[2],b[2],c[2], p[2];
	double ab[2],bc[2],ca[2];
	double ap[2],bp[2],cp[2];
	for(;scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a[0],&a[1],&b[0],&b[1],&c[0],&c[1],&p[0],&p[1])!=EOF;){
		ab[0]=b[0]-a[0];ab[1]=b[1]-a[1];
		bc[0]=c[0]-b[0];bc[1]=c[1]-b[1];
		ca[0]=a[0]-c[0];ca[1]=a[1]-c[1];
		ap[0]=p[0]-a[0];ap[1]=p[1]-a[1];
		bp[0]=p[0]-b[0];bp[1]=p[1]-b[1];
		cp[0]=p[0]-c[0];cp[1]=p[1]-c[1];
		if((crossProduct(ab,ap)>0&&crossProduct(bc,bp)>0&&crossProduct(ca,cp)>0)||(crossProduct(ab,ap)<0&&crossProduct(bc,bp)<0&&crossProduct(ca,cp)<0)){
			printf("YES\n");
		}
		else printf("NO\n");
	}
	return 0;
}

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

int main() {
	int64_t N;
	cin >> N;
	for (int i = 1;i <= 3500;i ++) {
		for (int j = 1;j <= 3500;j ++) {
			if ((4 * i * j - (i + j) * N) <= 0) continue;
			if ((i * j * N) % (4 * i * j - (i + j) * N) == 0) {
				cout << i << " " << j << " " << (i * j * N) / (4 * i * j - (i + j) * N);
				return 0;
			}
		}
	}
	return 0;
}

// 4hnw = Nnw + Nhw + Nhn
// (4hn - Nn - Nh)w = Nhn

Measured memory_bytes: 256
import math
a,b,C = map(int, input().split())

S = 0.5 * a * b * math.sin(C/180*math.pi)
L = a + b + math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C/180*math.pi))
h = b * math.sin(C/180*math.pi)

print(S)
print(L)
print(h)


Measured memory_bytes: 5716
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto s = RD!string;
	long ans;
	foreach (c; s)
	{
		if (c == '1')
			++ans;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){
    while(true){
        int N,M;
        cin >> N >> M;
        if(N == 0) break;

        vector<int> Hs;
        Hs.push_back(0);
        for(int i=0;i<N;i++){
            int h;
            cin >> h;
            Hs.push_back(Hs.back()+h);
        }

        vector<int> Ws;
        Ws.push_back(0);
        for(int i=0;i<M;i++){
            int w;
            cin >> w;
            Ws.push_back(Ws.back()+w);
        }

        vector<int> HW(Hs.back()+Ws.back()+10);
        for(int i=0;i<Hs.size();i++){
            for(int j=0;j<Ws.size();j++){
                int h = Hs[i];
                int w = Ws[j];

                int hw = h + w;
                HW[hw]++;
            }
        }
        int cnt = 0;
        for(int i=0;i<HW.size();i++){
            if(HW[i] >= 2){
                cnt += HW[i]*(HW[i]-1)/2;
            }
        }
        cout << cnt << endl;

    }
    return 0;
}

Measured memory_bytes: 5692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  char c;
  cin >> c;
  if ('a' <= c && c <= 'z')
  {
    cout << 'a' << endl;
  }
  else
  {
    cout << 'A' << endl;
  }
  return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int n; cin>>n;
	vector<queue<int>> a(n);
	for(int i=0; i<n; i++){
		for(int j=0; j<n-1; j++){
			int a0; cin>>a0;
			a.at(i).push(--a0);
		}
	}
	int ans{};
	vector<int> d(n);
	iota(d.begin(),d.end(),0);
	while(1){
		vector<bool> c(n);
		vector<int> e;
		for(int i=0; i<d.size(); i++){
			int j=d.at(i);
			if(a.at(j).empty()) continue;
			auto b = a.at(j).front();
			if(c.at(b)||c.at(j)) continue;
			if(a.at(b).front()==j){
				a.at(j).pop();
				a.at(b).pop();
				c.at(j)=1;
				c.at(b)=1;
				e.push_back(j);
				e.push_back(b);
			}
		}
		if(e.size()==0){
			bool flg{1};
			for(int i=0; i<n; i++){
				flg &= a.at(i).empty();
			}
			if(flg) break;
			else{
				cout << -1 << endl;
				return 0;
			}
		}
		ans++;
		d = e;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 4736
N = int(input())
S = input()
anss = []
for i in range(1000):
    str_i = str(i).zfill(3)
    idx1 = S.find(str_i[0], 0)
    idx2 = S.find(str_i[1], idx1 + 1)
    idx3 = S.find(str_i[2], idx2 + 1)
    if idx1 != -1 and idx2 != -1 and idx3 != -1:
        anss.append(str_i)

print(len(set(anss)))

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;i++)cin >> v[i];
	sort(v.begin(),v.end());
	float ans =v[0];
	for(int i=1;i<n;i++){
		ans= (ans+v[i])/2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX(a, b) (a >= b ? a : b)
#define MIN(a, b) (a >= b ? b : a)

int main(void)
{
  int n;
  int maxv = -1e9;
  int minv;

  std::cin >> n;
  std::cin >> minv;
  n--;

  while (n--){
    int temp;
    std::cin >> temp;
    maxv = MAX(maxv, temp - minv);
    minv = MIN(minv, temp);
  }
  std::cout << maxv << std::endl;
  return (0);
}

Measured memory_bytes: 1164
#include<stdio.h>

int main(void){
   int n, x;    // input; 3<=n<=100
   int i, j, k;
   int cnt = 0;

   scanf("%d %d", &n, &x);
   while(n!=0 || x!=0){
      for(i=n;i>=3;i--){
         for(j=i-1;j>=2;j--){
            for(k=j-1;k>=1;k--){
               if(i+j+k == x) cnt++;
            }
         }
      }
      printf("%d\n", cnt);
      scanf("%d %d", &n, &x);
      cnt = 0;
   }

   return 0;
}

Measured memory_bytes: 600
while (line = gets)
  print line.upcase
end


=begin

今回は一行だけであるので、単に、　puts gets.upcase だけでもいい。

・すべて大文字変換するのなら、 upcase を使用。
・すべて小文字変換するのなら、 downcase を使用。
・大文字と小文字の反転を行う場合には、swapcase　を使用。
・先頭だけ大文字に変換する場合には、capitalize　を使用
・特定の文字だけを変換したい場合、trを使用。

p "hello world".upcase
"HELLO WORLD"

p "WHAT IS THIS".downcase
"what is this"

p "ibc BootCamp".swapcase
"IBC bOOTcAMP"

p "ruby on rails".capitalize
"Ruby on rails"

p "こんにちわ　２０１６年".tr('０-９ａ-ｚＡ-Ｚ','0-9a-zA-Z')
"こんにちわ　2016年"

=end



Measured memory_bytes: 6852
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

struct Edge
{
    public int to;
    public int dist;
}
struct FC
{
    public int now;
    public int from;
    public bool color;
}
class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var u = new int[N - 1];
        var v = new int[N - 1];
        var w = new int[N - 1];
        for (int i = 0; i < N - 1; i++)
        {
            var line = ReadLine().Split(' ');
            u[i] = int.Parse(line[0]) - 1;
            v[i] = int.Parse(line[1]) - 1;
            w[i] = int.Parse(line[2]);
        }

        var tree = new List<Edge>[N];
        for (int i = 0; i < tree.Length; i++)
        {
            tree[i] = new List<Edge>();
        }
        for (int i = 0; i < u.Length; i++)
        {
            tree[u[i]].Add(new Edge { to = v[i], dist = w[i] });
            tree[v[i]].Add(new Edge { to = u[i], dist = w[i] });
        }

        var vis = new bool[N];
        var col = new bool[N];
        var q = new Queue<FC>();
        q.Enqueue(new FC { from = -1, color = false });
        vis[0] = true;
        while (q.Count != 0)
        {
            var n = q.Dequeue();
            if (n.from != -1)
            {
                col[n.now] = n.color;
            }
            foreach (var s in tree[n.now])
            {
                if (!vis[s.to])
                {
                    q.Enqueue(new FC { now = s.to, color = s.dist % 2 == 0 ? n.color : !n.color });
                    vis[s.to] = true;
                }
            }
        }

        for (int i = 0; i < N; i++)
        {
            WriteLine(col[i] ? "0" : "1");
        }
    }
}


Measured memory_bytes: 31684
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
 
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
 
 
 
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
 
 
//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}
 
 
 
int main() {

	int X,ans;
	cin >>X;

	if (X>=400 && X<=599){ans=8;}
	if (X>=600 && X<=799){ans=7;}
	if (X>=800 && X<=999){ans=6;}
	if (X>=1000 && X<=1199){ans=5;}
	if (X>=1200 && X<=1399){ans=4;}
	if (X>=1400 && X<=1599){ans=3;}
	if (X>=1600 && X<=1799){ans=2;}
	if (X>=1800 && X<=1999){ans=1;}
	
	cout << ans;
 
	return 0;
 
 
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var h = inputs[0];
            var w = inputs[1];

            var field = new string[h];
            var startBlack = 0;

            for(int i = 0; i < h; i++)
            {
                field[i] = Console.ReadLine();
                for(int j = 0; j < w; j++)
                {
                    if (field[i][j] == '#')
                    {
                        startBlack++;
                    }
                }
            }

            var que = new Queue<(int, int)>() ;
            que.Enqueue((0, 0));

            var moveCount = new int[h, w];

            var visited = new bool[h, w];
            visited[0, 0] = true;

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

            while (que.Count > 0)
            {
                var (x, y) = que.Dequeue();
                if((x,y) == (h - 1, w - 1))
                {
                    break;
                }

                for (int i = 0; i < 4; i++) 
                {
                    var nx = x + dx[i];
                    var ny = y + dy[i];

                    if(nx < 0 || nx  >= h)
                    {
                        continue;
                    }
                    if (ny < 0 || ny >= w) 
                    {
                        continue;
                    }
                    if (visited[nx, ny])
                    {
                        continue;
                    }
                    if (field[nx][ny] == '#')
                    {
                        continue;
                    }

                    visited[nx, ny] = true;
                    moveCount[nx, ny] = moveCount[x, y] + 1;
                    que.Enqueue((nx, ny));
                }
            }
            var endBlack = h * w - moveCount[h - 1, w - 1] - 1;
            var score = endBlack - startBlack;

            /*
            Console.WriteLine(moveCount[h - 1, w - 1]);
            Console.WriteLine(startBlack);
            Console.WriteLine(endBlack);
            Console.WriteLine(score);
            */

            Console.WriteLine(visited[h - 1, w - 1] ? score : -1);
        }
    }
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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 (b<a) { a=b; return 1; } return 0; }

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N1, N2, N3, N4;

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

	cin >> N1 >> N2 >> N3 >> N4;
	
	int x[4] = { 1, 9, 7, 4 };
	
	bool ans = true;
	REP(i, 0, 4) {
		if(N1 != x[i] && N2 != x[i] && N3 != x[i] && N4 != x[i]) {
			ans = false;
			break;
		}
	}
	if(ans)		cout << "YES" << endl;
	else		cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll A, B, K;
	cin >> A >> B >> K;

	auto rem = max(0ll, K - A);
	A = max(0ll, A - K);
	B = max(0ll, B - rem);
	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 111

int main(void){
	char str[MAX];
	int len,i,flag;
	int counter = 0;
	while(scanf("%s",str) != EOF){
		flag = 1;
		len = strlen(str);
		for(i = 0; i < len / 2; i++){
			if(str[i] != str[len-1-i]){
				flag = 0;
				break;
			}
		}
		if(flag){
			counter++;
		}
	}
	printf("%d\n",counter);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
const int maxn = 101;
const int maxw = 100001;
ll dp[maxw];
int n, lim;
					
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> lim;
	for(int w, v, i = 0;i < n;++i){
		cin >> w >> v;
		for(int j = lim;j >= w;--j)dp[j] = max(dp[j], dp[j-w] + v);
	}
	cout << *max_element(dp, dp + lim + 1) << '\n';
}

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

#define ll long long
#define mod 100000000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int> v;
    char ch=s[0],cnt=0;
    ffor(i,0,n)
    {
        if(s[i]==ch) cnt++;
        else
        {
            v.pb(cnt);
            cnt=1;
        }
        ch=s[i];
    }
    v.pb(cnt);
    cout<<n-max(1,sz(v)-2*k);
    return 0;
}



Measured memory_bytes: 1020
kazu = int(input())#文字数
mozi = input()#文字
sitei = int(input())#取り出す文字
lst = []
#print(mozi[sitei])
for i in range(kazu):
    if mozi[i] == mozi[sitei-1]:
        print(mozi[i],end ="")
    else:
        print("*",end="")

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

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

    int n;
    cin >> n;

    vector<int> x(n);
    REP(i, n) cin >> x[i];

    vector<int> tmp(n);
    tmp = x;
    sort(tmp.begin(), tmp.end());

    map<int, int> index;
    REP(i, n)
        index.insert(make_pair(tmp[i], i + 1));

    REP(i, n) {
        int itr = index[x[i]];
        if (itr <= n / 2) cout << tmp[n / 2] << '\n';
        if (itr >= n / 2 + 1) cout << tmp[n / 2 - 1] << '\n';
    }
    return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    int n = sz(s);
    vector<int> cnt(3);
    rep(i, n) {
        cnt[s[i] - 'a']++;
    }
    if (abs(cnt[0] - cnt[1]) > 1 || abs(cnt[1] - cnt[2]) > 1 || abs(cnt[2] - cnt[0]) > 1) {
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<set>
#define ll long long
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>=10||b>=10)
        printf("-1\n");
    else
        printf("%d\n",a*b);
    return 0;
 
}


Measured memory_bytes: 888
from sys import stdin
input = lambda: stdin.readline().rstrip()
na, nb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)
print(ans)


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


int main(void){
  std::string s;
  std::cin >> s;
  if(s.at(s.size()-1)=='s')s += "es";
  else s += "s";
  std::cout << s;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
#define mod 1000000007
signed main(){
    int n,t;
    cin>>n>>t;
    int m[300000];
    for(int i=0;i<n;i++)cin>>m[i];
    int memo=m[0];
    int ans=0;
    for(int i=0;i<n-1;i++){
        if(m[i+1]-m[i]>=t){
            ans+=m[i]+t-memo;
            memo=m[i+1];
        }
    }
    ans+=m[n-1]+t-memo;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int N,M;
cin>>N>>M;
map<int,bool> broken;
rep3(i,M){
    int A;
    cin>>A;
    broken[A]=true;
}
ll dp[N+1];
dp[0]=1;
rep3(i,N){
    if(broken[i])dp[i]=0;
    else{
        if(i==1)dp[i]=dp[i-1];
        else{
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=mod;
        }
    }


}
cout<<dp[N]<<endl;


return 0;
}

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

#ifndef __cpp_lib_optional

struct nullopt_t {
	nullopt_t(const nullopt_t &) = default;
};
nullopt_t nullopt(nullopt_t{});

template <class T> class optional {
	T val;
	bool flag;

public:
	optional() : flag(false) {}
	optional(nullopt_t) : flag(false) {}
	optional(const T &x) : val(x), flag(true) {}
	optional &operator=(const T &x) {
		val = x;
		flag = true;
		return *this;
	}
	void reset() {
		flag = false;
	}
	T &operator*() {
		assert(flag);
		return val;
	}
	const T &operator*() const {
		assert(flag);
		return val;
	}
	explicit operator bool() const {
		return flag;
	}
	bool has_value() const {
		return flag;
	}
	T &value() {
		assert(flag);
		return val;
	}
	const T &value() const {
		assert(flag);
		return val;
	}
	T value_or(const T &x) const {
		return flag ? val : x;
	}
};
#endif

template <class T> class RUQRmQ {
	int n;
	T init;
	vector<T> node;
	vector<optional<T>> lazy;
	static int ceil2(int n) {
		int m = 1;
		while (m < n) m *= 2;
		return m;
	}
	void eval(int k, int l, int r) {
		if (lazy[k]) {
			node[k] = *lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 0] = *lazy[k];
				lazy[2 * k + 1] = *lazy[k];
			}
			lazy[k].reset();
		}
	}
	void update_impl(int a, int b, const T &x, int k, int l, int r) {
		eval(k, l, r);
		if (b <= l || r <= a) {
			return;
		} else if (a <= l && r <= b) {
			lazy[k] = x;
			eval(k, l, r);
		} else {
			update_impl(a, b, x, 2 * k + 0, l, (l + r) / 2);
			update_impl(a, b, x, 2 * k + 1, (l + r) / 2, r);
			node[k] = min(node[2 * k + 0], node[2 * k + 1]);
		}
	}
	T query_impl(int a, int b, int k, int l, int r) {
		if (b <= l || r <= a) {
			return init;
		}
		eval(k, l, r);
		if (a <= l && r <= b) {
			return node[k];
		} else {
			auto vl = query_impl(a, b, 2 * k + 0, l, (l + r) / 2);
			auto vr = query_impl(a, b, 2 * k + 1, (l + r) / 2, r);
			return min(vl, vr);
		}
	}

public:
	RUQRmQ(const vector<T> &vec, const T &_init) : init(_init) {
		build(vec);
	}
	void build(const vector<T> &v) {
		n = ceil2(v.size());
		node.assign(n * 2, init);
		lazy.assign(n * 2, nullopt);
		for (size_t i = 0; i < v.size(); ++i) {
			node[i + n] = v[i];
		}
		for (int i = n - 1; i > 0; --i) {
			node[i] = min(node[i * 2 + 0], node[i * 2 + 1]);
		}
	}
	void update(int l, int r, const T &x) {
		update_impl(l, r, x, 1, 0, n);
	}
	T operator[](int i) {
		assert(0 <= i && i < n);
		return operator()(i, i + 1);
	}
	T operator()(int l, int r) {
		assert(0 <= l && l < r && r <= n);
		return query_impl(l, r, 1, 0, n);
	}
	vector<T> to_a() {
		vector<T> res(n);
		for (int i = 0; i < n; ++i) {
			res[i] = operator[](i);
		}
		return res;
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	RUQRmQ<int> seg(vector<int>(n, INT_MAX), INT_MAX);
	while (q--) {
		int com;
		cin >> com;
		if (com == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		} else if (com == 1) {
			int s, t;
			cin >> s >> t;
			cout << seg(s, t + 1) << endl;
		}
	}
}


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

using namespace std;

int n, ans;
long long x[105];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", x + i);
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			for (int k = j + 1; k < n; k++) {
				if (x[i] == x[j]) continue;
				if (x[i] == x[k]) continue;
				if (x[k] == x[j]) continue;
				if (x[i] + x[j] <= x[k]) continue;
				if (x[i] + x[k] <= x[j]) continue;
				if (x[k] + x[j] <= x[i]) continue;
				ans++;
			}
	printf("%d\n", ans);
}

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

using namespace std;

typedef long long int ll;

const ll N=1e6+1;

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

ll fact[N];
bool prime[N];

void sieve(){
    for(ll i=2;i<N;i++){
        if(prime[i]==true){
            for(ll j=i*i;j<=N;j+=i){
                prime[j]=false;
                fact[j]=i;
            }
        }
    }
}

int main(){
    ll n;
    cin>>n;
    ll a[n],ans=0;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1])
            ans+=a[i-1]-a[i],a[i]=a[i-1];
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 5156
#include "bits/stdc++.h"
#include <random>

using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll D=365;
vi c(26);
vi last(26,-1);
vvi dat(D, vi(26));  // N * M の2次元配列
vvi AAlist(D, vi(D));  // N * M の2次元配列




ll calcscore(vi &Alist)
{
  for(ll i=0;i<26;i++){
    last[i]=-1;
  }
  

  ll sc=0;
  ll sct=0;
  ll l;
  ll id;
  ll factscore=0;
  for(ll i=0;i<D;i++){
    sc=-922337203685477580LL;
    for(ll j=0;j<26;j++){
      if (Alist[i]==j)continue;
      l=i-last[j];
      sct=l*c[j];
      factscore-=sct;
    }

    id=Alist[i];
    factscore+=dat[i][id];
    last[id]=i;
  }

  return factscore;
}



void makeseed(int xid,int startoffset)
{

  ll sc=0;
  ll sct=0;
  ll maxid=-1;
  ll factscore=0;
  
  for(ll i=0;i<26;i++){
    last[i]=startoffset-1;
  }

  for(ll i=startoffset;i<D;i++){
    sc=-922337203685477580LL;
    maxid=0;
    
    for(ll j=0;j<26;j++){
      ll l=i-last[j];
      l*=l;
      sct=l*c[j];
      factscore-=sct;
      sct=dat[i][j]+sct;
      if (sc<sct){
        sc=sct;
        maxid=j;
      }
    }
    factscore+=sc;
    last[maxid]=i;
    AAlist[startoffset][i]=maxid;
    //cout<<(maxid+1)<<endl;
  }


}





int main(){
  ll ans=0;
  ll debug=0;//本番では0に
  cin>>ans;
  ll factscore=0;


  for(ll i=0;i<26;i++){
    cin>>c[i];
  }
  for(ll i=0;i<D;i++){
    for(ll j=0;j<26;j++){
      cin>>dat[i][j];
    }
  }


  for(ll i=0;i<D;i++){
    makeseed(0,i);
  }
  



  for(ll i=1;i<D;i++){
    for(ll j=0;j<i;j++){
      AAlist[i][j]=AAlist[i-1][j];
    }
  }
  
  ll score=-922337203685477580LL;
  ll ansid=0;
  for(ll i=0;i<D;i++){
    if (score<calcscore(AAlist[i])){
      score=calcscore(AAlist[i]);
      ansid=i;
    }

    if (debug==1){
      cout<<calcscore(AAlist[i])<<endl;
    }

  }



  if (debug==0)
  {
    for(ll i=0;i<D;i++){
      cout<<(AAlist[ansid][i]+1)<<endl;
    }
  }else{
    cout<<calcscore(AAlist[ansid])<<endl;
  }
    

  return 0;
}

Measured memory_bytes: 4784
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u32,
        k: u32,
        mut h: [u64; n],
    }

    h.sort();
    let mut ans = std::u64::MAX;
    let mut i = 0;
    while i + k - 1 < n {
        if h[(i + k - 1) as usize] - h[i as usize] < ans {
            ans = h[(i + k - 1) as usize] - h[i as usize];
        }
        i += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4236
#include <iostream>

 

using namespace std;
//Sample 1D
int main()
{
    int i, h, m, s;
    cin >> i;
    h = i / 3600;
    m = i % 3600 / 60;
    s = i % 60;
    
    cout << h << ":" << m << ":" << s <<endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int sum;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
string in_t;
cin>>in_t;
for(int i=0;i<in_t.length()-1;i++)
{
	if(in_t[i]!=in_t[i+1])  sum++;
}
cout<<sum<<endl;
getchar();getchar();
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
      ll counter=0;
      for(int a=1;a<=sqrt(n);a++)
      {
        for(int b=1;b<=sqrt(n);b++)
        {
          ll c=0;
          ll x=i-(a*a)-(b*b)-(a*b);
          ll A=1,B=(a+b),C=-1ll*x;
          ll f=B*B-(4*A*C);
          
          if(f>=0)
          {
            float d=float(sqrt(float(f)));
            d=d-B;
            /*if(i==6&&a==1&&b==1)
            {
              cerr<<"f = "<<f<<" B = "<<B<<" C = "<<C<<" float d = "<<d<<endl;
            }*/
            ll YY=d;
            if((YY%2)==0)
            {
               c=YY;
              c/=2;
              if(c>0)
              {
               ll temp=(a*a)+(b*b)+(c*c)+(a*b)+(b*c)+(a*c);
               if(temp==i)
                {
                 counter++;
                }
              }

            }
          }
          /*if(i==6&&a==1&&b==1)
            {
              cerr<<a<<" "<<b<<" "<<c<<endl;
            }*/


        }
      }
      cout<<counter<<endl;
    }
}
return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (int t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d))
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
// AOJ 2317 Class Representative Witch
// 2018.4.11 bal4u

#include <stdio.h>
#include <stdlib.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int N, M;
int s[100002], t[100002];
int p[100002], a[100002];
int even[100002], odd[100002];

// 見つからなければ、小さい要素のうちの最大を返す
int bisearch_LE(int x)
{
	int m, l = 0, r = M;

    while (l < r) {
        m = (l+r) >> 1;
//		if (p[m] == x) return m;
        if (p[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

// 見つからなければ、大きい要素のうちの最小を返す
int bisearch_GE(int x)
{
	int m, l = 0, r = M;

    while (l < r) {
        m = (l+r) >> 1;
        if (p[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int i, j, k, mi, ma, f;
	long long ans;

	N = in(), M = in()+1;
	for (i = 0; i < N; i++) s[i] = in(), t[i] = in();
	p[0] = 0;
	for (i = 1; i < M; i++) p[i] = in();
	qsort(p, M, sizeof(int), cmp);
	p[M++] = 1000000002;
	for (i = 1; i < M; i++) a[i] = p[i]-p[i-1];

	even[0] = 0;
	for (i = 1; i < M; i++) {
		if (i & 1) odd [i] = odd [i-1]+a[i], even[i] = even[i-1];
		else       even[i] = even[i-1]+a[i], odd [i] = odd [i-1];
	}

	ans = 0;
	for (i = 0; i < N; i++) {
		if (s[i] < t[i]) f = 0, mi = s[i], ma = t[i];
		else             f = 1, ma = s[i], mi = t[i];
		if (f) {
			j = bisearch_LE(ma), k = bisearch_GE(mi);
			if (p[k] >= ma) ans += ma-mi;
			else {
				ans += ma-p[j];
				if ((k&1) ^ (j&1)) ans += p[k]-mi, k++;
				if (j&1) ans += even[j]-even[k];
				else     ans += odd [j]-odd [k];
			}
		} else {
			j = bisearch_GE(mi), k = bisearch_LE(ma);
			if (p[j] >= ma) ans += ma-mi;
			else {
				ans += p[j]-mi;
				if ((k&1) ^ (j&1)) ans += ma-p[k];
				if (j&1) { if (k > j) ans += odd [k]-odd [j+1]; }
				else     { if (k > j) ans += even[k]-even[j+1]; }
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 4196
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

int inp(){
  int x; 
  cin>>x;
  return x;
}

//=============================================================================//

void solve() {
    string s,t; cin>>s>>t;
    int ans  = 0;
    for(int i=0; i+t.length()-1 < s.length(); i++){
      string sub = s.substr(i, t.length());
      int match = 0;
      for(int j=0; j<t.length(); j++){
        if(sub[j]==t[j]) match++;
      }
      ans = max(ans, match);
    }
    cout<<t.length()- ans;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()

	s := 0
	for k := 1; ; k++ {
		s += k
		if s-A == (s+k+1)-B {
			fmt.Println(s - A)
			return
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  long long M = -INF;
  for (int i = 0; i < N; i++){
    M = max(M, a[i]);
  }
  vector<bool> add(N, false);
  if (M < 0){
    for (int i = 0; i < N; i++){
      if (a[i] == M){
        add[i] = true;
        break;
      }
    }
  } else {
    vector<long long> sum(2, 0);
    for (int i = 0; i < N; i++){
      if (a[i] > 0){
        sum[i % 2] += a[i];
      }
    }
    int m = 0;
    if (sum[1] > sum[0]){
      m = 1;
    }
    for (int i = m; i < N; i+= 2){
      if (a[i] > 0){
        add[i] = true;
      }
    }
  }
  vector<int> ans;
  while (a.size() > 1){
    int sz = a.size();
    if (!add.front()){
      a.erase(a.begin());
      add.erase(add.begin());
      ans.push_back(1);
    } else if (!add.back()){
      a.erase(prev(a.end()));
      add.erase(prev(add.end()));
      ans.push_back(sz);
    } else {
      int p;
      for (int j = 1; j < sz - 1; j++){
        if (add[j - 1] && !add[j] && add[j + 1]){
          p = j;
        }
        if (!add[j - 1] && !add[j] && !add[j + 1]){
          p = j;
        }
      }
      long long next = a[p - 1] + a[p + 1];
      a.erase(a.begin() + p);
      add.erase(add.begin() + p);
      a.erase(a.begin() + p);
      add.erase(add.begin() + p);
      a[p - 1] = next;
      ans.push_back(p + 1);
    }
  }
  cout << a[0] << endl;
  int cnt = ans.size();
  cout << cnt << endl;
  for (int i = 0; i < cnt; i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end()
using namespace std;
typedef long long ll;
vector <vector <int> > D;
int farthest(int v) {
	int y = -1;
	for(int i = 0; i < D.size(); i++) {
		if(i != v) {
			y = max(D[i][v], y);
		}
	}
	return y;
}
int main() {fio;
	int N;
	cin >> N;
	D.resize(N, vector <int> (N, 1e9));
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < N; j++) {
			if(s[j] == '1') {
				D[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			for(int k = 0; k < N; k++) {
				D[j][k] = min(D[j][i] + D[i][k], D[j][k]);
			}
		}
	}
	vector <int> clr(N, -1);
	clr[0] = 0;
	for(int i = 0; i < N; i++) {
		for(int v = 0; v < N; v++) {
			if(clr[v] != -1) {
				for(int u = 0; u < N; u++) {
					if(D[v][u] == 1) {
						if(clr[u] == clr[v]) {
							cout << -1;
							return 0;
						}
						clr[u] = 1 - clr[v];
					}
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < N; i++) {
		ans = max((int)ans, farthest(i));
	}
	cout << ans + 1;
	return 0;
}


Measured memory_bytes: 512
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	if(s=="ABC") print("ARC");
	else print("ABC");
	return 0;
}


Measured memory_bytes: 3628
s=input()
t=input()
ans=[]
match=''
for i in range(len(s)-len(t)+1):
    flag=True
    for j in range(len(t)):
        if s[i+j]==t[j] or s[i+j]=='?':
            continue
        else:
            flag=False
    if flag:
        match=s[0:i]+t+s[i+len(t):]
        ans.append(match.replace('?','a'))
if ans==[]:
    print('UNRESTORABLE')
else:
    print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


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






	if( ((c-1)/b)<=((a-1)/d)     )puts("Yes");


	else puts("No");


}


Measured memory_bytes: 3852
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
  S[++top]=x;
}
int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
return 0;
  }



Measured memory_bytes: 2060
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
c = 0
for i in range(1,N+1,2):
    t = 0
    for j in range(1,i+1):
        if i%j == 0:
            t += 1
    if t >= 8:
        c += 1
print(c)


Measured memory_bytes: 3436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		while((input = br.readLine()) != null){
			String[] v = input.split(" ");
			int year = Integer.parseInt(v[0]);
			int month = Integer.parseInt(v[1]) - 1;	// 0 <= month <= 11
			int date = Integer.parseInt(v[2]);
			String era = transToEra(new GregorianCalendar(year, month, date));
			System.out.println(era + ((era.equals("pre-meiji"))? "": " " + (month + 1) + " " + date));
		}
	}

	public static String transToEra(GregorianCalendar date){
		GregorianCalendar startMeiji = new GregorianCalendar(1868, Calendar.SEPTEMBER, 8);
		GregorianCalendar startTaisho = new GregorianCalendar(1912, Calendar.JULY, 30);
		GregorianCalendar startShowa = new GregorianCalendar(1926, Calendar.DECEMBER, 25);
		GregorianCalendar startHeisei = new GregorianCalendar(1989, Calendar.JANUARY, 8);
		final int yearField = Calendar.YEAR;
		if(date.before(startMeiji)){
			return "pre-meiji";
		}else if(date.before(startTaisho)){
			return "meiji " + (date.get(yearField) - startMeiji.get(yearField) + 1);
		}else if(date.before(startShowa)){
			return "taisho " + (date.get(yearField) - startTaisho.get(yearField) + 1);
		}else if(date.before(startHeisei)){
			return "showa " + (date.get(yearField) - startShowa.get(yearField) + 1); 
		}else{
			return "heisei " + (date.get(yearField) - startHeisei.get(yearField) + 1);
		}
	}
}

Measured memory_bytes: 17076
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,k;
    cin>>x>>k;
    rep2(i,k-x+1,x+k){
        cout<<i;
        if(i!=x+k-1){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256