akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        var H = sc.ArrayInt(N);
        int ans = 0;

        for (int i = 0; i < N; i++) {
            if (!H.Take(i).Any(h => H[i] < h)) {
                ans++;
            }
        }
        WriteLine(ans);
    }
}


class Scanner {
    string[] s;
    int i;

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

    public Scanner() {
        s = new string[0];
        i = 0;
    }

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

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int long long

int M = (int)1e9 + 7;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vlll;
typedef vector<double> vd;
typedef vector<vd> vdd;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e18 + 100;
const string DIGITS = "0123456789", alph = "abcdefghijklmnopqrstuvwxyz", ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

//THE END OF TEMPLATE////////////////////////////////////////////////////////////////////////////////

#define N 2000

int dp[N][N];


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

	int n, m;
	cin >> n >> m;
	string s;
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < m; j++)
		{
			if (s[j] == '.')
			{
				if (i > 0 && dp[i - 1][j] != -1)
					dp[i][j] = msum(dp[i][j], dp[i - 1][j]);
				if (j > 0 && dp[i][j - 1] != -1)
					dp[i][j] = msum(dp[i][j], dp[i][j - 1]);
			}
			else {
				dp[i][j] = -1;
			}
		}
	}

	cout << dp[n - 1][m - 1];


}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

Measured memory_bytes: 16128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int a,b,k;
        cin >> a >> b >> k;
        for(int i=min(a,b);i>0;i--){
                if(a%i==0&&b%i==0) k--;
                if(k==0){
                        cout << i << endl; 
                        return 0;
                }        
        }
        return 0;
}


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


void solve(){
    int n,m;
    cin >> n >> m;
    int mi,ma;
    mi = 0;
    ma = n;
    rep(i,m){
        int l,r;
        cin >> l >> r;
        mi = max(mi,l);
        ma = min(ma,r);
    }
    cout << max(0,ma-mi+1) << endl;

}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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


  string s;
  cin>>s;
  int ca = 0;
  int cb = 0;
  rep(i,s.size()) {
    if(s[i] == '0') {
      ca++;
    } else {
      cb++;
    }
  }
  cout << s.size() - abs(ca-cb) << endl;


  return 0;
}


Measured memory_bytes: 512
line = input().split(" ")
N = int(line[0])
Y = int(line[1])

ret = ["-1","-1","-1"]
for z in range(N+1):
    x = (Y-5000*N+4000*z)
    if x%5000==0:
        x = x/5000
        y = N-z-x
        if x>=0 and y>=0:
            ret = [str(int(x)),str(int(y)),str(int(z))]
            break

print(" ".join(ret))

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define MOD 1000000007

