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

string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int> b(n, -1);
  {
    int i = 0;
    for (int t = 0; t < k; ++t) {
      while (s[i] == 'x') {
        ++i;
      }
      b[i] = t;
      i += c + 1;
    }
  }
  DEBUG(b);
  vector<int> dp(3 * n);
  for (int i = n; i--; ) {
    dp[i] = dp[i + 1];
    if (s[i] == 'o') {
      dp[i] = max(dp[i], 1 + dp[i + c + 1]);
    }
  }
  DEBUG(dp);
  for (int i = 0; i < n; ++i) {
    if (b[i] != -1 and b[i] + dp[i + 1] < k) {
      cout << i + 1 << '\n';
    }
  }
}
//dp算法

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

int main(){
  int N;
  string S;
  int C0 = 0, C1 = 0, C2 = 0, C3 = 0;
  cin >> N;  
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "AC") C0++;
    else if(S == "WA") C1++;
    else if(S == "TLE") C2++;
    else if(S == "RE") C3++;
  }
  cout << "AC x " << C0 << endl;
  cout << "WA x " <<C1 << endl;
  cout << "TLE x " << C2 << endl;
  cout << "RE x " <<C3 << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n, x, a, b, c;
double dp[307][307][307];

double solve(int a, int b, int c){
	int num = a + b + c;
	if(a == 0 && b == 0 && c == 0) return 0;
	if(dp[a][b][c] >= 0) return dp[a][b][c];
	double rem = 0, ans = 1.0 * n / num;
	if(a > 0) ans += solve(a - 1, b, c) * a / num;
	if(b > 0) ans += solve(a + 1, b - 1, c) * b / num;
	if(c > 0) ans += solve(a, b + 1, c - 1) * c / num;
	dp[a][b][c] = ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	memset(dp, -1, sizeof(dp));
	for(int i = 1; i <= n; i++){
		cin >> x;
		if(x == 1) a++;
		else if(x == 2) b++;
		else c++;
	}
	cout << (fixed) << setprecision(15) << solve(a, b, c);
}


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

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

	int n, x, o;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> x;
		a.push_back(x);
	}
	for (int i = a.size()-1; i >= 0; i -= 2){
		cout << a[i] << " ";
	}
	if (n%2 == 0){
		o = 0;
	}else{
		o = 1;
	}
	for (int i = o; i < a.size(); i += 2){
		cout << a[i] << " ";
	}
	cout << "\n";
	return 0;
}

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

long long N, K;
long long A[200005];
long long dis[200005];

int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
		dis[i] = -1;
	}


	long long cur = 0;
	long long cost = 0;
	long long rest = K;
	dis[0] = 0;
	bool skiped = false;

	while(rest) {
		//次の街に進む
		cur = A[cur];
		cost++;
		rest--;
		//cout << "cur = " << cur << " cost " << cost << " rest " << rest << endl;

		//loop発見
		if(!skiped && dis[cur] >= 0) {
			skiped = true;
			long long syuki = cost - dis[cur];
			//cout << "syuki " << syuki << endl;

			//ワープ
			//cout << "change rest from " << rest;
			rest %= syuki;
			//cout << " to " << rest << endl;
		}
		dis[cur] = cost;
	}
	cout << cur + 1 << endl;
}


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

using namespace std;

