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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 0; i < ty - sy; ++i) cout << 'U';
	for (int i = 0; i < tx - sx; ++i) cout << 'R';
	for (int i = 0; i < ty - sy; ++i) cout << 'D';
	for (int i = 0; i < tx - sx; ++i) cout << 'L';
	cout << 'L'; 
	for (int i = 0; i < ty - sy; ++i) cout << 'U';
	cout << "UR";
	for (int i = 0; i < tx - sx; ++i) cout << 'R';
	cout << "DR";
	for (int i = 0; i < ty - sy; ++i) cout << 'D';
	cout << "DL";
	for (int i = 0; i < tx - sx; ++i) cout << 'L';
	cout << 'U';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

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




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

    int n,k,q;
    cin>>n>>k>>q;
    vec a(q);
    rep(i,q) cin>>a[i];

    vector<int> b(n,k-q);
    rep(i,q) b[a[i]-1]++;

    rep(i,n){
        if(b[i]>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3980
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Card{
  char suit;
  int value;
};
void bubble(struct Card A[],int N){
  int i,j;
  struct Card t;
  for(i = 0 ; i < N ; i++){
    for(j = N - 1 ; j >= i + 1 ; j--){
      if(A[j].value < A[j - 1].value){
	t = A[j];
	A[j] = A[j - 1];
	A[j - 1] = t;
      }
    }
  }    
}

void selection(struct Card A[],int N){
  int i,j,minj;
  struct Card t;
  for(i = 0 ; i < N ; i++){
    minj = i;
    for(j = i ; j < N ; j++){
      if(A[j].value < A[minj].value)minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

void print(struct Card A[],int N){
  int i;
  for(i = 0 ; i < N ; i++){
    if(i > 0)printf(" ");
    printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[],struct Card C2[],int N){
  int i;
  for(i = 0 ; i < N ; i++){
    if(C1[i].suit != C2[i].suit)return 0;
  }
  return 1;
}

int main(){
  struct Card C1[100],C2[100];
  int N,i;
  char num[3];

  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%s",num);
    C1[i].suit = num[0];
    C1[i].value = atoi(&num[1]);
  }

  for(i = 0 ; i < N ; i++){
    C2[i] = C1[i];
  }
  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  return 0;
}



Measured memory_bytes: 2112
/*
  AUTHOR:SOURABH
  CREATED:06:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,a,b,c,k,ans=0;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>a>>b>>c>>k;
        ans+=min(k,a);
        k-=min(k,a);
        k-=min(k,b);
        ans-=min(k,c);
        cout<<ans;
    }
    return 0;
}
















Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
struct node
{
    long long x,y,r;
}s[1005];

int n;
double map1[1005][1005],d[1005];
bool vis[1005];

long double cal(node a,node b)
{
    return (long double)sqrt((long double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
void dijkstra(int s)
{
    d[s]=0;
    while(1)
    {
        int v=-1;
        for(int i=0; i<=n+1; i++)
        {
            if(!vis[i] && (v==-1 || d[i]<d[v]))
            v=i;
        }
        if (v==-1) break;
        vis[v]=1;
        for(int i=0; i<=n+1;i++)
        d[i]=min(d[i],d[v]+map1[v][i]);
    }
}

int main()
{
    long long x1,y1;
    scanf("%lld%lld%lld%lld",&s[0].x,&s[0].y,&x1,&y1);
    scanf("%d",&n);
    s[n+1].x=x1;
    s[n+1].y=y1;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld%lld",&s[i].x,&s[i].y,&s[i].r);
    }
    for(int i=0; i<=n+1; i++)
    {
        for(int j=i+1; j<=n+1; j++)
        {
            map1[i][j]=cal(s[i],s[j]);
            map1[i][j]-=s[i].r+s[j].r;
            if(map1[i][j]<0)
                map1[i][j]=0;
            map1[j][i]=map1[i][j];
        }
    }
    for(int i=0; i<=n+1; i++)
        d[i]=1e37;
    dijkstra(0);
    printf("%.9lf\n",d[n+1]);
    return 0;
}


Measured memory_bytes: 8192
import java.util.*

fun simple(P: List<Long>): Long {
    var res = 0L
    for (i in P.indices) {
        for (k in 2..P.size - i) {
            val l = P.subList(i, i + k).sorted()
            res += l[l.size - 2]
        }
    }
    return res
}

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val P = readLine()!!.split(" ").map{it.toLong()}
    val Q = Array(N + 1) {0}

    for (i in P.indices) {
        Q[P[i].toInt()] = i
    }

    val st = TreeSet<Long>()
    var res = 0L

    for (k in N downTo 1) {
        val idx = Q[k].toLong()

        val l = st.lower(idx)
        val ll = idx - (l ?: -1L)
        val l2 = if (l == null) null else st.lower(l)
        val l2l = idx - (l2 ?: -1L)
        val r = st.higher(idx)
        val rl = (r ?: N.toLong()) - idx
        val r2 = if (r == null) null else st.higher(r)
        val r2l = (r2 ?: N.toLong()) - idx

        res += (l2l - ll) * rl * k
        res += ll * (r2l - rl) * k

        st.add(idx)
    }

    println(res)
//    println(simple(P))
}


Measured memory_bytes: 58580
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  string str; cin >> str;
  bool res = false;
  rep(i, str.size()){
    if(str[i] == '7') res = true;
  }

  if(res){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}  


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
template<typename T>inline void in(T &a)
{
	T ch=getchar(),f=1;
	for(a=0;!isdigit(ch);ch=getchar())
	  ch=='-'?f=-1:f=f;
	for(;isdigit(ch);ch=getchar())
	  a=(a<<3)+(a<<1)+ch-'0';
	a*=f;
}
template<typename T>inline void print(T x)
{
	if(x<0)
	  x=-x,putchar('-');
	if(x>9)
	  print(x/10);
	putchar(x%10+'0');
}
int a,n;
int ans=0;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		in(a);
		if(!(a&1))
		  ans++;
	}
	if(ans==n)
	  cout<<"second"<<endl;
	else
	  cout<<"first"<<endl;
		
	return 0;
}


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

int main(void){
    int n=0;
    string s;
    int k=0;
    char poyo=0;

    cin >> n;
    cin >> s;
    cin >> k;

    poyo=s[k-1];

    for(int i=0;i<n;i++){
        if(s[i]!=poyo)s[i]='*';
    }

    cout << s << endl;

    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int h, w;
    cin >> h >> w;
    char s[52][52];
    rep(i, h){
        rep(j, w){
            cin >> s[i][j];
        }
    }
    bool ok = true;
    
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#'){
                if(s[i][j-1] != '#' && s[i][j+1] != '#' && s[i-1][j] != '#' && s[i+1][j] != '#'){
                    ok = false;
                }
            }
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    ll n, m;
    cin >> n >> m;

    vl a(n);
    rep(i, n) cin >> a[i];

    ll hlcd = 1;
    rep(i, n) {
        hlcd = lcm(hlcd, a[i] / 2);
    }

    rep(i, n) {
        if ((hlcd * 2 / a[i]) % 2 == 0) {
            prt(0);
            return 0;
        }
    }

    prt((m / hlcd + 1) / 2);

    return 0;
}


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

int main() {
  int n, x, count = 0;
  
  while(1){
    cin >> n >> x;
    if(n == 0 && x == 0) break;
    
    for(int i = 1; i <= n;i++){
      for(int j = i + 1; j <= n;j++){
        for(int k = j + 1;k <= n;k++){
          if(i + j + k == x) count++;
        }
      }
    }
    
    cout << count << endl;
    count = 0;
    
  }
  
}



Measured memory_bytes: 3084
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int a = Cin.Ni();
        int b = Cin.Ni();

        if (a % 3 == 0 ||
        b % 3 == 0 ||
        (a + b) % 3 == 0) {
            Console.WriteLine("Possible");
        } else {
            Console.WriteLine("Impossible");
        }
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int i = 0, sum = 0;
  bool flag = false;
  for (int i = 1; i <= 100; i++) {
    sum += a;
    if (sum % b == c) {
      flag = true;
      break;
    }
  }
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int k,s,c=0;
    cin >> k >> s;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(i+j>s) continue;
            int d=s-i-j;
            if(d>=0&&k>=d){
                c++;
            }
        }
    }
    cout << c << "\n";
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int h, w, s;

constexpr int kMaxWH = 33;

#define F first
#define S second

// 未定義，不可能
constexpr int kUnd = -2;
constexpr int kImp = -1;

// (グループ数, 予備力)
pii memo[kMaxWH][kMaxWH][kMaxWH][kMaxWH];

// 消費電力の和
int sum[kMaxWH + 1][kMaxWH + 1];

int field[kMaxWH][kMaxWH];

pii dfs(pii lu, pii rd){
    if(memo[lu.F][lu.S][rd.F][rd.S] != mp(kUnd, kUnd)){
        return memo[lu.F][lu.S][rd.F][rd.S];
    }

    int yobi =  s - (sum[h][w] - (sum[rd.F + 1][rd.S + 1] - sum[rd.F + 1][lu.S] - sum[lu.F][rd.S + 1] + sum[lu.F][lu.S]));
    if(yobi < 0){
        memo[lu.F][lu.S][rd.F][rd.S] = mp(kImp, kImp);
        return mp(kImp, kImp);
    }

    pii ret = mp(kImp, kImp);
    range(y, lu.F, rd.F){
        pii ret1 = dfs(mp(lu.F, lu.S), mp(y, rd.S));
        pii ret2 = dfs(mp(y + 1, lu.S), mp(rd.F, rd.S));

        if(ret1 == mp(kImp, kImp) || ret2 == mp(kImp, kImp)) continue;

        ret = max(ret, mp(ret1.F + ret2.F, min(ret1.S, ret2.S)));
    }
    range(x, lu.S, rd.S){
        pii ret1 = dfs(mp(lu.F, lu.S), mp(rd.F, x));
        pii ret2 = dfs(mp(lu.F, x + 1), mp(rd.F, rd.S));

        if(ret1 == mp(kImp, kImp) || ret2 == mp(kImp, kImp)) continue;

        ret = max(ret, mp(ret1.F + ret2.F, min(ret1.S, ret2.S)));
    }

    if(ret == mp(kImp, kImp)){
        ret = mp(1, yobi);
    }

    memo[lu.F][lu.S][rd.F][rd.S] = ret;
    return ret;
}

int main(void){
    for(; cin >> h >> w >> s, h;){
        rep(y, h) rep(x, w) cin >> field[y][x];

        rep(y, h) rep(x, w) rep(yy, h) rep(xx, w) memo[y][x][yy][xx] = mp(kUnd, kUnd);

        rep(y, h + 1) sum[y][0] = 0;
        rep(x, w + 1) sum[0][x] = 0;
        rep(y, h){
            rep(x, w){
                sum[y + 1][x + 1] = sum[y][x + 1] + sum[y + 1][x] + field[y][x] - sum[y][x];
            }
        }

        pii res = dfs(mp(0, 0), mp(h - 1, w - 1));
        cout << res.F << " " << res.S << endl;
    }

	return 0;
}

Measured memory_bytes: 10448
package main

import (
	"fmt"
)

func main() {
	var word string
	fmt.Scan(&word)
	palindromeHugger(word)
}

func palindromeHugger(word string) {
	var incidences int
	wordLenght := len(word) - 1

	for i, letter := range word {
		if letter != rune(word[wordLenght-i]) {
			incidences++
		}

		if i == wordLenght/2 {
			break
		}
	}

	fmt.Println(incidences)
}


Measured memory_bytes: 1772
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


//#define int long long
#define all(v) v.begin() , v.end()
#define endl '\n'

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

const int N = 2e3 + 10 ;

int n , k , can ;
vector < int > adj [ N ] ; 
pair < int , int > ar [ N ] ; 

void dfs ( int v , int lim = -1 , int p = -1 , int d = 0 ) {
	if ( d > k / 2 ) return ; 
	++ can ; 
	for ( int u : adj [ v ] ) {
		if ( ( u ^ lim ) && ( u ^ p ) )
			dfs ( u , lim , v , d + 1 ) ; 
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k ;
	for ( int i = 0 ; i < n - 1 ; ++ i ) {
		int u , v ;
		cin >> u >> v ;
		adj [ v ] . push_back ( u ) ;
		adj [ u ] . push_back ( v ) ;
		ar [ i ] . first = u ;
		ar [ i ] . second = v ; 
	}
	int res = n + 1 ;
	if ( k & 1 ) {
		for ( int i = 0 ; i < n - 1 ; ++ i ) {
			can = 0 ; 
			dfs ( ar [ i ] . first , ar [ i ] . second ) ;
			dfs ( ar [ i ] . second , ar [ i ] . first ) ;
			smin ( res , n - can ) ; 
		}
	}
	else {
		for ( int i = 1 ; i <= n ; ++ i ) {
			can = 0 ;
			dfs ( i ) ;
			smin ( res , n - can ) ; 
		}
	}
	cout << res << '\n' ; 
}


Measured memory_bytes: 384
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    long long k, a, b;
    cin >> k >> a >> b;
    if (a + 2 >= b || a - 1 >= k) {
        cout << k + 1 << endl;
        return 0;
    }
    else {
        long long num1 = k - a + 1;
        long long num2 = num1 / 2;
        long long num3 = num1 % 2;
        long long ans = a + num2 * (b - a) + num3;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<ll> a,c;
int main(){
    IOS();
    ll n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    REP (i,n-1) if (s[i] == 'A' && s[i+1] == 'C') {
        a.eb(i);
        c.eb(i+1);
    }

    while (q--) {
        ll l,r;
        cin >> l >> r;
        l--,r--;
        cout << (upper_bound(ALL(c),r)-c.begin()) - (lower_bound(ALL(a),l)-a.begin()) << endl;
    }
}


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


int main () {

string s;
cin >> s;

if(s=="SUN")
{
	cout << "7" << endl;
}
 else if(s=="MON")
{
	cout << "6" << endl;
}
else if(s=="TUE")
{
	cout << "5" << endl;
}
else if(s=="WED")
{
	cout << "4" << endl;
}
else if(s=="THU")
{
	cout << "3" << endl;
}
else if(s=="FRI")
{
	cout << "2" << endl;
}
else if(s=="SAT")
{
	cout << "1" << endl;
}
	return 0;
}








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

using namespace std;

int main(void) {
    int N, M, cnt[55] = {}, a, b;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }

    for (int i = 1; i <= N; i++)
        cout << cnt[i] << endl;

    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))

DP=[[C[P[n]]] for n in range(N)]

for start in range(N):
    visited=set()
    cur=P[start]
    while cur not in visited:
        visited.add(cur)
        cur = P[cur]
        DP[start].append(C[cur]+DP[start][-1])


for n in range(N):
    DP[n]=DP[n][:-1]

ans=-float("inf")

for start in range(N):
    for goal in range(min(K,len(DP[start]))):
        no_loop_sum=DP[start][goal]
        remain_hops=K-goal-1
        if DP[start][-1]>0:
            loops=remain_hops//len(DP[start])
        else:
            loops=0
        ans=max(ans,no_loop_sum+DP[start][-1]*loops)
print(ans)


Measured memory_bytes: 413528
#include<stdio.h>
signed main(){
    int x[5],i;
    for(i=0;i<5;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<5;i++){
        if(x[i]==0){
            printf("%d\n",i+1);
        }
    }
    return(0);
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 200005;

int n;
char a[N];
int f[N][3];

bool check(int l1, int r1, int l2, int r2) {
	if (r1 - l1 != r2 - l2) {
		return true;
	}
	for (int i = 0; i <= r1 - l1; ++i) {
		if (a[l1 + i] != a[l2 + i]) {
			return true;
		}
	}
	return false;
}

int main() {
	n = readStr(a + 1);
	f[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= i && j <= 2; ++j) {
			for (int k = 0; k <= i - j && k <= 2; ++k) {
				if (check(i - j - k + 1, i - j, i - j + 1, i)) {
					f[i][j] = std::max(f[i][j], f[i - j][k] + 1);
				}
			}
		}
	}
	print(std::max(f[n][1], f[n][2]));
}


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


int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int ac = 0, wa = 0,  tle=0, re = 0 ;
    int n;
    string s;
    
    cin >> n;
    
    for(int i=1; i <= n; i++)
    {
         string s;
         cin >> s;
        if(s.compare("AC")==0) ac++;
        else if(s.compare("WA")==0) wa++;
        else if(s.compare("TLE")==0) tle++;
       else  re++;
    }
    
   
    cout << "AC" << " x " << ac << "\n" ;
    cout << "WA" << " x " << wa << "\n" ;
    cout << "TLE" << " x " << tle << "\n" ;
    cout << "RE" << " x " << re << "\n" ;
    
    
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main{
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((a-1) * (b-1));
    }
}


Measured memory_bytes: 20176
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

vi p(100000);
vl d(100000);

vi sp[2];
vl sd[2], smid[2];

int getp(int v) {
  if (p[v] == v) return v;
  int allp = getp(p[v]);
  d[v] += d[p[v]];
  p[v] = allp;
  return p[v];
}

bool join(int a, int b, ll dif) {
  int pa = getp(a);
  int pb = getp(b);
  dif += d[b] - d[a];
  if (pa == pb) {
    if (dif) return false;
  } else {
    if (rand()) {
      swap(pa, pb);
      dif *= -1;
    }
    p[pa] = pb;
    d[pa] = dif;
  }
  return true;
}

bool f(const vi & x, const vi & y, const vi & a, int t) {
  vector<vii> v(100000);
  for (int i = 0; i < x.size(); ++i) {
    v[x[i]].push_back(pii(y[i], a[i]));
  }
  d.assign(d.size(), 0);
  for (int i = 0; i < p.size(); ++i) p[i] = i;
  for (int i = 0; i < v.size(); ++i) {
    for (int j = 0; j + 1 < v[i].size(); ++j) {
      if (!join(v[i][j].first, v[i][j+1].first, v[i][j+1].second-v[i][j].second)) return false;
    }
  }
  vl mid(d.size(), 0);
  for (int i = 0; i < d.size(); ++i) {
    int pi = getp(i);
    assert(d[pi] == 0);
    mid[pi] = min(mid[pi], -d[i]);
  }
//  if (t == 0) for (int i = 0; i < 3; ++i) { cout << p[i] << ' ' << d[i] << ' ' << mid[i] << endl; }
  sp[t] = p;
  sd[t] = d;
  smid[t] = mid;
/*  for (int i = 0; i < x.size(); ++i) {
    int pi = getp(y[i]);
    if (a[i] + d[y[i]] + mid[pi] < 0) return false;
  }*/
  return true;
}

bool g(const vi & x, const vi & y, const vi & a) {
  for (int i = 0; i < x.size(); ++i) {
    int px = sp[1][x[i]], py = sp[0][y[i]];
    assert(sd[0][y[i]] + smid[0][py] <= 0 && sd[1][x[i]] + smid[1][px] <= 0);
//    cerr << x[i] << ' ' << y[i] << ' ' << a[i] << ' ' << sd[1][x[i]] << ' ' << smid[1][px] << ' ' << px << ' ' << sd[0][y[i]] << ' ' << smid[0][py] << endl;
    if (a[i] + sd[0][y[i]] + smid[0][py] + sd[1][x[i]] + smid[1][px] < 0) return false;
  }
  return true;
}

int main() {
  int r, c, n;
  cin >> r >> c >> n;
  vi x(n), y(n), a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &x[i], &y[i], &a[i]);
    --x[i]; --y[i];
  } 
  if (f(x, y, a, 0) && f(y, x, a, 1) && g(x, y, a)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 12744
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  long long N;
  long long X[5];
  cin>>N;
  for (int i=0;i<5;i++){
    cin>>X[i];
  }
  sort(X,X+5,greater<long long>());
  long long S;
  S=(N-1)/X[4];
  long long goukei;
  goukei=S+5;
  cout<<goukei;
  return 0;
}


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

int n,m,a[210];

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&m,&n);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if (n==1)
	{
		printf("%d\n",a[1]);
		if (a[1]==1)
			printf("1\n1\n");
		else
		{
			printf("2\n");
			printf("%d 1\n",a[1]-1);
		}
		return 0;
	}
	if (m&1)
	{
		for (i=1;i<=n;i++)
			if (a[i]&1) swap(a[1],a[i]);
		for (i=2;i<=n;i++)
			if (a[i]&1)
			{
				puts("Impossible");
				return 0;
			}
		for (i=1;i<=n;i++)
			printf("%d ",a[i]);
		puts("");
		printf("%d\n",n);
		printf("%d ",a[1]+1);
		for (i=2;i<n;i++)
			printf("%d ",a[i]);
		printf("%d\n",a[n]-1);
	}
	else
	{
		for (i=1;i<=n;i++)
		for (j=i+1;j<=n;j++)
			if (!(a[i]&1)&&(a[j]&1)) swap(a[i],a[j]);
		if (a[3]&1)
		{
			puts("Impossible");
			return 0;
		}
		swap(a[2],a[n]);
		for (i=1;i<=n;i++)
			printf("%d ",a[i]);
		puts("");
		printf("%d\n",n-(a[n]==1));
		printf("%d ",a[1]+1);
		for (i=2;i<n;i++)
			printf("%d ",a[i]);
		if (a[n]!=1) printf("%d",a[n]-1);
		puts("");
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a[51],b[51],c[51],d[51];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    cin >>c[i] >> d[i];
  }
  for(int i=0;i<n;i++){
    int mi=1234567890;
    int mn=-1;
    for(int j=0;j<m;j++){
      int ma=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(mi>ma){
	mi=ma;
	mn=j+1;
      }
    }
    cout << mn << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  int n,m,q;
  scanf("%d%d%d",&n,&m,&q);
  static int a[100010];
  for(int i=0;i<q;i++){
    scanf("%d",a+i);
    a[i]--;
  }
  bool F=1;
  static int P[100010],C[100010],T[100010];
  for(int i=0;i<m;i++){
    P[i]=-1;
  }
  int N=0;
  for(int i=q-1;i>=0;i--){
    int k=a[i];
    if(P[k]==-1){
      P[k]=N;
      C[N]=1;
      T[N]=k;
      N++;
    }
    else if(C[P[k]]<n){
      C[P[k]]++;
      if(P[k]>0&&C[P[k]-1]<C[P[k]]){
	C[P[k]]--;
      }
    }
  }
  if(F){
    vector<int> V;
    int K=0;
    for(int i=0;i<m;i++){
      if(P[i]==-1||C[P[i]]<n){
	V.push_back(i);
      }
      else{
	K++;
      }
    }
    for(int i=K;i<N;i++){
      if(T[i]!=V[i-K]){
	F=0;
      }
    }
  }
  puts(F?"Yes":"No");
  return 0;
}


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

int main(void){
  int K = 0;
  cin >> K;

  if(K % 2 == 0){
    cout << K*K/4 << endl;
  } else {
    cout << ((K-1)/2)*((K-1)/2 + 1) << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int a[3];
  for(int i=0;i<3;i++)cin>>a[i];
  sort(a, a+3);
  cout<<(a[2]-a[0])<<endl;
}

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


using namespace std;

int n;
int maxW;
vector<pair<int,int>> vec;
long long meme[105][100007];


long long solve(int index, int remain){
    if(index==n){
        return 0;
    }
    
    if(meme[index][remain]!=-1){
        return meme[index][remain];
    }
    long long res1;
     res1 = solve(index+1,remain);
    long long res2 =0;
    if(remain>=vec[index].first){
        res2 = solve(index+1,remain-vec[index].first) + vec[index].second;
    }
    return meme[index][remain] = max(res1,res2);
}

int main(){
    cin>>n>>maxW;
    memset(meme,-1,sizeof(meme));
    int one,two;
    for(int i = 0 ; i<n ; i++){
        cin>>one>>two;
        vec.push_back(make_pair(one,two));
    }
    long long go = solve(0, maxW);
    cout<<go<<endl;
    return 0;
}

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

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

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

ll dp[100]={};

int main(){
    int N;
    cin >> N;
    ll a[N+1];
    for(int i=1;i<=N;i++){
        cin >> a[i];
    }
    dp[0]=1000;
    for(int i=1;i<=N;i++){
        dp[i]=max(dp[i-1],dp[i]);
        for(int j=i+1;j<=N;j++){
            if(a[i]==0||(a[j]-a[i]<0)) continue;
            ll s=dp[i]/a[i];
            dp[j]=max(dp[j],dp[i]+s*(a[j]-a[i]));
        }
    }
    cout << dp[N] << endl;
}

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

long long N, Q, A[3009], X[3009], Y[3009], dp[3009][3009], mul = 1, inv = 500000004, mod = 1000000007;
long long nex[3009][3009];

int main() {
	cin >> N >> Q;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= Q; i++) { cin >> X[i] >> Y[i]; if (X[i] > Y[i]) swap(X[i], Y[i]); }

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (A[i] < A[j]) dp[i][j] = 1;
		}
	}
	
	// 確率で DP
	for (int i = 1; i <= Q; i++) {
		nex[X[i]][Y[i]] += (dp[X[i]][Y[i]] + dp[Y[i]][X[i]]) * inv; nex[X[i]][Y[i]] %= mod;
		nex[Y[i]][X[i]] += (dp[X[i]][Y[i]] + dp[Y[i]][X[i]]) * inv; nex[Y[i]][X[i]] %= mod;
		for (int j = 1; j <= N; j++) {
			if (j == X[i] || j == Y[i]) continue;
			nex[Y[i]][j] += (dp[Y[i]][j] + dp[X[i]][j]) * inv; nex[Y[i]][j] %= mod;
			nex[X[i]][j] += (dp[Y[i]][j] + dp[X[i]][j]) * inv; nex[X[i]][j] %= mod;
			nex[j][Y[i]] += (dp[j][Y[i]] + dp[j][X[i]]) * inv; nex[j][Y[i]] %= mod;
			nex[j][X[i]] += (dp[j][Y[i]] + dp[j][X[i]]) * inv; nex[j][X[i]] %= mod;
		}

		for (int j = 1; j <= N; j++) {
			dp[j][X[i]] = nex[j][X[i]];
			dp[j][Y[i]] = nex[j][Y[i]];
			dp[X[i]][j] = nex[X[i]][j];
			dp[Y[i]][j] = nex[Y[i]][j];
		}
		for (int j = 1; j <= N; j++) {
			nex[X[i]][j] = 0; nex[Y[i]][j] = 0; nex[j][X[i]] = 0; nex[j][Y[i]] = 0;
		}
		mul *= 2; mul %= mod;
	}
	long long ans = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (i > j) { ans += dp[i][j]; ans %= mod; }
		}
	}
	cout << (ans * mul) % mod << endl;
	return 0;
}

