akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	ll x;
	cin>>x;
	vint v(n);
	rep(i,n) cin>>v[i];
	ll ans = 0;
	if(v[0]>=x){
		ans += v[0] - x;
		v[0] = x;
	}
	reep(i,1,n){
		if(v[i-1]+v[i]>x){
			ll t = x-v[i-1];
			ans += v[i]-t;
			v[i] = t;
		}
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

int dp[4096];
int a[1009];
vector<vector<int>> c(1009);

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

	int N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i];
		int b; cin >> b;
		for (int j = 0; j < b; j++) {
			int tmp; cin >> tmp;
			c[i].push_back(tmp);
		}
	}
	int num = 1;
	for (int i = 0; i < N; i++) num *= 2;
	for (int i = 1; i < num; i++) dp[i] = INF;
	for (int i = 0; i < num; i++) { // 状態
		for (int j = 0; j < M; j++) { // 鍵の番号
			bool isopen[13];
		    int tmp = i;
			for (int k = 1; k <= N; k++) {
				isopen[k] = tmp % 2;
				tmp /= 2;
			}

			// j番目のカギで開けられる箱
			for (int k = 0; k < c[j].size(); k++) {
				isopen[c[j][k]] = true;
			}

			// 次の状態
			int next_num = 0;
			int cnt = 1;
			for (int k = 1; k <= N; k++) {
				if (isopen[k]) next_num += cnt;
				cnt *= 2;
			}

			// 遷移
			dp[next_num] = min(dp[next_num], dp[i] + a[j]);
		}
	}
	if (dp[num - 1] < INF) cout << dp[num - 1] << endl;
	else cout << -1 << endl;

	return 0;
}

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

struct st {
	string ct;
	int sc, id;
} a[105];
int n;

bool cmp(st p, st q) {
	if(p.ct != q.ct) return p.ct < q.ct;
	else return p.sc > q.sc;
}

int main() {
	int i;
	cin>>n;
	for(i=1; i<=n; i++) {
		cin>>a[i].ct>>a[i].sc;
		a[i].id = i;
	}
	sort(a+1, a+n+1, cmp);
	for(i=1; i<=n; i++) {
		cout<<a[i].id<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n, m, t;
	cin >> n >> m >> t;
	int a[102], sum = 0;
	a[0] = -m;
	a[n + 1] = t + m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 0; i <= n; i++) {
		int x = a[i + 1] - a[i];
		if (x > m * 2) {
			sum += (x - m * 2);
		}
	}
	cout << sum << endl;
}

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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename dtype> using ordered_set = tree<dtype, null_type, less<dtype>, rb_tree_tag, tree_order_statistics_node_update>;

class Timer {
    clock_t start;
    string name;
public:
    Timer() {name = "";start = clock();}
    Timer(string s){name = s;start = clock();}
    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
};

//#define isValid(a, b) (a >= 0 && a < b)
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0L);

template<typename dtype> inline dtype sq(dtype a){return a*a;}
template<typename dtype1, typename dtype2> inline pair<dtype1, dtype2> mp(dtype1 a, dtype2 b){return make_pair(a, b);}
template<typename dtype1, typename dtype2> inline dtype1 safeMod(dtype1 a, dtype2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename dtype1, typename dtype2> inline bool isEq(dtype1 a, dtype2 b){return abs(a - b) < EPS;}
template<typename dtype1, typename dtype2, typename dtype3> inline bool isEq(dtype1 a, dtype2 b, dtype3 eps){return abs(a - b) < eps;}
template<typename dtype> inline bool isKthBitOn(dtype n, int k){assert(n <= numeric_limits<dtype>::max());assert(k<=numeric_limits<dtype>::digits);dtype ONE = 1;return bool((n & (ONE<<k)));}
template<typename dtype> inline void setKthBit(dtype& n, int k){assert(n <= numeric_limits<dtype>::max());assert(k<=numeric_limits<dtype>::digits);dtype ONE = 1;n = (n|(ONE<<k));}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

int dp[MAX];
int broken[MAX];
int main(int argc, char* argv[])
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i = 0, x; i < m; i++){
        cin >> x;
        broken[x] = true;
    }
    dp[n] = 1;
    for(int i = n-1; i >= 0; i--){
        if(!broken[i]){
            int a = i+1;
            int b = i+2;
            if(a <= n && !broken[a]){
                dp[i] += dp[a];
            }
            if(b <= n && !broken[b]){
                dp[i] = (dp[i] +dp[b])%MOD;
            }
        }
    }
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 1024
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let n: u64 = line.trim().parse().unwrap();
    let mut devide = (n as f64).sqrt().floor() as u64;
    loop {
        let reminder = n % devide;
        if reminder == 0 {
            let division = n / devide;
            print!("{}", devide + division - 2);
            return;
        }
        devide -= 1;
    }
}


