akhauriyash/Code-Regression huggingface dataset:
////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

namespace my {
/*汎用*/
template <typename T>
void input_vec(vector<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

/*整数*/
ll gcd(ll a, ll b) {  // O( log(max(a,b)) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(max(a,b)) )
ll modinv(ll n, ll mod) {                               // O( log(max(n,mod)) )
  assert(mod > 0 && my::gcd(n, mod) == 1);
  n %= mod;
  if (n < 0) n += mod;
  ll a = mod, b = n, x = 1, y = 0;
  while (b != 0) {
    ll q = a / b, r = a % b;
    a = b;
    b = r;
    y -= q * x;
    swap(x, y);
  }
  y %= mod;
  if (y < 0) y += mod;
  return y;
}

bool is_prime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
vector<pair<ll, ll>> prime_factorize(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}

/*union find*/
class unionfind {
 private:
  /*根のparの値は「-(その木の要素数)」とする*/
  ll n_;
  vector<ll> par;

  ll root(ll a) {  // O( log(n) )
    if (par.at(a) < 0)
      return a;
    else {
      par.at(a) = root(par.at(a));  //経路圧縮
      return par.at(a);
    }
  }

 public:
  unionfind(ll n) : n_(n), par(n, -1) {}  // O(n)

  void unite(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    if (root(a) == root(b))
      return;
    else {
      ll ra = root(a), rb = root(b);
      if (-par.at(ra) < -par.at(rb)) swap(ra, rb);  //サイズによる併合
      par.at(ra) += par.at(rb);
      par.at(rb) = ra;
    }
  }

  bool is_same(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    return root(a) == root(b);
  }

  ll size(ll a) {  // O( log(n) )
    assert(0 <= a && a < n_);
    return -par.at(root(a));
  }
};
}  // namespace my
////////////////////////////////////////////////

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int c = 1; c < n; c++) {
    int d = n - c;
    vector<pair<ll, ll>> pf = my::prime_factorize(d);
    int yakusu = 1;
    for (auto &pfi : pf) yakusu *= pfi.second + 1;
    ans += yakusu;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;

int V;
vector<int> G[105], rG[105], vs;
bool used[105];
int cmp[105];
double p[105];
double P[105];
bool g[105][105];
void add_edge(int from, int to) {
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		if (!used[G[v][i]]) dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v, int k) {
	used[v] = true;
	cmp[v] = k;
	P[k] *= p[v];
	for (int i = 0; i < rG[v].size(); i++) {
		if (!used[rG[v][i]]) rdfs(rG[v][i], k);
	}
}

int scc() {
	memset(used, 0, sizeof(used));
	vs.clear();
	for (int v = 0; v < V; v++) {
		if (!used[v]) dfs(v);
	}
	memset(used, 0, sizeof(used));
	int k = 0;
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}

int main() {
	while (cin >> V, V) {
		for (int i = 0; i < V; i++) {
			G[i].clear();
			rG[i].clear();
		}
		for (int i = 0; i < V; i++) {
			cin >> p[i];
			int m;
			cin >> m;
			for (int j = 0; j < m; j++) {
				int a;
				cin >> a; a--;
				add_edge(i, a);
			}
		}
		for (int i = 0; i < V; i++) {
			P[i] = 1;
		}
		int K=scc();
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) g[i][j] = 0;
		}
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < G[i].size(); j++) {
				g[cmp[i]][cmp[G[i][j]]] = 1;
			}
		}
		double ans = 1;
		for (int i = 0; i < K; i++) {
			bool in = 0;
			for (int j = 0; j < K; j++) {
				if (i == j) continue;
				if (g[j][i]) {
					in = 1; break;
				}
			}
			if (!in) ans *= (1 - P[i]);
		}
		printf("%.15lf\n", ans);
	}
}

Measured memory_bytes: 3324
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <bitset>
#define ll long long
using namespace std;


int main(){//cout<<1<<endl;
  int n,k;
  cin>>n>>k;
  int ans;
  ans=n/2;
  if(n%2==1) ans++;
  
  if(k>ans){cout<<"NO"<<endl;return 0;}
  cout<<"YES"<<endl;return 0;
  
  
}


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int highest = 0;
    for (int i = 0; i < n; i++) {
        highest = max(h[i],highest);
    }
    int count = 0;
    for (int i = 0; i < highest; i++) {
        for (int j = 0; j < n; j++) {
            if (h[j]>i) {
                while (h[j]>i) {
                    j++;
                }
                count++;
            }
        }
    }
     cout << count << endl;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int cnt(int c, int k) {
    if(c == 1) return 0;
    if(c <= k) return 1;
    c -= k;
    return 1 + (c + k - 2) / (k - 1);
}