Measured memory_bytes: 141696
lst=list(map(int, input().split()))
lst.sort()
a,b,c=lst
lst=[0,b-a,c-a]
a,b,c=lst
if(0==b%2==c%2):
  ans=(2*c-b)//2
elif(1==b%2==c%2):
  ans=1+(2*(c+1)-b-1)//2
elif(b%2==0):
  ans=1+(c-1+c-b-1)//2
elif(c%2==0):
  ans=1+(c+c+1-b)//2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
#define reprange(i, a) for(int i : vector<int>a)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL << 60;
const ll mod=1e9+7;

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

  string s;
  cin >> s;
 
  if(s[(int)s.size()-1]!='s')cout << s << 's' << endl;
  else if(s[(int)s.size()-1]=='e')cout << s << "s" << endl;
  else cout << s << "es" << endl;

  return 0;
}

Measured memory_bytes: 3648
//shivamkr21
#include<bits/stdc++.h>
#define endl "\n"
#define lli long long int
using namespace std;
int main()
{
    lli n;
  	cin>>n;
  	lli p,ma=0,sma=0,k=0;
    vector<lli> ar;
  	for(lli i=0;i<n;i++)
    {
      	cin>>p;
        ar.push_back(p);
      	if(p>ma)
        {
          	ma=p;
            k=i;
        }
      	else if(p>sma && sma!=ma)
        {
            sma=p;
        }
    }
    //cout<<ma<<" "<<sma<<"\n";
    if(sma<0)
    {
        sma=ma;
    }
  	for(lli i=0;i<n;i++)
    {
      	if(i==k)
        {
          	cout<<sma<<endl;
        }
      	else
        {
          	cout<<ma<<endl;
        }
    }
	return 0;
}

