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


int main()
{
    string S,T;
    cin >> S >> T;
    
    bool check = false;
    vector<int> ins(S.size(),0);
    int temp = 0;
    if(S.size() >= T.size())
    {
    for(int i = 0;i<=S.size()- T.size();i++)
    {
        bool keep = true;
        for(int j = 0;j < T.size();j++)
        {
            if(S[i+j] != '?' & S[i+j] != T[j])
            {
                keep = false;
                break;
            }
        }
        if(keep)
        {
            check = true;
            ins[i] = 1;
            temp = i;
        }
    }
    }
    if(!check)
    {
        S = "UNRESTORABLE";
    }
    else
    {
        for(int i = 0;i<S.size();i++)
        {
            if(ins[i] != 0 && i != temp)
            {
                ins[i] = 0;
            }
        }
        
        for(int i = 0;i<S.size();i++)
        {
            if(ins[i] == 1)
            {
                for(int j = 0;j<T.size();j++)
                {
                    S[i+j] = T[j];
                }
            }
            else if(S[i] == '?')
            {
                S[i] = 'a';
            }
        }
        
        
    }
    cout << S << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main (void)
{
 int N, K;
 vector <int> p;
 cin >> N >> K;
 p.resize (N);
 for (auto &e: p)
 	cin >> e;
 sort (p.begin (), p.end ());
 int sumMoney = 0;
 for (int i = 0; i < K; i++)
 	sumMoney += p [i];
 cout << sumMoney << endl;
 return 0;
}

Measured memory_bytes: 3588
import java.math.*;
import java.util.*;

public class Main {
    public static class MyPair<T1, T2> {
        T1 first;
        T2 second;

        @Override
        public boolean equals(Object obj) {
            if (!(obj instanceof MyPair)) return false;
            MyPair p = (MyPair) obj;
            return first.equals(p.first) && second.equals(p.second);
        }

        MyPair(T1 first, T2 second) {
            this.first = first;
            this.second = second;
        }
    }

    static Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        int n, m;
        n = input.nextInt();
        m = input.nextInt();
        TreeMap<Integer, TreeSet<Integer>> path = new TreeMap<>();
        int a = 0, b = 0;
        for (int i = 0; i < m; i++) {
            a = input.nextInt();
            b = input.nextInt();
            if (!path.containsKey(a)) path.put(a, new TreeSet<Integer>());
            if (!path.containsKey(b)) path.put(b, new TreeSet<Integer>());
            path.get(a).add(b);
            path.get(b).add(a);
        }
        LinkedList<Integer> d = new LinkedList<>();
        d.add(a);
        d.add(b);
        int[] vis = new int[n + 1];
        vis[a] = vis[b] = 1;
        boolean updated = true;
        while (updated) {
            updated = false;
            for (int e : path.get(d.getFirst())) {
                if (vis[e] == 0) {
                    vis[e] = 1;
                    d.addFirst(e);
                    updated = true;
                    break;
                }
            }
            for (int e : path.get(d.getLast())) {
                if (vis[e] == 0) {
                    vis[e] = 1;
                    d.addLast(e);
                    updated = true;
                    break;
                }
            }
        }
        System.out.println(d.size());
        for(int e:d) {
            System.out.print(e + " ");
        }
        System.out.println();
    }
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  cout << (s.substr(0, min((int)s.size(), 4ll)) == "YAKI" ? "Yes" : "No") << endl;


  return 0;
}


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

int main()
{
  int R[MAX];
  int n,i,j;
  int maxv=-2000000000;
  int minv;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&R[i]);
  minv=R[0];
  for(j=1;j<n;j++){
      if(maxv<(R[j]-minv))maxv=R[j]-minv;
      if(minv>R[j])minv=R[j];
  }
  printf("%d\n",maxv);
  return 0;
}
    

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

int a, b;

