akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 ll m[100] ;
 P k[100] ;
 int main(){
  ll n ; cin>> n ;
  vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
  m[0]=1000 ;
  k[0]=mpa(0,1000) ;
  rep(i,n){
    m[i+1]=max(m[i],k[i].fi*A[i]+k[i].se) ;
    if((  (m[i]/A[i])>k[i].fi)  || ((m[i]/A[i])==k[i].fi)&&(m[i]%A[i])>k[i].se){
      k[i+1].fi= (m[i]/A[i]) ;
      k[i+1].se =(m[i]%A[i]) ;
    }
    else{
      k[i+1].fi=k[i].fi ;
      k[i+1].se=k[i].se ;
    } 
     }

     cout<<m[n]<<endl ;

   return 0 ;
 }



Measured memory_bytes: 3628
from collections import deque
N, K = map(int, input().split())
*S, = map(int, input())

C = []
prv = 1; cnt = 0
for c in S:
    if prv != c:
        C.append(cnt)
        cnt = 1
    else:
        cnt += 1
    prv = c
if cnt > 0:
    C.append(cnt)
if prv == 0:
    C.append(0)

M = len(C)//2
que = deque([C[0]])
res = ans = C[0]
for i in range(M):
    if len(que) == 2*K+1:
        res -= que.popleft() + que.popleft()
    que.append(C[2*i+1])
    que.append(C[2*i+2])
    res += C[2*i+1] + C[2*i+2]
    ans = max(res, ans)
print(ans)

Measured memory_bytes: 5272
#include <iostream>
#include <string>

using namespace std;

struct Item{
	string name;
	int price;
	int item_number;
	bool cook_flag;
};

struct Recipe{
	int item_number[100];
	int material;
};
Item item[100];
Recipe recipe[100];

int min(Item _item, int _num){
	if (!_item.cook_flag){
		return _item.price;
	}
	else{
		int sum = 0;
		for (int i = 0; i < recipe[_num].material; i++){
			int num = recipe[_num].item_number[i];
			int cook_price = min(item[num], num);
			if (cook_price > item[num].price) sum += item[num].price;
				else sum += cook_price;
		}
		if (sum > _item.price) sum = _item.price;
		return sum;
	}
}

int get_num(string name){
	for (int i = 0; i < 100; i++){
		if (name == item[i].name){
			return i;
		}
	}

}

int main(){
	while (1){
		int n;
		cin >> n;
		if (!n)break;
		for (int i = 0; i < n; i++){
			cin >> item[i].name;
			cin >> item[i].price;
			item[i].item_number = i;
			item[i].cook_flag = false;
		}

		int m;
		cin >> m;
		string o;
		int k;
		for (int i = 0; i < m; i++){
			cin >> o;
			int o_num = get_num(o);
			item[o_num].cook_flag = true;
			cin >> k;
			recipe[o_num].material = k;

			for (int j = 0; j < k; j++){
				string name;
				cin >> name;
				int num = get_num(name);
				recipe[o_num].item_number[j] = num;
			}
		}

		string req;
		cin >> req;
		int num = get_num(req);
		int ans;
		ans = min(item[num], num);
		cout << ans<<"\n";
	}
	return 0;
}

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

int main()
{
	int i=-1;
	char str[1024];
	gets(str);
	while(i++!=strlen(str))if('`'<str[i]&&str[i]<'{')str[i]-=' ';
	printf("%s\n",str);
	return 0;
}

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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        int n = ipar();
        double count = 0;
        for (int i = 1; i <= n; i++)
        {
            if (i % 2 == 1)
            {
                count++;
            }
        }
        out.println(count / n);

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


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