void solve()
{
    int N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

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


Measured memory_bytes: 256
from collections import deque
n=int(input())
a=[0]*n
for i in range(n):
    a[i]=int(input())
a.sort()
ans1=0
d1=deque([a[0]])
l1=1
r1=n-1
while l1<=r1:
    d1.appendleft(a[r1])
    r1-=1
    if l1<=r1:
        d1.append(a[r1])
        r1-=1
    if l1<=r1:
        d1.appendleft(a[l1])
        l1+=1
    if l1<=r1:
        d1.append(a[l1])
        l1+=1
d1_l=list(d1)
ans2=0
d2=deque([a[n-1]])
l2=0
r2=n-2
while l2<=r2:
    d2.appendleft(a[l2])
    l2+=1
    if l2<=r2:
        d2.append(a[l2])
        l2+=1
    if l2<=r2:
        d2.appendleft(a[r2])
        r2-=1
    if l2<=r2:
        d2.append(a[r2])
        r2-=1
d2_l=list(d2)
for i in range(n-1):
    ans1+=abs(d1_l[i]-d1_l[i+1])
for i in range(n-1):
    ans2+=abs(d2_l[i]-d2_l[i+1])
print(max(ans1,ans2))


Measured memory_bytes: 55000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	ll h;
	cin>>h;
	ll count=0;
	vector<ll> v;
	while(h!=0){
		v.push_back(h);
		h=h/2;
	}
	for (int i = 0; i < v.size(); ++i)
	{
		count=count+pow(2, i);
	}

	cout<<long(count);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int pro[4];
int rob[4];
int main()
{
    pro[1] = rob[1] =300000;
    pro[2] = rob[2] =200000;
    pro[3] = rob[3] =100000;

    int x,y;
    cin >> x >> y;

    long long sum = pro[x] + rob[y];

    if ((x == 1)&&(y == 1))sum+=400000;

    cout << sum <<endl;

    return 0;
}


Measured memory_bytes: 256
/*
 * https://atcoder.jp/contests/abc144/tasks/abc144_b
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long


/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// `chmax(a, b)` aがbより小さければ、aをbに上書きする。chminは逆
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1e9 + 7;
int main() {
    INIT();

    double k;
    cin >> k;
    cout << k*3.1415*2;
    return 0;
}

Measured memory_bytes: 3800
# A - Colorful Transceivers

a, b, c, d = map(int, input().split())

e = a - b
f = b - c
g = c - a

x = abs(e)
y = abs(f)
z = abs(g)

if x <= d and y <= d or z <= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9120
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] a_asArgs)
        {
			int l_iN = int.Parse(Console.ReadLine());

			SortedList<int, int> l_List = new SortedList<int, int>();
			for (int l_iBuf = 1; l_iBuf <= 1000; l_iBuf++)
			{
				int l_iValue = l_iBuf;
				for (int l_iPow = 1; l_iPow <= 10; l_iPow++)
				{
					l_iValue *= l_iBuf;
					if (l_iValue <= 1000)
					{
						if (!l_List.ContainsKey(l_iValue))
						{
							l_List.Add(l_iValue, 0);
						}
					}
				}
			}
			for (int l_iIdx = 0; l_iIdx < l_List.Count; l_iIdx++)
			{
				int l_iValue = l_List.Keys[l_List.Count - 1 - l_iIdx];
				if (l_iValue <= l_iN)
				{
					Console.WriteLine(l_iValue);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 11276
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, K;
  cin >> N >> K;
  cout << N - K + 1 << endl;

  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li v[300300];
li w[300300];
li n;

li memo[555][100100];

inline li dfs(li now, li sum_v, li sum_w, li lim) {
    if (sum_w > lim) {
        return 0;
    }
    if (now < 512) {
        return memo[now][lim - sum_w] + sum_v;
    }
    li parent = (now - 1) / 2;
    return max(dfs(parent, sum_v, sum_w, lim),
               dfs(parent, sum_v + v[now], sum_w + w[now], lim));
}

inline li solve() {
    li vv, l;
    cin >> vv >> l;
    vv--;
    return dfs(vv, 0, 0, l);
}

int main() {
    cin >> n;
    rin{
        cin >> v[i] >> w[i];
    }
    rep(i, 100001) {
        memo[0][i] = 0;
    }
    repp(i, w[0], 100001) {
        memo[0][i] = v[0];
    }
    repp(i, 1, min(512ll, n)) {
        li parent = (i - 1) / 2;
        rep(j, 100001) {
            memo[i][j] = memo[parent][j];
            if (j >= w[i]) {
                memo[i][j] = max(memo[i][j], memo[parent][j - w[i]] + v[i]);
            }
        }
    }
    li q;
    cin >> q;
    rep(i, q) {
        cout << solve() << endl;
    }

    return 0;
}

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

int main(){
    int n,memo = 0,a[6] = {1,5,10,50,100,500};
    
    
    rep(i,0,6){
        cin >> n;
        memo += n*a[i];
    }
    
    cout << ((memo >= 1000) ? "1" : "0") << endl;
    return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    vector<pair<int, int>> A;
    A.reserve(N);
    REP(i, N) {
        int a;
        std::cin >> a;
        A.emplace_back(a, i);
    }

    SORT(A);

    int ans = 0;
    REP(i, N) {
        if(i % 2 == 1 && A[i].second % 2 == 0) ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int i;
	int counter;
	counter = 0;
	for(i = a; i<=b; i++){
		if(c%i==0){
			counter++;
			
		}
	}
	cout << counter << endl;
	
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int H, W;
string field[105];
bool Hvalid[105];
bool Wvalid[105];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    for(int h = 0; h < H; h++) {
        cin >> field[h];
    }
    for(int h = 0; h < H; h++) {
        for(int w = 0; w < W; w++) {
            if(field[h][w] == '#') {
                Hvalid[h] = true;
                Wvalid[w] = true;
            }
        }
    }
    for(int h = 0; h < H; h++) {
        if(!Hvalid[h]) continue;
        for(int w= 0; w < W; w++) {
            if(Wvalid[w]) cout << field[h][w];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


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


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

int main(){
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
  
    if(A>=K){
      cout << K << endl;
    }
    else if(A+B>=K){
        cout << A << endl;
    }
    else if(A+B<K){
        cout << A-K+A+B << endl;
    }
    
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] h = new int[N + 1];
    for (int i = 1; i <= N; i++) h[i] = scanner.nextInt();

    long[][] dp = new long[N + 1][N + 1];
    final long INF = 1_000_000_000_000L;
    for (int i = 0; i <= N; i++) for (int j = 0; j <= N; j++) dp[i][j] = INF;
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= i; j++) {
        for (int k = 0; k < i; k++)
          dp[i][j] = Math.min(dp[i][j], dp[k][j - 1] + Math.max(h[i] - h[k], 0));
      }
    }

    long min = INF;
    for (int i = 0; i <= N; i++) min = Math.min(min, dp[i][N - K]);
    System.out.println(min);
  }
}


Measured memory_bytes: 25556
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,k,flag,tot;
const int maxn=1e5+5,mod=1e9+7;
int co[maxn],vis[maxn],head[maxn],nex[maxn<<1],to[maxn<<1];
ll qpow(int a,int b)
{
    ll base=a;
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=ans*base%mod;
        base=base*base%mod;
        b>>=1;
    }
    return ans;
}
void add(int u,int v)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;
}
void dfs(int x,int fa,int flag)
{
    if(flag<2)
        co[k-vis[fa]-flag]++;
    else
        co[k-vis[fa]-2]++;
    vis[fa]++;
    flag++;
    for(int i=head[x];i;i=nex[i])
    {
        int v=to[i];
        if(v==fa) continue;
        dfs(v,x,flag);
    }
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    ll res=1;
    dfs(1,0,0);
    for(int i=1;i<=k;i++)
    {
        res=qpow(i,co[i])*res%mod;
    }
    if(co[0]>0)
        printf("0\n");
    else
        printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 6144
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	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;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    map<char, ll> mp;
    rep(i,n){
        ++mp[s[i]];
    }
    mint ans = 1;
    for(auto p : mp){
        ans *= (p.second + 1);
    }
    ans -= 1;
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 512
def gcd(a, b):
  if b==0:
    return a
  return gcd(b, a%b)

a,b = map(int, input().split())
g = gcd(a,b)
N = int(g**0.5)
ans = 1
for i in range(2, N+1):
  if g%i==0:
    ans += 1
  while(g%i==0):
    g /= i
if g != 1:
  ans += 1
print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        ll N;
        cin >> N;
        ll A = 5;
        vector<ll> v(A);
        rep(i, 0, A) cin >> v[i];

        ll m = *min_element(all(v));
        ll turn = N / m + (N % m != 0) - 1;
        ll ans = turn + 5ll;

        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var val = Console.ReadLine().Split(' ');
            var a = ulong.Parse(val[0]);
            var b = ulong.Parse(val[1]);

            ulong num = gcd(a, b);
            var f = factorize(num).Count;


            Console.Write(f + 1);

        }

        public static ulong gcd(ulong x, ulong y)
        {
            if (y == 0) return x;
            return gcd(y, x % y);
        }

        public class Pair<F, S>
        {
            public Pair(F first, S second)
            {
                this.first = first;
                this.second = second;
            }
            public F first { get; set; }
            public S second { get; set; }
        }

        /// <summary>
        /// 因数分解
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public static List<Pair<ulong, int>> factorize(ulong num)
        {
            var res = new List<Pair<ulong, int>>();//<素数,階乗数>
            for (ulong i = 2; i * i <= num; ++i)
            {
                if (num % i != 0) continue;
                res.Add(new Pair<ulong, int>(1, 0));
                while (num % i == 0)
                {
                    num /= i;
                    res[res.Count - 1].second += 1;
                }
            }
            if (num != 1) res.Add(new Pair<ulong, int>(num, 1));
            return res;
        }

    }
}


Measured memory_bytes: 13268
n = int(input())
f = [0]*100000005
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            x = i**2 + j**2 + k**2 + i*j + j*k+ k*i
            f[x] += 1

for i in range(1, n + 1):
    print(f[i])

Measured memory_bytes: 790388
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> bs(m);
    REP(i,m){
        cin >> bs[i];
    }
    int tmpin,tmpsum=0,result=0;
    REP(i,n){
        REP(j,m){
            cin >> tmpin;
            tmpsum += tmpin * bs[j];
        }
        if(tmpsum>-c){
            result++;
        }

        tmpsum = 0;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	int a, b;

	cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)cout << "Possible\n";
	else cout << "Impossible\n";

	return 0;
}

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

const int MAX_N = 2e5+2;
const int MOD = 998244353;
int N,M,K;
ll fact[MAX_N], invf[MAX_N];

ll powmod(ll x, ll y)
{
	ll res = 1;
	while(y){
		if(y&1) (res*=x)%=MOD;
		(x*=x)%=MOD;
		y>>=1;
	}
	return res;
}

ll nChoosek(int n, int k)
{
	return (fact[n]*invf[n-k])%MOD*invf[k]%MOD;
}

void solve()
{
	fact[0]=1;
	for(int i=1;i<MAX_N;++i) fact[i]=1LL*i*fact[i-1]%MOD;
	invf[MAX_N-1]=powmod(fact[MAX_N-1],MOD-2);
	for(int i=MAX_N-2;i>=0;--i) invf[i]=(i+1)*invf[i+1]%MOD;
	
	ll tot = 0;
	for(int p=N-K;p<=N;++p){
		(tot += nChoosek(N-1,p-1)*M%MOD*powmod(M-1,p-1)%MOD)%=MOD;
	}
	cout << tot << '\n';
}

int main()
{
	cin >> N >> M >> K;
	solve();
	return 0;
}

Measured memory_bytes: 6764
from random import randint
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range (len(l)-1) :
  try:
    if l[i] == l[i + 1]:
        ans += 1
        l[i + 1] = randint(0, 10000)
  except:
    continue
print(ans)

Measured memory_bytes: 9408
n  = gets.to_i
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i)

ans = 0
before = -10
as.each do |a|
  ans += bs[a-1]
  if a == before + 1
    ans += cs[before-1]
  end
  before = a
end
puts ans

Measured memory_bytes: 1788
/* Code by Saborit */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast") 
#define MX 100005
#define INF (1<<30)
#define EPS 1e-9
#define MOD 1000000007
#define mid (x+xend)/2
#define izq nod*2
#define der nod*2+1
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define unique(X) (X).resize(unique(all(X)) - (X).begin())
#ifdef LOCAL 
	#include "debug.h"
#endif
using namespace std;
using namespace __gnu_pbds;
typedef long long int64;
typedef unsigned long long unt64;

struct par{
	int nwn, id;
};

int cn, best;
int sol[MX];
vector<par> G[MX];

void dfs(int nod, int p, int c){
	int t = 0;
	for(auto i: G[nod]) if( i.nwn != p ){
		++t;
		if( t == c ) ++t;
		
		best = max(best, t);
		sol[i.id] = t;
		
		dfs(i.nwn, nod, t);
	}
}

int main(void){
    //~ freopen("a.in", "r", stdin);
    //~ freopen("a.out", "w", stdout);
    
    scanf("%d", &cn);
    for(int i=1, a, b; i < cn; i++){
		scanf("%d%d", &a, &b);
		
		G[a].pb({b, i});
		G[b].pb({a, i});
	}
	
	dfs(1, -1, 0);
	
	printf("%d\n", best);
	for(int i=1; i < cn; i++)
		printf("%d\n", sol[i]);
    
   return 0;
}


Measured memory_bytes: 12584
def my_index_multi(l, x):
  return [i for i, _x in enumerate(l) if _x == x]

n = int(input())
cards = [list(input().split()) for i in range(n)]
heart  = [0] * 14
diamond  = [0] * 14
club  = [0] * 14
spade = [0] * 14
heart[0] = diamond[0] = club[0] = spade[0] = -1
ans = []
for card in cards:
  if card[0] == "H":
    heart[(int(card[1]))] += 1
  elif card[0] == "D":
    diamond[(int(card[1]))] += 1
  elif card[0] == "C":
    club[(int(card[1]))] += 1
  elif card[0] == "S":
    spade[(int(card[1]))] += 1
for s in my_index_multi(spade, 0):
  ans += [["S", s]]
for h in my_index_multi(heart, 0):
  ans += [["H", h]]
for c in my_index_multi(club, 0):
  ans += [["C", c]]
for d in my_index_multi(diamond, 0):
  ans += [["D", d]]
for j in ans:
  print("{} {}".format(j[0], j[1]))


Measured memory_bytes: 5620
private val map = hashMapOf<Long, Long>()

fun main() {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }
    repeat(n.toInt()) { _ ->
        val (a, b) = readLine()!!.split(" ").map { it.toLong() }
        map[a] = (map[a] ?: 0) + b
    }

    var count = m
    var result = 0L
    map.toSortedMap().forEach {
        val index = it.key
        val i = it.value

        val take = if (i <= count) {
            i
        } else {
            count
        }
        result += take * index
        count -= take
        if (count == 0L) {
            println(result)
            return
        }
    }
}