Measured memory_bytes: 3312
from fractions import Fraction

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
vote_num = sum(A)
ans = 0
x = Fraction(1, 4*M)

for i in A:
        if i >= vote_num*x:
                ans += 1

if ans >= M:
        print("Yes")
else:
        print("No")

Measured memory_bytes: 10400
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int[] X = new int[N];
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            X[i] = sc.nextInt();
            list.add(X[i]);
        }

        Collections.sort(list);

        int ml = list.get(N / 2 - 1);
        int mr = list.get(N / 2);

        for(int i=0; i<N; i++){
            if(X[i]<=ml){
                System.out.println(mr);
            }
            else{
                System.out.println(ml);
            }
        }
    }
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

vector<LL> A;
vector<vector<int>> V;
const LL INF = 1e18;

vector<vector<LL>> solve(int p, int q){
	vector<vector<LL>> ret(1,vector<LL>(2,INF));
	ret[0][0] = A[q];
	if(A[q] > 0) ret[0][1] = A[q];
	for(auto u : V[q]) if(u != p){
		auto z = solve(q,u);
		vector<vector<LL>> nx(ret.size()+z.size(),vector<LL>(2,INF));
		repp(i,0,ret.size()) repp(j,0,z.size()){
			nx[i+j][0] = min(nx[i+j][0],ret[i][0]+z[j][0]);
			nx[i+j][1] = min(nx[i+j][1],ret[i][1]+z[j][1]);
			if(z[j][0] < 0 || z[j][1] < INF){
				nx[i+j+1][0] = min(nx[i+j+1][0],ret[i][0]);
				nx[i+j+1][1] = min(nx[i+j+1][1],ret[i][1]);
			}
		}
		swap(ret,nx);
	}
	return ret;
}