int main() {
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t L, R, d;

    std::cin >> L >> R >> d;

    int64_t count = 0;
    for (int64_t i = L; i <= R; ++i) {
        if (i%d == 0) count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  vector<int> size(n+2*k+1, 0);
  int c = 0;
  int group_num = 0;
  bool is_zero_first = s[0] == '0';
  bool is_zero_group = is_zero_first;

  for (int i = 0; i < n; i++) {
    if ((is_zero_group && s[i] == '1') || (!is_zero_group && s[i] == '0')) {
      size[group_num] = c;
      is_zero_group = !is_zero_group;
      c = 0;
      group_num++;
    }
    c++;
    if (i == (n - 1)) {
      size[group_num] = c;
      group_num++;
    }
  }

  int max_sum = 0;
  for (int i = 0; i < group_num; i+=2) {
    int sum = 0;
    int init;
    if (is_zero_first) {
      init = i - 1;
    } else {
      init = i;
    }

    for (int j = init; j < (init + 2*k + 1); j++) {
      if (j < 0) {
        continue;
      }
      sum += size[j];
    }
    if (sum > max_sum) {
      max_sum = sum;
    }
  }

  cout << max_sum << endl;

  return 0;
}

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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
int a[N];

string solve( int cntMem, int cnt ){
    if ( cnt <= 0 ){
        return "No";
    }
    if ( cnt * 2 <= cntMem ){
        return "Yes";
    }
    return "No";
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int mx = -1e9, mn = 1e9, n, x, cnt = 0;
    scanf("%d",&n);
    for ( int i = 1; i <= n; i++ ){
        scanf("%d",&x);
        mx = max( mx, x );
        mn = min( mn, x );
        a[i] = x;
    }
    if ( mx - mn > 1 ){
        cout << "No";
    }
    else
    if ( mx - mn == 0 ){
        if ( mx == n - 1 ){
            cout << "Yes";
        }
        else{
            cout << solve(n,mx);
        }
    }
    else{
        for ( int i = 1; i <= n; i++ ){
            if ( a[i] == mn ){
                cnt++;
            }
        }
        cout << solve( n - cnt, mx - cnt );
    }

    return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
long long a[100010] , b[30] , INF=100000000007 , ans=0 , x=0;
/*long long f(long long k)
{
	long long c=((k+99)*(k+10))%INF;
	return c*(c+21)%INF;
}*/
int main()
{
	for(int i=1;i<=28;i++)
	{
		b[i]=181384*i*i-i;
		b[i]%=INF;
		b[i]*=(b[i]+i);
		b[i]%=INF;
		b[i]-=(b[i]/i)-INF;
		b[i]+=i*i*i;
		b[i]%=INF;
	}
	int n;	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;	cin>>s;
		for(int j=0;j<s.size();j++){
			a[i]+=b[s[j]-'a'+1];
			a[i]%=INF;
		}
	}
	sort(a+1 , a+1+n);
	a[n+1]=-1;
	for(int i=1;i<=n;i++)
	{
		x++;
		if(a[i]!=a[i+1]){
			ans+=x*(x-1)/2;
			x=0;
		}
	}
	/*for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;*/
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>

int main()
{
	double a, b, c, rad, pi;
	pi = acos(-1);
	scanf("%lf%lf%lf", &a, &b, &c);
	rad = c * pi / 180;

	printf("%lf\n%lf\n%lf\n"
		, a * b * sin(rad) / 2
		, sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad)) + a + b
		, b * sin(rad));

	return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>

int main(){
  long long int time[10001] = {}, wtime[10001] = {}, min, sum;
  int j, k, n;
  while(scanf("%d", &n) && n){
    for(j = 0;j < n;j++)
      scanf("%lld", &time[j]);

    for(j = 0;j < n - 1;j++){
      min = j;
      for(k = j + 1;k < n;k++)
	min = time[min] < time[k] ? min : k;
      if(min != j){
	time[min] += time[j];
	time[j] = time[min] - time[j];
	time[min] -= time[j];
      }
    }
    sum = 0;
    for(j = 1;j < n;j++){
      wtime[j] = wtime[j - 1] + time[j - 1];
      sum += wtime[j];
    }
    
    printf("%lld\n", sum);
  }
  return 0;
}

Measured memory_bytes: 764
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}