int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<int> deg(n);
    vector<vector<pair<int, int>>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        u--, v--;
        deg[u]++;
        deg[v]++;
        g[u].emplace_back(v, i);
        g[v].emplace_back(u, i);
    }
    for (int i = 0; i < n; ++i) {
        if (deg[i] & 1) {
            puts("No");
            return 0;
        }
    }
    int x = 0, y = 0;
    for (int i = 0; i < n; ++i) {
        x += deg[i] >= 4;
        y += deg[i] >= 6;
    }
    if (y >= 1 || x >= 3) {
        puts("Yes");
        return 0;
    }

    if (x == 2) {
        vector<int> dfn(n, -1), low(n, -1);
        int cnt = 0;
        function<void(int, int)> Dfs = [&](int x, int p) {
            static int tk = 0;
            dfn[x] = low[x] = tk++;
            for (auto &p : g[x]) {
                int u = p.first, e = p.second;
                if (dfn[u] == -1) {
                    Dfs(u, x);
                    if (low[u] >= dfn[x]) cnt++;
                    low[x] = min(low[x], low[u]);
                } else {
                    low[x] = min(low[x], dfn[u]);
                }
            }
        };
        Dfs(0, -1);
        if (cnt == 3) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 12032
from itertools import combinations

n = int(input())
s = [input() for _ in range(n)]
m = [0]*5
for i in range(n):
    if s[i][0] == 'M':
        m[0] += 1
    elif s[i][0] == 'A':
        m[1] += 1
    elif s[i][0] == 'R':
        m[2] += 1
    elif s[i][0] == 'C':
        m[3] += 1
    elif s[i][0] == 'H':
        m[4] += 1

ans = 0
for i,j,k in combinations(range(5),3):
    ans += m[i]*m[j]*m[k]
print(ans)

Measured memory_bytes: 9772
#import <stdio.h>
#import <stdlib.h>
typedef long long INT;

int compare_int(const void *a, const void *b) {
    return (int)(*(INT*)a - *(INT*)b);
}

int main(int argc, const char * argv[]) {
    int N;
    INT x;
    scanf("%d %lld", &N, &x);
    INT *numbers = (INT*)malloc(N * sizeof(INT));
    
    INT n;
    int i = 0;
    while (scanf("%lld", &n) != EOF) {
        numbers[i] = n;
        i++;
    }
    
    qsort(numbers, N, sizeof(INT), compare_int);
    i=0;
    int count=0;
    while (x>0 && i<N) {
        if (x>=numbers[i]) {
            x -= numbers[i];
            count++;
        } else {
            x=0;
            break;
        }
        i++;
    }
    if (x>0) {
        count--;
    }

    printf("%d", count);
    
    free(numbers);
    return 0;
}


Measured memory_bytes: 2164
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define bfo(i,v,u) for(int i=BB[v],u=B[i][1];i;u=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=5e5+5,mo=1e9+7;
int n,premx[N],sufmn[N];
struct node
{
	int k,b;
}a[N];
bool cmp(node a,node b) {return a.k!=b.k ? a.k<b.k : a.b<b.b;}
struct seg
{
	int x,y;
}b[N];
bool cmpseg(seg a,seg b) {return a.y!=b.y ? a.y<b.y : a.x<b.x;}
ll f[N],g[N];
int main()
{
	n=read();
	fo(i,1,n) a[i].b=read(),a[i].k=read();
	sort(a+1,a+n+1,cmp);
	premx[1]=a[1].b;
	fo(i,2,n) premx[i]=max(premx[i-1],a[i].b);
	sufmn[n]=a[n].b;
	fd(i,n-1,1) sufmn[i]=min(sufmn[i+1],a[i].b);
	fo(i,1,n)
	{
		int l=1,r=i;
		while(l<r)
		{
			int mid=(l+r)>>1;
			if(premx[mid]>=a[i].b) r=mid;
			else l=mid+1;
		}
		b[i].x=l;
		l=i,r=n+1;
		while(l<r-1)
		{
			int mid=(l+r)>>1;
			if(sufmn[mid]<=a[i].b) l=mid;
			else r=mid;
		}
		b[i].y=l;
	}
	sort(b+1,b+n+1,cmpseg);
	ll ans=0;
	f[0]=g[0]=1;
	for(int i=1,j=0;i<=n;++i)
	{
		for(;j<n && b[j].y+1<b[i].x;++j);
		f[i]=(f[i]+g[i-1]-g[j-1]+mo)%mo;
		g[i]=(g[i-1]+f[i])%mo;
		if(b[i].y==n) ans=(ans+f[i])%mo;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    string s;
    cin>>s;
    int n=s.size();
    ll cnt=0;
    ll sum=0;
    rep(i, n){
        if(s[i]=='W'){
            sum+=i-cnt;
            cnt++;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 720
N, K = map(int, input().split())
S = list((num+1)/2 for num in map(int, input().split()))
temp = 0
ans = 0
for i in range(K):
    temp += S[i]
ans = temp
for i in range(K, N):
    temp = temp + S[i] - S[i-K]
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 23588
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF INT32_MAX
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
const int N=1e+5;
int dp[N];
int main() {
	El3zba;
	int n,q;
	string s;
	cin>>n>>q>>s;
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		if(s[i-1]=='A'&&s[i]=='C')
			dp[i]=dp[i-1]+1;
		else dp[i]=dp[i-1];
	}
	while(q--)
	{
		int l,r;
		cin>>l>>r;
		l--;
		r--;
		cout<<dp[r]-dp[l]<<endl;
	}
	return 0;
}



Measured memory_bytes: 1488
#include <iostream>
#include <vector>

using int64 = long long;
constexpr static int64 INF = 1e15;

struct Edge {
    int from;
    int to;
    int64 cost;

    Edge(int from, int to, int64 cost)
        : from{from}, to{to}, cost{cost} {}
};

class BellmanFord {
private:
    int V;
    int E;
    std::vector<Edge> es;
    std::vector<int64> d;

public:
    BellmanFord(int V, int E, std::vector<Edge> es)
        : V{V}, E{E}, es{es} {}

    bool find_negative_loop(int s)
    {
        d.assign(V, INF);
        d[s] = 0;

        int cnt = 0;
        bool update = false;
        for (int i = 0; i < V; i++) {
            update = false;
            cnt++;
            for (const Edge &e : es) {
                if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    if (cnt == V && e.to == V - 1)
                        return true;

                    update = true;
                }
            }

            if (!update)
                break;
        }

        return false;
    }

    std::vector<int64> calc_shortest_path(int s) {
        if (find_negative_loop(s))
            return {};

        return d;
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    std::vector<Edge> es;
    for (int i = 0; i < M; i++) {
        int a, b;
        int64 c;
        std::cin >> a >> b >> c;
        a--; b--;
        es.emplace_back(a, b, -c);
    }

    BellmanFord bf{N, M, es};
    auto d = bf.calc_shortest_path(0);
    if (d.empty())
        std::cout << "inf" << std::endl;
    else
        std::cout << -d[N - 1] << std::endl;

    return 0;
}

Measured memory_bytes: 384
import sys

A, B = (int(i) for i in input().split())
S = input()

a = S[0:A]
M = S[A]
b = S[A+1:]

for i in a:
    if i == "-":
        print("No")
        sys.exit()

if M != "-":
    print("No")
    sys.exit()

for i in b:
    if i == "-":
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

struct edge { int to, cost; };
int co[114514];
int n;
vector<edge>G[114514];
void dfs(int x, int y) {
	if (y % 2)co[x] = 1;
	else co[x] = 0;
	rep(i, G[x].size()) {
		if (co[G[x][i].to] == -1) {
			dfs(G[x][i].to, y + G[x][i].cost);
		}
	}
}
signed main() {
	cin >> n;
	rep(i, n)co[i] = -1;
	rep(i, n - 1) {
		int a, b, c; cin >> a >> b >> c; a--; b--;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	dfs(0, 0);
	rep(i, n)cout << co[i] << endl;
}

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

using namespace std;

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

int ans = 0;
int h, w;
bool s[21][21];
int way[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};

void bfs(int y, int x){
    bool been[21][21]={false};
    queue<PP> que;
    que.push(PP(P(y,x), 0));
    while(que.size()){
        PP pp = que.front(); que.pop();
        P p = pp.first;
        int dis = pp.second;
        if(!s[p.first][p.second] || been[p.first][p.second]) continue;
        ans = max(ans, dis);
        been[p.first][p.second] = true;
        for(int i = 0; i < 4; i++){
            int ny = p.first+way[i][0], nx = p.second+way[i][1];
            if(0 <= ny && ny < h && 0 <= nx && nx < w){
                que.push(PP(P(ny,nx), dis+1));
            }
        }
    }
}

int main(){
    
    cin >> h >> w;
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char ss;
            cin >> ss;
            s[i][j] = bool(ss == '.');
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) bfs(i,j);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 1e6+9;
string s;
int n,white;

int main(){

    cin>>n>>s;
    for(int i=0;i<n;i++)
        white += (s[i]=='W');
    int ans = white;
    for(int i=n-1;i>=n-white;i--)
        ans -= (s[i]=='W');
    cout<<ans<<endl;
}


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

int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K<A){
        cout << K << endl;
    }else if(K<A+B){
        cout << A << endl;
    }else{
        cout << A -(K-A-B) << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

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

int main() {
    string s;
    cin >> s;
    vector<int> v(3, 0);
    for (auto &&i : s) {
        v[i - 'a']++;
    }
    auto n = s.length();
    for (auto &&j : v) {
        if(n/3 > j) {
            cout << "NO\n";
            return 0;
        }else {
            j -= n/3;
        }
    }
    if(max({v[0], v[1], v[2]}) == 2){
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

vector<int> convert(string s){
  std::vector<int> num(s.size(), 0);
  std::vector<char> lis;
  int tmp = 0;
  range(i, s.size()){
    int flag = -1;
    range(j, lis.size()){
      if(lis[j]==s[i]) flag = j;
    }
    if(flag != -1) num[i] = flag;
    else{
      num[i] = lis.size();
      lis.push_back(s[i]);
      tmp++;
    }
  }
  return num;
}

int main(int argc, char const *argv[]) {
  string S, T;
  std::cin >> S;
  std::cin >> T;
  std::vector<int> ansS = convert(S);
  std::vector<int> ansT = convert(T);
  bool ans = 0;
  if(ansS.size()!= ansT.size()){
    std::cout << "No" << '\n';
    return 0;
  }
  range(i, ansS.size()){
    if(ansS[i] != ansT[i]) ans = 1;
    //std::cout << ansS[i] << '\n';
    //std::cout << ansT[i] << '\n';
  }
  (ans == 1)?std::cout << "No" << '\n':std::cout << "Yes" << '\n';;
  return 0;
}


Measured memory_bytes: 2428
(let* ((n (read))
       (m (read))
       (k (read))
       (fr (make-array (list (1+ n)) :initial-element nil))
       (fn (make-array (list (1+ n))))
       (g (make-array (list (1+ n)) :initial-element nil))
       (s (make-array (list (1+ n))))
       (ans (make-array (list (1+ n)))))
  ;
  (loop :for i :from 1 :to m
        :for a := (read)
        :for b := (read)
        :do (push b (aref fr a))
        :do (push a (aref fr b))
        :do (incf (aref fn a))
        :do (incf (aref fn b)))
  ;
  (loop :with gn := 1
        :for i :from 1 :to n
        :if (not (aref g i))
        :do (let ((stack (list i))
                  (num 0))
              (loop :while stack
                    :for j := (pop stack)
                    :if (not (aref g j))
                    :do (progn 
                          (setf (aref g j) gn)
                          (incf num)
                          (loop :for k :in (aref fr j)
                                :do (push k stack))))
              (setf (aref s gn) num)
              (incf gn)))
  ;
  (loop :for i :from 1 :to n
        :for x := (aref s (aref g i))
        :do (setf (aref ans i) (- x (aref fn i) 1)))
  ;
  (loop :for i :from 1 :to k
        :for c := (read)
        :for d := (read)
        :if (= (aref g c) (aref g d))
        :do (progn
              (decf (aref ans c))
              (decf (aref ans d))))
  ;
  (loop :for i :from 1 :to n
        :do (format t "~A " (aref ans i)))
  (format t "~%"))



Measured memory_bytes: 84976
#include <iostream>
using namespace std;
constexpr long INF = 1LL << 62;

inline bool C(long n,long s,long b) {
    long sum = 0;
    while(n) {
        sum += n % b;
        n /= b;
    }
    return sum == s;
}

int main() {
    long n, s; cin >> n >> s;
    if(n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    for(long b=2; b*b <= n; ++b) {
        if(C(n, s, b)) {
            cout << b << endl;
            return 0;
        }
    }

    // when b > sqrt(n), n = p * b + q, s = p + q
    // p * b < n, p < sqrt(n)
    // from above two equation, (n - s) / p = b - 1

    long ans = INF;
    for(long p=1; p*p < n; ++p) {
        long b = (n - s) / p + 1;
        if(b < 2) continue;
        if(C(n, s, b)) ans = min(ans, b);
    }

    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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(){
  int K,A,B;
  cin>>K>>A>>B;
  for(ll i=A;i<=B;i++){
    if(i%K==0){
      cout<<"OK"<<endl;
      return 0;
    } 
  }
  cout<<"NG"<<endl;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  map<int,int> ma;
  lol o=m;
  while(o%2==0){
    ma[2]++;
    o/=2;
  }
  for(lol i=3;i*i<=m;i+=2){
    while(o%i==0){
      o/=i;
      ma[i]++;
    }
  }
  lol ans=1;
  for(auto l=ma.begin();l!=ma.end();l++){
    if(n<=l->se){
      ans*=pow(l->fi,(l->se/n));
    }
  }
  if(n==1) cout <<m<<'\n';
  else cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define lb long double

using namespace std;
int main()
{
	string s;
	cin >> s;
	bool flag=true;
	for(int i=0;i<s.length();i++)
		{
			if(s[i]==s[i+1]) 
			{
			flag=false;break;}
			
		}
		if (flag) cout << "Good";
		else cout <<"Bad";
		return 0;
}

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


int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a , b;
	cin >> a >> b;
	cout << a*b;
}

Measured memory_bytes: 3612
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int z,ans=100000000000000,i,n,k,x;
  vector<long long int> a,b;
  scanf("%lld %lld\n",&n,&k);
  for(i=0;i<n;i++){
    scanf("%lld ",&x);
    if(x>0){
      a.push_back(x);
    }
    else{
      b.push_back(-x);
    }
  }
  sort(b.begin(),b.end());
  for(i=0;i<=a.size();i++){
    z=k-i;
    if(z<0 || z>b.size()){
      continue;
    }
    long long int c,d;
    if(i<1){
      c=0;
    }
    else{
      c=a[i-1];
    }
    if(z<1){
      d=0;
    }
    else{
      d=b[z-1];
    }
    if(c<d){
      c=c*2;
    }
    else{
      d=d*2;
    }
    if(ans>c+d){
      ans=c+d;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1656
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-11 17:02:48
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    int m = 0;
    for (int i = 0; i < n; i++)
        if (m < a[i]) m = a[i];

    sort(all(b), rev(int));

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (h > 0 && b[i] > m) {
            h -= b[i];
            ans++;
        } else {
            break;
        }
    }

    if (h > 0) {
        if (h % m == 0) ans += h/m;
        else ans += h/m + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n%3==0){
      System.out.println(n/3);
    }else{
      System.out.println(n/3);
    }
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x-a) > abs(x-b)){
    cout << "B" << endl;
  } else { 
    cout << "A" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
class BIT
  attr_accessor(:size, :table)

  def initialize(n)
    @size = n
    @table = Array.new(@size + 1, 0)
  end

  def add(p, x)
    p += 1
    while p <= @size
      @table[p] += x
      p += p & (- p)
    end
  end

  def sum(r)
    s = 0
    while r > 0
      s += @table[r]
      r -= r & (- r)
    end
    return s
  end
  
  def range(l, r)
    return sum(r) - sum(l)
  end
end

n, q = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
bit = BIT.new(n)
n.times do |i|
  bit.add(i, a[i])
end

q.times do
  t, *rest = gets.chomp.split.map(&:to_i)
  if t == 0
    p, x = rest
    bit.add(p, x)
  elsif t == 1
    l, r = rest
    puts bit.range(l, r)
  end
end

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Otoshidama
            var line = Console.ReadLine();
            var array = line.Split(' ');

            int n = int.Parse(array[0]);    //お札の枚数
            int y = int.Parse(array[1]);    //合計金額

            string pairs = GetBillsPairs(n, y);

            if (pairs == null)
            {
                Console.WriteLine("-1 -1 -1");
            }
            else
            {
                Console.WriteLine(pairs);
            }
        }

        static string GetBillsPairs(int n, int y)
        {
            //i,j,k をそれぞれ10000円,5000円,1000円札の枚数とする

            for(int i = 0; i <= n; i++)
            {
                for(int j = 0; j <= n - i; j++)
                {
                    int k = n - i - j;
                    int total = CalcTotalMoney(i, j, k);

                    if (total == y)
                    {
                        return String.Format("{0} {1} {2}", i, j, k);
                    }
                }
            }

            return null;
        }

        static int CalcTotalMoney(int i, int j, int k)
        {
            return i * 10000 + j * 5000 + k * 1000;
        }
    }
}

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	int i = 0;
	if (a == b) {
		i++;
	}
	if (a == c) {
		i++;
	}
	if (b == c) {
		i++;
	}
	string ans;
	if (i == 1) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
let (n,a,b) = Scanf.scanf "%d %d %d\n" (fun x y z -> (x,y,z))

let pr x = print_endline (string_of_int x)

let (--) m n =
  let rec iter i res =
    if i >= m then iter (i - 1) (i::res)
    else res in
  let rec iter' i res =
    if i <= m then iter' (i + 1) (i::res)
    else res in
  if m <= n then iter n []
  else iter' n []

let digit_list_of_num n =
  let rec iter rem res =
    let top = rem mod 10 in
    if rem < 10 then top::res
    else iter (rem / 10) (top::res) in
  iter n []

let sum_digits n = digit_list_of_num n |> List.fold_left (+) 0
    
let () = List.fold_left
           (fun sum x ->
             let s = sum_digits x in
             if s >= a && s <= b then sum + x
             else sum) 0 (1--n)
         |> pr


Measured memory_bytes: 1536
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	int n,m,l,r,lm=0,rm=10000000;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>l>>r;
		lm=max(lm,l);
		rm=min(rm,r);
	}
	cout<<max(rm-lm+1,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = 0
for bit in range(1 << (n - 1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]
    ans += sum(map(int, f.split("+")))
print(ans)

Measured memory_bytes: 3060
N = int(input())
A = []
xy = []
for i in range(N):
    Ai = int(input())
    A.append(Ai)
    xyi = [list(map(int,input().split())) for i in range(Ai)]
    xy.append(xyi)




ans = 0
for i in range(2**N):
    s = str(bin(i))[2:].zfill(N)
    flag = True
    d = [k for k in range(len(s)) if s[k]=='1']
    honest = [1 if s[k]=='1' else 0 for k in range(len(s))]
    for j in d:
        for k in range(A[j]):
            if honest[xy[j][k][0]-1]^xy[j][k][1]==1:
                flag = False
                break
            else:
                continue
        if not flag:
            break
    if flag:
        ans = max(ans,len(d))
print(ans)


Measured memory_bytes: 51164
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
namespace {
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    static ostringstream oss; oss.str("");
    for(Itr i=begin; i != end; ++i) { if(i != begin)oss << sp; oss << *i; }
    return oss.str();
  }
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
  // }}}

constexpr int MX = ten(5) + 10;

void _main(const vector<char*> &args)
{
  int n; cin >> n;
  bool f = n == 3 || n == 5 || n == 7;
  outl(f ? "YES" : "NO");
}

} // {{{
signed main(signed argc, char *argv[]) {
#ifndef DEBUG
  ios::sync_with_stdio(false); cin.tie(nullptr);
#endif
  cout << fixed << setprecision(9); _main(vector<char*>(argv, argv+argc)); return 0;
} // }}}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w,k,w1,w2,w3,k1,k2,k3,i,j,x,y;
	w1=0;
	w2=0;
	w3=0;
	k1=0;
	k2=0;
	k3=0;
	for(i=1;i<=10;i++) {
		scanf("%d",&w);
		if(w1<=w) {
			w3=w2;
			w2=w1;
			w1=w;
		}
		if(w2<=w && w<w1) {
			w3=w2;
			w2=w;
		}
		if(w3<=w && w<w2) {
			w3=w;
		}
	}
	for(j=1;j<=10;j++) {
		scanf("%d",&k);
		if(k1<=k) {
			k3=k2;
			k2=k1;
			k1=k;
		}
		if(k2<=k && k<k1) {
			k3=k2;
			k2=k;
		}
		if(k3<=k && k<k2) {
			k3=k;
		}
	}
	x=w1+w2+w3;
	y=k1+k2+k3;
	printf("%d %d\n",x,y);
	return 0;
}

Measured memory_bytes: 596
from collections import deque

def bfs(sx, sy):
    queue = deque([[sx, sy]])
    visit[sx][sy] = 0
    while queue:
        x, y = queue.popleft()
        if [x, y] == [gx, gy]:
            return visit[x][y]
        for k in range(4):
            nx, ny = x + dx[k], y + dy[k]
            if nx < 0 or h <= nx or ny < 0 or w <= ny or graph[nx][ny] == "#":
                continue
            elif graph[nx][ny] == "." and visit[nx][ny] == -1:
                visit[nx][ny] = visit[x][y] + 1
                queue.append([nx, ny])

h, w = map(int, input().split())
graph = [list(input()) for _ in range(h)]
visit = [[-1 for _ in range(w)] for _ in range(h)]
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]

sx, sy = 0, 0
gx, gy = h-1, w-1

cnt = 0
for i in range(h):
    for j in range(w):
        if graph[i][j] == "#":
            cnt += 1

bfs(sx, sy)
path = visit[gx][gy] + 1
if visit[gx][gy] == -1:
    print(-1)
else:
    print(h * w - path - cnt)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> ans(N);
    map<ll,pair<ll,ll>> mp;
    rep(i,N){
        ll a;
        cin >> a;
        if(!mp.count(a))mp[a].first = i;
        mp[a].second++;
    }

    ll total = 0; // 出現回数的な？
    ll minv = N; // 一番左のindex

    for(auto itr = mp.rbegin();itr != mp.rend();itr++){
        // 一番大きい山から見ていく感じ

        auto v = *itr;
        // v.second = pair<ll,ll> で v.second.first = index
        // v.second.second は出現回数
        auto it2 = itr;
        it2++;
        // 次に小さい山を調べる
        ll prev;
        if(it2 == mp.rend()) prev = 0;
        // もしもitrが一番小さい山だったら 次に小さい山のサイズは0にする
        else prev = it2->first;
        // そうじゃない場合は次に小さい山の大きさをprevにセットする

        total += v.second.second;
        // 個数をv.second.second個足す
        minv = min(minv,v.second.first);
        // 現時点で一番index番号が小さい場所を探す
        ans[minv] += total * (v.first - prev);
        // 現時点で一番index番号が小さい場所を基準として
        // 次に小さい山と同じサイズになるまで山をカットする
    }
    for(int i=0;i<N;i++)cout << ans[i] << endl;
}


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

typedef long long ll;
const int N = 1e5 + 100;

ll n, k, ans, ps[N], good[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		ps[i] = ps[i - 1] + a;
		good[i] = good[i - 1] + max(0, a);
	}
	for (int i = k; i <= n; i++)
		ans = max(ans, max(0LL, ps[i] - ps[i - k]) + good[i - k] + good[n] - good[i]);
	cout << ans;
}


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

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  int left = 0;
  int right = W;
  int top = H;
  int bottom = 0;
  rep(i,N) {
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1) left = max(left,x);
    if(a == 2) right = min(right,x);
    if(a == 3) bottom = max(bottom,y);
    if(a == 4) top = min(top,y);
  }
  if(left >= right || top <= bottom) cout << 0 << endl;
  else cout << (right-left)*(top-bottom) << endl;
  return 0;
}

Measured memory_bytes: 3572
n,m = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()

total = max(x) - min(x)
if n >= m:
    print(0)
elif n == 1:
    print(total)
else:
    gap = []
    for i,j in zip(x, x[1:]):
        gap.append(j-i)
    gap.sort(reverse=True)
    print(total - sum(gap[:n-1]))

Measured memory_bytes: 20552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
	int A, B, M;
	cin >> A >> B >> M;

	vector<int> a(A);
	vector<int> b(B);
	int mina = 1000001;
	int minb = 1000001;
	for (int i = 0; i < A; i++) {
		cin >> a.at(i);
		if (a.at(i) < mina) mina = a.at(i);
	}
	for (int i = 0; i < B; i++) {
		cin >> b.at(i);
		if (b.at(i) < minb) minb = b.at(i);
	}

	int min = 1000001;
	for (int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		
		int sum = a.at(x - 1) + b.at(y - 1) - c;
		if (sum < min) min = sum;
	}

	if (mina + minb < min) min = mina + minb;

	cout << min << endl;

	return 0;
}

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