void solve() {
	int n, k; cin >> n >> k;
    vector<int> a(n);
    int j = 0;
    rep(i, n) {
        cin >> a[i];
        if(a[i] == 1) {
            j = i;
        }
    }
    cout << 1 + (n - k + k - 2) / (k - 1) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
	uint32_t N;
	cin >> N;
	string s;
	cin >> s;
	uint32_t i = 0,B = 0, R = 0;

	while(i < N){
		switch(s[i]){
			case 'B':
				B++;
				break;
			case 'R':
				R++;
				break;
			default:
				break;
		}
		++i;
	}

	if(R > B)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}


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

const int maxn=1e5+5;
const int maxm=40;
#define ll long long

int f[maxn][maxm];
ll sum[maxn][maxm];

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

    ll n,x,m;
    cin>>n>>x>>m;
    for(ll i=0;i<m;i++)
    {
        f[i][0]=(i*i)%m;
        sum[i][0]=f[i][0];
    }

    for(int j=1;j<maxm;j++) for(int i=0;i<m;i++)
    {
        f[i][j]=f[f[i][j-1]][j-1];
        sum[i][j]=sum[i][j-1]+sum[f[i][j-1]][j-1];
    }

    ll ans=x;n--;
    for(int i=39;i>=0;i--) if((n>>i)&1)
    {

        ans+=sum[x][i];
        x=f[x][i];
    }
    cout<<ans;
    return 0;
}

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