Measured memory_bytes: 68720
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            for (int i = 0; i < 1 << 4; i++) {
                StringBuilder sb = new StringBuilder();
                if ((i & 1) == 1) sb.append("A");
                sb.append("KIH");
                if ((i >> 1 & 1) == 1) sb.append("A");
                sb.append("B");
                if ((i >> 2 & 1) == 1) sb.append("A");
                sb.append("R");
                if ((i >> 3 & 1) == 1) sb.append("A");

                if (s.equals(sb.toString())) {
                    out.println("YES");
                    return;
                }
            }

            out.println("NO");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23508
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
bool arr[100001];
int Nmax=100001;
void Eratosthenes(){
	for(int i = 0; i < Nmax; i++){
		arr[i] = true;
	}
	arr[0]=false; arr[1]=false;
	for(int i = 2; i < sqrt(Nmax); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < Nmax; j++){
				arr[i *(j + 2)] = false;
			}
		}
	}
}
int main(){
	Eratosthenes();
	int Q;
	int l[100000],r[100000];
	int kisukosusum[100001]={0};
	rep1(i,100000){
		if(i%2&&arr[i]&&arr[(i+1)/2]){
			kisukosusum[i]=kisukosusum[i-1]+1;
		}
		else{
			kisukosusum[i]=kisukosusum[i-1];
		}
	}
	scan(Q);
	rep(i,Q){
		scan(l[i]);scan(r[i]);
		prin(kisukosusum[r[i]]-kisukosusum[l[i]-1]);
	}

	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
long long ans,a,b,c;
int main()
{
	cin>>a>>b;
	for(int x=0;x<=a;x++)
	{
		for(int y=0;y<=a;y++)
		{
			c=b-x-y;
			if(c>=0&&c<=a)ans++;
		}
	}
	cout<<ans<<endl; 
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		long[][] dp = new long[n][n];
		for(int i = 0; i < n; i++) {
			Arrays.fill(dp[i], Integer.MAX_VALUE/2);
			dp[i][i] = 0;
		}
		for(int i = 1; i < n; i++) {
			for(int j = 0; j + i < n; j++) {
				for(int k = j; k < j+i; k++) {
					dp[j][j + i] = Math.min(dp[j][j + i], dp[j][k] + dp[k + 1][j + i] + a[j] * b[k] * a[k + 1] * b[j + i]);
				}
			}
		}
		System.out.println(dp[0][n-1]);
	}
	

}

