akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
 
class Program
{
    static void Main()
    {
        var xs = Console.In.ReadToEnd().TrimEnd()
            .Split()
            .Select(n => int.Parse(n))
            .ToArray();
        
        int k = xs[xs.Length - 1];
        int min = xs[0];
        int max = xs[xs.Length - 2];
        
        Console.WriteLine(max - min <= k ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
#include <climits>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int s = 1;
vector<int> dat;

void init(int n_) {
	while (s < n_)s *= 2;
	dat.resize(2 * s - 1);
}

void add(int k, int x) {
	k += s - 1;
	dat[k] = max(dat[k], x);
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
	}
}

int query(int a, int b, int k = 0, int l = 0, int r = s) {
	if (r <= a || b <= l)return 0;
	if (a <= l && r <= b)return dat[k];
	int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
	return max(vl, vr);
}

int n, k, a[300010];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n >> k;
	init(300001);
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		int ma = query(a[i] - k, a[i] + k + 1);
		add(a[i], ma + 1);
	}
	cout << query(0, s) << endl;
}

Measured memory_bytes: 8488
#include<cstdio> 
#include<cstring> 
const int maxn = 100007; 
char t[maxn]; 
int n,s[maxn]; 
int f[maxn]; 
const int mod = 1e9 + 7; 
int main() { 
	scanf("%s",t + 1); 
	n = strlen(t + 1); 
	bool flag = 0; 
	for(int i = 2;i <= n;++ i) if(t[i] == t[i - 1])flag = 1; 
	if(!flag) return !printf("1"); 
	int now = 0,pre[3] = {0,-1,-1}; f[0] = 1; 
	for(int i = 1;i <= n;++ i) { 
		now = (now + 2 - (t[i] == 'a')) % 3; 
		if(!now && i < n) f[i] = 1; ++ now,now %= 3; 
		if(pre[now] != - 1) (f[i] += f[pre[now]]) %= mod;  ++ now,now %= 3; 
		if(pre[now] != -1) (f[i] += f[pre[now]]) %= mod; ++ now,now %= 3; 
		pre[now] = i; 
	} 
	printf("%d",f[n]); 
} 

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size();
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int MOD=1e9+7;
int INF=1e9+7;
//
int N,M;
int S[100001];
int main(){
  cin>>N>>M;
  FOR(i,0,M){
    int a,b;
    cin>>a>>b;
    S[a]++;
    S[b]++;
  }
  FOR(i,1,N+1){
    if(S[i]%2){
      YES(0);
      return 0;
    }
  }
  YES(1);
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;

const int ans = 101234567;
int dx[] = {-1, 1, -4, 4, };

int swapnum(int n, int x, int y)
{
    int a[10];
    for(int i=8; i>=0; --i)
    {
        a[i] = n%10;
        n/=10;
    }
    swap(a[x], a[y]);
    int ret = 0;
    for(int i=0; i<9; i++) ret = ret*10+a[i];
    return ret;
}

int pos0(int n)
{
    int a[10];
    for(int i=8; i>=0; --i)
    {
        a[i] = n%10;
        n/=10;
    }
//    for(int i=0; i<=8; i++) cout << a[i] << "*";
//    cout << endl;
    for(int i=0; i<=8; i++) if(a[i] == 0) return i;
    return -1;
}

    map<int, int> d;
void bfs()
{
    int n = ans;
    queue<int> que;
    que.push(n);
    d[n] = 0;
    int now, nxt;
    while(!que.empty())
    {
        now = que.front(); que.pop();
//        if(now == ans) return d[ans];
        int pos = pos0(now);
        for(int i=0; i<4; i++)
        {
            if(pos == 4 && dx[i]==1) continue;
            if(pos == 5 && dx[i]==-1) continue;
            nxt = pos+dx[i];
            if(nxt<1 || nxt>8) continue;
            nxt = swapnum(now, pos, nxt);
            if(d.find(nxt)==d.end())
            {
                d[nxt] = d[now]+1;
                que.push(nxt);
            }
        }
    };
}

int main()
{
    bfs();
    int a, n=1;
    while(scanf("%d", &a) == 1)
    {
        n = n*10+a;
        for(int i=0; i<7; i++)
        {
            scanf("%d", &a);
            n = n*10+a;
        }
        cout << d[n] << endl;
        n=1;
    }

    return 0;
}

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

typedef long long ll;
 
const int INF= 1001001001;
const ll LINF= 1e18;

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int main(){
    string s;
    ll ans = 0;
    cin >> s;
    int t[s.size()+1] = {0};
    int n = s.size();
    int i = 0;
    while(1){
        if(i == n) break;
        if(s[i]=='<'){
            if(i==0){
                t[i] = 0;
                i++;
                continue;
            }
            if(s[i-1]=='>'){
                t[i] = 0;
                i++;
                continue;
            }
            t[i] = t[i-1] + 1;
            i++;
            continue;
        }
        if(s[i] == '>'){
            int j = 0;
            while(s[j + i + 1] == '>'){
                j++;
                if(i+j+1==n) break;
            }
            if(j >= t[i-1] || i==0 ){
                for(int k = i; k < i+j+1; k++) t[k] = j - k + i+1;
            }else{
                for(int k = i+1;k<i+j+1;k++) t[k] = j - k + i+1;
                t[i] = t[i-1] + 1;
            }

            i = i + j + 1;
        }
    }
    if(s[n-1]=='<') t[n] = t[n-1] + 1;
    else t[n] = 0;
    for(int i = 0; i < n; i++){
        ans+=t[i];
    }
    ans += t[n];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  int st = 0;
  int en = 0 + K;
  for(int i = 0; i < N - K; i++) {
    if(S.at(st) >= S.at(en)) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
    st++;
    en++;
  }
}

Measured memory_bytes: 4852
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n;
int h, w;
int a, b;

int main(){
  ios_base::sync_with_stdio(false);

  int ans = 0;

  cin >> n >> h >> w;

  for(int i=0;i<n;i++){
    cin >> a >> b;

    if(h <= a && w <= b){
      ans++;
    }

  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x)
{
	int f = 1; x = 0; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
}
const int N = 1e6 + 5;
int n, a[N];
inline int gcd(int x, int y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}
vector <int> prime;
bool vis[N];
inline void sieve()
{
	for (int i = 2; i <= 1000; i++)
	if (!vis[i])
	{
		prime.push_back(i);
		for (int j = i; j <= 1000; j += i) vis[j] = 1;
	}
}
int cnt[N];
inline void divide(int num)
{
	for (int i = 0; i < prime.size(); i++)
	if (num % prime[i] == 0)
	{
		cnt[prime[i]]++;
		while (num % prime[i] == 0) num /= prime[i];
	}
	if (num > 1) cnt[num]++;
}
int main(){
	read(n);
	sieve();
	for (int i = 1; i <= n; i++)
	{
		read(a[i]);
		divide(a[i]);
	}
	bool flag = 1;
	for (int i = 2; i <= N - 5; i++)
	if (cnt[i] > 1)
	{
		flag = 0;
		break;
	}
	if (flag)
	{
		puts("pairwise coprime");
		return 0;
	}
	int now = 0;
	for (int i = 1; i <= n; i++) now = gcd(now, a[i]);
	if (now == 1) puts("setwise coprime");
	else puts("not coprime");
  return 0;
} 

Measured memory_bytes: 11364
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
    char buf[2][201];
    char *p1 = buf[0];
    char *p2 = buf[1];

    while (scanf("%s\n", p1) && strcmp(p1, "-")) {
        int m;
        scanf("%d\n", &m);

        while (m--) {
            int h;  
            scanf("%d\n", &h);

            // shuffle
            int rest = strlen(p1) - h;
            memcpy(p2, p1 + h, rest);
            memcpy(p2 + rest, p1, h);
            *(p2 + h + rest) = '\0';

            // swap buffer
            char *t = p1;
            p1 = p2;
            p2 = t;
        }   
        puts(p1);
    }
}


Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool is(string s)
{
  int n = (int)s.size();
 	for(int i = 0 ; i < n/2 ; i++)
  	  if(s[i]!=s[n-1-i])
        return false;
  return true;
  
}
int main()
{
  string s; cin>>s;
  if(is(s))
  {
     int n = s.size();
    if(is(s.substr(0,(n-1)/2))&&is(s.substr((n+1)/2,(n-1)/2)))
      cout<<"Yes\n";
    else
      cout<<"No\n";
  }
  else
	  cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, H: "List[int]"):
    H = sorted(H,reverse=True)
    H = H[K:]
    print(sum(H))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 30592
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(void)
{
    char s;
    cin >> s;
    s++;
    cout << s << endl;

    return 0;
}
/** atcodr **/


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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    string s;
    int k;
    cin >> s >> k;

    int cnt = 0;
    char next;
    for (auto i : s) {
        if (i == '1')
            cnt++;
        else {
            next = i;
            break;
        }
    }

    if (cnt < k)
        print(next);
    else
        print(1);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

const long long MOD = 1000000000 + 7;

long long fastPow(long long v, long long p) {
    if (p == 0) {
        return 1;
    }

    long long hp = fastPow(v, p/2);
    hp *= hp;
    hp %= MOD;

    if (p%2) {
        hp *= v;
        hp %= MOD;
    }

    return hp;
}

int main() {
    string S;
    int K;
    cin >> K >> S;

    long long N = S.size();
    // a^(p-1) mod P = 1
    long long invP = fastPow(26, MOD-2);
    long long val = fastPow(26, K);
    long long ans = 0;
    long long mul = 1;

    for (int k = 0; k <= K; ++k) {
        // H (K N)
        // C(K+N-1 N-1)
        ans += mul * val;
        ans %= MOD;

        mul *= (k+N);
        mul %= MOD;
        mul *= fastPow(k+1, MOD-2);
        mul %= MOD;

        val *= invP;
        val %= MOD;

        val *= 25;
        val %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5336
/*
ID: darynbo2
TASK: ride
LANG: C++14                 
*/
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define all(s) s.begin(),s.end()
#define ld long double

using namespace std;

const int maxn = 1e5 + 7;
const ld eps = 1e-6;
const ll inf = 1e9 + 7;

string s;
int x, y;
int curx = 0, cury = 0;
int dir = 1;
vector<int> vec;      
map<int,int> dp1,dp2,dp3,dp4;

int main() {
	cin >> s;
	cin >> x >> y;
	int cur = 0;          
	s.pb('T');
	bool check = 1;
	bool p = 0;
	       
	vector<int>fir,sec;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'T') {
			if (check) {
				x-=cur;
				cur = 0;
				check = 0;
			}
			else {
				if (!p)fir.pb(cur);
				else sec.pb(cur);
				cur = 0;
				p ^= 1;
			}
		}
		else cur++;
	}                  
	sort (fir.begin(), fir.end());
	reverse (fir.begin(), fir.end());
	sort (sec.begin(), sec.end());
	reverse (sec.begin(), sec.end());
	for (int i = 0; i < fir.size(); i++) {
		if (abs(y + fir[i]) > abs(y - fir[i])) y-=fir[i];
		else y+=fir[i];
	}
	for (int i = 0; i < sec.size(); i++) {
		if (abs(x + sec[i]) > abs(x - sec[i])) x-=sec[i];
		else x+=sec[i];
	}
	if (x == 0 && y == 0) cout << "Yes";
	else cout << "No";
	return 0;
}


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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    int n;

    cin >> n;

    cout << ceil(n*1.0/2) << endl;





    return 0;
}




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

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

