akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
const int DEBUG = 1;

const int N = 100100;
int a[N], b[N], v[N], p[N];

VI edges[N];
PI cons[N];
int val[N];
int col[N];

PI intersec(PI a, PI b) {
  if (a.first > a.second) {
    return PI(0, -1);
  }
  if (b.first > b.second) {
    return PI(0, -1);
  }
  if ((a.first - b.first) % 2 != 0 || a.second < b.first || b.second < a.first) {
    return PI(0, -1);
  }
  return PI(max(a.first, b.first), min(a.second, b.second));
}

PI dfs(int v, int par, PI c) {
  if (c.first > c.second) {
    return PI(0, -1);
  }
  //assert ((c.second - c.first) % 2 == 0);
  if (val[v] >= 0) {
    c = intersec(c, PI(val[v], val[v]));
  }
  REP(i, 0, edges[v].size()) {
    int w = edges[v][i];
    if (w == par) {
      continue;
    }
    PI child_c = dfs(w, v, PI(c.first - 1, c.second + 1));
    if (child_c.first > child_c.second) {
      return cons[v]=PI(0, -1);
    }
    child_c.first--;
    child_c.second++;
    c = intersec(c, child_c);
  }
  cons[v] = c;
  return c;
}

void dfs2(int v, int par, int c) {
  //assert (cons[v].first <= c && c <= cons[v].second);
  col[v] = c;
  REP(i, 0, edges[v].size()) {
    int w = edges[v][i];
    if (w == par) {
      continue;
    }
    if (cons[w].first <= c - 1 && c - 1 <= cons[w].second) {
      dfs2(w, v, c - 1);
    } else {
      dfs2(w, v, c + 1);
    }
  }
}

int main(void){
  int n;
  cin >> n;
  REP(i, 0, n - 1) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    edges[a[i]].push_back(b[i]);
    edges[b[i]].push_back(a[i]);
  }
  int k;
  cin >> k;
  int root = -1;
  REP(i, 0, N) {
    val[i] = -1;
  }
  REP(i, 0, k) {
    cin >> v[i] >> p[i];
    v[i]--;
    if (root == -1) {
      root = v[i];
    }
    val[v[i]] = p[i];
  }
  assert (root >= 0);
  REP(i, 0, N) {
    cons[i] = PI(-1, -1);
  }
  PI ok = dfs(root, -1, PI(val[root], val[root]));
  if (DEBUG) {
    REP(i, 0, n) {
      cerr << "cons["  << i << "]=" << cons[i].first << "," << cons[i].second << endl;
    }
  }
  if (ok.first > ok.second) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  dfs2(root, -1, val[root]);
  REP(i, 0, n) {
    cout << col[i] << endl;
  }
}


Measured memory_bytes: 16768
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] A = new int[N];
        long sum = 0;
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextInt() - (i + 1) + N;
            sum += A[i];
        }
        Arrays.sort(A);
        long ans = 0;
        for (int i = 0; i < N; ++i) {
            ans += Math.abs(A[i] - A[N / 2]);
        }
        _out.println(ans);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 64820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define pc putchar
#define gc getchar
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void wri(ll x){write(x),pc(' ');}
void writeln(ll x){write(x);pc('\n');}
const int maxn = 2e5+233;
const int mod = 1e9+7;
int fac[maxn],ifac[maxn],n,i,ans,ct[maxn],ct2,X,Y,m11,m12,c11,m2[maxn],c[maxn],w[maxn];
bool b[maxn];
inline int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)	
		if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