int main()
{
  int X,Y;
  cin >>X >>Y;
  int cont = 0;
  if(X>=Y)
  {
    cont+=X;
    X--;
  }
  else{
    cont+=Y;
    Y--;
  }
  if(X>=Y)
  {
    cont+=X;
  }
  else{
    cont+=Y;
  }
  cout << cont;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int n,m,mod;
ll c[1010][1010],f[1010][1010],s[1010][1010];
int main(){
	scanf("%d%d%d",&n,&m,&mod);
	c[0][0]=1;
	for(register int i=1;i<=n;i++)for(register int j=0;j<=i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	for(register int i=0;i<=m;i++)f[1][i]=1;
	for(register int i=m;~i;i--)s[1][i]=(s[1][i+1]+f[1][i])%mod;
	for(register int i=2;i<=n+1;i++){
		for(register int j=m;~j;j--){
			for(register int k=1;k<i;k++){
				f[i][j]=(f[i][j]+c[i-2][k-1]*f[i-k][j]%mod*s[k][j+1]%mod)%mod;
			}
			//cout<<"f["<<i<<"]["<<j<<"]="<<f[i][j]<<endl;
			s[i][j]=(s[i][j+1]+f[i][j])%mod;
		}
	}
	printf("%lld",f[n+1][0]);
	return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int a, b;
    cin >> a >> b;
    if(0 <= a && a <= 9 && 0 <= b && b <= 9){
        cout << a * b << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

const int N = 2e5+5 , M = 1e9+5, OO = 0x3f3f3f3f;
typedef long long ll;
ll n;
map<string, int> ma;
ll ans;
string s;

ll calc(ll x)
{
    return (x * (x-1)/2) ;
}

int main()
{
    cin >> n;
    for(int i=0; i<n; ++i)
    {
        cin >> s;
        sort(s.begin(), s.end());
        ma[s]++;
    }
    for(auto sf : ma)
    {
        //cout << sf.first << " " << sf.second << endl;
        if(sf.second > 1)
        {
            //cout << calc(sf.second) << endl;
            ans += calc(sf.second);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11136
INF = 1000000000000000
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ai = a[n - 1]
aj = -1
center = ai / 2
margin = INF
for i in range(n):
    if margin > abs(center - a[i]):
        aj = a[i]
        margin = abs(center - a[i])
print(ai, aj)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	cin>>s;
	REP(i,(int)s.length()){
		if((i+1)%2==0){
			if(!(s[i]=='L' || s[i]=='U' || s[i]=='D')){
				puts("No\n");
				return 0;
			}
		}
		if((i+1)%2==1){
			if(!(s[i]=='R' || s[i]=='U' || s[i]=='D')){
				puts("No\n");
				return 0;
			}
		}
	}
	puts("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d,e;
int n[100];
scanf("%d",&a);
for(b=0;b<a;b++){
scanf("%d",&n[b]);
}
b=a;
while(1){
	b--;
	printf("%d",n[b]);
	if(b==0)
	break;
	printf(" ");
}
printf("\n");
return 0;
}

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

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//素因数分解(素因数,何乗か？)
vector<pair<ll,ll>> fact(ll n){
	vector<pair<ll,ll>> res;
	for(ll i=2;i*i<=n;i++){
		if(n%i)continue;
		res.emplace_back(i,0);//push_back(make_pair(a,b))よりらく
		while(n%i==0){
			n/=i;
			res.back().second++;
		}
	}
	if(n!=1)res.emplace_back(n,1);
	return res;
}

//考察よりgcd(A,B)の素因数を求めればよい
int main() {
	ll a,b,c;
	cin>>a>>b;
	
	c=gcd(a,b);
	auto f=fact(c);
	cout<<f.size()+1<<endl;
	
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,a,b,c,d,i;
    bool flg=false;
    string str;
    cin>>n>>a>>b>>c>>d;
    a--;b--;c--;d--;
    cin>>str;
    if(a<c && c<b)
    {
        for(i=a;i<c;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=b;i<d;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
    }
    else if(a<b && b<c && c<d)
    {
        for(i=b;i<d;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=a;i<c;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
    }
    else if(a<b && b<d && d<c)
    {
        for(i=a;i<c;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=b;i<d;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=b-1;i<=d-1;i++)
        {
            if(str[i]=='.' && str[i+1]=='.' && str[i+2]=='.')
            {
                flg=true;
                cout<<"Yes";
                return 0;
            }
        }
        if(flg==false)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <numeric>
#include <vector>
#include <type_traits>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;

ll gcd(ll x, ll y){
    //if(x < y)
    //    swap(x, y);
    if(y == 0)
        return x;
    else
        return gcd(y, x % y);
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> left(n+1, 0), right(n+1, 0);
    for(int i = 0; i < n; ++i)
        left[i+1] = gcd(left[i], a[i]);
    for(int i = n-1; i >= 0; --i){
        right[i] = gcd(right[i+1], a[i]);
    }

    int ans = 0;

    REP(i, n){
        int l = left[i];
        int r = right[i+1];

        int tmp = gcd(l, r);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <vector>
#define fi first
#define se second
#define maxn 200003
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

int n,m;
LL lazy[4*maxn];
LL tree[4*maxn];
vector<pi> v[maxn];

void push( int x , int y , int id ) {
	tree[id] += lazy[id];
	if( x != y ) {
		lazy[id*2] += lazy[id];
		lazy[id*2+1] += lazy[id];
	}
	lazy[id] = 0;
}

LL update( int cx , int cy , int qx , int qy , int id , LL val ) {
	push( cx , cy , id );
	if( qy < cx || cy < qx )
		return tree[id];
	if( qx <= cx && cy <= qy ) {
		lazy[id] += val;
		push( cx , cy , id );
		return tree[id];
	}
	int mid = (cx + cy) >> 1;
	LL left = update( cx , mid , qx , qy , id*2 , val );
	LL right = update( mid+1 , cy , qx , qy , id*2+1 , val );
	return tree[id] = max( left , right );
}

LL query( int cx , int cy , int qx , int qy , int id ) {
	push( cx , cy , id );
	if( qy < cx || cy < qx )
		return 0;
	if( qx <= cx && cy <= qy )
		return tree[id];
	int mid = (cx + cy) >> 1;
	LL left = query( cx , mid , qx , qy , id*2 );
	LL right = query( mid+1 , cy , qx , qy , id*2+1 );
	return max( left , right );
}

int main() {
	cin >> n >> m;
	for( int i = 0 , x , y , z ; i < m ; i++ ) {
		cin >> x >> y >> z;
		v[y].pb( pi( x , z ) );
	}
	for( int i = 1 ; i <= n ; i++ ) {
		LL val = query( 0 , n , 0 , i-1 , 1 );
		update( 0 , n , i , i , 1 , val );
		for( int j = 0 ; j < (int) v[i].size() ; j++ )
			update( 0 , n , v[i][j].fi , i , 1 , v[i][j].se );
	}
	cout << query( 0 , n , 0 , n , 1 );
}


Measured memory_bytes: 22912
#include <iostream>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

#define EPS (1e-8)

struct Point {
    double x, y, z;
    Point(){}
    Point(double x, double y, double z) :
        x(x), y(y), z(z) {}
};

double dot(const Point &a, const Point &b)
{
    return a.x*b.x + a.y*b.y + a.z*b.z;
}

double norm(const Point &p)
{
    return dot(p, p);
}

double abs(const Point &p)
{
    return sqrt(norm(p));
}

bool can_watch(const Point &a, const Point &b, double the)
{
    double t = acos(dot(a, b) / abs(a) / abs(b));
    return (t < the + EPS);
}

int main()
{
    int n, m;
    while (cin >> n, n) {
        vector<Point> s(n);
        for (int i = 0; i < n; i++) {
            cin >> s[i].x >> s[i].y >> s[i].z;
        }
        Point p;
        double the;
        set<int> stars;
        cin >> m;       
        for (int i = 0; i < m; i++) {
            cin >> p.x >> p.y >> p.z >> the;
            for (int j = 0; j < n; j++) {
                if (can_watch(s[j], p, the)) {
                    stars.insert(j);
                }
            }
        }
        cout << stars.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3384
n = int(input())
s = list(input())
white = 0
black = 0
for i in range(n):
    if s[i] == '.':
        white+=1

ans = white
for i in range(n):
    if s[i] == '.':
        white -= 1
    else:
        black += 1
    ans = min(ans, white + black)
print(ans)



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL MC = 1e9;
LL Q,H,S,D;
LL N;

int main(){
	scanf("%lld%lld%lld%lld" , &Q , &H , &S , &D);
	scanf("%lld" , &N);
	H = min(H , Q*2);
	S = min(S , H * 2);
	D = min(D , S * 2);
	printf("%lld\n" , D*(N/2) + (N%2 ? S : 0));
	return 0;
}


Measured memory_bytes: 256
class SegmentTreeMAX():
    def __init__(self,A,n,ide_ele_max=-1):
        self.ide_ele_max = ide_ele_max
        self.num_max =2**(n-1).bit_length()
        self.seg_max=[ide_ele_max]*2*self.num_max
        #set_val
        for i in range(n):
            self.seg_max[i+self.num_max-1]=A[i]
        #built
        for i in range(self.num_max-2,-1,-1) :
            self.seg_max[i]=max(self.seg_max[2*i+1],self.seg_max[2*i+2])

    def update_max(self,k,x):
        k += self.num_max-1
        self.seg_max[k] = x
        while k:
            k = (k-1)//2
            self.seg_max[k] = max(self.seg_max[k*2+1],self.seg_max[k*2+2])

    def query_max(self,p,q):
        if q<=p:
            return self.ide_ele_max
        p += self.num_max-1
        q += self.num_max-2
        res=self.ide_ele_max
        while q-p>1:
            if p&1 == 0:
                res = max(res,self.seg_max[p])
            if q&1 == 1:
                res = max(res,self.seg_max[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = max(res,self.seg_max[p])
        else:
            res = max(max(res,self.seg_max[p]),self.seg_max[q])
        return res

N,K=list(map(int,input().split()))
T = [0]*(300001)
SegTree = SegmentTreeMAX(T,300001)
for i in range(N):
    A=int(input())
    X=SegTree.query_max(max(0,A-K),min(A+K,300000)+1)
    SegTree.update_max(A,X+1)
    T[A]=X+1
print(SegTree.query_max(0,300000+1))

Measured memory_bytes: 100788
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N)
	b := make([]int, N)
	c := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	for i := 0; i < N; i++ {
		b[i] = getInt()
	}
	for i := 0; i < N; i++ {
		c[i] = getInt()
	}
	sort.Ints(a)
	sort.Ints(b)
	sort.Ints(c)
	//	out(a)
	//	out(b)
	//	out(c)
	B := make([]int, N)
	pa := 0
	for i := 0; i < N; i++ {
		for pa < N && a[pa] < b[i] {
			//			out(pa, a[pa], b[i])
			pa++
		}
		B[i] = pa
	}
	C := make([]int, N)
	pb := 0
	cnt := 0
	ans := 0
	for i := 0; i < N; i++ {
		for pb < N && b[pb] < c[i] {
			//			out(pb, b[pb], c[i])
			cnt += B[pb]
			pb++
		}
		C[i] = cnt
		ans += cnt
	}
	//	out(B)
	//	out(C)
	out(ans)
}


Measured memory_bytes: 7552
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    i = 0
    while i < len(A):
        A[i] -= (i + 1)
        i += 1

    A.sort()
    b = A[len(A) // 2]

    sad = 0
    for a in A:
        sad += abs(a - b)

    print(sad)

main()


Measured memory_bytes: 28664
/*
                _____________   ______________       __
               / _________  /\ /_____   _____/\     / /\
              / /\       / /  \\    /  /\    \ \   / /  \
             / /  \_____/ /   / \__/  /  \____\/  / /   /
            / /   /    / /   /    /  /   /       / /   /
           / /   /    / /   /    /  /   /       / /   /
          / /   /    / /   /    /  /   /       / /   /
         / /___/____/ /   /    /  /   /       / /___/________
        /____________/   /    /__/   /       /______________/\
        \            \  /     \  \  /        \              \ \
         \____________\/       \__\/          \______________\/
           ___       ___               ___    ___________
          /  /\     /  /\             /  /\  /_______   /\
         /  /__\___/  /  \           /  /  \ \      /  /  \
        /____    ____/   /          /  /   /  \____/  /   /
        \   /   /\   \  /          /  /   /       /  /   /
         \_/   /  \___\/ ___      /  /   /       /  /   /
          /   /   /     /  /\    /  /   /       /  /   /
         /   /   /     /  /__\__/  /   /       /  /___/____
        /___/   /     /___________/   /       /___________/\
        \   \  /      \           \  /        \           \ \
         \___\/        \___________\/          \___________\/

          A FAN OF FIZZYDAVID

*/

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//orz jzm
#define ll long long
#define ull unsigned ll
#define orz int
#define yjz main
#define fizzydavid return
#define ak 0
#define la ;
#define plusonesecond {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define minusonesecond exit(0)
const double EPS = 1e-8;
const ll PR = 19260817;
const ll inv2 = 500000004;
const ll inv3 = 333333336;
int a[100005];
orz yjz() {
	int n, tt;
	scanf("%d%d", &n, &tt);
	for(int i =0; i<n; i++)
		scanf("%d", &a[i]);
	int mx=0, ans=0;
	for(int i =n-1; i>=0; i--) {
		mx=max(mx, a[i]);
		a[i]=mx-a[i];
		ans = max(ans, a[i]);
	}
	int cnt=0;
	for(int i =0; i<n; i++)
		if(ans==a[i]) cnt++;
	printf("%d\n", cnt);
	fizzydavid ak la
}

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

void swap(int a, int b, int *A){
	int tmp = A[a];
	A[a] = A[b];
	A[b] = tmp;
}

int main(){
	int N, M, i, odd_num = 0;
	scanf("%d%d", &N, &M);
	int *A = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		scanf("%d", &A[i]);
		odd_num += A[i] % 2;
	}
	if(M == 1){
		if(A[0] == 1){
			printf("1\n");
			printf("1\n");
			printf("1\n");
		}
		else{
			printf("%d\n", A[0]);
			printf("2\n");
			printf("%d %d\n", 1, A[0] - 1);
		}
		return 0;
	}
	if(odd_num > 2){
		printf("Impossible\n");
		return 0;
	}
	if(odd_num > 0){
		for(i = 0; A[i] % 2 == 0; i++);
		swap(0, i, A);
		for(i = M - 1; A[i] % 2 == 0; i--);
		swap(i, M - 1, A);
	}
	for(i = 0; i < M; i++){
		printf("%d ", A[i]);
	}
	printf("\n");
	int *B = (int *)malloc(sizeof(int) * M);
	B[0] = A[0] - 1;
	for(i = 1; i < M - 1; i++){
		B[i] = A[i];
	}
	B[M - 1] = A[M - 1] + 1;
	if(B[0] == 0){
		printf("%d\n", M - 1);
	}
	else{
		printf("%d\n", M);
		printf("%d ", B[0]);
	}
	for(i = 1; i < M; i++){
		printf("%d ", B[i]);
	}
	printf("\n");
	return 0;
}

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

int A[100010];
int B[100010];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> A[i];
		B[A[i]] = i;
	}
	for (int i = 1; i <= n; i++) {
		cout << B[i];
		if (i != n) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    cout << min(n % k, k - (n % k)) << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import heapq

def main():
    """
    q:0.25l
    h:0.5l
    s:1l
    d:2l
    """
    q, h, s, d = [int(i) for i in input().strip().split()]
    n = int(input().strip())
    
    prices = list()
    heapq.heappush(prices, (q * 4, q, 0.25))
    heapq.heappush(prices, (h * 2, h, 0.5))
    heapq.heappush(prices, (s, s, 1))
    heapq.heappush(prices, (d / 2, d, 2))

    ans = 0
    _,price,size = heapq.heappop(prices)
    
    while n != 0:
        if size > n:
            _, price, size = heapq.heappop(prices)
            continue
        else:
            if size >= 1:
                ammount = n // size
                n = n % size
                ans += price * ammount
                continue
            else:
                ammount = int(n / size)
                ans += price * ammount
                break
    print(ans)
    return



if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int h, w;
  cin >> h >> w;
  
  int dif[h][w];
  int max = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> dif[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int tmp; cin >> tmp;
      dif[i][j] = abs(dif[i][j] - tmp);
      if (dif[i][j] > max) {
        max = dif[i][j];
      }
    }
  }
  int K = (max+1)*(h+w+1);
  bool dp[h][w][K];
  memset(dp, 0, sizeof(dp));
  dp[0][0][dif[0][0]] = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = 0; k < K; k++) {
        if (i) {
          if (dp[i-1][j][k]) {
            dp[i][j][abs(k - dif[i][j])] = true;
            if (k + dif[i][j] <= K) {
              dp[i][j][k + dif[i][j]] = true;
            }
          }
        }
        if (j) {
          if (dp[i][j-1][k]) {
            dp[i][j][abs(k - dif[i][j])] = true;
            if (k + dif[i][j] <= K) {
              dp[i][j][k + dif[i][j]] = true;
            }
          }
        }
      }
    }
  }
  
  for (int i = 0; i < K; i++) {
    if (dp[h-1][w-1][i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 81792
#include <stdio.h>

int max(int a, int b)
{
   if(a>b) return a;
   else return b;
}
int min(int a, int b)
{
   if(a<b) return a;
   else return b;
}

int main(void)
{
   int q1, b, c1, c2, q2;
   int qa;
   int hi, lo, ce;

   while(scanf("%d", &q1)){
      if(q1==0) break;
      scanf("%d %d %d %d", &b, &c1, &c2, &q2);

      qa=0;
      hi=q2;
      lo=1;
      while(hi>=lo){
         ce=(hi+lo)/2;
	 if(c1*ce+c2*max(q1-ce, 0)<=b){
	    lo=ce+1;
	    qa=ce;
	 }
	 else {
	    if(c1>=c2 || c1*ce>b) hi=ce-1;
	    else {
	       qa=min(b/c1, q2);
	       if(c1*qa+c2*max(q1-qa, 0)>b){
	          qa=0; break;
               }
	    }
	 }
      }
      if(qa==0) printf("NA\n");
      else printf("%d %d\n", qa, (b-c1*qa)/c2);
   }
   return 0;
}

Measured memory_bytes: 612
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll T;
	cin >> T;
	rep(t,0,T) {
		ll N;
		cin >> N;
		struct Camel {
			ll K;
			ll V;
		};
		vector<Camel> left;
		vector<Camel> right;
		ll ans = 0;
		rep(i,0,N) {
			ll K, L, R;
			cin >> K >> L >> R;
			ll loc_offset = min(L, R);
			L -= loc_offset;
			R -= loc_offset;
			ans += loc_offset;
			if (L > 0) {
				left.push_back({K, L});
			} else {
				right.push_back({N-K, R});
			}
		}
		rep(p,0,2) {
			vector<Camel>* camels = nullptr;
			if (p == 0) {
				camels = &left;
			} else {
				camels = &right;
			}
			priority_queue<ll> queue;
			unordered_map<ll, vector<ll>> pos_to_vals;
			rep(i,0,camels->size()) {
				pos_to_vals[(*camels)[i].K].push_back((*camels)[i].V);
			}
			rrep(i,N,0) {
				for (ll v : pos_to_vals[i+1]) {
					queue.push(v);
				}
				if (queue.size() > 0) {
					// cout << "t: " << t << ", p: " << p << ", i: " << i << ", v: " << queue.top() << endl;
					ans += queue.top();
					queue.pop();
				}
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 22524
d31 = [1, 3, 5, 7, 8, 10, 12]
d30 = [4, 6, 9, 11]
d28 = [2]

x, y = gets.split.map(&:to_i)

puts ((d31.include?(x) and d31.include?(y)) or (d30.include?(x) and d30.include?(y)) or (d28.include?(x) and d28.include?(y))) ? "Yes" : "No"

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

using namespace std;

int main(){
    long int n;
    cin>>n;
    long int enemies[n+1];
    long int heroes[n];
    long int HERO=0;
    
    for(int i=0;i<n+1;i++){
        cin>>enemies[i];
    }
    for(int i=0;i<n;i++){
        cin>>heroes[i];
    }

for(int i=0;i<n;i++){
    if(heroes[i]>enemies[i]){
        if(enemies[i]+enemies[i+1]<heroes[i]){
                HERO+=(enemies[i]+enemies[i+1]);
                enemies[i+1]=0;
        }
        else{
           enemies[i+1]-=(heroes[i]-enemies[i]);
        HERO+=heroes[i]; 
        }
    }
    
    else if(heroes[i]==enemies[i]){
        HERO+=heroes[i];
    }
    
    else if(heroes[i]<enemies[i]){
        HERO+=heroes[i];
    }
}
    cout<<HERO<<endl;
   return 0;
}


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

using ll = long long;
const int limit = 100010;
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v,int p, ll d){
	depth[v] = d;
	for(auto &e : tree[v]){
		if(e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

int main(){
	int n;
	 cin >> n;
	 for(int i = 0; i < n - 1; i++){
	 	int a, b, c;
		 cin >> a >> b >> c;
		 tree[a].push_back({b, c});
		 tree[b].push_back({a, c});
	 }
	 int q, k;
	 cin >> q >> k;
	 k;
	 
	 dfs(k, -1, 0);
	 for(int i = 0; i < q; i++){
	 	int x, y;
		 cin >> x >> y;
		 x, y;
		 cout << depth[x] + depth[y] << endl;
	 }

	 return 0;
}


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

using namespace std;

int main()
{
    long long x,a=0,b=0,c=0,d=0,e=0;
    cin>>x;
    while(x>=500)
    {
        a=a+1000;
        x=x-500;
    }
    while(x>=100)
    {
        b=b+100;
        x=x-100;
    }
    while(x>=50)
    {
        c=c+50;
        x=x-50;
    }
    while(x>=10)
    {
        d=d+10;
        x=x-10;
    }
    while(x>=5)
    {
        e=e+5;
        x=x-5;
    }
    cout<<a+b+c+d+e;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    long long b[n] = {0};
    long long sum = 0;
    for(int i=0; i<n; i++){
        sum += a[i];
    }
    for(int i=1; i<=n-2; i+=2){
        sum -= 2*a[i];
    }
    b[0] = sum;
    cout << b[0] << ' ';
    for(int i=1; i<n; i++){
        b[i] = 2*a[i-1] - b[i-1];
        cout << b[i] << ' ';
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 2432
# すぬけくんはレストランに通うのが好きです。
# すぬけくん行きつけのレストランは何を食べても
# 1食 800円で、15食食べる毎にその場で200円もらえます。
# すぬけくんは今までで合計 N食食べました。
# 今までに払った金額を x円、
# レストランからもらった金額を y 円として、
# x − y を求めなさい。

# 制約
# 1 <= N <= 100

# 整数をNに入力できるようにする

N = int(input())

# 今までに払った金額　N * 800 = x
x = N * 800

# レストランからもらった金額yを計算
y = N // 15 * 200

# x-y
print(x-y)


Measured memory_bytes: 9080
#include <stdio.h>
int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)>(a-b)){
		if((a+b)>(a*b)){
			printf("%d",a+b);
		}else{
			printf("%d",a*b);
		}
	}else if((a-b)>(a*b)){
		printf("%d",a-b);
	}else{
		printf("%d",a*b);
	}
	return 0;
}

Measured memory_bytes: 256
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
N=int(input())
for i in range(N):
  b = int(input())
  for k in range(3):
    if A[k]==b:
      A[k]=0
    if B[k]==b:
      B[k]=0
    if C[k]==b:
      C[k]=0 
if (A[0]==A[1]==A[2]) or (B[0]==B[1]==B[2]) or (C[0]==C[1]==C[2]) or (A[0]==B[0]==C[0]) or (A[1]==B[1]==C[1]) or (A[2]==B[2]==C[2]) or(A[0]==B[1]==C[2]) or (A[2]==B[1]==C[0]):
  print('Yes')
else:
  print('No')

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n),c(n);
    for(int i = 0; i < n; i++){
        cin >> v.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> c.at(i);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += max(v.at(i) - c.at(i),0);
    }
    cout << ans << endl;
}


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

  struct input{
   public long a;
   public long b;
  }

class MainClass {
  static input input; 

  public static void Main (string[] args) {
    
    var temp = Console.ReadLine().Split(' ').Select(long.Parse);
    input.a = temp.ElementAt(0);
    input.b = temp.ElementAt(1);
    var n = input.b - input.a;
    Console.WriteLine(n * (n-1) / 2 - input.a);
  }
}

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

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int a, b; cin >> a >> b;
    if(a < b) swap(a, b);
    if(a < 9) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

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

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void Countsort(int ,int ,unsigned short *,unsigned short *);
void Countsort(int n,int k,unsigned short *A,unsigned short *B)
{
  int i,C[VMAX+1];

  for( i=0; i<=k; i++ )
    C[i] = 0;

  for( i=1; i<=n; i++ )
    C[A[i]]++;

  for( i=1; i<=k; i++ )
    C[i] = C[i] + C[i-1];

  for( i=n; i>=1; i-- )
    {
      B[C[A[i]]] = A[i];
      C[A[i]]--;
    }
  for( i=1; i<n; i++)
    printf("%d ",B[i]);
  printf("%d\n",B[n]); 
}
    
int main()
{
  unsigned short *A, *B;
  int k=0,n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for( i=0; i<n; i++ )
    {
      scanf("%hd",&A[i+1]);
      if( k < A[i] ) k = A[i];
    }
  Countsort(n,k,A,B);

  return 0;
}



Measured memory_bytes: 9640
def main():
    N = int(input())
    A = list(map(int, input().split()))
    set_A = set(A)

    if len(set_A) % 2 == 0:
        print(len(set_A)-1)
    else:
        print(len(set_A))

if __name__ == "__main__":
    main()

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

ll N;
vector<vector<vector<double>>> dp(310, vector<vector<double>>(310, vector<double>(310, -1)));

double rec(ll i, ll j, ll k)
{
  if (dp[i][j][k] >= 0) return dp[i][j][k];
  if (i==0 && j==0 && k==0) return 0.0;
  double res = 0.0;
  if (i>0) res += rec(i-1, j, k) * i;
  if (j>0) res += rec(i+1, j-1, k) * j;
  if (k>0) res += rec(i, j+1, k-1) * k;
  res += N;
  res *= 1.0 / (i+j+k);
  return dp[i][j][k] = res;
}

int main()
{
  cin >> N;
  vector<ll> a(N);
  ll i=0, j=0, k=0;
  for (int l=0; l<N; l++){
    ll a; cin >> a;
    if (a==1) i++;
    else if (a==2) j++;
    else k++;
  }

  double ans = rec(i, j, k);
  printf("%.10lf\n", ans);

  return 0;
}

/*

dp[i][j][k] * ((N-i-j-k)/N)
dp[i-1][j][k] * (i/N)
dp[i+1][j-1][k] * (j/N)
dp[i][j+1][k-1] * (k/N)

X = X*(N-i-j-k)/N + A*i/N + B*j/N + C*k/N + 1
X(N-(N-i-j-k)) = A*i + B*j + C*k + N
X(i+j+k) = A*i + B*j + C*k + N
X = A*i + B*j + C*k + N * 1.0/(i+j+k)

*/


Measured memory_bytes: 237568
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b= sc.nextInt();
    int answer = 0;
    if(a>9||b>9){
      answer = -1;
    }else{
      answer = a*b;
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007
const int INF=1001001001;

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

ll ma[15][15];

int main(){
    ll n,m,x,ans=INF;
    cin >> n >> m >> x;
    
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m+1;j++){
            cin >> ma[i][j];
        }
    }
    
    vector<int> a(m,0);
    ll nedan=0;
    bool flag=true;
    
    for(ll i=0;i<(1<<n);i++){
        for(ll j=0;j<n;j++){
            if(i&1<<j){
                for(int k=0;k<m;k++){
                    a[k]+=ma[j][k+1];
                }
                nedan+=ma[j][0];
            }
        }
        for(int l=0;l<m;l++){
            if(a[l]<x) flag=false;
        }
        if(flag) ans=min(ans,nedan);
        
        for(int l=0;l<m;l++){
            a[l]=0;
        }
        nedan=0;
        flag=true;
    }
    
    if(ans==INF) ans=-1;
    
    cout << ans << endl;

    return 0;
}











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

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

Measured memory_bytes: 3632
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());

            int ans = 0;
            while(a <= b && c != 0 && b != 0){
                b -= a;
                c--;
                ans++;
            }

            System.out.println(ans);
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 23764
using System;

class Daydream
{
	static string S;
	static string[] str = {"dream", "dreamer", "erase", "eraser"};
	static public void Main(string[] args)
	{
		S = Console.ReadLine();
		if(search(0))
			Console.WriteLine("YES");
		else
			Console.WriteLine("NO");
	}

	static bool search(int i)
	{
		if(i == S.Length)
			return true;
		for(int j=0; j<str.Length; j++)
		{
			if(S.IndexOf(str[j], i) == i)
			{
				if(search(i+str[j].Length))
					return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 4056
#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#define fr first
#define sc second
using namespace std;

typedef pair<int, int> iP;
typedef pair<iP, int> iiP;

int n;
bool used[10][10];
iP s[10];
int pdx[] = {-2, -2, -2, 1, 1, 0, 0, -1, -1, 2, 2, 2}, pdy[] = {1, 0, -1, 2, -2, 2, -2, 2, -2, 1, 0, -1};
int sdx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}, sdy[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};

bool check(int x, int y, int i){
  
  for(int j = 0; j < 9; j++){
    int nx = s[i].fr + sdx[j], ny = s[i].sc + sdy[j];
    if(x == nx && y == ny) return true;
  }
  return false;

}

bool bfs(int sx, int sy){
  
  memset(used, false, sizeof(used));
  queue <iiP> que;
  que.push(iiP(iP(sx, sy), 0));
  while(!que.empty()){
    iiP p = que.front(); que.pop();
    int x = p.fr.fr, y = p.fr.sc;
    if(p.sc == n) return true;
    for(int i = 0; i < 12; i++){
      int nx = x + pdx[i], ny = y + pdy[i];
      if(nx < 0 || nx > 9 || ny < 0 || ny > 9 || used[ny][nx]) continue;
      if(check(nx, ny, p.sc)){
	que.push(iiP(iP(nx, ny), p.sc + 1));
	used[ny][nx] = true;
      }
    }
  }
  return false;

}
    
  
int main(){
  
  int sx, sy;
  while(cin >> sx >> sy, sx||sy){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> s[i].fr >> s[i].sc;
    
    cout << (bfs(sx, sy) ? "OK" : "NA") << endl;
  }

}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cctype>
#include <sstream>
#include <algorithm>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;

vector<int> sieve(int n) {
  vector<int> prime(n);
  for(int i=2; i<n; i++) prime[i]=i;
  for(int i=2; i*i<n; i++) {
    if(prime[i]) {
      for(int j=i*i; j<n; j+=i) prime[j]=0;
    }
  }
  return prime;
}

int main() {
  vector<int> prime=sieve(30000);
  vector<int> prime2=prime;
  prime.erase(remove(all(prime),0),prime.end());
  int n;
  while(cin >> n && n) {
    int cnt=0;
    for(int i=0; i<prime.size() && i*3<=n; i++) {
      for(int j=i; j<prime.size(); j++) {
	int a=prime[i],b=prime[j];
	int c=n-a-b;
	if(c<b) break;
	int sum=a+b+c;
	int z=max(a,max(b,c));
	if(z>=sum-z) continue;
	if(prime2[c]) cnt++;
      }
    }
    pr(cnt);
  }
  return 0;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
  return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
  if (P == 0)
  return 1;
  if (P % 2 == 0)
  {
    int t = mpow(N, P / 2, M);
    return t * t % M;
  }
  return N * mpow(N, P - 1, M) % M;
}
signed main()
{
  string S;
  cin >> S ;
  if(S == "SUN"){
    cout << "7" << endl;
  }else if(S == "MON"){
    cout << "6" << endl;
  }else if(S == "TUE"){
    cout << "5" << endl;
  }else if(S == "WED"){
    cout << "4" << endl;
  }else if(S == "THU"){
    cout << "3" << endl;
  }else if(S == "FRI"){
    cout << "2" << endl;
  }else if(S == "SAT"){
    cout << "1" << endl;
  }

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int a;
    int id;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a == 1) id = i;
    }
    auto f = [&](int l, int r) {
        int ans = 1;
        if (l > 0 && r >= n - 1) {
            ans += l / (k - 1) + min(1, l % (k - 1));
        } else if (l <= 0 && r < n - 1) {
            ans += (n - r - 1) / (k - 1) + min(1, (n - r - 1) % (k - 1));
        } else if (l > 0 && r < n - 1) {
            ans += (l + 1) / (k - 1) + min(1, (l + 1) % (k - 1)) +
                   (n - r - 1) / (k - 1) + min(1, (n - r - 1) % (k - 1));
        }
        return ans;
    };
    int ans = INT32_MAX;
    for (int l = 0; l < k; l++) {
        int r = l + k - 1;
        ans = min(ans, f(l, r));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from math import fabs

def main():
  N = int(input())

  cors = [list(map(int, input().split())) for _ in range(N)]
  cors_sorted = sorted(cors, key = lambda x: x[2], reverse=True)
  top_x, top_y, top_h = cors_sorted[0]

  for C_x in range(101):
    for C_y in range(101):
      H = top_h + fabs(top_x - C_x) + fabs(top_y - C_y)
      if all([h == max(H - fabs(x - C_x) - fabs(y - C_y), 0) for x,y,h in cors_sorted]):
        print(C_x, C_y, int(H))
        return


main()

Measured memory_bytes: 3064
import java.util.*; 

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

  		int[] a=new int[n];
		for(int c=0;c<n;c++){
    		a[c]=sc.nextInt();
    	}
  		int max1=a[0];
  		int max2=0;
  		int b1=0;
  		
  		
  		for(int b=0;b<n-1;b++){
        	if(max1<=a[b+1]){
              	max2=max1;
            	max1=a[b+1];
              	b1=b+1;
              	
            }else if(max2<=a[b+1]){
            	max2=a[b+1];
            }
        }
 
    for(int e=0;e<n;e++){
 	if(e==b1){
    		System.out.println(max2);
    	}else{
     		System.out.println(max1);
   	 }
    }
    }
}



Measured memory_bytes: 99236
#include<bits/stdc++.h>
using namespace std;
int n,m,c;
double x,y;
int main()
{
	int i;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=m)
		{
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

ll encode(const vi& a)
{
	ll x=0;
	rep(i,a.size()) x|=ll(a[i])<<i*4;
	return x;
}
vi decode(ll x)
{
	vi a;
	for(;x;x>>=4) a.push_back(x&15);
	return a;
}

int main()
{
	for(int n;cin>>n && n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		
		vi b(n); iota(all(b),1);
		if(a==b){
			cout<<0<<endl;
			continue;
		}
		
		queue<pair<ll,int>> q[2];
		unordered_map<ll,int> m[2];
		q[0].emplace(encode(a),0); m[0].insert(mp(encode(a),0));
		q[1].emplace(encode(b),0); m[1].insert(mp(encode(b),0));
		
		int res=INF;
		for(int k=0;;k^=1){
			queue<pair<ll,int>> tmp;
			while(q[k].size()){
				ll x; int t; tie(x,t)=q[k].front(); q[k].pop();
				if(m[k^1].count(x)){
					res=t+m[k^1][x];
					goto end;
				}
				vi a=decode(x);
				rep(i,n) repi(j,i,n){
					reverse(begin(a)+i,begin(a)+j+1);
					ll x=encode(a);
					if(!m[k].count(x)){
						tmp.emplace(encode(a),t+1);
						m[k][x]=t+1;
					}
					reverse(begin(a)+i,begin(a)+j+1);
				}
			}
			swap(q[k],tmp);
		}
		end:
		cout<<res<<endl;
	}
}

Measured memory_bytes: 93216