Measured memory_bytes: 4352
n = gets.to_i

x = 0
y = 0
n.times do
  t, a = gets.split.map(&:to_i)
	unless t >= x && a >= y
		_t = t
		_a = a
    m = [x / t, y / a].max
    t *= m
    a *= m
		until t >= x && a >= y
			t += _t
			a += _a
		end
	end
	x = t
	y = a
end
puts x + y


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int m;
  std::cin >> m;
  print(24 + (24 - m));
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
double func(double n){
  double ans=0;
  for(int i=1; i<=n; i++){
    ans += (double)(i)/n;
  }
  return ans;
} 

int main() {
  ll x,y,z=0,k,n,m,h,w,Min=1e9+1;
  double sum=0,Max=-1e9;
  string s,t,u;
  bool ok = false;
  cin >> n >> k; 
  VI a(n);
  vector<double> b(n);
  vector<double> c(n+1);
  c[0] = 0;
  rep(i,n){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    b[i] = func(a[i]);
  }
  rep(i,n){
    c[i+1] = b[i]+c[i];
  }

  Max = c[k] - c[0];

  for(int i=0; i<n-k+1; i++){
    double tmp = c[i+1+k] - c[i+1];
    if(Max < tmp){
      Max = tmp;
    }
  }
  double ans = Max;
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 4096
import java.util.*;
import java.io.*;

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int x = sc.nextInt(), y = sc.nextInt(), z = sc.nextInt(), z1 = sc.nextInt();
        if (x + y > z + z1) {
            System.out.println("Left");
        } else if (x + y == z + z1) {
            System.out.println("Balanced");
        } else {
            System.out.println("Right");
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
ll n,ans;
vector<int> abcd(4);
bool dfs(int d,string &s,int sum){
  if(d==3) return sum == 7;
  if(dfs(d+1,s,sum+abcd[d+1])){
    s[d]='+';
    return true;
  }
  if(dfs(d+1,s,sum-abcd[d+1])){
    s[d]='-';
    return true;
  }
  return false;
}
  
int main(){
  int a;
  cin >> a;
  rep(i,4){
    abcd[i]=a%10;
    a/=10;
  }
     
  reverse(abcd.begin(),abcd.end());
  /*rep(i,abcd.size()){
    cout << abcd[i] ;
  }*/
  string s = "+++";
  if(dfs(0,s,abcd[0])){
    rep(i,3){
      cout << abcd[i] << s[i];
    }
    cout << abcd[3] << "=7" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int X,Y;
  cin >> X >> Y;
  int ans=0;
  if(X==1 && Y==1) ans+=400000;
  if(X==1) ans+=300000;
  if(X==2) ans+=200000;
  if(X==3) ans+=100000;
  if(Y==1) ans+=300000;
  if(Y==2) ans+=200000;
  if(Y==3) ans+=100000;
  cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
Hs = gets.chomp.split(' ').map(&:to_i).reverse

@output = 'Yes'

Hs.each_with_index do |h, i|
  break if i == (N - 1)
  diff = h - Hs[i + 1]
  if diff >= 0
    next
  elsif diff.abs == 1
    Hs[i + 1] -= 1
  elsif diff.abs > 1
    @output = 'No'
    break
  end
end

puts @output


Measured memory_bytes: 10500
import sys

input = sys.stdin.readline

N = int(input())
S = input().rstrip()

if N % 2 == 1:
    print('No')
else:
    mid = int(N / 2)
    head = S[:mid].rstrip()
    S2 = head + head
    #print(S)
    #print(S2)
    if S == S2:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> a(100010, 0);
	rep(i, N)
	{
		ll tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		a[tmp1] += tmp2;
	}

	ll ind = 0;
	rep1(i,100000)
	{
		ind += a[i];
		if (ind>=K)
		{
			co(i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
N, T = map(int,input().split())
r = [list(map(int,input().split())) for i in range(N)]
ans = 10**10
for c,t in r:
    if t <= T:
        ans = min(ans, c)
if 10**10 == ans:
    print("TLE")
else:
    print(ans)



Measured memory_bytes: 38256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
    int n, sum,ans =(1 << 25), a[100],ma = -1000,mi = 1000;cin >> n;
    rep(i, n) {
        cin >> a[i];
        ma = max(ma, a[i]);
        mi = min(mi, a[i]);
    }
    for (int i = mi;i <= ma;i++) {
        sum = 0;
        rep(j, n) {
            sum += (i - a[j]) * (i - a[j]);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
red_points = [tuple(map(int, input().split())) for i in range(N)]
blue_points = [tuple(map(int, input().split())) for i in range(N)]

red_points.sort(key=lambda x: -x[1])
blue_points.sort(key=lambda x: x[0])

count = 0

points_used = [False for i in range(N)]

for blue in blue_points:
    for i, red in enumerate(red_points):
        if not points_used[i] and red[0] < blue[0] and red[1] < blue[1]:
            count += 1
            points_used[i] = True
            break
            
print(count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std ;
int main (){


int x,z,c;
cin >> x>> z>> c;


if (x!=z&&x!=c){
    cout << x;
}

else if (z!=x&&z!=c){
    cout <<z;

}
else if (c!=x&&c!=z){
    cout << c;
}
return 0;
}


Measured memory_bytes: 256
import math
import collections
import sys

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

n,m=MI()
A=LI()
def num2(x):
    ans=0
    while x%2==0:
        x=x//2
        ans+=1
    return ans
mod=2**(num2(A[0]))
for i in range(1,n):
    if A[i]%mod!=0:
        print(0)
        sys.exit()
    if A[i]%mod==0 and (A[i]//mod)%2==0:
        print(0)
        sys.exit()
#print(A)
for i in range(n):
    A[i]//=2
#print(A)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b

L=A[0]   
for i in range(1,n):
    L=lcm(L,A[i])
#print(L)
if L>m:
    an=0
else:
    an=int(((m/L)-1)/2)+1
print(an)

Measured memory_bytes: 14624
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,K=map(int, input().split())
A = list(map(int, input().split()))

print(ceil((N-1)/(K-1)))


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    if (s.back()=='s') s += "es";
    else s += "s";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3596
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  int x;
  cin >> x;

  int ans = 10 - (x / 200);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=100000000;
    for(int i=-100;i<=100;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

   


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read()
{
    char s;
    int k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
    if(s==EOF)exit(0);
    if(s=='-')base=-1,s=getchar();
    while(s>='0'&&s<='9')
    {
        k=k*10+(s-'0');
        s=getchar();
    }
    return k*base;
}
void write(int x)
{
    if(x<0)
    {
        putchar('-');
        write(-x);
    }
    else
    {
        if(x/10)write(x/10);
        putchar(x%10+'0');
    }
}
const int maxn=110;
int n,ans,l,r;
int a[maxn];
int b[maxn],c[maxn];
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		c[i]=read();
	}
	l=0;r=24;
	if (n==1)
	{
		printf("%d\n",c[1]);
		return 0;
	}
	sort(c+1,c+n+1);
	r=c[1];
	while (l<=r)
	{
		int mid=(l+r)/2;
		bool flag=true;
		memset(b,0,sizeof(b));
		b[0]=1;b[24]=1;
		for (int i=1;i<=n;i++)
		{
			bool qaq=false,qwq=true,bj1=false,bj2=false;
			a[i]=c[i];
			for (int j=max(0,a[i]-mid+1);j<=min(24,a[i]+mid-1);j++)
			{	
				if (b[j]==1) 
				{
					qwq=false;
					break;
				}
			}
			if (qwq)
			{
				qaq=true;
				bj1=true;
			}
			
			
			qwq=true;
			a[i]=24-c[i];
			for (int j=max(0,a[i]-mid+1);j<=min(24,a[i]+mid-1);j++)
			{	
				if (b[j]==1) 
				{
					qwq=false;
					break;
				}
			}
			if (qwq)
			{
				qaq=true;
				bj2=true;
			}
			
			if (!qaq) 
			{
				flag=false;
				break;
			}
			
			if (bj1) b[c[i]]=1; else b[24-c[i]]=1;
		}
		if (!flag) r=mid-1; else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }




void solve() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k) {
		  cout<<k<<endl;
		}
	else if(a+b>=k) {
		  cout<<a<<endl;
		}	
	else {
		   cout<<a-(k-(a+b))<<endl;
		}	
     	   
 }

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

return 0;	   
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int sum = 0;
  for(int e:v)sum += e;
  int m; cin >> m;
  for(int i = 0; i < m; ++i){
    int p,t;cin >> p >> t;
    p--;
    cout << sum - v[p] + t << endl;
  }
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
using ll = long long;
using namespace std;
const ll mod = 1000000007;
char A[1234][1234];
signed main() {
	ll n, ans = 1; cin >> n; map<ll, ll> m;
	m[0 - 1] = 3;
	rep(i, n) {
		ll a; cin >> a;
		ans *= (m[a - 1] - m[a]); m[a]++; ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9848
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n;
    string s;
    cin >> n >> s;

    vector<vector<int> > a(10,vector<int>(30010));

    for(int i = 0;i < n;i ++){
        int x = s.at(i) - '0';
        a.at(x).at(i+1) ++;
    }

    for(int i = 0;i < 10;i ++){
        for(int j = 1;j < 30001;j ++){
            a.at(i).at(j) = a.at(i).at(j-1) + a.at(i).at(j);
        }
    }

    int ans = 0;

    for(int i = 0;i < 10;i ++){
        for(int j = 0;j < 10;j ++){
            for(int k = 0;k < 10;k ++){
                int hantei = 0;
                int me = 1;
                
                while(a.at(i).at(me-1) == a.at(i).at(me) && me < 30001){
                    me ++;
                }
                me ++;
                while(me < 30001 && a.at(j).at(me-1) == a.at(j).at(me)){
                    me ++;
                }
                
                if(me < 30001 && a.at(k).at(30000) - a.at(k).at(me) > 0) hantei = 1;
                

                if(hantei) ans ++;                
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5824
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
LL a[100000];
int main() {
	int n;
	cin >> n;
	rep(i, n) cin >> a[i];
	bool posi = 1;
	LL sum1 = 0, sum2 = 0;
	LL cnt1 = 0, cnt2 = 0;
	rep(i, n) {
		sum1 += a[i];
		sum2 += a[i];
		if (posi&&sum1 <= 0) {
			cnt1 += 1 - sum1;
			sum1 = 1;
		}
		else if (!posi&&sum1 >= 0) {
			cnt1 += 1 + sum1;
			sum1 = -1;
		}
		if (!posi&&sum2 <= 0) {
			cnt2 += 1 - sum2;
			sum2 = 1;
		}
		else if (posi&&sum2 >= 0) {
			cnt2 += 1 + sum2;
			sum2 = -1;
		}
		posi ^= 1;
	}
	cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#define test
#ifdef test
#define IOS()
#define time() cout<<double(end-start)/CLOCKS_PER_SEC<<"S\n"
#else
#define IOS() ios::sync_with_stdio(0)
#define time()
#endif
using namespace std;
int main()
{
	IOS();
	string s;
	while(cin>>s)
	{
		int num=0;
		for(char c:s)
		{
			num+=c-'0';
		}
		if(num%9) cout<<"No\n";
		else cout<<"Yes\n";
	}
} 

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

int main(void){
    char c[3][4];
    for(int i=0; i<2; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

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

int n,h;
ll bsum=0,cnt=0;
vector<int> a(100010),b(100010);


int main(){
  cin >> n >> h;
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  //攻撃力高い順にソート
  sort(all(a));
  reverse(all(a));
  sort(all(b));
  reverse(all(b));

  rep(i,n){
    if(b[i] > a[0]){
      h -= b[i];
      cnt++;
    }else{
      break;
    }
    if(h <= 0){
      cout << cnt << endl;
      return 0;
    }
  }

  while(h>0){
    h -= a[0];
    cnt++;
    if(h <= 0){
      cout << cnt << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <algorithm>

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  std::array<int, 3> inputs{a, b, c};
  
  auto found5 = std::count(inputs.begin(), inputs.end(), 5);
  auto found7 = std::count(inputs.begin(), inputs.end(), 7);

  std::cout << ((found5 == 2 && found7 == 1) ? "YES" : "NO");
}

Measured memory_bytes: 256
import sys
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))
S.sort()
ans = sum(S)
if ans % 10 != 0:
    print(ans)
    sys.exit()
for i in S:
    if i % 10 != 0:
        ans -= i
        print(ans)
        sys.exit()
print(0)

Measured memory_bytes: 3060
def binary_search(lst, target, start, end):
    if (start > end):
        return 0

    mid = (start + end) // 2

    if (lst[mid] < target):
        return binary_search(lst, target, mid + 1, end)
    elif (lst[mid] == target):
        return 1
    else:
        return binary_search(lst, target, start, mid - 1)

n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

count = 0
for t in T:
    count += binary_search(S, t, 0, len(S) - 1)
print(count)




Measured memory_bytes: 16708
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,p[110]={},dp[102][4][4]={};
  cin>>n>>t;
  for(int i=0;i<t;i++){
    int a,b;
    cin>>a>>b;
    p[a]=b;
  }
  
  if(p[1]&&p[2])dp[3][p[2]][p[1]]=1;
  else if(p[2])for(int i=1;i<4;i++)dp[3][p[2]][i]=1;
  else if(p[1])for(int i=1;i<4;i++)dp[3][i][p[1]]=1;
  else 
    for(int i=1;i<4;i++)
      for(int j=1;j<4;j++)dp[3][i][j]=1;

  for(int i=3;i<=n;i++)
    for(int j=1;j<4;j++) //1
      for(int k=1;k<4;k++){//2
	if(p[i]==j&&j==k)continue;
	if(p[i])dp[i+1][p[i]][j]=(dp[i+1][p[i]][j]+dp[i][j][k])%10000;
	else 
	  for(int l=1;l<4;l++){
	    if(j==k&&k==l)continue;
	    dp[i+1][l][j]=(dp[i+1][l][j]+dp[i][j][k])%10000;
	  }
      }
  int ans=0;
  for(int i=1;i<4;i++)
    for(int j=1;j<4;j++)ans+=dp[n+1][i][j];
  cout<<ans%10000<<endl;
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long, long>;
using pdd = pair<ld, ld>;

template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<ll>;
V(size_t) -> V<ll>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

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 (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, K;
    cin >> N >> K;
    V<ll> p(N);
    REP(i, N) cin >> p[i];
    sort(ALL(p));
    ll res = 0;
    REP(i, K) res += p[i];
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3660
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))


tmp_ans=0

for i in range(N):
    if(A[i]<=B[i]):
        tmp_ans += A[i]
        B[i] = B[i] - A[i]
        A[i] = 0



        if(A[i+1]<=B[i]):
            tmp_ans += A[i+1]
            B[i] = B[i]-A[i+1]
            A[i+1] = 0

        
        else:
            tmp_ans += B[i]
            A[i+1] -= B[i] 
            B[i] = 0



    else:
        tmp_ans += B[i]
        A[i] -= B[i]
        B[i] = 0


print(tmp_ans)

Measured memory_bytes: 82148
//????¨???????????????????????????????????????????.
//????????????????????????????????°??????.
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int n;
string people;
string result;

string rshift(string s) {
	string ret;
	ret += s[s.length() - 1];
	for (int i = 0; i < s.length() - 1; i++) ret += s[i];
	return ret;
}

string lshift(string s) {
	string ret;
	for (int i = 1; i < s.length(); i++) ret += s[i];
	ret += s[0];
	return ret;
}

string swaplr(string s) {
	string pre, suf;
	for (int i = 0; i < s.length() / 2; i++) pre += s[i];
	for (int i = 0; i < s.length() / 2; i++) suf += s[s.length() / 2 + s.length() % 2 + i];
	if (s.length() % 2) return suf + s[s.length() / 2] + pre;
	return suf + pre;
}

string reverse(string s) {
	int l = 0, r = s.length() - 1;
	while (l < r) {
		swap(s[l], s[r]);
		l++;
		r--;
	}
	return s;
}

string decrements(string s) {
	for (int i = 0; i < s.length(); i++) {
		if ('0' <= s[i] && s[i] <= '9') {
			if (s[i] == '0') s[i] = '9';
			else s[i]--;
		}
	}
	return s;
}

string increments(string s) {
	for (int i = 0; i < s.length(); i++) {
		if ('0' <= s[i] && s[i] <= '9') {
			if (s[i] == '9') s[i] = '0';
			else s[i]++;
		}
	}
	return s;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> people >> result;
		for (int j = people.length() - 1; j >= 0; j--) {
			char c = people[j];
			if (c == 'J') result = rshift(result);
			if (c == 'C') result = lshift(result);
			if (c == 'E') result = swaplr(result);
			if (c == 'A') result = reverse(result);
			if (c == 'P') result = decrements(result);
			if (c == 'M') result = increments(result);
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
judge = True

while judge:
    h,w = map(int, input().split(" "))
    if h == 0 and w == 0:
        judge = False
    else:
        for i in range(h):
            if i % 2 == 0:
                for j in range(w):
                    if j % 2 == 0:
                        print("#", end="")
                    else:
                        print(".", end="")
            else:
                for j in range(w):
                    if j % 2 == 0:
                        print(".", end="")
                    else:
                        print("#", end="")
            print()
        print()

Measured memory_bytes: 9140
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

vector<int> bfs(int n, vector<vector<int>> &g, int start) {

    vector<int> ans(n, INT_MAX);
    ans[start] = 0;
    queue<int> q;
    q.push(start);
    while (!q.empty()) {
        int from = q.front();
        q.pop();

        int next_cost = ans[from] + 1;
        for (int to : g[from]) {
            if (ans[to] > next_cost) {
                ans[to] = next_cost;
                q.push(to);
            }
        }

    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<P> v(n - 1);
    for (P &p : v) cin >> p.first >> p.second, p.first--, p.second--;

    vector<vector<int>> g(n);
    for (P p : v) g[p.first].push_back(p.second);
    for (P p : v) g[p.second].push_back(p.first);

    vector<int> v1 = bfs(n, g, 0);

    int ma = distance(v1.begin(), max_element(v1.begin(), v1.end()));
    vector<int> v2 = bfs(n, g, ma);

    int r = *max_element(v2.begin(), v2.end());
    bool ans = r % 3 == 1;
    cout << (ans ? "Second" : "First") << endl;

}


Measured memory_bytes: 20408
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

struct card { char suit, value;};

int bubble(struct card a[], int n){
    rep(i, n){
        for (int j = n-1; j >=1; j--){
            if( a[j].value < a[j - 1].value){
                card t = a[j]; a[j] = a[j-1]; a[j-1]=t;
            }
        }
    }
}

int selection(struct card a[], int n){
    rep(i,n){
    int minj = i;
    for(int j=i;j<n;j++){
        if( a[j].value < a[minj].value) minj = j;
        }
        card t = a[i]; a[i] = a[minj]; a[minj] = t;
    }
}

void print(struct card a[], int n){
    rep(i, n) {
        if(i > 0) cout << " ";
        cout << a[i].suit << a[i].value ;
    }
    cout  << endl;
}

bool isStable(struct card c1[], struct card c2[], int n){
    rep(i,n){
        if( c1[i].suit != c2[i].suit) return false;
    }
    return true;
}

int main(){
    card c1[100], c2[100];
    int n;
    char ch;

    cin >> n;
    rep(i, n){
        cin >> c1[i].suit >> c1[i].value;
    }

    rep(i,n) c2[i] = c1[i];

    bubble(c1,n);
    selection(c2,n);

    print(c1,n);
    cout << "Stable" << endl;
    print(c2,n);
    if( isStable(c1, c2, n)){
    cout << "Stable" << endl;
    } else{
        cout << "Not stable" << endl;
    }
    return 0;
}














Measured memory_bytes: 3120
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

string grid[6] = {""};

void choose(map<int, int> &memo, int bits, int &comp, int size) {
  for(int i = 0; i < size; i++) {
    if (bits & comp) {
      memo[i] = 1;
    }
    comp = comp << 1;
  }
}

int count(int h, int w, map<int, int> &row, map<int, int> &col) {
  int result = 0;
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      if (row.count(i) == 0) continue;
      if (col.count(j) == 0) continue;
      if (grid[i][j] == '#') result++;
    }
  }
  return result;
}

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  rep(i, h)
  {
    cin >> grid[i];
  }
  int cand = 0;
  for(int i = 0; i < pow(2, h + w); i++) {
    int comp = 1;
    map<int, int> row;
    map<int, int> col;  
    choose(row, i, comp, h);
    choose(col, i, comp, w);
    int temp = count(h, w, row, col);
    if (temp == k) cand++;
  }
  cout << cand << endl;
}


Measured memory_bytes: 4084
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut a = Vec::new();
    for i in 0..n {
        let s: &str = itr.next().unwrap();
        let b: i64 = itr.next().unwrap().parse().unwrap();
        a.push((s, -b, i));
    }
    a.sort();

    let mut out = Vec::new();
    for i in 0..n {
        writeln!(out, "{}", a[i].2 + 1).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 4352
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <cmath> 
#include <set>
#include <vector>
using namespace std;


int main(){ 
    multiset<int> s;
    vector<vector<int> > v;
    
    int n,m;
    cin >>n>>m;
    rep(i,n){
        int a;
        cin >> a;
        s.insert(a);
    }
    rep(i,m){
        int b,c;
        cin >> b >> c;
        v.push_back({c,b});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());   
    // for(auto x:v){
    //     cout << x[0] << x[1] <<endl;
    // }
    for(auto x:v){
        int i=0;
        for(auto it = s.begin();it!=s.end();){
            if(i==x[1]){
                break;
            }
            if(x[0]>*it){
                it = s.erase(it);
                s.insert(x[0]);
            }else{
                break;
            }
            i++;
        }
    }
    long long int t=0;
    for(auto x:s){
        t+=(long long int)x;
    }
    cout << t ;
}

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

using namespace std;

int ans, N, M, mod = 1e9 + 7, a[200009], b[200009], fac[8009], inv[8009], dp[4009][4009];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}

int pow (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = pow (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

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

scanf ("%d", &N), Prec (8000), M = 2000, ans = 0;
for (int i=1; i<=N; i++)
{
    scanf ("%d %d", &a[i], &b[i]), dp[M + 1 - a[i]][M + 1 - b[i]] ++;
    ans = substract (ans, comb (2 * a[i] + 2 * b[i], 2 * a[i]));
}
for (int i=1; i<=2 * M + 1; i++)
    for (int j=1; j<=2 * M + 1; j++)
        dp[i][j] = add (dp[i][j], add (dp[i - 1][j], dp[i][j - 1]));
for (int i=1; i<=N; i++)
    ans = add (ans, dp[M + 1 + a[i]][M + 1 + b[i]]);
ans = mul (ans, pow (2, mod - 2));
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 64512
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, k;
    cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    }
}

Measured memory_bytes: 38892
N = int(input())
h = list(map(int, input().split()))
c = []
tmp = 0
for x in reversed(range(len(h))):
  if len(h) == 1:
    c.append(0)
  elif h[x] <= h[x-1]:
    tmp += 1
  else:
    c.append(tmp)
    tmp = 0
if len(c) == 0:
  c.append(tmp-1)
print(sorted(c)[-1])


Measured memory_bytes: 15020
#include<iostream>
using namespace std;
int n;
int d[1000000];
int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        d[i] = 0;
    }
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        d[a] ++;
    }
    int ans = 0;
    int sum = 0;
    bool sw = false;
    for(int i = 0;i<=100000;i++){
         sum+= d[i];
        if(sw){
            ans ++;
            if(sum > n/2){
                sw = false;
            }
        }
        if(sum == n/2){
            sw = true;
        }
        //cout << sum << endl;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640