using namespace std;


int main()
{
    int N;
    cin>>N;
    vector<vector<int>> c(N,vector<int>(3)); 

    for(int i=0;i<N;i++)
        for(int j=0;j<3;j++)
        {
            cin>> c[i][j]; 
        }

    vector<vector<int>> dp(N,vector<int>(3)); 
    for(int j=0;j<3;j++)
    {
        dp[0][j] = c[0][j]; 
    }

    for(int i=1;i<N;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int t=0;t<3;t++)
            {
                //cout<<"i and j and t "<<i <<" "<<j<<" " <<t<<endl; 
                if(t==j) continue; 
                
                dp[i][j] = max(dp[i-1][t]+c[i][j],dp[i][j]); 
            }
        }
    }
    int max=0; 
    for(int i=0;i<3;i++)
    {
        if(dp[N-1][i]>max)
        {
            max = dp[N-1][i]; 
        }
    }
    cout<<max<<endl;
    return 0; 
}


Measured memory_bytes: 11136
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

double x[50];
double y[50];

int main(){
	int n;
	int count = 0;
	while(cin >> n && n != 0){
		for(int i = 0; i < n; i++){
			cin >> x[i] >> y[i];
		}
		double sum = 0.0;
		for(int i = 2;  i < n; i++){
			double dx1 = x[i-1] - x[0];
			double dx2 = x[i] - x[0];
			double dy1 = y[i-1] - y[0];
			double dy2 = y[i] - y[0];
			sum += (dx1 * dy2 - dx2 * dy1) / 2;
		}
		cout << ++count << " " << fixed << setprecision(1) << abs(sum) << endl;
	}
	return 0;
}

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