int main(){
	string s; cin>>s;
	int sum = 0;
	for(int i=0; i<s.length(); i++) sum += s[i]-'0';
	if(sum%9==0) cout<<"Yes";
	else cout<<"No";
}



Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int main() {
	int n, m, temp, sum = 0;
	cin >> n >> m;
	
	for(int i = 0; i < m; i++) {
		cin >> temp;
		sum += temp;
	}
	
	cout << (n-sum < 0 ? -1 : n-sum) << endl;
		
	return 0;
}

















Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing if(db)cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, k, A[MAXN], dp[MAXN];
bool win = 0;
bool dpdp(ll k)
{
	// if(k<0)return 1;
	if(~dp[k]) return dp[k];
	dp[k] = 0;
	if(k==0){ return dp[k] = 0; }
	FOR(i,0,n)
	{
		if(k>=A[i])dp[k] |= (!dpdp(k - A[i]));
	}
	// cout << k << ' ' << dp[k] << '\n';
	return dp[k];
}
int main()
{
	cin >> n >> k;
	FOR(i,0,n) cin >> A[i];
	mmst(dp, -1);
	cout << (dpdp(k/*, 0*/)/*;*/ ? "First\n" : "Second\n") << '\n';
}


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

int flag[4];

int main(){
  int N;
  cin>>N;
  char S[100];
  for(int i=0;i<N;i++){
    cin>>S[i];
    if(S[i]=='P') flag[0]++;
    else if(S[i]=='W') flag[1]++;
    else if(S[i]=='G')flag[2]++;
    else flag[3]++;
  }
  int cnt=0;
  for(int i=0;i<4;i++){
    if(flag[i]) cnt++;
  }
  switch(cnt){
    case 3:cout<<"Three"<<endl;break;
    case 4:cout<<"Four"<<endl;break;
  }
  return 0;   
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> counter(3);
    rep(i,3) counter[i] = 0;
    rep(i,n)
    {
        if(a[i]%2==0)
        {
            if (a[i]%4==0)
            {
                counter[2]++;
            }else
            {
                counter[1]++;
            } 
        }else
        {
            counter[0]++;
        } 
    }
    if(counter[1]==0)
    {
        if(counter[2]>=counter[0]-1)
        {
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
        return 0;
    }
    if(counter[2]>=counter[0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, N, D = 0, L, count = 0;
  cin >> N >> X;
  for (int i = 0; i < N; i++){
    cin >> L;
    D = D + L;
    if (D > X){
      count = i + 1;
      cout << count << endl;
      break;
    }
  }

  if (count == 0){
    count = N + 1;
    cout << count << endl;
  }

}

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

int main() {
  int N, M, P;
  cin >> N >> M;
  int ds = 0;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(M);
  vector<int> d(M);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  for(int i = 0; i < M; i++) {
    cin >> c.at(i) >> d.at(i);
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      if(j == 0) {
        ds = abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
        P = j+1;
      }
      else {
        if(ds > abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j))) {
          P = j+1;
          ds = abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
        }
      }
    }
    cout << P << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
#define rep(i,n) for (int i = 0; i < n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;

struct edge{int to, cost;};

int main(){
	int n;
	cin >> n;
	vector<edge> G[100010];
	for (int i = 0; i < n-1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--;v--;w %= 2;
		G[u].push_back({v,w});
		G[v].push_back({u,w});
	}
	int root = 0;
	rep(i,n){
		if(G[i].size() == 1) root = i;
	}
	queue<pi> que;
	int used[100010] = {0};
	que.push(make_pair(root, 0));
	used[root] = true;
	int ans[100010];
	ans[root] = 0;
	while(!que.empty()){
		pi p = que.front(); que.pop();
		int node = p.first, color = p.second;
		rep(i,G[node].size()){
			int to = G[node][i].to;
			int cost = G[node][i].cost;
			if(used[to])continue;
			used[to] = 1;
			que.push(make_pair(to, cost ^ color));
			ans[to] = cost ^ color;
		}
	}
	rep(i,n) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;
struct P{long double x,y;};
#define rep(i,n) for(int i=0;i<n;i++)

const long double EPS = 1e-15;

vector<P> cross(P a, P b){
	vector<P> ret;
	
	long double x = a.x - b.x , y = a.y - b.y;
	long double L = x * x + y * y;
	if(L > 4.0)return ret;
	
	L = sqrt(L);
	long double C = atan2(b.y-a.y,b.x-a.x);
	long double alpha = acos(L/2);
	
	P r1,r2;
	r1.x = a.x + cos(C+alpha) , r1.y = a.y + sin(C+alpha);
	r2.x = a.x + cos(C-alpha) , r2.y = a.y + sin(C-alpha);
	
	ret.push_back(r1) , ret.push_back(r2);
	
	return ret;
}

bool check(P cir , P pt){
	cir.x -= pt.x , cir.y -= pt.y;
	//if(pt.x>10.0 + EPS || pt.y>10.0+EPS || pt.x<0.0 || pt.y<0.0)return false;
	return (cir.x*cir.x + cir.y * cir.y) <= 1.0 + EPS;
}
int main(){
	int n;
	while(scanf("%d",&n) && n){
		int ret = 1;
		vector<P> data(n);
		vector<P> search;
		rep(i,n)scanf("%Lf,%Lf\n",&data[i].x,&data[i].y);
		
		rep(i,n){
			for(int j=i+1;j<n;j++){
				vector<P> get = cross(data[i],data[j]);
				//cout << "(" << data[i].x << "," << data[i].y << ")" << " and " << "(" << data[j].x << "," << data[j].y << ") = ";
				rep(k,get.size()){
				//	cout << " " << "(" << get[k].x << "," << get[k].y << ")" << " ";
					search.push_back(get[k]);
				}
				//cout << endl;
			}
		}
		rep(i,search.size()){
			int count = 0;
			rep(j,n){
				count += check(data[j],search[i]);
			}
			//cout << search[i].x << "," << search[i].y << " is " << count << endl;
			ret = max(ret,count);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;
int selectionsort(int a[],int n){
    int count =0;
    for(int i=0; i<n;i++){
        int min =i;
        
        for (int j=i;j<n;j++){
            if (a[j]<a[min]){
                min=j;
            }
        }
        int amin=a[min];
            a[min]=a[i];
            a[i]=amin;
           if(i!=min) count+=1;
    }
    return count;
}

int result (int a[],int n,int count){
    for (int i=0;i<n-1;i++){
        cout << a[i] <<" ";
    }
    cout << a[n-1] << endl;
    cout << count <<endl;
    return 0;
}




int main() {
    int a[103],n,count;
    cin >>n;
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    count =selectionsort(a,n);
    result (a,n,count);
    return 0;
}


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

#define DEBUG

#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

//#define int long long
typedef long long ll;
constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

int dp[10004];

decltype(1) main() {
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i <= h; ++i) {
        dp[i] = INF;
    }
    dp[h] = 0;
    for (int i = h; i > 0; --i) {
        for (int j = 0; j < n; ++j) {
            const int nx = max(i - a[j], 0);
            dp[nx] = min(dp[nx], dp[i] + b[j]);
        }
    }
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
 
signed main()
{
  int n,k;
  cin>>n>>k;
  if(n<k)
    cout<<min(n,k-n);
  else if(!(n%k))
	cout<<0;
  else
    cout<<k-n%k;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	string str;
	int K;

	cin >> str >> K;

	for (int i = 0; i < K; i++) {
		if (str[i] != '1') {
			cout << str[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;

	return 0;
}


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

int k, n, a[200005], mx;

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

    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (i) {
            mx = max(mx, a[i] - a[i-1]);
        }
    }
    mx = max(mx, a[0] + k-a[n-1]);

    cout << k - mx << endl;
}


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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

ll N, T;

int main()
{
	ll ret = 0;
	cin >> N >> T;
	ll t1, t2;
	cin >> t1;
	t2 = t1 + T;
	for( ll i=1; i<N; i++ ){
		ll t;
		cin >> t;
		if( t > t2 ){
			ret += t2 - t1;
			t1 = t;
		}
		t2 = t + T;
	}
	ret += t2 - t1;

	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 256
# C - Replacing Integer
# https://atcoder.jp/contests/abc161/tasks/abc161_c

N,K = list(map(int,input().split()))

# while 1 != 0:
#     if N - K >= 0:
#         N = abs(N - K)
#     else:
#         print(N)
#         exit()

# Nの数が大きすぎるとタイムアウトする
# 求める最小値がN/Kの余りかK-(N/K)の余りであることを利用して解く。

# 7%3 -> 1
# 3-(7%3) -> 2

print(min((N%K),K-(N%K)))

Measured memory_bytes: 3068
#include"bits/stdc++.h"
 
using namespace std;
 
typedef long long LL;
 
const int N=132005;
 
struct pr{
	LL in,out;
	pr(LL _i=0,LL _o=0){in=_i,out=_o;}
};
vector<pr>dp[N],temp1,temp2;
vector<int>e[N];
int n,fa[N],dis[N],son[N][2],d[N];
LL deep[N],lim;
 
void insert(vector<pr>&v,const pr&i){
	int p=v.size()-1;
	if(!~p)v.push_back(i);
	else if(i.out<v[p].out)v.push_back(i);
}
 
void vector_merge(vector<pr>&v,vector<pr>&l,vector<pr>&r){
	v.clear();
	int x=l.size(),y=r.size(),p=0,q=0;
	if(!y)return;
	while(p!=x){
		while(q!=y&&l[p].out+r[q].in<=lim)q++;
		if(q)q--;
		if(l[p].out+r[q].in<=lim)v.push_back(pr(l[p].in,r[q].out));
		p++; 
	}
}
 
void merge_sort(vector<pr>&v,vector<pr>&l,vector<pr>&r){
	v.clear();
	int x=l.size(),y=r.size(),p=0,q=0;
	while(p!=x||q!=y){
		if(p==x)insert(v,r[q++]);
		else if(q==y)insert(v,l[p++]);
		else if(l[p].in<r[q].in)insert(v,l[p++]);
		else insert(v,r[q++]);
	}
}
 
void dfs(int x){
	if(!d[x]){
		dp[x].clear();
		dp[x].push_back(pr(deep[x],deep[x]));
		return;
	}
	int ls=son[x][0],rs=son[x][1];
	dfs(ls),dfs(rs);
	lim+=2*deep[x];
	vector_merge(temp1,dp[ls],dp[rs]);
	vector_merge(temp2,dp[rs],dp[ls]);
	merge_sort(dp[x],temp1,temp2);
	lim-=2*deep[x];
}
 
int main(){
//	freopen("travel.in","r",stdin);
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d%d",fa+i,dis+i);
		deep[i]=deep[fa[i]]+dis[i];
		son[fa[i]][d[fa[i]]++]=i;
	}
	LL l=0,r=1E13,ans=(l+r)>>1;
	while(l<r){
		lim=ans,dfs(1);
		if(dp[1].size())
			r=ans;
		else
			l=ans+1;
		ans=(l+r)>>1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int dp[3100][3100];
char s[3100], t[3100], ans[3100];

int max(int a, int b) {
    return (a > b ? a : b);
}

int main() {
    scanf("%s%s", s, t);
    int n = strlen(s), m = strlen(t);

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i == 0 || j == 0) dp[i][j] = 0;
            else {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    int r = n, c = m, id = dp[n][m];
    ans[id] = '\0'; id--;
    while (r > 0 && c > 0) {
        if (s[r - 1] == t[c - 1]) {
            ans[id--] = s[r - 1];
            r--, c--;
        }
        else if (dp[r - 1][c] > dp[r][c - 1]) r--;
        else c--;
    }

    printf("%s\n", ans);
}

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

int main(){

  int n;

  while(1){

    cin >> n;
    if(n < 0) break;

    string s;

    while(1){
      s += (n%4 + 48);

      n /= 4;
      if(n == 0) break;
    }

    for(int i=s.size()-1;i >= 0;i--) cout << s[i];
    cout << endl;
  }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vi> g(h + 2, vi(w + 2, -1));
  stack<pair<int, int>> st;
  int num = 1;
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    char c;
    cin >> c;
    if(c == '#') {
      g[i][j] = num;
      num++;
      st.push(P(i, j));
    } else {
      g[i][j] = 0;
    }
  }
  while(!st.empty()) {
    int i = st.top().first;
    int j = st.top().second;
    st.pop();
    rep(k, 2) {
      int nj = j + 2 * k - 1;
      if(g[i][nj] != 0) continue;
      g[i][nj] = g[i][j];
      st.push(P(i, nj));
    }
  }
  rep2(i, 1, h + 1) {
    if(g[i][1] != 0 && (g[i + 1][1] == 0 || g[i - 1][1] == 0)) {
      rep2(j, 1, w + 1) st.push(P(i, j));
    }
  }
  while(!st.empty()) {
    int i = st.top().first;
    int j = st.top().second;
    st.pop();
    rep(k, 2) {
      int ni = i + 2 * k - 1;
      if(g[ni][j] != 0) continue;
      g[ni][j] = g[i][j];
      st.push(P(ni, j));
    }
  }
  rep2(i, 1, h + 1) {
    rep2(j, 1, w + 1) cout << g[i][j] << ' ';
    cout << '\n';
  }
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
#define  fi0(i,n)  for(int i=0;i<n;i++)
#define   pb()    push_back()
#define   mk()    make_pair()
#define   fst      first
#define   scnd    second
#define   fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define   endl     '\n';
using namespace std;
ll d(ll i)
{
}
void solve()
{
   int t;cin>>t;int k=1;while(t--){
   double t_r,r,b;
   cin>>t_r>>r>>b;
    double c_r,r_r;
   if(t_r<=r){
      r_r=0;
   }
   else{
      double d=t_r-r+1;
      r_r=d/(b/6);
   }
    b=300-b;
    if(b<=0){
      c_r=0;
    }
    else{
      c_r=(r)/(b/6);
    }
    cout<<setprecision(2)<<fixed<<c_r<<' '<<r_r<<endl;
}
}
void f()
{
    vector<string>xxx;
    cin.ignore();
    string s,test;
    getline(cin,s);
    reverse(s.begin(),s.end());
    for(int i=0; i<s.size(); i++)
    {
        if(i==s.size()-1)
        {
            test+=s[i];
            xxx.push_back(test);
            break;
        }
        if(s[i]!=' ')
        {
            test+=s[i];
        }
        else if(s[i]==' ')
        {
            xxx.push_back(test);
            test="";
        }
    }
    for(int i=0; i<xxx.size(); i++)
    {
        reverse(xxx[i].begin(),xxx[i].end());
        cout<<xxx[i]<<' ';
    }
}
void ff()
{
    int terget,run,ball;
    cin>>terget>>run>>ball;
    int r_run=terget-run+1;
    double over=50-(double)(ball)/6;
    double c_r_r=(double) run/over;
    double r_r_r=r_run/((double)(ball)/6);

    cout<<setprecision(2)<<fixed<<c_r_r<<' '<<r_r_r<<endl;
}
void mrge(int *arr,int low,int mid,int high){
    int i=low,k=low,j=mid+1,test[high];
    while(i<=mid&&j<=high){
      if(arr[i]<arr[j]){
        test[k++]=arr[i++];
      }
      else{
        test[k++]=arr[j++];
      }
    }
    while(i<=mid){
      test[k++]=arr[i++];
    }
    while(j<=high)test[k++]=arr[j++];
    for(int i=low;i<=high;i++)arr[i]=test[i];
}
void srt(int *arr,int low,int high){
  int mid;
   if(low<high){
  mid=(low+high)/2;
  srt(arr,low,mid);
  srt(arr,mid+1,high);
  mrge(arr,low,mid,high);
   }
   else return;
}
bool isprime(ll n){
  bool x=0;
  if(n==1)return x;
  for(int i=2;i*i<=n;i++){
    if(!(n%i))return x;
  }
  return !x;
}
vector<ll>save(){
      vector<ll>a;
      for(ll i=2;i<=100000;i++){
      if(isprime(i))a.push_back(i);
    }
    return a;
}
ll n=100007;
bool sa[100007];
void saive(){
    sa[2]=1;
    for(ll i=3;i<=n;i+=2){
            bool x=0;
        for(ll j=2;j*j<=i;j++){
            if(i%j==0){x=1;break;}
        }
        if(!x){sa[i]=1;}
    }
}
int main()
{
    fast;
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')s+="es";
    else s+='s';
    cout<<s<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n;
int main(){
  cin>>n;
  vector<int> v(101,0);
  for(int a=1;a<=n;a++){
    int b=a;
    for(int i=2;i<=b;i++){
      while(b%i==0){
        b/=i;
        v[i]++;
      }
    }
  }
  sort(v.begin(),v.end());
  int ans=0;
  int num2=v.end()-lower_bound(v.begin(),v.end(),2);
  int num4=v.end()-lower_bound(v.begin(),v.end(),4);
  int num14=v.end()-lower_bound(v.begin(),v.end(),14);
  int num24=v.end()-lower_bound(v.begin(),v.end(),24);
  int num74=v.end()-lower_bound(v.begin(),v.end(),74);
  //cout<<num2<<" "<<num4<<endl;
  ans+=num74;
  //cout<<ans<<endl;
  ans+=num24*(num2-1);
  //cout<<ans<<endl;
  ans+=num14*(num4-1);
  //cout<<ans<<endl;
  ans+=((num4*(num4-1))/2)*(num2-2);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for _ in range(h)]

a = [ai for ai in a if set(ai) != {'.'}]
a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))]
a = [ai for ai in a if set(ai) != {'.'}]
a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))]

for ai in a:
    print(ai)


Measured memory_bytes: 3064
num=int(input())
for i in range (num):
    info=list(map(float,input().split()))
    info=list(map(lambda x:int(x*10**10),info))
    if info[2]==info[0]:
        if info[6]==info[4]:
            print("YES")
        else:
            print("NO")
    elif info[6]==info[4]:
        if info[2]==info[0]:
            print("YES")
        else:
            print("NO")
    else:
        if (info[3]-info[1])/(info[2]-info[0])==(info[7]-info[5])/(info[6]-info[4]):
            print("YES")
        else:
            print("NO")

Measured memory_bytes: 7556
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#define ll long long
#define vel vector<int>
#define vvel vector<vel>
#define veb vector<bool>
#define pin pair<int,int>
#define mp make_pair 
using namespace std;
int main() {
	double ans = 0;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		double x; cin >> x;
		string u; cin >> u;
		if (u == "JPY") { ans += x; }
		else { ans += x * 380000; }
	}
	printf("%6.9lf", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const double PI  = acos(-1.0);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF  = 0x3f3f3f3f3f3f3f3f;
const int N=3e5+10;
const int M=1e6+10;
const int mod=1e9+7;
inline LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
inline LL lcm(LL a, LL b) { return a * b / gcd(a, b); }
inline LL read(){LL x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}return x*f;}
inline LL qpow(LL x,LL k=mod-2,LL m=mod){LL res=1;while(k){if(k&1) res=res*x%m;x=x*x%m;k>>=1;}return res;}
/*=================================================================================================================*/


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


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n/10 == 9 || n%10 == 9){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
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 = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll 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(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct Hint {
    int x, y, h;
};

ll check(int x, int y, vector<Hint> &hints) {

    vector<ll> over;
    vector<ll> match;

    for (Hint hint : hints) {
        if (hint.h == 0) {
            ll md = abs(hint.x - x) + abs(hint.y - y);
            ll h = hint.h + md;
            over.push_back(h);
        } else {
            ll md = abs(hint.x - x) + abs(hint.y - y);
            ll h = hint.h + md;
            match.push_back(h);
        }
    }

    assert(!match.empty());

    ll ma = *max_element(match.begin(), match.end());
    ll mi = *min_element(match.begin(), match.end());
    if (ma != mi) return -1;

    for (ll o : over) if (o < ma) return -1;
    return ma;
}

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

    vector<Hint> hints(n);
    rep(i, n) cin >> hints[i].x >> hints[i].y >> hints[i].h;

    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
            ll h = check(x, y, hints);
            if (h != -1) {
                printf("%d %d %lld\n", x, y, h);
            }
        }
    }
}

Measured memory_bytes: 256
import copy

N = int(input())
P = [int(x) for x in input().split()]
mano = []
min = N+1
for i in range(N):
    if P[i] < min:
        min = P[i]
    mano.append(min)

count = 0
for i in range(N):
    if mano[i] >= P[i]:
        count += 1
print(count)


Measured memory_bytes: 33200
n, k = map(int, input().split())
A = [0] + list(map(int, input().split()))

# 訪問順
B = [1]

# 訪問済み
C = [False] * (n + 1)
C[1] = True


while True:
    B.append(A[B[-1]])
    if C[B[-1]]:
        break
    C[B[-1]] = True

s = B.index(B[-1])

if k < s:
    print(B[k])
    exit()

B = B[B.index(B[-1]):-1]
print(B[(k - s) % len(B)])

Measured memory_bytes: 32376
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

long long absb(long long a){
	if(a<0)a=a*(-1);
	return a;
}

int main(){
	int a,b,q,i,y,j;
	long long s[100000],t[100000],x[100000],ans[100000];
	scanf("%d%d%d",&a,&b,&q);
	for(i=0;i<a;i++)scanf("%lld",&s[i]);
	for(i=0;i<b;i++)scanf("%lld",&t[i]);
	for(i=0;i<q;i++)scanf("%lld",&x[i]);
	for(y=0;y<q;y++){
		int al=-1,au=a,bl=-1,bu=b;
		if(a>1){while(au-al>1){
			int mid=(al+au)/2;
			if(s[mid]>=x[y])au=mid;
			else al=mid;
		}}
		else al=au=0;
		if(a>1&&au==0&&al==-1)al=0;
		if(a>1&&al==a-1&&au==a)au=a-1;
		if(b>1){while(bu-bl>1){
			int mid=(bl+bu)/2;
			if(t[mid]>=x[y])bu=mid;
			else bl=mid;
		}}
		else bl=bu=0;
		if(b>1&&bu==0&&bl==-1)bl=0;
		if(b>1&&bl==b-1&&bu==b)bu=b-1;
		ans[y]=200000000000;
		long long  tr[2]={absb(x[y]-s[al]),absb(x[y]-s[au])};
		long long  sr[2]={absb(x[y]-t[bl]),absb(x[y]-t[bu])};
		if(x[y]-s[al]>=0&&x[y]-t[bl]>=0)ans[y]=max(tr[0],sr[0]);
		if(x[y]-s[au]<=0&&x[y]-t[bu]<=0)ans[y]=min(ans[y],max(tr[1],sr[1]));
		if(s[al]<=x[y]&&x[y]<=t[bu])ans[y]=min(ans[y],tr[0]+sr[1]+min(tr[0],sr[1]));
		if(t[bl]<=x[y]&&x[y]<=s[au])ans[y]=min(ans[y],tr[1]+sr[0]+min(tr[1],sr[0]));
	}
	for(i=0;i<q;i++)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct problems {
    int num;
    int bonus;
};

/// bit配列のインクリメント
/// 全てが1になったらfalseを返す
bool abc(vector<int> &x, int index, int limit) {
    if(x[index] == 0) {
        x[index] = 1;
        return true;
    }
    else {
        if(index == limit) {
            return false;
        }
    }
    
    x[index] = 0;
    return abc(x, index + 1, limit);
}

void showBit(vector<int> &bit) {
    cout << "[ ";
    for(int i = 0; i < bit.size(); i++) {
        cout << bit[i] << " ";
    }
    cout << "]" << endl;
}

int main() {
    int d, g;
    cin >> d >> g;
    
    vector<problems> v(d);
    for(int i = 0; i < d; i++) {
        cin >> v[i].num >> v[i].bonus;
    }
    
    vector<int> bit(d, 0);
    int ans = 1010;
    do {
        int max_point = 0;
        int max_num = 0;
        int p_num = 0;
        int p_point = 0;
        for(int i = 0; i < d; i++) {
            if(bit[i] == 1) {
                p_num += v[i].num;
                p_point += v[i].bonus + (v[i].num * (i + 1) * 100);
            }
            else {
                max_point = max(max_point, (i + 1) * 100);
                max_num = v[i].num;
            }
        }
        
        if(p_point < g) {
            int cnt = ceil((g - p_point) / (double)max_point);
            
            if(cnt < max_num) {
                p_num += cnt;
            }
            else {
                continue;
            }
        }
        
        ans = min(ans, p_num);

    } while(abc(bit, 0, d - 1));
    
    cout << ans << endl;
    
    return 0;
}


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

int main(void){
    string S;cin>>S;
    int ans=753;
    for(int i=0;i<S.size()-2;i++){
        string tmp;
        tmp=S.substr(i,3);
        int X=abs(stoi(tmp)-753);
        if(ans>X){
            ans=X;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int i,s=700;
    char a[3];
    
    scanf("%s",a);
    
    for(i=0;i<3;i++){
        if(a[i]=='o'){
            s=s+100;
        }
        else if(a[i]=='x'){
            s=s+0;
        }
    }
    
    printf("%d\n",s);
    
    return 0;
}

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

int main(){
	getline(cin,s);
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'a' && s[i] <= 'z'){
			s[i] += 'A' - 'a';
		}
		else if(s[i] >= 'A' && s[i] <= 'Z'){
			s[i] -= 'A' - 'a';
		}
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class CF
{


    public static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }

    public static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    public static string ReadStr()
    {
        return Console.ReadLine();
    }

    public static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    public static long[] ReadLongArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m));

    }


    public static void Main()
    {
        long[] A = ReadLongArray();

        long ans = 0;
     
        ans += Math.Min(A[0],A[3]);

        if (A[3] - (A[1] + A[0]) > 0)
            ans -= A[3] - (A[1] + A[0]);


        Console.WriteLine(ans);

    }

}


Measured memory_bytes: 17860