int main(){
	fac[0] = 1;rep(i,1,maxn) fac[i] = 1ll * fac[i-1] * i % mod;
	ifac[maxn - 1] = qpow(fac[maxn-1],mod-2);
	Dep(i,maxn-2,0) ifac[i] = 1ll * ifac[i+1] * (i+1) % mod;
	n = read(),Y = read(),X = read();
	Rep(i,1,n) m2[i]=1<<30,m11=m12=1<<30;
	Rep(i,1,n){
		c[i]=read(),w[i]=read();
		m2[c[i]]=min(m2[c[i]],w[i]);
		if(w[i]<m11) m12=m11,m11=w[i],c11=c[i]; else
		if(w[i]<m12) m12=w[i];
	}
	Rep(i,1,n)if(c11!=c[i]&&m11+w[i]<=X || c11==c[i]&&m12+w[i]<=X)
		++ct[c[i]],++ct2,b[i]=1;
	Rep(i,1,n)if(!b[i] && ct[c[i]] && m2[c[i]]+w[i]<=Y)
		++ct[c[i]],++ct2;
	int ans=fac[ct2];
	Rep(i,1,n) ans=1ll*ans*ifac[ct[i]]%mod;
	writeln(ans);
}

Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int wt = in.nextInt();
		Item[] items = new Item[n];
		for (int i = 0; i < n; i++) {
			Item m = new Item(in.nextInt(), in.nextInt());
			items[i] = m;
		}
		int[][] dp = new int[n+1][wt+1];

		// solve
		for (int i = 0; i < n; i++) {
			for (int w = 0; w <= wt; w++) {
				if (items[i].weight <= w) {
					dp[i+1][w] = Math.max(dp[i][w-items[i].weight] + items[i].value
							, dp[i][w]);
				} else {
					dp[i+1][w] = dp[i][w];
				}
			}
		}
		System.out.println(dp[n][wt]);
	}

	static class Item {
		int value;
		int weight;

		public Item(int v, int w) {
			value = v;
			weight = w;
		}
	}
}



Measured memory_bytes: 31180
from collections import Counter,defaultdict

N=int(input())
count = defaultdict(int)
for i in range(N):
  s=Counter(list(input()))
  count[str(sorted(s.items()))] += 1

count = list(count.values())
SUM = 0
for c in count:
  if c>1:SUM += c*(c-1)//2
print(SUM)

Measured memory_bytes: 30064
from collections import Counter
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    A.sort(reverse=True)
    C = Counter(A)
    for a in A:
        if C[a] == 0: continue
        C[a] -= 1
        p = (1 << a.bit_length()) - a
        if p > a: continue
        if p in C and C[p] > 0:
            ans += 1
            C[p] -= 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 102612
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair <int,int>
#define ull unsigned long long
#define mp make_pair
#define s second
#define f first                                          
#define _ ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;

const int maxn = (int)(1e5)+2;
const int mod = (int)(1e9)+7;

int n;
char a[55], b[55];
ll d[55][3];