int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        string s = ins();
        ll d1[n + 1], d2[n + 1];

        d1[0] = 0, d2[0] = 0;
        rep(i, n) {
            if (s[i] == '.') {
                d1[i + 1] = d1[i] + 1;
                d2[i + 1] = d2[i];
            } else {
                d2[i + 1] = d2[i] + 1;
                d1[i + 1] = d1[i];
            }
        }
        ll ans = ll_inf;
        for (int i = 0; i <= n; ++i) {
            if (i == 0) ans = min(ans, d1[n]);
            else ans = min(ans, d1[n] - d1[i - 1] + d2[i - 1]);
        }
        ans = min(ans, d1[n]);
        ans = min(ans, d2[n]);
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll t[5];
	ll time = 0;
	for(int i = 0; i < 5; i++)cin >> t[i];
	sort(t, t+5);
	cout << 4+(n+t[0]-1)/t[0] << endl;
	return 0;
}

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

void solveA(){
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  cout << H*W- (h*W+w*H) + h*w << endl;
}
void solveB(){
  int n,m,c;
  cin >> n >> m >> c;
  int ans=0;

  int b[m];

  for(int i =0 ;i<m ; i++){
    cin >> b[i];
  }

  for(int i =0 ;i<n ; i++){
    int sum=0;
    for(int j =0 ;j<m ; j++){
      int a;
      cin >> a;
      sum += a * b[j];		   
    }
    if (sum+c > 0) ans++;
  }

  cout << ans << endl;
}
void solveC(){
  long long n,m;
  cin >> n >> m;
  map<long,long> mp;
  long long k = 0;
  long long ans = 0;

  long long a,b;
  for(long long i = 0; i<n ; i++){
    cin >> a >> b;
    if (mp.count(a) == 0){
      mp[a] = b;
    }
    else{
      mp[a] += b;
    }
  }
  for (auto x: mp)
    {
      if (x.second >= m){
	ans += m*x.first;
	break;
      }
      else{
	ans += x.second*x.first;
	m -= x.second;
      }
      
    }
  cout << ans << endl;
  
}

void solveD(){
}

int main(){
  solveC();
}


Measured memory_bytes: 6528
#include <iostream>