int main() {
    vector<int> vec(5);
    rep(i, 5) cin >> vec[i];
    int k;
    cin >> k;
    if (vec[4] - vec[0] > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> A(N+1);
  vector<int> B(N+1);
  vector<int>kotae;
  for(int i=0;i<N;i++){
    cin>>A[i+1];
  }
  for(int i=N;i>=1;--i){
    int sum=0;
    for(int j=i+i;j<=N;j+=i){
      sum^=B[j];
    }
    B[i]=sum^A[i];
  }
  for(int i=1;i<=N;i++){
    if(B[i]){
      kotae.push_back(i);
    }
  }
  cout<<kotae.size()<<endl;
  for(int i=0;i<kotae.size();i++){
    if(i!=kotae.size()-1){
      cout<<kotae[i]<<" ";
    }else{
      cout<<kotae[i]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<tuple>
#define llint long long int
#define lldo long double
#define fir first
#define sec second
#define pub push_back
#define mp make_pair
#define mt make_tuple
using namespace std;
int main(void){
	int i,j,n;cin>>n;
	vector<pair<int,int>> pot(n);
	vector<tuple<lldo,int,int>>kata;
	for(i=0;i<n;i++){cin>>pot[i].fir>>pot[i].sec;}
	for(i=0;i<n;i++){
		for(j=0;j<i;j++){
			lldo dy=pot[i].sec-pot[j].sec;
			lldo dx=pot[i].fir-pot[j].fir;if(abs(dx)<0.5){dx=1e-16*dy;}//0????????????
			kata.pub(mt(dy/dx,i,j));
		}
	}
	sort(kata.begin(),kata.end());
	static int dp[65536]={0};
	vector<pair<int,int>> hen;
	for(i=0;i<kata.size();i++){
		hen.pub(mp(get<1>(kata[i]),get<2>(kata[i])));
		if(i==kata.size()-1||abs(get<0>(kata[i])-get<0>(kata[i+1]))>1e-7){
			//?¬?????????¨???????????§??????
			for(int bii=0;bii<(1<<hen.size());bii++){
				int use=0;
				int pot=0;
				for(j=0;j<hen.size();j++){
					if((bii&(1<<j))==0){continue;}
					use+=(1<<hen[j].fir);
					use+=(1<<hen[j].sec);
					pot++;
				}
				pot*=(pot-1);
				if(pot==0){continue;}
				for(int bi=0;bi<(1<<n);bi++){
					if((bi&use)!=0){continue;}
					if(dp[bi+use]<dp[bi]+pot){dp[bi+use]=dp[bi]+pot;}
				}
			}
			hen.clear();
		}
		
	}
	int ans=0;
	for(i=0;i<65536;i++){if(ans<dp[i]){ans=dp[i];}}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 3388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	ll H, W;
	ll ans;
	cin >> H >> W;
	if(H==1 || W==1)
	{
	    cout << 1 << endl;
	    return 0;
	}
	if(H%2==0) ans = W*H/2;
	else ans = W*(H/2)+(W+1)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from copy import copy

N = int(input())
S = [int(input()) for _ in range(N)]
S2 = copy(S)
total = 0

for s in S:
    total += s
    if s % 10 == 0:
        S2.remove(s)
        
S2.sort()

if not S2:
  	print(0)
else:
    while total % 10 == 0:
        total -= S2.pop(0)
    print(total)

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
int main(){
    lint n;
    cin>>n;
    vec a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)b[i]=a[(i+1)%n]-a[i];
    lint sm=SUM(a);
    if(sm%(n*(n+1)/2)!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    lint cnt=sm/(n*(n+1)/2);
    rep(i,n)b[i]=cnt-b[i];
    rep(i,n){
        if(b[i]%n!=0||b[i]<0){
            cout<<"NO"<<endl;
            return 0;
        }
        cnt-=b[i]/n;
    }
    if(cnt!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1792
# https://atcoder.jp/contests/abc049/tasks/arc065_a

s = input()

strings = ['dream', 'dreamer', 'erase', 'eraser']
i = len(s)
while s:
    for i in range(4):
        t = strings[i]
        if s[-len(t):] == t:
            s = s[:-len(t)]
            break
    else:
        print('NO')
        break
else:
    print('YES')


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

int main()
{
    char x, y, ans = '=';
    cin >> x >> y;
    if ((int)x < (int)y)
        ans = '<';
    if ((int)x >(int) y)
        ans = '>';
    cout << ans << "\n";
    return 0;
}


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

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

  int n = s;
  int i = 0;

  if (n == 4 || n == 2 || n == 1) {
    cout << 4 << endl;
    return 0;
  }

  while (n != 4) {
    i += 1;
    if (n % 2 == 0) {
      n = n / 2;
    } else {
      n = 3 * n + 1;
    }
  }

  cout << i + 3 + 1 << endl;
}

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sort(v.rbegin(), v.rend());
	int a = 0, b = 0;
	for (int i = 0; i < n; i++)
		if (i & 1)
			b += v[i];
		else
			a += v[i];
	cout << a - b;
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = str(input())
position = [0] * N
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i + 1] == "C":
        count += 1
    position[i+1] = count
answers = []
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    answer = position[r] - position[l]
    answers.append(answer)
for i in range(Q):
    print(answers[i])

Measured memory_bytes: 10300
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
int a, b;

cin >> a >> b;

int ans, ans1, ans2, ans3;

ans1 = a + b;
ans2 = a * b;
ans3 = a - b;

ans = max(ans1, ans2);
ans = max(ans3, ans);

cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int calc(int a,int b){
	if(a%b==0)return a/b;
	int to=a;
	int am=to%b/(a/b+1);
	to-=am*(a/b+1);
	if(am==0){
		to-=a/b+1;
	}
	return calc(to,b);
}
int main(){
	int a;scanf("%d",&a);
	int ret=0;
	for(int i=0;i<a;i++){
		int p,q;scanf("%d%d",&p,&q);
		int tmp=calc(p,q);
		ret^=tmp;
	}
	if(ret==0)printf("Aoki\n");
	else printf("Takahashi\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k; cin>>n>>k;
	int h[n];
	for(int i=0;i<n;i++) cin>>h[i];
	int dp[n];
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=INT_MAX;
	//	cout<<"for "<<i<<endl;
		for(int j=i-1;j>=i-k and j>=0;j--){
	//		cout<<j<<" ";
			dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
		}//cout<<endl;
	}
//	for(int x:dp) cout<<x<<" ";cout<<endl;
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
from collections import Counter
 
def check():
    S = sorted(Counter(input()).values())
    T = sorted(Counter(input()).values())
    
    for s,t in zip(S,T):
        if s !=t: # 置換できるならば要素の数は同じになるはず
            return 'No'
    return 'Yes'
  
print(check())

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

int main() {
    int n,d,x,sum=0,i,j;
    cin>>n>>d>>x;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        for(j=1;j<=d;)
        {
            if(j<=d)
            sum++;
            j+=a[i];
        }
    }
    sum=sum+x;
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int N, M;
  cin>>N>>M;
    int sum=0;
    int a;
    rep(i, M){
        cin>>a;
        sum+=a;
    }
    if(sum<=N){
        cout<<N-sum<<endl;
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int a[1000000],i;
int p(int k)
{
	return k/2;
}
int l(int k)
{
	return k*2;
}
int r(int k)
{
	return k*2+1;
}
int main()
{
	int n;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<=n;i++)
	{
		cout<<"node "<<i<<": key = "<<a[i]<<", ";
		if(p(i)>=1)
		{
			cout<<"parent key = "<<a[p(i)]<<", ";
		}
		if(l(i)<=n)
		{
			cout<<"left key = "<<a[l(i)]<<", ";
		}
		if(r(i)<=n)
		{
			cout<<"right key = "<<a[r(i)]<<", ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  int N;
  cin >>N;
  ll mod=pow(10,9)+7;
  vector<ll> dp(N+1);
  dp[0]=1;
  for(int i=1;i<=N+1;i++){
    for(int j=0;j<=i-3;j++){
      dp[i]+=dp[j];
      dp[i]%=mod;
    }
  }
  cout << dp[N] <<endl;
}

  
  

Measured memory_bytes: 3628
n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
sum = 0

for i in range(len(a)):
    sum += b[a[i] - 1]
    #print("i:{0} sum{1}".format(i, sum))#
    if(i != len(a) - 1 and a[i] + 1 == a[i + 1]):
        sum += c[a[i] - 1]
        #print("i:{0} sum{1}".format(i, sum))#

print(sum)

Measured memory_bytes: 3064
from collections import deque


N, M = map(int, input().split())
to = [[] for _ in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)

route = deque([0])
dist = [0]*N
prev = [-1]*N
dist[0] = 0

while route:
    v = route.popleft()
    for u in to[v]:
        if dist[u]: continue
        dist[u] = dist[v]+1
        prev[u] = v
        route.append(u)

print("Yes")
for pre in prev[1:]:
    print(pre+1)

Measured memory_bytes: 35668
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var ans int
	if v := abs(n - m); v == 0 {
		ans = 2
	} else if v == 1 {
		ans = 1
	} else {
		fmt.Println(0)
		return
	}
	const mod = 1000000007
	for i := 2; i <= n; i++ {
		ans *= i
		ans %= mod
	}
	for i := 2; i <= m; i++ {
		ans *= i
		ans %= mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
n, m = map(int, input().split())

if n > 2 and m > 2:
  print((n-2)*(m-2))
elif n == 2 or m == 2:
  print(0)
elif n < 2 and m < 2:
  print(1)
else:
  print(max([0, m-2, n-2]))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int j_state = 0,
      i_state = 0,
      joi     = 0,
      ioi     = 0;
  int c;

  while ((c = getchar()) != EOF) {
    switch (c) {
      case 'J':
        i_state = 0;
        j_state = 1;
        break;
      case 'I':
        if (i_state == 2) {
          ioi++;
        } else if (j_state == 2) {
          joi++;
        }
        i_state = 1;
        j_state = 0;
        break;
      case 'O':
        if (i_state == 1) {
          i_state = 2;
        } else if (j_state == 1) {
          j_state = 2;
        } else {
          i_state = 0;
          j_state = 0;
        }
        break;
      case '\n':
        printf("%d\n%d\n", joi, ioi);
        joi = 0;
        ioi = 0;
        i_state = 0;
        j_state = 0;
      default:
        i_state = 0;
        j_state = 0;
        break;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int N;
    cin >> N;
    int rate[3][2];
    for (int i = 0; i <= 1; i++) {
        cin >> rate[0][i] >> rate[1][i] >> rate[2][i];
    }

    long long maximum = N;

    int X = 0;
    for (int X = 0; X <= 1; X++) {
        N = maximum;
        vector<long long> dp(N + 1, 0);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j <= N; j++) {
                if (j >= rate[i][X]) {
                    dp[j] = max(
                        dp[j],
                        dp[j - rate[i][X]] + rate[i][1 - X]
                    );
                }
            }
        }

        for (int i = 0; i <= N; i++) {
            maximum = max(maximum, dp[i] + N - i);
        }
    }

    cout << maximum << endl;

    return 0;
}

Measured memory_bytes: 195584
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <cfloat>
using namespace std;

vector<int> solve(vector<vector<int> >& x, vector<vector<int> >& y)
{
    int n = x.size();
    x.push_back(x[0]);
    y.push_back(y[0]);
    reverse(x[n].begin(), x[n].end());
    reverse(y[n].begin(), y[n].end());

    for(int i=0; i<n+1; ++i){
        int m = x[i].size();
        for(int j=m-1; j>=0; --j){
            x[i][j] -= x[i][0];
            y[i][j] -= y[i][0];
        }
        while(x[i][1] <= 0){
            for(int j=0; j<m; ++j){
                swap(x[i][j], y[i][j]);
                y[i][j] *= -1;
            }
        }
    }

    vector<int> ret;
    for(int i=1; i<n; ++i){
        if((x[i] == x[0] && y[i] == y[0]) || (x[i] == x[n] && y[i] == y[n]))
            ret.push_back(i);
    }
    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            break;
        vector<vector<int> > x(n+1), y(n+1);
        for(int i=0; i<n+1; ++i){
            int m;
            cin >> m;
            x[i].resize(m);
            y[i].resize(m);
            for(int j=0; j<m; ++j)
                cin >> x[i][j] >> y[i][j];
        }
        vector<int> ret = solve(x, y);
        for(unsigned i=0; i<ret.size(); ++i)
            cout << ret[i] << endl;
        cout << "+++++" << endl;
    }
}

Measured memory_bytes: 0
h,n=map(int,input().split())
a=[]
b=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)

INF=float("inf")
    
dp=([[INF]*(1+h) for i in range(1+n)])


dp[0][0]=0

for i in range(n):
    # print(dp)
    for j in range(h+1):
        # print("i+1=",i+1,"j=",j)
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][min(h,j+a[i])]=min(dp[i+1][min(h,j+a[i])],dp[i+1][j]+b[i])
        # print(i+1,j,min(h,j+a[i]),"\n",dp)
    # print("==================")

# print(dp)
print(dp[n][h])


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

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

	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<int> B(N);
	rep(i, N) {
		cin >> B[i];
	}
	vector<int> C(N);
	rep(i, N-1) {
		cin >> C[i];
	}

	int ans = 0;
	rep(i, N) {
		ans += B[i];
	}
	rep(i, N - 1) {
		if (A[i] + 1 == A[i + 1]) ans += C[A[i]-1];
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int A[100];
	int n;
	int minj;
	int ch;
	
	scanf("%d", &n);
	for (int i = 0;i < n;i++) {
		scanf("%d", &A[i]);
	}

	ch = 0;
	for (int i = 0;i < n;i++) {
		minj = i;
		for (int j = i;j < n;j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (i != minj)ch++;
		int sub = A[i];
		A[i] = A[minj];
		A[minj] = sub;
	}

	for (int i = 0;i < n;i++) {
		printf("%d", A[i]);
		if (i + 1 < n)printf(" ");
		else printf("\n");
	}
	printf("%d\n", ch);

	return 0;
}

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

#define BIT_LIM 40

using namespace std;

typedef long long ll;

int main(int argc, char **argv)
{
    vector<ll> A, B;
    ll n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    for (int i = 0; i < n; i++)
    {
        ll b;
        cin >> b;
        B.push_back(b);
    }

    ll res = 0;
    for (int k = 0; k < BIT_LIM; k++)
    {
        ll T = 1LL << (k + 1);
        ll num_kth_bit_is_1 = 0;
        vector<ll> Bk;
        for (auto &&b : B)
        {
            Bk.push_back(b & (T - 1));
        }
        sort(Bk.begin(), Bk.end());

        for (auto &&ai : A)
        {
            ll ai_mod = ai & (T - 1);

            T = T >> 1;
            num_kth_bit_is_1 +=
                lower_bound(Bk.begin(), Bk.end(), 2 * T - ai_mod) -
                lower_bound(Bk.begin(), Bk.end(), T - ai_mod);

            num_kth_bit_is_1 +=
                lower_bound(Bk.begin(), Bk.end(), 4 * T - ai_mod) -
                lower_bound(Bk.begin(), Bk.end(), 3 * T - ai_mod);
            T = T << 1;
        }

        res = ((num_kth_bit_is_1 & 1) << k) | res;
    }

    cout << res << endl;

    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> to[n];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i, n) sort(to[i].begin(), to[i].end());
  bool flag = false;
  for (int x : to[0]) {
    if (to[x].back() == n-1) flag = true;
  }
  cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){
	int n;
	cin >> n ;
	vi a(n) ;re(a);
	int cnt = 0 ;
	map<int,int> ma;
	rep(i,0,n){
		cnt+=ma[i-a[i]];
		ma[i+a[i]]++;
	}
	cout << cnt << endl;
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 27484
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=55;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
map<int,int>Map;
int m,a[N],C[N][N];
bool check(int x,int y)
{
	return x==(x&y);
}

signed main()
{
	int n=read(),k=read(),s=read(),t=read(),ans=0;
	for (int i=1;i<=n;i++)
	{
		int x=read();
		if (check(s,x)&&check(x,t)) a[++m]=x;
	}
	n=m;
	memset(C,0,sizeof(C));
	for (int i=0;i<=n;i++) C[i][0]=1;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=i;j++) C[i][j]=C[i-1][j-1]+C[i-1][j];
	for (int i=1;i<=n;i++)
	for (int j=1;j<=k;j++) C[i][j]+=C[i][j-1];
	for (int p=0;p<(1<<18);p++)
	{
		bool flag=1;
		for (int i=0;i<18;i++)
		if ((p>>i&1)&&(s>>i&1)==(t>>i&1))
		{
			flag=0;
			break;
		}
		if (!flag) continue;
		Map.clear();
		int sum=0;
		for (int i=1;i<=n;i++) Map[a[i]&p]++;
		for (int i=1;i<=n;i++)
		if (Map[a[i]&p])
		{
			sum+=C[Map[a[i]&p]][k]-1;
			Map[a[i]&p]=0;
		}
		for (int i=0;i<18;i++) if (p>>i&1) sum=-sum;
		ans+=sum;
	}
	print(ans);

	return 0;
}

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

int main() {
  int a;
  cin >>a;
  int b;
  cin >>b;
  int c[1000];
  for(int i=0;i<a;i++)
    cin >> c[i];
  
 int e;
  
    e =0;
  for(int i=0;i<a;i++){
   
    if(c[i] <= b/2){
    e += c[i];
    }
    if(c[i] > b/2){
      e += (b-c[i]);
  }
  }
  
  
  cout << 2*e << endl;
    
  
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def sum_digits(val):
    work = 0
    while True:
        work += val % 10
        val //= 10
        if val == 0:
            break
    return work
   
n = int(input())

values = []
for a in range(1, n + 1):
    b = n - a
    if b < 1:
        continue
    # print("{}, {} / {}, {}".format(a, sum_digits(a), b, sum_digits(b)))
    values.append(sum_digits(a) + sum_digits(b))

values.sort()
# print(values)
print("0" if len(values) == 0 else values[0])

Measured memory_bytes: 3864
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scan = new Scanner(System.in)) {
          int num = scan.nextInt();
          int Bsum = 0;
          List<Integer> array = new ArrayList<>();
			List<Integer> Carray = new ArrayList<>();
          
          for (int i = 0; i < num-1; i++) {
				int a = scan.nextInt();
				array.add(a);
			}
          
          Bsum = array.get(0) + array.get(array.size()-1);
          
          if(array.size() > 1) {
            for (int i = 1; i < array.size(); i++) {
              if(array.get(i-1) < array.get(i)) {
                Bsum+=array.get(i-1);
              } else {
                Bsum+=array.get(i);
              }
            }
          }
          
          
          System.out.println(Bsum);
        }
    }
}

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

int main(){
    long long int n, a, b;
    cin >> n >> a >> b;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    long long int ans = 0;
    for(int i = 1; i < n; i++){
        if((x[i]-x[i-1])*a > b) ans += b;
        else ans += a*(x[i]-x[i-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    int dis=y-x;
    for (int i = 1; i < n; ++i) {
        ll ans=0;
        for (int j = 1; j <= n; ++j) {
            if(j<=x){
                ll nokori=i-(x-j);
                if(nokori<=0)ans++;
                else{
                    if(nokori<=dis){
                        if(dis-(nokori-1)>nokori)ans+=2;
                        else if(dis-(nokori-1)==nokori)ans++;
                        if(nokori-1>=1 && nokori-1<=n-y)ans++;
                    }
                    else{
                        if(nokori-1<=n-y)ans++;
                    }
                }
            }
            else if(x<j && j<y){
                if((j-x)<(y-j)){
                    if(i-(j-x+1)>=1 && y+i-(1+j-x)<=n)ans++;
                    if(i>=j-x+1) {
                        if (j + i == y - (i - (j - x + 1)))ans++;
                        else if (i >= j - x + 1 && j + i < y - (i - (j - x + 1)))ans += 2;
                    }
                    else{
                        if(j+i<y)ans++;
                    }
                }
                else{
                    if(j+i<=n)ans++;
                }
            }
            else if(y<=j){
                if(j+i<=n)ans++;
            }
            //cout<<ans;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import string

def get_info(N):
    d = 1
    while N > pow(26, d):
        N -= pow(26, d)
        d += 1
    return d, N

def convert(x, n):
    if x // n == 0:
        return [x % n]
    return convert(x // n, n) + [x % n]

N = int(input().strip())
digit, n = get_info(N)
name = [string.ascii_lowercase[i] for i in convert(n-1, 26)]
if len(name) < digit:
    name = ["a" for _ in range(digit-len(name))] + name

print("".join(name))


Measured memory_bytes: 9924
#include <iostream>
#include <cmath>
#define MAX 1000000
using namespace std;

int main() {
	int n, count;
	bool a[MAX];
	for (int i = 2;i < MAX;i++) { a[i] = true; }
	for (int i = 2;i < sqrt(MAX);i++) {
		if (a[i] ==true) {
			for (int j = 2;j*i < MAX;j++) { a[j*i] = false; }
		}
	}
	
	while (cin >> n) {
		count = 0;
		for (int i = 2;i <= n;i++) {
			if (a[i])
				count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 2136
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll s[1001];
ll a[1001];
int n,k;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	s[0]=0;
	for(int i=0;i<n;i++){
		s[i+1]=a[i]+s[i];
	}
	vector<ll>sum;
	for(int i=0;i<n+1;i++){
		for(int j=i+1;j<n+1;j++){
			sum.push_back(s[j]-s[i]);
		}
	}
	// for(auto itr:sum){
	// 	cout<<" sum "<<itr<<endl;
	// }
	//cout<<sum.size()<<endl;
	ll ans=0;
	for(int i=39;i>=0;i--){
		int count=0;
		ll flag=ans|(1LL<<i);
		for(auto &itr:sum){
	//		cout<<itr<<" "<<flag<<" and "<<(flag&itr)<<endl;
	// &には括弧をつけないと違う意味になる
			if((flag&itr)==flag){
				count++;
			}
		}
	//	cout<<count<<" "<<flag<<endl;
		if(count>=k){
			ans=ans|flag;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
const int K=3e5+5;
int x[K],y[K];
vector<int>v[K];
vector<int>p[K];
map<pair<int,int>,bool>mp;
int numx[K],numy[K];
int maxx,maxy;
bool calx[K],caly[K];
int main(){
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1;i<=k;i++){
		scanf("%d %d",&x[i],&y[i]);
		mp[pair<int,int>{x[i],y[i]}]=1;
		v[x[i]].push_back(y[i]);
		p[y[i]].push_back(x[i]);
		numx[x[i]]++;
		numy[y[i]]++;
		maxx=max(maxx,numx[x[i]]);
		maxy=max(maxy,numy[y[i]]);
	}
	int ans=0;
	long long num=0;
//	printf("\n%d %d\n",maxx,maxy);
//	printf("%d %d\n",numx[maxx],numy[maxy]);
	int nx=0,ny=0;
	for(int i=1;i<=k;i++){
		if(numx[x[i]]==maxx&&numy[y[i]]==maxy) num++;
		if(numx[x[i]]==maxx&&!calx[x[i]]) nx++,calx[x[i]]=1;
		if(numy[y[i]]==maxy&&!caly[y[i]]) ny++,caly[y[i]]=1;
	}
	if(num==1ll*nx*ny){
		printf("%d",maxx+maxy-1);
	}
	else printf("%d",maxx+maxy);
	return 0;
}

Measured memory_bytes: 60528
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;

int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
         
    // }
    string s;
    cin>>s;
    ll n=s.length();
    if(s[n-1]=='s')
    cout<<s<<"es"<<endl;
    else
    cout<<s<<"s"<<endl;
}



Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

int gcd_euclid(int u, int v) {
	int r;
	while (0 != v) {
		r = u % v; u = v; v = r;
	}
	return u;
}

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

	INT g;
	cin >> g;

	for (size_t i = 1; i < n; i++)
	{
		INT a;
		cin >> a;
		g = gcd_euclid(g, a);
	}

	cout << g << endl;

	return 0;
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  VLL x(n);
  rep(i, n) cin >> x[i];
  ll ans = 1e10;
  rep(i, n) {
    if(i + k - 1 < n) {
      if(x[i] >= 0 && x[i + k - 1] >= 0) {
        chmin(ans, x[i + k - 1]);
      } else if(x[i] <= 0 && x[i + k - 1] > 0) {
        chmin(ans, -x[i] + x[i + k - 1] + min(-x[i], x[i + k - 1]));
      } else {
        chmin(ans, -x[i]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N+1];
		for(int i = 1; i <= N; i++)
			a[i] = sc.nextInt();
		int[] b = new int[N+1];
		int M = 0;
		for(int i = N; i >= 1; i--) {
			int x = 0;
			for(int j = i; j <= N; j += i)
				x += b[j];
			if(x % 2 != a[i]){
				b[i] = 1;
				M++;
			}
		}
		System.out.println(M);
		for(int i = 1; i <= N; i++) {
			if(b[i] == 1)
				System.out.println(i);
		}

	}

}


Measured memory_bytes: 87116
#include <iostream>

using namespace std;

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

  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

// binary index tree
// note: i&(-i) gives the least significant bit
template <typename T>
struct BIT
{
    int n;
    vector<T> a;
    BIT(int n) : n(n), a(n + 1) {}

    void add(int i, T x = 1)
    {
        for (++i; i <= n; i += i & (-i))
        {
            a[i] += x;
        }
    }
    T sum(int i)
    {
        T ret = 0;
        for (++i; i; i -= i & (-i))
        {
            ret += a[i];
        }
        return ret;
    }
    T sum(int l, int r)
    {
        return sum(r - 1) - sum(l - 1);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    vint c(n);
    rep(i, n) cin >> c[i];

    vint pi(n + 1, -1);
    vvint ps(n);
    rep(i, n)
    {
        int l = pi[c[i]];
        if (l != -1)
            ps[l].emplace_back(i);
        pi[c[i]] = i;
    }

    vvp qs(n);
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        qs[l].emplace_back(r, i);
    }

    vint ans(q);
    BIT<int> d(n);
    for (int x = n - 1; x >= 0; --x)
    {
        for (int y : ps[x])
            d.add(y);

        for (P qr : qs[x])
        {
            int r = qr.first, i = qr.second;
            ans[i] = (r - x + 1) - d.sum(r);
        }
    }

    for (int x : ans)
    {
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 59912
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <limits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define lowbit(x) ( x&( -x) )
#define pi 3.141592653589793
#define e 2.718281828459045
#define INF 0x3f3f3f3f
#define efs 1e-7
#define HalF (l + r)>>1
#define lsn rt<<1
#define rsn rt<<1|1
#define Lson lsn, l, mid
#define Rson rsn, mid+1, r
#define QL Lson, ql, qr
#define QR Rson, ql, qr
#define myself rt, l, r
#define MP(a, b) make_pair(a, b)
using namespace std;
typedef unsigned long long ull;
typedef unsigned int uit;
typedef long long ll;
const int maxN = 105;
char s[maxN];
bool check[maxN] = {false};
ll N;
ll K;
int main()
{
    scanf("%s", s + 1);
    N = (int)strlen(s + 1);
    int same_fir = 1, same_las = 1;
    scanf("%lld", &K);
    if(N == 1)
    {
        printf("%lld\n", K / 2LL);
        return 0;
    }
    for(int i=2; i<=N; i++)
    {
        if(s[i] == s[1]) same_fir++;
        else break;
    }
    if(N % 2 == 1 && same_fir == N)
    {
        printf("%lld\n", N * K / 2LL);
        return 0;
    }
    for(int i=N - 1; i>= 1; i--)
    {
        if(s[i] == s[N]) same_las++;
        else break;
    }
    ll diff = 0;
    for(int i=2; i<=N; i++)
    {
        if(s[i] == s[i-1])
        {
            check[i] = true;
            diff++;
            i++;
        }
    }
    ll op = 0;
    if(s[1] == s[N] && !check[N])
    {
        op++;
        if(same_fir % 2 == 0) op--;
    }
    printf("%lld\n", diff * K + op * (K - 1));
    return 0;
}
/*
aaa
2
ans:3
 */
/*
abaaa
3
ans:5
 */

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

int n, k, d, tmp, sum;

int main()
{
  cin >> n >> k;
  vector<int> snk(n, 1);

  REP(i, k){
    cin >> d;
    REP(j, d){
      cin >> tmp;
      snk[tmp - 1] = 0;
    }
  }

  sum = accumulate(snk.begin(), snk.end(), 0);

  cout << sum << endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main{
	public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        
        int X = Integer.parseInt(a,16);
        int Y = Integer.parseInt(b,16);

        if(X < Y){
            System.out.println("<");
        }else if(X > Y){
            System.out.println(">");
        }else{
            System.out.println("=");
        }

		
		
	}
}

Measured memory_bytes: 23764