int main() {
	_
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	
	int st;
	if (a[1]==b[1]) {
		d[1][0] = 3;
		st = 2;
	}
	else {
		d[2][1] = 6;
		st = 3;
	}
	for (int i = st; i <= n; i++) {
		 if (a[i]==b[i]) {
			d[i][0] = (d[i-1][1] + d[i-1][0]*2)%mod;
	 	 }
		else {
	 		i++;
	 		d[i][1] = (d[i-2][0] * 2 + d[i-2][1]*3)%mod;
	 	}
	}
	cout << (d[n][0] + d[n][1]);

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc154() {
	ll n;
	string ans;

	cin >> n;

	multiset<ll> a;
	ll tmp;
	ans = "YES";
	rep(i, n) {
		cin >> tmp;
		if (a.find(tmp) == a.end()) {
			a.insert(tmp);
		}
		else {
			ans = "NO";
			break;
		}
	}

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

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

	solve_abc154();

	return 0;
}

Measured memory_bytes: 9600
fn main() {
    proconio::input! {
        a: char,
    }
    let ans = match a {
        'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o'
        | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' => 'a',
        _ => 'A',
    };
    println!("{}", ans);
}


Measured memory_bytes: 2188
N = int(raw_input())
H = []

for _ in xrange(N):
    a, b, c = map(int, raw_input().split())
    H.append([a, b, c])

dp = [[0]*3 for __ in xrange(N)]

for i in xrange(0, N):
    for j in xrange(3):
        if i==0:
            dp[i][j] = H[0][j]
        else:
            dp[i][j] = max(dp[i-1][j-1]+H[i][j], dp[i-1][j-2]+H[i][j])

print max(dp[N-1])



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

int main(){
  string w;
  std::cin >> w;
  map<char, int> hash;
  for (int i = 0; i < w.length(); i++) {
    hash[w[i]]++;
  }
  for (auto i: hash) {
    if(i.second%2 == 1){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
        cin >> A[i];

    int counter = 0;
    for (int i = 0; i < N; i++)
    {
        int minIndex = i;
        for (int j = i + 1; j < N; j++)
        {
            if (A[j] < A[minIndex])
            {
                minIndex = j;
            }
        }
        if (minIndex != i)
        {
            swap(A[i], A[minIndex]);
            counter++;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (i > 0)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << counter << endl;
}



Measured memory_bytes: 3096
import math
import numpy as np
from itertools import chain
count = 0
t = 0
a,b = map(int,input().split())

p = [list(map(int,input().split()))for i in range(a)]

fp = list(chain.from_iterable(p))

pp = np.abs(fp)

for i in range(a):
    s = math.sqrt(pp[t]**2 + pp[t+1]**2)
    t +=2
    if s <= b:
        count+=1
print(count)

Measured memory_bytes: 72984
#include <stdio.h>
#include <stdlib.h>

void swap(int Array[], int i, int j) {
    int temp;
    temp = Array[i];
    Array[i] = Array[j];
    Array[j] = temp;
}

int partition(int Array[], int pIndex, int rIndex) {
    int x = Array[rIndex];
    int i = pIndex;
    int temp;
    
    for (int j = pIndex; j < rIndex; j++)
        if (Array[j] <= x)
            swap(Array, i++, j);

    swap(Array, i, rIndex);
    return i;
}

void printArray(int array[], int n) {
    for (int i = 0; i < n; i++) {
        if (i != 0) printf(" ");
        printf("%d", array[i]);
    };
}

void printArrayHighlight(int array[], int n, int hightlightIndex) {
    for (int i = 0; i < n; i++) {
        if (i != 0) printf(" ");
        if (i == hightlightIndex)
            printf("[%d]", array[i]);
        else
            printf("%d", array[i]);
    };
}

int main(int argc, char** argv) {
    int nArray;
    scanf("%d", &nArray);
    
    int array[nArray], brrby[nArray];
    
    for (int iArray = 0; iArray < nArray; iArray++) {
        scanf("%d", &array[iArray]);
    }
    
    // do the magic
    int index = partition(array, 0, nArray - 1);
    
    printArrayHighlight(array, nArray, index);
    printf("\n");

    return (EXIT_SUCCESS);
}




Measured memory_bytes: 2116
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
    long long N;
    cin >> N;
    long long A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];
    long long B[N];
    for (int i = 0; i < N; ++i) B[i]=0;
    long long sum=0;
    for (int i = 0; i < N; ++i) B[A[i]-1]++;
    for (int i = 0; i < N; ++i){
        sum+=B[i]*(B[i]-1)/2;
    }
    for (int i = 0; i < N; ++i){
        cout << sum-B[A[i]-1]+1 << endl;
    }
}

Measured memory_bytes: 5760
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
int main() {
    using VertexId = std::uint32_t;
    using EdgeId = std::uint64_t;
    using EdgeWeight = std::uint64_t;

    const auto invalid_distance = std::numeric_limits<EdgeWeight>::max();

    auto n = VertexId(0);
    auto m = EdgeId(0);
    auto r = VertexId(0);
    std::cin >> n >> m >> r;

    auto perm = std::vector<VertexId>();
    for (auto i_ = 0; i_ < r; ++i_) {
        auto v = VertexId(0);
        std::cin >> v;

        perm.emplace_back(v - 1);
    }

    auto map = std::vector<std::vector<EdgeWeight>>(n, std::vector<EdgeWeight>(n, invalid_distance));
    for (auto i_ = 0; i_ < m; ++i_) {
        auto source = VertexId(0);
        auto target = VertexId(0);
        auto weight = EdgeWeight(0);
        std::cin >> source >> target >> weight;

        map[source - 1][target - 1] = weight;
        map[target - 1][source - 1] = weight;
    }

    for (auto k = 0; k < n; ++k) {
        for (auto i = 0; i < n; ++i) {
            for (auto j = 0; j < n; ++j) {
                if ((map[k][i] != invalid_distance && map[k][j] != invalid_distance) &&
                    (map[k][i] + map[k][j] < map[i][j])) {
                    map[i][j] = map[k][i] + map[k][j];
                    map[j][i] = map[k][i] + map[k][j];
                }
            }
        }
    }

    std::sort(perm.begin(), perm.end());

    auto min_distance = invalid_distance;
    do {
        auto sum_distance = EdgeWeight(0);
        for (auto i = 0; i < r - 1; ++i) {
            sum_distance += map[perm[i]][perm[i + 1]];
        }

        if (sum_distance < min_distance) min_distance = sum_distance;
    } while (std::next_permutation(perm.begin(), perm.end()));

    std::cout << min_distance << std::endl;

    return 0;
}

Measured memory_bytes: 640
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	n, _ := strconv.Atoi(readLine())
	inputH := strings.Split(readLine(), " ")

	var max, count int

	max, _ = strconv.Atoi(inputH[0])
	count = 1

	for i := 1; i < n; i++ {
		h, _ := strconv.Atoi(inputH[i])
		if h >= max {
			count++
			max = h
		}
	}

	fmt.Println(count)
}


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

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

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;

ll dfs(ll num, string s) {
    if (sz(s) == 0) return num;
    int n = sz(s);
    ll res = 0;
    ll temp = 0;
    rep(i, n) {
        temp = 10 * temp + (s[0] - '0');
        s = s.substr(1);
        res += dfs(num + temp, s);
    }
    return res;
}

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

    string s;
    cin>>s;
    ll ans = dfs(0, s);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N;

int main() {
	cin >> N; string S;
	while (N >= 1) {
		N--;
		long long E = N % 26LL;
		S += (char)('a' + E);
		N /= 26LL;
	}
	reverse(S.begin(), S.end());
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int
main()
{
    int N, M, h[100001];
    int hoge[100001] = {0};
    int a, b;
    int count = 0;
    cin >> N >> M;
    for(int i = 1; i <= N; ++i) {
        cin >> h[i];
    }
    for(int i = 0; i < M; ++i) {
        cin >> a >> b;
        hoge[a] = max(hoge[a], h[b]);
        hoge[b] = max(hoge[b], h[a]);
    }
    for(int i = 1; i <= N; ++i) {
        if(h[i] > hoge[i]) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 4416
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string a, b; cin >> a >> b;
	println(b+a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{ 
  long double a,b,d,c;
  cin>>a>>b>>c;
  d=2*(sqrtl(a)*sqrtl(b));
  if((a+b+d)<c)
     cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int64_t i = 0;i < n;i++)
using ll = int64_t;
template<class T> bool chmin(T& a,T b){
    if(a > b){ a = b; return true; }else return false;
}
template<class T> bool chmax(T& a,T b){
    if(a < b){ a = b; return true; }else return false;
}

/*
 * Modint struct
 * library author : @snuke
 * */
const int mod = 1e9 + 7;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
class CReconciled {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);

        int64_t n,m;cin >> n >> m;
        if(abs(n - m) > 1){
            cout << 0 << '\n';
            return;
        }

        if(n == m){
            mint ans = 2;
            rep(i,n) ans *= (mint)((i+1)*(i+1));
            cout << ans << '\n';
        }else{
            mint ans = 1;
            if(n > m) swap(n,m);
            rep(i,n) ans *= (mint)((i+1)*(i+1));
            ans *= mint(m);
            cout << ans << '\n';
        }

        //int t;cin >> t;rep(i,t)main2(cin,cout);
	}
	void main2(istream& cin,ostream& cout){

	}
};


int main() {
	CReconciled solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;

int main(){
    int N,M;
    cin>>N>>M;
    vector<set<int>>svec;
    REP(m,M){
        int k;
        cin>>k;
        set<int>st;
        REP(kk,k){
            int s;
            cin>>s;s--;
            st.insert(s);
        }
        svec.PB(st);
    }
    vector<int>p(M);
    REP(i,M)cin>>p[i];
    int res=0;
    REP(S,1<<N){
        bool f=true;
        REP(m,M){
            int cnt=0;
            REP(n,N)if(svec[m].find(n)!=svec[m].end()){
                if(S>>n&1)cnt++;
            }
            if(p[m]!=cnt%2)f=false;
        }
        if(f)res++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main(string[] args)
    {
        string[] line = Console.ReadLine().Split(' ');
        int a = int.Parse(line[0]);
        int b = int.Parse(line[1]);

        int sub = b - a;
        int sum = 0;
        for (int i = sub-1; i > 0; i--)
            sum += i;
        Console.WriteLine(sum - a);
    }
}

Measured memory_bytes: 11092
n = int(input())
x = [0]*n
for i in range(n):
    x[i] = list(map(int,input().split()))
x.sort(key= lambda val : val[0])
i = 0
while 1:
    if i >= n - 1:
        break
    
    if x[i][0] + x[i][1] > x[i+1][0] - x[i+1][1]:
        if x[i][0] + x[i][1] > x[i+1][0] + x[i+1][1]:
            del x[i]
            n -= 1
        else:
            del x[i+1]
            n -= 1
    else:
        i += 1
print(len(x))


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

int main() {
  int a, b;
  cin >> a >> b;
  int x, y;
  x = a % 2;
  y = b % 2;
  
  if(x==0 || y==0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  for (int& x : a) {
    cin >> x;
    ++mp[x];
  }
  int64 ans = 0;
  for (const auto& pr : mp) {
    ans += pr.second * 1ll * (pr.second - 1) / 2;
  }
  for (int x : a) {
    cout << ans - mp[x] + 1 << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 8320
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local n, k = io.read("*n", "*n", "*l")
local s = io.read()
for i = 1, n do
  if(i ~= k) then io.write(s:sub(i, i))
  else
    io.write(string.char(s:byte(i, i) + 32))
  end
end
io.write("\n")


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

using namespace std;
using ll = long long;

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> ps(D);
  vector<int> cs(D);
  rep(i, D) cin >> ps[i] >> cs[i];
  int ans = 1e9;
  for (int bit = 0; bit < (1 << D); bit++) {
    int s = 0, num = 0, m = -1;
    rep(i, D) {
      if (bit & (1 << i)) {
        s += 100 * (i + 1) * ps[i] + cs[i];
        num += ps[i];
      } else {
        m = i;
      }
    }
    if (s < G) {
      int s1 = 100 * (m + 1);
      int need = (G - s + s1 - 1) / s1;
      if (need >= ps[m]) {
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3572
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])



Measured memory_bytes: 2940
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int a,b,c;cin>>a>>b>>c;
	if(a<b&&b<c){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
	RE;
}


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

using namespace std;

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

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

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

    int N;
    cin >> N;
    string S;
    cin >> S;

    Vi es(N), ws(N);
    for (int i = 0; i < N; i++) {
        if (S[i] == 'E')
            es[i] = 1;
        else
            ws[i] = 1;
    }

    Vi csum_e(N + 1), csum_w(N + 1);
    for (int i = 0; i < N; i++) {
        csum_e[i + 1] = csum_e[i] + es[i];
        csum_w[i + 1] = csum_w[i] + ws[i];
    }

    int ans = I_INF;
    for (int i = 0; i < N; i++) {
        int tmp = csum_w[i] + csum_e[N] - csum_e[i + 1];
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5396
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
  
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
  
int t[4][4];
int limit;
  
int getHeuri(){
  int res=0,a;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(t[i][j]==0)continue;
      a=t[i][j]-1;
      res+=abs(a/4-i)+abs(a%4-j);
    }
  }
  return res;
}
  
bool check(int depth,int prev,int py,int px){
  int heuri=getHeuri();
  if(heuri+depth>limit)return false;
  if(heuri==0)return true;
  for(int i=0;i<4;i++){
    if(abs(i-prev)==2)continue;
    int ny=py+dy[i],nx=px+dx[i];
    if(ny<0||nx<0)continue;
    if(ny>=4||nx>=4)continue;
    swap(t[ny][nx],t[py][px]);
    if(check(depth+1,i,ny,nx)) return true;
    swap(t[ny][nx],t[py][px]);
  }
  return false;
}
  
void solve(int py,int px){
  for(limit=0;;limit++){
    if(check(0,99,py,px)){
      cout<<limit<<endl;
      return;
    }
  }
}
  
int main(){
  int py,px;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      cin>>t[i][j];
      if(t[i][j]==0){
    py=i;
    px=j;
      }
    }
  }
  solve(py,px);
  return 0;
}


Measured memory_bytes: 3120
from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(m):
  l2=[]
  a,b=map(int,input().split())
  l2.append(a)
  x=list(map(int,input().split()))
  ct=0
  for i in range(n):
    if i+1 in x:
      ct+=2**i
  l2.append(ct)
  l.append(l2)

dp=[[999999999999 for i in range(2**n)] for j in range(m+1)]
dp[0][0]=0
for i in range(1,m+1):
  for j in range(2**n):
    dp[i][j|l[i-1][1]]=min(dp[i-1][j|l[i-1][1]],dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]])
  for j in range(2**n):
    dp[i][j]=min(dp[i][j],dp[i-1][j])

if dp[m][2**n-1]<10**11:
  print(dp[m][2**n-1])
else:
  print(-1)

Measured memory_bytes: 82632
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) {string s; ist >> s; return ist;}
bool Inside(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
string s;
int c[3];
int main() {
	cin >> s;
	REP(i, 0, s.size()) {
		c[s[i] - 'a']++;
	}
	sort(c, c + 3);
	YESNO(c[2] - c[0] <= 1);
	return 0;
}

/*-------------------------*/
/*-----    二分探索   -----*/
/*-------------------------*/

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long ans = fib(n);


        System.out.println(ans);
    }

    public static long fib(long n) {
       long dp[] = new long[(int)(n+1)];

       dp[0] = 2;
       dp[1] = 1;

       for (long i = 2; i < n + 1; i++) {
           dp[(int)i] = dp[(int)(i - Long.valueOf(1))] + dp[(int)(i - 2)];
       }

       return dp[(int)n];

    }
}


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

signed main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  if(n % 2 == 0 ^ s.front() == s.back()) {
    cout << "Second" << '\n';
  } else {
    cout << "First" << '\n';
  }
}

Measured memory_bytes: 3760
def bubble_sort(target):
    global cnt
    flag = True
    while flag:
        flag = False
        for i in range(len(target)-1, 0, -1):
            if target[i] < target[i-1]:
                target[i-1], target[i] = target[i], target[i-1]
                flag = True
                cnt += 1
    return target

N = int(input())
A = [int(s) for s in input().split()]
cnt = 0
print(' '.join(str(s) for s in bubble_sort(A)))
print(cnt)

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

#define MAX 100000

vector <int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;

void dfs(int current,int prev)
{
	prenum[current]=lowest[current]=timer;
	timer++;
	
	visited[current]=true;
	
	int next;
	
	for(int i=0;i<G[current].size();i++)
	{
		next=G[current][i];
		if(!visited[next])
		{
			parent[next]=current;
			dfs(next,current);
			
			lowest[current]=min(lowest[current],lowest[next]);
		}
		else if(next!=prev)
		{
			lowest[current]=min(lowest[current],prenum[next]);
		}
	}
}

void art_points()
{
	for(int i=0;i<N;i++)visited[i]=false;
	timer=1;
	dfs(0,-1);
	set<int> ap;
	int np=0;
	for(int i=1;i<N;i++)
	{
		int p=parent[i];
		if(p==0)np++;
		else if(prenum[p]<=lowest[i])ap.insert(p);
	}
	if(np>1)ap.insert(0);
	for(set<int>::iterator it=ap.begin();it!=ap.end();it++)cout<<*it<<endl;
}

int main()
{
	int m;
	cin>>N>>m;
	
	for(int i=0;i<m;i++)
	{
		int s,t;
		cin>>s>>t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	art_points();
	
	return 0;
}

Measured memory_bytes: 7008
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy


def primes():

    MAX = 60000
    prime = [False] * MAX
    prime[0] = prime[1] = True
    i = 2
    ret = []

    while i < MAX:
        if not prime[i]:
            if i % 5 == 1:
                ret.append(i)
            j = 2 * i
            while j < MAX:
                prime[j] = True
                j += i
        i += 1

    return ret

N = int(input())
print(*primes()[:N])

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define len(a) (int) (a).size()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define int long long
using namespace std;
void solve();
mt19937 rnd(2007);
signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    swap(rng, rnd);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
}

void solve() {
    string s; cin >> s;
    const int mod = 2019;
    int cur_pw = 1, cur = 0;
    int ans = 0;
    map<int, int> cnt; cnt[0] = 1;
    for (int i = len(s) - 1; i >= 0; --i){
        cur += cur_pw * (s[i] - '0');
        cur %= mod;
        ans += cnt[cur];
        cnt[cur]++;
        cur_pw *= 10;
        cur_pw %= mod;
    }
    cout << ans << endl;

}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

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

  string S;
  cin >> S;
  string items[] = {"dream", "dreamer", "erase", "eraser"};

  while (true) {
    bool deleted = false;
    for (auto item : items) {
      if (S.size() >= item.size() && S.substr(S.size()-item.size(), item.size()) == item) {
        S.erase(S.end() - item.size(), S.end());
        deleted = true;
        break;
      }
    }
    if (S.empty()) {
      cout << "YES" << endl;
      return 0;
    }
    if (!deleted) break;
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3784
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
string S;

void solve() {
	
	cin >> S;
	int N = S.size();
	/*
	RL	
	*/
	vector<int> OE(2, 0);
	vector<int> ans(N, 0);

	bool RR = true;
	int Rstart = 0;
	int Lstart = -1;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'R') {
			if (RR) {
				OE[(i - Rstart) % 2]++;
			}
			else {
				RR = true;
				Rstart = i;
				OE[(i - Rstart) % 2]++;
			}
		}
		else {//L
			if (RR == true) {
				RR = false;
				Lstart = i;

				if ((i-Rstart) % 2 == 0) {
					ans[i] += OE[0];
					ans[i - 1] += OE[1];
				}
				else {
					ans[i - 1] += OE[0];
					ans[i] += OE[1];
				}
				OE[0] = 0;
				OE[1] = 0;
			}

			{
				if ((i - Lstart) % 2 == 0) {
					ans[Lstart]++;
				}
				else {
					ans[Lstart - 1]++;
				}
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		cout << ans[i] << " ";
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  string s;
  cin>>s;
  if(s[s.size()-1]=='s'){
    s=s+"es";
  }
  else{
    s=s+'s';
  }
  cout<<s;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 200010

int N;
vector<int> A;

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

    cin >> N;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
    }

    int len = 1;
    REP(i, N) {
        if(A[i] == len) {
            len++;
        }
    }
    len--;

    if(len == 0) {
        printf("-1\n");
        return 0;
    }

    printf("%lld\n", N - len);

    return 0;
}


Measured memory_bytes: 1792
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 5000 + 20 , inf = 3e18 + 20 ;
int n , a , b , p[N] ;
int cnt[N][N] , dp[N] , ans = inf ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> a >> b ;

	for (int i = 0 ; i < n ; i ++) cin >> p[i] , p[i] -- , dp[i] = inf ;

	for (int i = 0 ; i < n ; i ++) {
		for (int j = 0 ; j <= n ; j ++) cnt[i + 1][j] = cnt[i][j] ;
		for (int j = p[i] + 1; j <= n; j ++) cnt[i + 1][j] ++ ;
	}

	for (int i = 0 , mn = inf ; i < n ; i ++) {
		mn = min(mn , p[i]) ;

		if (p[i] == mn) {
			dp[i] = a * (i - cnt[i][p[i]]) + b * (cnt[n][p[i]] - cnt[i][p[i]]) ;	
		}

		int mx = -1 ;

		for (int j = i - 1 ; j >= 0 ; j --) {
			if (p[j] < mx || p[i] < p[j]) continue ;
			mx = p[j] ;

			int val = dp[j] ;

			val += a * ((i - cnt[i][p[i]]) - (j - cnt[j][p[i]])) + b * (cnt[n][p[i]] - cnt[n][p[j]] - cnt[i][p[i]] + cnt[i][p[j]]) ;

			dp[i] = min(dp[i] , val) ;
		}

		mx = -1 ;

		for (int j = n - 1 ; j > i ; j --) mx = max(mx , p[j]) ;

		if (mx < p[i]) ans = min(ans , dp[i]) ;
	}

	cout << ans << '\n' ;
}


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

ll sa(ll a,ll b,ll c){
    ll mx,mn;
    vector<ll> num(3);
    num[0] = a;
    num[1] = b;
    num[2] = c;
    sort(num.begin(),num.end());
    return num[2]-num[0];
}

int main(){
    ll h,w;
    cin >> h >> w;
    if(h%3 == 0 || w%3 == 0){
        cout << 0 << endl;
        return 0;
    }    
    if(w == 1 || h == 1){
        cout << 1 << endl; 
        return 0;
    }
    //cout << "OK" << endl;
    ll ans = 1e18;
    for(ll i = 0; i < h-1; i++){
        ll a = w*(i+1);
        ll b = (w/2)*(h-i-1);
        ll c = w*(h-i-1)-b;
        if(ans > sa(a,b,c)) ans = sa(a,b,c);
        //if(ans == 3) cout << a  << " " << b << " " << c << endl; 
    }
    for(ll i = 0; i < w-1; i++){
        ll a = h*(i+1);
        ll b = (w-i-1)*(h/2);
        ll c = (w-i-1)*h-b;
        if(ans > sa(a,b,c)) ans = sa(a,b,c);
        //if(ans == 3) cout << a  << " " << b << " " << c << endl; 
    }
    if(ans > w) ans = w;
    if(ans > h) ans = h;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

void add_self (int& a, int b){ a += b; if (a >= MOD) a -= MOD; }
//-------------------------------------------------------------------------------------------------------//

void solve(){
    int n;
    cin >> n;
    vi a;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x;
        if(x % 10 != 0) a.push_back(x);
    }
    sort(all(a));
    if(sum % 10 == 0){
        for(int i = 0; i < sz(a); i++){
            sum -= a[i];
            if(sum % 10 != 0) break;
        }
    }
    if(sum % 10 == 0) cout << 0;
    else cout << sum;
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


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

int H,W;

int main()
{
    cin>>H>>W;
    char s[H][W];
    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++) cin>>s[i][j];
    }

    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            if (s[i][j]=='.') {
                int cnt=0;
                for (int k=i-1; k<=i+1; k++){
                    for (int l=j-1; l<=j+1; l++){
                        if (k>=0&&k<H&&
                            l>=0&&l<W&&
                            s[k][l]=='#') cnt++;
                    }
                }
                cout<<cnt;
            }

            if(s[i][j]=='#') cout<<'#';

            if (j==W-1) cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 636
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x= (a+d-1)/d;
	int y= (c+b-1)/b;
	cout<<(x>=y?"Yes":"No")<<"\n";
	return 0;
} 

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

const int MAX = 9;
bool connect[MAX][MAX];
bool visit[MAX];
int n, m;

int dfs(int node) {
        bool all_visit = true;
        for (int i=1; i<=n; ++i) {
                if (visit[i]==false) {
                        all_visit = false;
                        break;
                }
        }
        if (all_visit) return 1;

        int ret = 0;
        for (int i=1; i<=n; ++i) {
                if (connect[node][i] && !visit[i]) {
                        visit[i] = true;
                        ret += dfs(i);
                        visit[i] = false;
                }
        }
        return ret;
}

int main() {
        cin >> n >> m;
        for (int i=0; i<m; ++i) {
                int a, b;
                cin >> a >> b;
                connect[a][b] = connect[b][a] = true;
        }
        visit[1] = true;
        cout << dfs(1) << endl;
        return 0;
}


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

int main(){
  int n,l;
  cin>>n>>l;
  if(l>0) cout<<(2*l+n)*(n-1)/2;
  else{
	if((l+n)<1) cout<<(2*l+n-2)*(n-1)/2;
	else cout<<(2*l+n-1)*n/2;
  }
  return 0;
}

Measured memory_bytes: 256