int main(){
	int N; cin >> N;
	A.resize(N); repp(i,0,N) cin >> A[i];
	V.resize(N);
	repp(i,1,N){
		int u,v; cin >> u >> v;
		--u; --v;
		V[u].push_back(v);
		V[v].push_back(u);
	}
	auto ans = solve(-1,0);
	repp(i,0,N) if(ans[i][1] < INF || ans[i][0] < 0) return cout << i << endl, 0;
	return 0;
}


Measured memory_bytes: 2012
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;

using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {

	int N;
	int K;
	cin >> N >> K;
	
	int res=0;

	if (N%K != 0) {
		res++;
	}


	ce(res);
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n;
    cin1(n);
    lli a[n];
    lli b[n];
    lli c[n-1];
    ncin1(n, a);
    ncin1(n, b);
    ncin1(n-1, c);
    lli ans = 0;
    REP(i, 0, n) {
        ans += b[a[i]-1];
        if (i == 0)
            continue;
        if (a[i] == a[i-1] + 1) {
            ans += c[a[i-1]-1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  map<int,int> m;
  rep(i, N) m[a[i]]++;
  
  if(m.size() == 3){
    auto b = m.begin();
    auto c = next(b, 1);
    auto d = next(b, 2);
    int bn = (*b).second;
    int cn = (*c).second;
    int dn = (*d).second;
    int bb = (*b).first;
    int cc = (*c).first;
    int dd = (*d).first;
    if(bn == cn && cn == dn && (bb^cc) == dd) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(m[0] > 0) {
    if(m.size() == 1) {
      cout << "Yes" << endl;
      return 0;
    }
    if(m.size() == 2) {
      auto b = next(m.begin(), 1);
      int bn = (*b).second;
      int bb = (*b).first;
      if(bn == 2*m[0]) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;

    

}

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

using namespace std;
using ll = long long;

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

#define INF 99999999
#define MOD (int)1e9 + 7
#define rep(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end()


int main() {

	string s;
	cin >> s;

	if (s[0] == 'Y' && s[1] == 'A' &&s[2] == 'K' && s[3] == 'I')
		cout << "Yes" << endl;
	else cout << "No" << endl;

	 
	return 0;
}

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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
constexpr ll INF = 1LL << 62;
constexpr ll MAX_N = 200000;

ll N, K, L;
unordered_map<ll, vector<ll> > road, line;
ll road_link[MAX_N + 1], line_link[MAX_N + 1];


void patrol(ll root, ll node, unordered_map<ll, vector<ll> >& graph, ll* link, vector<bool>& used) {
    used[node] = true;
    link[node] = root;
    
    for (auto next : graph[node]) {
        if (!used[next]) {
            patrol(root, next, graph, link, used);
        }
    }
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K >> L;
    
    for (ll i = 0; i < K; i++) {
        ll from, to;
        cin >> from >> to;
        road[from].push_back(to);
        road[to].push_back(from);
    }
    
    for (ll i = 0; i < L; i++) {
        ll from, to;
        cin >> from >> to;
        line[from].push_back(to);
        line[to].push_back(from);
    }
    
    
    vector<bool> road_used(N + 1, false), line_used(N + 1, false);
    for (ll i = 1; i <= N; i++) {
        if (!road_used[i]) {
            patrol(i, i, road, road_link, road_used);
        }
        
        if (!line_used[i]) {
            patrol(i, i, line, line_link, line_used);
        }
    }
    
    unordered_map<ll, unordered_map<ll, ll> > m;
    for (ll i = 1; i <= N; i++) {
        m[road_link[i]][line_link[i]] += 1;
    }
    
    for (ll i = 1; i <= N; i++) {
        cout << m[road_link[i]][line_link[i]] << " \n"[i == N];
    }

    return 0;
}


Measured memory_bytes: 58256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.replaceAll("hi", "");
        if ("".equals(s)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 23764
module Main where
import Data.Char
int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[]) . show 

solver :: [Int] -> Int
solver [a,b] = length $ filter (\x -> x == reverse x) $ map show $ [(a)..(b)]


Measured memory_bytes: 892