Measured memory_bytes: 20588
import copy
N, M = list(map(int, input().split()))

g = [[] for _ in range(N)]

for i in range(M):
    a, b = list(map(int, input().split()))

    g[a-1].append(b-1)
    g[b-1].append(a-1)

visited = [False for _ in range(N)]

def dfs(now, prev, vis):
    visited_copy = copy.copy(vis)
    visited_copy[now] = True
    all_visited = True

    for is_node_visited in visited_copy:
        if not is_node_visited:
            all_visited = False

    if all_visited:
        return 1

    counter = 0
    for adj in g[now]:
        if prev == adj:
            continue

        if visited_copy[adj]:
            continue
        counter += dfs(adj, now, visited_copy)

    return counter

ans = dfs(0, -1, visited)
print(ans)


Measured memory_bytes: 74756
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define ld long double
#define oo 2e18
#define OS tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n;
map<ll, int> p;
set<ll> s;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (ll i = -6208; i <= 6208; i++) {
        s.insert(i * i * i * i * i);
        p[i * i * i * i * i] = i;
    }
    for (ll i = -6208; i <= 6208; i++) {
        if (((n >= 0 && LLONG_MAX - n >= i * i * i * i * i) ||
             (n < 0 && abs(LLONG_MIN - n) >= abs(i * i * i * i * i))) &&
            s.find(n + i * i * i * i * i) != s.end()) {
            cout << p[n + i * i * i * i * i] << " " << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4996
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;


int main() {

	long N; cin >> N;
	string S; cin >> S;
	string res = S;

	long point = 0;//"("の数 - ")"の数

	for (int i = 0; i < N; i++) {
		if (S[i] == '(') point++; else point--;
		if (point < 0) {
			res = '(' + res;
			point++;
		}
	}

	if (point > 0) while (point--) res = res + ')';

	cout << res << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "set"
#include "vector"
#include "map"
#include "cmath"
#define MAXN 516
//#define int long long
using namespace std;
typedef long long ll;
#define P 1000000007
int n;
int A[MAXN];

ll work( int l , int r , int L , int R ) {
    if( r - l <= 1 ) return 0;
    ll ans = 0x3f3f3f3f3f3f3f3f;
    for( int i = l + 1 ; i <= r - 1 ; ++ i ) ans = min( ans , work( l , i , L , L + R ) + work( i , r , L + R , R ) + 1ll * ( L + R ) * A[i] );
    return ans;
}

int main() {
    cin >> n;
    for( int i = 1 ; i <= n ; ++ i ) scanf("%d",&A[i]);
    cout << work( 1 , n , 1 , 1 ) + A[1] + A[n] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
const ll mod2= 998244353;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main(){
    ll n,k,ans=0;
    cin>>n;
    ll c=1;
    irep(i,n-1,1){
        c=n/i;
        if(n%i==0)c--;
        ans+=c;
    }
cout<<ans;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if(s[n-1] == 's'){
        s += "es";
        printf("%s\n", s.c_str());
    }
    else{
        s+= 's';
        printf("%s\n", s.c_str());
    }

}

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

void Main(){
    int N, M, K;
    cin >> N >> M >> K;
    rep(n,N+1)rep(m,M+1){
        if (n * (M - m) + m * (N - n) == K)
        {
            cout << "Yes" << endl;
            return ;
        }
        
    }
    cout << "No" << endl;
    return ;
}
int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

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

A = []
for i in range(a):
    A.append(list(input()))

for i in range(a+2):
    if i == 0:
        print("#" * (b+2))
    elif i != 0 and i != a+1:
        print("#" + "".join(A[i-1]) + "#")
    elif i == a+1:
        print("#" * (b+2))

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath> // abs など
#include <numeric> // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

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

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << H << " ";
  debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

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

// constexpr inline ll MOD = 1'000'000'007;

int main()
{
  // 入出力
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n; cin >> n;
  switch(n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }

  return 0;
}


Measured memory_bytes: 3652
INF = 10**9
n, m = map(int, input().split())
keys = []
for _ in range(m):
    a, _ = map(int, input().split())
    c = 0
    for i in input().split():
        c += 2**(int(i)-1)
    keys.append((a, c))

dp = [INF]*(2**n)
dp[0] = 0
for a, c in keys:
    tmp = [INF]*(2**n)
    for j, d in enumerate(dp):
        if d == INF:
            continue
        if d < tmp[j]:
            tmp[j] = d
        if d+a < tmp[j|c]:
            tmp[j|c] = d+a
    dp = tmp

print(dp[-1] if dp[-1]<INF else -1)


Measured memory_bytes: 3308
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// find_by_order(k) (k+1)th largest element
// order_of_key(k) no of elements <=k

typedef long long ll;
typedef long double ld;
#define endl '\n'
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define ff first
#define ss second
#define pb push_back
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ld PI = 4*atan((ld)1);
const ll INF = 1e18;
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n; cin >> n;
        ll t= n/1000;
        ll ans ;
        if(n%1000!=0){
            ans = (t+1)*1000;
            ans -= n;
        }else{
            ans =0;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3640
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=4e2+5,maxm=1e5+5;
int n,m,ans;
bitset<maxn>S[maxn];
int x[maxm],y[maxm],ban[maxn];
int main(){
	read(n);read(m);
	rep(i,1,m)read(x[i]),read(y[i]);
	rep(i,1,n){
		S[i][i]=1;
		per(j,m,1){
			if(S[i][x[j]]&&S[i][y[j]]){
				ban[i]=1;
				break;
			}else if(S[i][x[j]])S[i][y[j]]=1;
			else if(S[i][y[j]])S[i][x[j]]=1;
		}
	}
	rep(i,1,n)rep(j,i+1,n)if(!ban[i]&&!ban[j]&&(S[i]&S[j])==0u)ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    ll N,K,S;
    cin >> N >> K >> S;
    vector<ll> res(N,0);
    ll len=(N-K)+1;
    if(len<=S){
        ll mod=S%len;
        ll unit=S/len;
        for(ll i=1;i<=N;i++)
        {
            if(i%len==0)cout<<unit+mod;
            else cout<<unit;
            if(i!=N)cout<<" ";
        } 
    }
    else{
        ll padding=len-S;
        for(ll i=0;i<N;i++)
        {
            if(i<padding)cout<<1+S;
            else cout<<1;
            if(i!=N-1)cout<<" ";
        } 
    }
    return 0;
}

Measured memory_bytes: 4020
// 2011/11/21 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){

	string str;
	cin >> str;

	if(cin.eof())
		break;

	int joi = 0;
	int ioi = 0;

	string::size_type index = 0;
	while(true){
		index = str.find("JOI", index);
		if(index==string::npos)
			break;
		joi++;
		index++;
	}

	index = 0;
	while(true){
		index = str.find("IOI", index);
		if(index==string::npos)
			break;
		ioi++;
		index++;
	}

	cout << joi << endl;
	cout << ioi << endl;

	}

	return 0;
}

Measured memory_bytes: 0