using namespace std;
int main() {
	int A, B, C, D;

	cin >> A >> B >> C >> D;

	if (A < C) {
		if (B < D) {
			if (C < B) cout << B - C << endl;
			else cout << 0 << endl;
		}
		else {
			cout << D - C << endl;
		}
	}
	else {
		if (D < B) {
			if (A < D) cout << D - A << endl;
			else cout << 0 << endl;
		}
		else {
			cout << B - A << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 384
/*
分割は n 個以下の単位分数の和である。
分割に含まれる単位分数の分母の積は a 以下である。
の２つの枝刈り条件を含めたアルゴリズムを書くだけ。
*/

#include<stdio.h>

int func(int,int,int,int,int);
int p,q,a,n;
int main(void){
  
  while(scanf("%d %d %d %d",&p,&q,&a,&n),p,q,a,n){
    printf("%d\n",func(n,1,1,0,1));
  }
  
  return 0;
}

/*
turn     単位分数の個数 
last      単位分数の最後の要素の分母
product  単位分数の分割の全要素の積
c,d       単位分数の分割の全要素の和の分子、分母
 */
int func(int turn,int last,int product,int c,int d){

  if(p*d==c*q)return 1;  //if(p/q==c/d)ではダメ。

  if(!turn)return 0;
  
  int i,count=0;
  for(i=last;product*i<=a;i++){

    if(c/d+1/i<=p/q)
      count+=func(turn-1,i,product*i,i*c+d,i*d);
    /*
      func(...,i*c+d,i*d);
      のc,dに渡す引数について。
      c/d+1/i = (c*i)/(d*i)+d/(d*i) = (i*c+d)/(i*d)
    */
  }  
  return count;
}

Measured memory_bytes: 408
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, M;
	cin >> N >> M;
	ll ans = 1;
	if (abs(N - M) >= 2) cout << 0 << endl;
	else {
		for (int i = N; i > 0; i--) {
			ans *= i;
			ans %= mod;
		}
		for (int i = M; i > 0; i--) {
			ans *= i;
			ans %= mod;
		}
		if (N == M) {
			ans *= 2;
			ans %= mod;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
mod = 998244353
N,M,K = map(int,input().split())
ans = 0
def pow(x,n):
    if n == 0:  
        return 1
    if n % 2 == 0:  
        return pow((x ** 2)%mod, n // 2)%mod
    else:
        return x * pow((x ** 2)%mod, (n - 1) // 2)%mod
A = 1
for i in range(K+1):
    p = N - i
    x = M*pow(M-1,p-1)*A % mod
    ans += x
    A = A*(N-i-1)%mod
    y = pow(i+1,mod-2)
    A = A*y % mod
print(ans%mod)

Measured memory_bytes: 72876
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

    for (int i = 1; i <= 26; i++)
    {

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 1e7;
    double T1 = 1e4;
    double TL = 1980;

    ll count = 0;

    while (1)
    {
        ll msec;

        msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > 0.5)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    int m, k;
    cin >> m >> k;
    if (m == 1)
    {
        if (k == 0)
        {
            cout << "0 0 1 1" << endl;
            return 0;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    if (pow(2, m) - 1 < k)
    {
        cout << -1 << endl;
        return 0;
    }

    for (int i = pow(2, m) - 1; i >= 0; i--)
    {
        if (i == k)
        {
            continue;
        }
        cout << i << " ";
    }
    cout << k << " ";
    for (int i = 0; i < pow(2, m); i++)
    {
        if (i == k)
        {
            continue;
        }
        cout << i << " ";
    }
    cout << k << endl;

    return 0;
}


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

ll dp[20][20];
int h, w, n;

int main()
{
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
            return 0;
        cin >> n;
        for (int i = 0; i < 20; i++)
        {
            for (int j = 0; j < 20; j++)
            {
                dp[i][j] = 0;
            }
        }
        for (int i = 0; i < n; i++)
        {
            int p, q;
            cin >> p >> q;
            dp[p][q] = -100000000;
        }
        dp[1][1] = 1;
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                if (dp[i][j] < 0)
                    continue;
                if (i != 1 && dp[i - 1][j] >= 0)
                    dp[i][j] += dp[i - 1][j];
                if (j != 1 && dp[i][j - 1] >= 0)
                    dp[i][j] += dp[i][j - 1];
            }
        }
        cout << dp[h][w] << endl;
    }
}


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    int n;
    long[] xs;

    void Read()
    {
        n = ReadLine(int.Parse)[0];
        xs = ReadLine(long.Parse);
    }

    long Solve()
    {
        var min = long.MaxValue;

        var sum = xs.Sum();

        var s = xs[0];
        for (var i = 1; i < n; i++)
        {
            min = Math.Min(min, Math.Abs(s - (sum - s)));

            s += xs[i];
        }

        return min;
    }

    public void Run()
    {
        Read();
        WriteLineOne(Solve());
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


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

#define INF 900000000
#define LINF 9000000000000000000

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

int H, W;
map<string, int> mp;
int ls[5];

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

	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < W; j++) {
			string a = s.substr(j,1);
			mp[a]++;
		}
	}

	for (auto y : mp) {
		int x = y.second;
		if (x > 4) while (x >= 4) x -= 4,	ls[4]++;
		if (x == 3) x -= 2, ls[2]++;
		ls[x]++;
	}

	if (ls[1] > 1) {
		cout << "No" << endl;
		return 0;
	}

	while (W >= 2 && H >= 2) {
		int w1 = W/2-1, w2 = W % 2;
		int h1 = H/2-1, h2 = H % 2;
		if (ls[4] < h1+w1+1) {
			cout << "No" << endl;
			return 0;
		}
		if (ls[2] < h2*w2) {
			while (ls[4] >= 1 && ls[2] < h2*w2) {
				ls[4]--, ls[2] += 2;
			}
			if (ls[2] < h2*w2) {
				cout << "No" << endl;
				return 0;
			}
		}
		ls[4] -= w1+h1+1;
		ls[2] -= h2+w2;
		W -= 2;
		H -= 2;
	}


	if (H == 1 || W == 1) {
		while (ls[4] != 0) ls[4]--, ls[2]+=2;
		if (H == 1 && W == 1) {
			if (ls[1] == 1) cout << "Yes" << endl;
			else cout << "No" << endl;
			return 0;
		}
		int ma = max(H, W), mi = min(H, W);
		int ma1 = ma / 2 - 1, ma2 = ma % 2;
		if (ls[2] < ma1 || ls[1] < ma2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s, t;
    cin>>s>>t;
    string ans = "Yes";
    for(ll i=0;i<s.size();++i){
        if(s[i] == t[i]){
            continue;
        }else{
            ans = "No";
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	vector<ll> vec(n+1,0);
	for(ll i=1;i<=n;i++){
		cin>>vec[i];
	}
	map<ll,ll> map;
	std::map<ll,ll> ::iterator it;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		it=map.find(i-vec[i]);
		if(it!=map.end()){
			ans+=map[i-vec[i]];
		}
		map[i+vec[i]]++;
	}
	cout<<ans<<endl;
}


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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9'){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
max_n = 0
max_count = -1

for i in range(1, N+1):
    count = 0
    c = i
    while c % 2 == 0:
        c //= 2
        count += 1
    if count > max_count:
        max_n = i
        max_count = count

print(max_n)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int cutup(int a,int b){
    return (a+b-1)/b;
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    int oya(int x){
        if(r[x]<0){
            return 1;
        }else{
            return 0;
        }
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n>>m;
    UnionFind tree(n);
    rep(i,m){
        cin>>pp[i].first>>pp[i].second;
        tree.unite(pp[i].first,pp[i].second);
    }
    rep(i,n+1){
        cnt+=tree.oya(i);
    }
    cout<<cnt-1;
}

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

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

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll a, b, c;
string s, t, N;
ll ans;
int main(){
	cin >> N;
	ll M = N.size();
	ll carry = 0;
	RREP(i, 0, M){
		if(N[i] - '0' + carry > 5){
			ans += 10 - (N[i] - '0'+ carry);
			carry = 1;
		}else if(N[i] - '0' + carry == 5){
			if(i>=1 && N[i-1] - '0' >= 5){
				carry = 1;
			}else{
				carry = 0;
			}
			ans += 5;

		}else{
			ans += N[i] - '0' + carry;
			carry = 0;
		}
	}

	if(carry){
		ans++;
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	string s,t;
	in(s,t);
	int n=s.size();
	int ans=0;
	rep(i,n)if(s[i]!=t[i])ans++;
	out(ans);
	return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>
#include <string.h>

#define N 1000003


int GetChar(char);
long long getkey(char *);
int Find(char *);
void Insert(char *);
int hash1(int);
int hash2(int);

int n = 0;
char Hash[N][13];

int main () {
  int i;
  char c[7], str[13];

  for(i = 0 ; i < N ; i++) Hash[i][0] = '\0';
  

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    scanf("%s %s",c,str);

    if(strcmp(c,"insert") == 0) {
      Insert(str);
    }
    
    else {
      if(Find(str) ==  1) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}


int Find(char *str) {
  long long i = 0, j = 0, len = 0;

  len = getkey(str);
  while((j = (hash1(len) + i * hash2(len)) % N) <= N) {
    if(strcmp(Hash[j], str) == 0) return 1;
    else if(strlen(Hash[j]) == 0) return 0;
    else i++;
  }
 
  return 0;
}


void Insert(char *str) {
  long long i = 0, j = 0, h = 0, len = 0;

  len = getkey(str);
  while((h = (hash1(len) + i * hash2(len)) % N) <= N) {
    
    if(strcmp(Hash[h],str) == 0) break; 
    else if(strlen(Hash[h]) == 0) {
      strcpy(Hash[h], str);
      break;
    }
    else i++;
  }
}


int hash1(int x) {
  return x % N;
}


int hash2(int x) {
  return 1 + (x % (N - 1));
}


int GetChar(char ch) {
  
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  
}


long long getkey(char str[]){
  
  long long sum = 0, p = 1, i;
  
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(GetChar(str[i]));
    p *= 5;
  }

  return sum;
}



Measured memory_bytes: 14484
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    llu n,m;

    cin>>n;
    if(n%2){
        cout<<0;
        return 0;
    }
    
    llu ans = 0;

    llu val = 5;

    while(1){
        if(n<val){
            break;
        }
        ans += (n/val)/2;
        val = val*5;
    }
    // cout<<ans;
    cout<<(ans);

    return 0;
}

Measured memory_bytes: 256
package main

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

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func main() {
	n, _ := strconv.Atoi(nextLine())
	a := nextIntArray()
	for i := 0; i < n; i++ {
		a[i] -= i + 1
	}
	sort.Ints(a)
	b := a[n/2]
	sum := 0
	for _, v := range a {
		sum += int(math.Abs(float64(v - b)))
	}
	fmt.Println(sum)
}


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

using namespace std;

bool positivo(int x)
{
    return x > 0;
}

int main()
{
    int x,y;
    int ans = 0;
    cin >> x >> y;
    if(x == y && x == 0)
    {
        cout << 0 << '\n';
        return 0;
    }
    if(x == 0)
        x--;
    ans += abs(abs(x)-abs(y));
    if( positivo(x) && positivo(y))
    {
        if(x > y) ans+=2;
    }
    if( positivo(x) && !positivo(y) )
        ans++;
    if( !positivo(x) && positivo(y) )
        ans++;
    if( !positivo(x) && !positivo(y) )
    {
        if(x > y) ans+=2;
    }
    cout << ans << '\n';

    return 0;
}


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

long long comb[51][51];

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;
  int ans = std::min(C, A + B + 1) + B;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
maisu, kingaku = [int(x) for x in input().split()]
result = [-1,-1,-1]
for itr_10000 in range(maisu+1):
    for itr_5000 in range(maisu+1-itr_10000):
        itr_1000 = maisu - itr_5000 - itr_10000
        total = itr_10000*10000 + itr_5000*5000 + itr_1000*1000
        if total == kingaku:
            result = [itr_10000, itr_5000, itr_1000]
result = map(str, result)
print(' '.join(result))

Measured memory_bytes: 3060
import copy
n = int(input())
b = list(map(str, input().split()))
a = copy.copy(b)
c = copy.copy(b)
k = 'Stable'

flag = 1
i = 0
while flag:
    flag = 0
    for j in range(n - 1, i, -1):
        if b[j][1] < b[j - 1][1]:
            t = b[j]
            b[j] = b[j - 1]
            b[j - 1] = t
            flag = 1
    i += 1

for i in range(0, n - 1):
    print(b[i], end=' ')
print(b[n - 1])
print(k)

for i in range(0, n):
    minj = i
    for j in range(i + 1, n):
        if a[j][1] < a[minj][1]:
            minj = j
    t = a[i]
    a[i] = a[minj]
    a[minj] = t

fl = 0
for i in range(0, n):
    for j in range(i+1, n):
        if a[i][1] == a[j][1]:
            for q in range(0, n):
                if c[q][1] == a[i][1]:
                    if c[q][0] == a[i][0]:
                        break
                    else:
                        fl = 1
if fl == 1:
    k = 'Not stable'


for i in range(0, n - 1):
    print(a[i], end=' ')
print(a[n - 1])
print(k)


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


int main() 
{ 
int  a,b,c,d,x,y; 

cin>>a>>b>>c>>d; 

x=(a+b+c+d)/60; 

y=(a+b+c+d)%60; 

cout<<x<<"\n"<<y<<"\n"; 

return 0; 

}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] list = new long[n];
		long max = 0;
		long sum = 0;

		for(int i = 0; i < n;i++) {
			list[i] = scan.nextLong();
		}

		for(int i = 0;i < n;i++) {
			if(list[i] >= max) {
				max = list[i];
			}else {
				sum += max - list[i];
			}
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 61804
def main():
    s = input()
    n = len(s)
    dp = [0 for _ in range(2019)]
    dp[0] += 1
    x = 0
    for i in range(n):
        x = (x+int(s[n-1-i])*pow(10,i,2019))%2019
        dp[x] += 1
    ans = 0
    for i in range(2019):
        ans += (dp[i]*(dp[i]-1))//2
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 68196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  rep(i,0,n) cout<<"x";
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;


/*
	樹構造を作りたい
	深さと管理番号をインデックスとする
	→内容を示す
*/

struct node{
	int indx;				//管理番号
	string post;			//ポスト内容
	vector< int > chnode;	//子ノードのインデックス
	int pnode;				//親ノードのインデックス
	bool flg;
};

void output( vector<node> *tree, int indx, int depth ) {
	string s = "";
	for(int i = 0; i < depth; i++)
		s += ".";

	if( !tree -> at(indx).flg )
		cout << s << tree->at(indx).post << endl;

	tree -> at(indx).flg = true;

	if( tree->at(indx).chnode.size() > 0 ) {
		for(int i = 0; i < tree->at(indx).chnode.size(); i++) {
			output( tree, tree->at(indx).chnode[i], depth+1);
		}
	}
}

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	int n;
	cin >> n;
	
	vector< node > nlist;

	for(int i = 0; i < n; i++) {
		int k;
		string M;
		cin >> k >> M;

		node newnode;
		newnode.indx = i;
		newnode.post = M;
		newnode.pnode = k - 1;
		newnode.flg = false;

		if( k > 0 )
			nlist[k - 1].chnode.push_back( i );

		nlist.push_back( newnode );
	}

	output( &nlist, 0, 0 );
	//while(1){}

    return 0;
}

Measured memory_bytes: 2180
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
//#define int long long
int32_t main()
{
    string  s; cin >> s;
    cout << s;
    if(s.back() == 's') cout << "es";
    else cout <<"s";		
}

Measured memory_bytes: 3624
// AGC039 B

#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int a[205], G[205][205];
queue <int> q;

int main() {
    
  int n; read(n);
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= n; ++j) {
      char ch = gc();
      while (ch != '0' && ch != '1') ch = gc();
      if (ch == '1') G[i][j] = 1;
    }
  int ans = 0;
  for (RI i = 1; i <= n; ++i) {
    memset(a, 0, sizeof(a));
    a[i] = 1;
    q.push(i);
    while (!q.empty()) {
      int t = q.front(); q.pop();
      for (RI i = 1; i <= n; ++i)
        if (G[t][i]) {
          if (!a[i]) a[i] = a[t] + 1, q.push(i);
          else if (abs(a[i] - a[t]) != 1) return puts("-1"), 0;
        }
    }
    for (RI j = 1; j <= n; ++j)
      ans = max(ans, a[j]);
  }
  printf("%d\n", ans);

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	int vec[100010];
  	for(int i = 0;i < 100010;i++) {
      	vec[i] = 0;
    }
	for(int i = 0;i < N;i++) {
		int A;
		cin >> A;
		vec[A]++;
	}
	int cnt = 0;
  	int zero = 0;
	for(int i = 0;i < 100010;i++) {
		cnt += max(vec[i] - 1,zero);
	}
	cout << N - ((cnt + 1) / 2) * 2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<list>

using namespace std;

int main(){
    long long int x,y,a,b,c,pd,qd,rd;
    list<long long int> p,q,r;
    cin >> x >> y >> a >> b >> c;

    for(long long int i=0;i<a;i++){ cin >>pd; p.push_back(pd); }

    for(long long int j=0;j<b;j++){ cin >>qd; q.push_back(qd); }

    for(long long int k=0;k<c;k++){ cin >>rd; r.push_back(rd); }

    p.sort(); q.sort(); r.sort(std::greater<long long int>());
 
    while(p.size() > x)p.pop_front();
    while(q.size() > y)q.pop_front();

    for(auto itr = r.begin(); itr != r.end(); ++itr) {
        if(*p.begin()<*itr){
            if(*q.begin()<*itr){
                if(*p.begin()<=*q.begin()){
                    p.push_back(*itr);
                    p.pop_front();
                }else{
                    q.push_back(*itr);
                    q.pop_front();
                }      
            }else{
                p.push_back(*itr);
                p.pop_front();
            }
        }else if(*q.begin()<*itr){
            q.pop_front();
            q.push_back(*itr);

        }
    }

    long long int ans = 0;
    for(auto itr = p.begin(); itr != p.end(); ++itr) { ans+=*itr; }
    for(auto itr = q.begin(); itr != q.end(); ++itr) { ans+=*itr; }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 9600
#include <cstdio>
using namespace std;
int main()
{
    int m,n,i,s=0x7fffffff,t;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        t=0;
        while(m%2==0)
        {
            t++;
            m/=2;
            if(t>=s)
                break;
        }
        if(t<s)
            s=t;
    }
    printf("%d\n",s);
    return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    if(a == b){
        puts("0");
    }else {
        ll ans1 = 0, ans2 = INF<int>;
        for (int i = 0; i < n; ++i) {
            if(a[i] > b[i]) ans2 = min(ans2, b[i]);
            ans1 += a[i];
        }
        cout << ans1 -ans2 << "\n";
    }
    return 0;
}


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

#define int long long
const int mod = 1e9+7;

class FermatCombination{
private:
	vector<int> fac, inv;
	
	int Pow(int x, int n){
		int ans = 1;
		while(n > 0){
			if(n & 1)ans = (ans*x)%mod;
			x = (x*x)%mod;
			n >>= 1;
		}
		return ans%mod;
	}
	void Factrial(int n){
		fac[0] = inv[0] = 1;
		for(int i = 1;i <= n;i++){
			fac[i] = (fac[i-1]*i)%mod;
			inv[i] = Pow(fac[i], mod-2);
		}
	}
	
public:
	void init(int n){	//nCk
		fac.resize(n+1);
		inv.resize(n+1);
		Factrial(n);
	}
	int combine(int n, int k){
		int tmp = (fac[n]*inv[k])%mod;
		return (tmp*inv[n-k])%mod;
	}
};

FermatCombination C;
int comb(int h, int w){
	return C.combine((h+w), w);
}

signed main(){
	int h, w, a, b;
	C.init(200002);
	//printf("%lld", comb(3, 2));
	scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
	h--;w--;a--;b--;
	int ans = 0;
	for(int i = b+1;i <= w;i++){
		int y = h-a-1, x = i;
		int res1 = comb(y, x);
		int res2 = comb(h-y-1, w-x);
		//printf("%lld %lld %lld %lld %lld %lld\n", y, x, h-y, w-x, res1, res2);
		ans += res1*res2;
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3328