def solve(N: int):
    res = []

    def rec(depth, charset, lst):
        if depth >= N:
            res.append("".join(lst))
            return

        valid_chars = [chr(ord("a") + i) for i in range(len(charset) + 1)]

        for c in valid_chars:
            rec(depth + 1, charset | set(c), lst + [c])

    rec(0, set(), [])
    print("\n".join(res))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15128
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

bool win[100010];
bool mark[100010];
int a[100010];
int n;

bool calc(int val)
{
	if (val < 0) return 1;
	if (val == 0) return 0;
	if (mark[val]) return win[val];
	mark[val] = true;
	for (int i = 0; i < n; ++i)
	{
		win[val] |= (calc(val-a[i])^1);
	}
	return win[val];
}

int main(void)
{
	fast;
	#ifndef ONLINE_JUDGE
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	#endif

	cin >> n;
	int k; cin >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	bool ans = calc(k);
	if (ans) cout << "First\n";
	else cout << "Second\n";
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



int main () {
  ios::sync_with_stdio(0); srand(time(0));
  cin.tie(0); cout.tie(0);

  int x[3];
  cin >> x[0] >> x[1] >> x[2];
  sort(x, x+3);
  int ans = ((x[1] - x[0]) / 2);
  x[0] += 2 * ans;
  if( x[0] != x[1] ) {
    x[0]++, x[2]++, ans++;
  }
  ans += x[2] - x[0];
  cout << ans << nl;

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;
class Card {
  public:
    char type;
    int number;
    Card(char _type, int _number) {
      type = _type;
      number = _number;
    }
    // Card(const Card &original) { // Copy Constractor
      // type = new char[1];
      // type = original.type;
      // number = new int[1];
      // number = original.number;
    // }
    string str() {
      stringstream ss;
      ss << type << number;
      // cout << ss.str() << endl;
      // return ss.str();
      return ss.str();
    }
    bool operator > (const Card &right) {
      return (number > right.number);
    }
    bool operator < (const Card &right) {
      return (number < right.number);
    }
    bool operator >= (const Card &right) {
      return (number >= right.number);
    }
    bool operator <= (const Card &right) {
      return (number <= right.number);
    }
    bool operator == (const Card &right) {
      return (number == right.number);
    }
    bool operator != (const Card &right) {
      return (number != right.number);
    }
};

void pResult(vector<Card> &, vector<Card> &);
vector<Card> BubbleSort(vector<Card>);
vector<Card> SelectionSort(vector<Card>);
string cardsToStr(vector<Card> &);


int main() {
  int n;
  cin >> n;
  vector<Card> cards;
  for(int i = 0; i < n; ++i) {
    string s_card;
    cin >> s_card;
    char c_card;
    int d_card;
    stringstream ss;
    ss << s_card;
    ss >> c_card;
    ss >> d_card;
    Card card(c_card, d_card);
    cards.push_back(card);
  }
  vector<Card> result1 = BubbleSort(cards);
  vector<Card> result2 = SelectionSort(cards);
  pResult(result1, result1);
  pResult(result2, result1);
  return 0;
}

void pResult(vector<Card> &sorted, vector<Card> &original) {
  string s_result = cardsToStr(sorted);
  cout << s_result << endl;
  cout << ((s_result == cardsToStr(original)) ? "Stable" : "Not stable") << endl;
}

string cardsToStr(vector<Card> &cards) {
  stringstream result;
  for(auto i = cards.begin(); i != cards.end(); ++i) {
    result << (*i).str();
    // cout << (*i).str() << endl;
    // cout << cards[0].str() << endl;
    if(i != cards.end() - 1) result << ' ';
  }
  return result.str();
}

vector<Card> BubbleSort(vector<Card> cards) {
  // result.resize(cards.size());
  // copy(cards.begin(), cards.end(), result.begin());
  for(int i = 0; i < cards.size(); ++i) {
    for(int j = cards.size() - 1; j > 0; --j) {
      if(cards[j] < cards[j - 1]) swap(cards[j], cards[j - 1]);
    }
  }
  return move(cards);
}

vector<Card> SelectionSort(vector<Card> cards) {
  for(auto i = cards.begin(); i != cards.end(); ++i) {
    auto itr_min = min_element(i, cards.end());
    iter_swap(i, itr_min);
  }
  return move(cards);
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  string camp[55];
  for (int i = 0 ; i < h; i++) {
    cin >> camp[i];
  }
  
  int dh[4] = {1,  0,  -1,  0};
  int dw[4] = {0,  1,   0, -1};
  
  bool can = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (camp[i][j] == '#') {
        bool can2 = false;
        for (int k = 0 ; k < 4; k++) {
          int nh = i + dh[k];
          int nw = j + dw[k];
          if (nh < 0 || nh >= h) 
            continue;
          if (nw < 0 || nw >= w)
            continue;
          if (camp[nh][nw] == '#') { 
            can2 = true;
            break;
          }
        }
        if (can2 == false)
          can = false;
      }
      if (can == false)
        break;
    }
  }  
  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;

namespace C2
{
    class Program
    {
        static int[] ToIntAry(string[] str)
        {
            int len = str.Length;
            int[] intary = new int[len];
            for(int i = 0; i < len;i++)
            {
                intary[i] = int.Parse(str[i]);
            }
            return intary;
        }
        static int[] AddZero(int[] intary)
        {
            int len = intary.Length + 1;
            int[] addIntary = new int[len];
            addIntary[0] = 0;
            intary.CopyTo(addIntary,1);
            return addIntary;
        }
        static void Main(string[] args)
        {
            int[] H,MA;
            int[] NM = ToIntAry(Console.ReadLine().Split(' '));
            int N  = NM[0], M = NM[1];
            H = AddZero(ToIntAry(Console.ReadLine().Split(' ')));
            MA = new int[N+1];
            for(int i = 0; i < M;i++)
            {
                int[] AB = ToIntAry(Console.ReadLine().Split(' '));
                int A = AB[0],B = AB[1];
                MA[A] = Math.Max(MA[A],H[B]);
                MA[B] = Math.Max(MA[B],H[A]);
            }
            int Answer = 0;
            for(int i = 1; i <= N ;i++)
            {
                Answer += Convert.ToInt32(H[i] > MA[i]);
            }
            Console.WriteLine(Answer);
        }
    }
}

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

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

int main(void){
	int N,M;
	cin >> N >> M;
	if(N*500 >= M) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

void solve() {
  std::string EnglishLowerCase;

  std::cin >> EnglishLowerCase;
  
  if (EnglishLowerCase.length() == 3) {
    std::reverse(EnglishLowerCase.begin(), EnglishLowerCase.end());
  }

  std::cout << EnglishLowerCase << "\n";
}

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

Measured memory_bytes: 764