akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    bool A = false; bool B = false;
    REP(i,3){
        if(S[i] == 'A') A = true;
        else B = true;
    }
    if(A && B) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>s1;
    l(i,0,s1.size())
    {
        d=d+s1[i]-'0';
    }
    //cout<<d<<endl;

if(d%9==0)
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}

    }


Measured memory_bytes: 3792
import math
import numpy as np

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

a = 1
a_list = list(np.arange(N) + 1)
for i in range(N - 1):
    a += a_list.index(P[i]) * math.factorial(N - (i + 1))
    a_list.remove(P[i])
    
b = 1
b_list = list(np.arange(N) + 1)
for j in range(N):
    b += b_list.index(Q[j]) * math.factorial(N - (j + 1))
    b_list.remove(Q[j])
    
print(abs(a - b))

Measured memory_bytes: 21112
R,G,B,N=gets.chomp.split.map(&:to_i)
ans=0
0.upto(N/R) do |r|
  0.upto(N/G) do |g|
    next if N-r*R-g*G < 0
    if (N-r*R-g*G) % B == 0
      ans += 1
    end
  end
end
puts ans

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;

  if (L > R) {
    cout << "Left" << endl;
  }
  
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  }
}


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

#define WHITE -1
#define BLACK 1


const int MAX = 100005;
vector<int> A[MAX];
int color[MAX];


void bfs(int u, int v) {
    queue<int> qf, qs;
    qf.push(u);
    qs.push(v);
    int s, t;
    int p;
    int m;
    while (!qf.empty() || !qs.empty()) {
        m = qf.size();
        for (int j = 0; j < m; j++) {
            s = qf.front(); qf.pop();
            for (int i = 0; i < A[s].size(); i++) {
                p = A[s][i];
                if (color[p] == BLACK || color[p] == WHITE) continue;
                color[p] = WHITE;
                qf.push(p);
            }
        }
        m = qs.size();
        for (int j = 0; j < m; j++) {
            t = qs.front(); qs.pop();
            for (int i = 0; i < A[t].size(); i++) {
                p = A[t][i];
                if (color[p] == BLACK || color[p] == WHITE) continue;
                color[p] = BLACK;
                qs.push(p);
            }
        }
    }
}

int main() {
    int N, a, b;
    scanf("%d", &N);
    for (int i = 0; i < N-1; i++) {
        scanf("%d %d", &a, &b);
        a--; b--;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    
    for (int i = 0; i < N; i++) color[i] = 0;
    color[0] = WHITE;
    color[N-1] = BLACK;

    bfs(0, N-1);
    int fen, snu;
    fen = snu = 0;
    for (int i = 0; i < N; i++) {
        if (color[i] == WHITE) fen++;
        else snu++;
    }

    if (fen > snu) printf("Fennec\n");
    else printf("Snuke\n");
    
    return 0;
}



Measured memory_bytes: 6272
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main = mapM_ (print. solve) . analyze . map readInt . B.words =<< B.getContents
readInt = fst . fromJust . B.readInt
analyze (n:a:b:cs) = let (hs,as) = splitAt n cs in (n,a,b,hs):analyze as
analyze _ = []
solve (n,a,b,hs) = f 0 (maximum $ map (\h->(h+b-1)`div`b) hs) where
  f lo hi
    |lo+1>=hi = hi
    |r>m = f m hi
    |otherwise = f lo m
    where
      m = (lo+hi)`div`2
      r = sum . map g $ hs
      g h = if h<=m*b then 0 else (h-m*b+(a-b)-1)`div`(a-b)

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

const int N = 5e5 + 9;

int n, A[N], k, q[N], h = 1, t, d[N], Gree[N], ans[N], tot, u;
set<int>P;
vector<int>V[N];
priority_queue<int, vector<int>, greater<int>>Q;

void AddEdge (int u, int v) {
	V[u].push_back(v); ++Gree[v];
}

int main () {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) scanf("%d", &A[i]), d[A[i]] = i;
	for (int i = 1; i <= n; ++i) {
		if (i - k > 0) P.erase(A[i - k]);
		auto p = P.upper_bound(A[i]);
		if (p != P.end()) AddEdge(i, d[*p]);
		P.insert(A[i]);
	}
	P.clear();
	for (int i = n; i; --i) {
		if (i + k <= n) P.erase(A[i + k]);
		auto p = P.upper_bound(A[i]);
		if (p != P.end()) AddEdge(i, d[*p]);
		P.insert(A[i]);
	}
	for (int i = 1; i <= n; ++i) if (!Gree[i]) Q.push(i);
	while (!Q.empty()) {
		u = Q.top(); Q.pop();
		ans[u] = ++tot;
		for (auto v : V[u]) if (--Gree[v] == 0) Q.push(v);
	}
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 64128
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,k;
  cin >> n >> k;
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  ll cnt=0;
  exrep(b,k+1,n){
    cnt+=(n/b)*max((b-k),0ll)+max(n%b-k+1,0ll);
  }
  cout << cnt << endl;
      
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9

int main() {
	int N, M; cin >> N >> M;
	int a[N+1];
	a[0] = 0;
	for (int i = 1; i <= N; i++) {
		int tmp; cin >> tmp;
		a[i] = (a[i-1] + tmp) % M;
	}

	sort(a, a + N+1);
	ll ans = 0;
	int i = 0;
	while (i < N+1) {
		ll tmp_count = 1;
		int tmp_val = a[i];
		while (i + 1 < N+1 && a[i + 1] == tmp_val) {
			tmp_count++;
			i++;
		}
		if (tmp_count >= 2) ans += (tmp_count * (tmp_count - 1) / 2);
		i++;
	}

	cout << ans << endl;

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct edge{
	ll R, C, A;
	bool operator<(const edge &right)const{
		return A < right.A;
	}
};

// par[i]  は，iがrootなら-(連結成分のサイズ)を，iがrootではないならばrootを返す
// root(x) は必ずroot を返す
struct UnionFindSize {
    vector<int> par;
    
    UnionFindSize(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    ll N, H, W;
    cin >> N >> H >> W;

    vector<edge> edges;

    REP(i, N){
    	ll R, C, A;
    	cin >> R >> C >> A;
    	R--, C--;
    	edges.push_back(edge{R, C, A});
    }
    sort(edges.rbegin(), edges.rend());

    UnionFindSize uf(H+W);
    vector<ll> cnt(H+W, 0);


    ll res = 0;
    REP(i, N){
    	ll r1 = uf.root(edges[i].R);
    	ll r2 = uf.root(H+edges[i].C);
    	ll s1 = uf.size(r1);
    	ll s2 = uf.size(r2);
    	ll e1 = cnt[r1];
    	ll e2 = cnt[r2];
    	
    	if(r1 == r2){
    		if(s1>e1){
    			res += edges[i].A;
    			cnt[r1]++;
    		}
    	}else{
    		if(s1+s2>e1+e2){
    			res += edges[i].A;
    			uf.merge(r1, r2);
    			cnt[uf.root(r1)] = e1+e2+1;
    		}
    	}
    }

    cout << res << endl;

    return 0;
}

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

namespace TestApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var strar = str.Select(_ => int.Parse(_.ToString())).ToList();
            var len = str.Length;
            var bits = new List<List<bool>>();
            if (len == 1)
            {
                Console.WriteLine(str);
                return;
            }
            var x = CreateBits(bits, len - 1,0);
            long valls = 0;
            foreach (var item in x)
            {
                var count = bits.Count;
                long val = 0;
                var before = "";
                for (int i = 0; i < len; i++)
                {
                    if (i < len - 1)
                    {
                        if (item[i])
                        {
                            before += strar[i];
                        }
                        else
                        {
                            before += strar[i];
                            val += long.Parse(before);
                            before = "";
                        }
                    }
                    else
                    {
                        if (before == "")
                            val += strar[i];
                        else
                        {
                            val += long.Parse((before + strar[i]));
                        }
                    }
                }
                valls += val;
            }

            Console.WriteLine(valls);
            Console.ReadLine();

        }

        private static List<List<bool>> CreateBits(List<List<bool>> bits, int len, int count)
        {
            if (count == 0)
            {
                var lss = new List<bool>();
                lss.Add(true);
                bits.Add(lss);
                var lx = new List<bool>();
                lx.Add(false);
                bits.Add(lx);
                count++;
                return CreateBits(bits, len, count);
            }
            if (len - count == 0)
                return bits;
            count++;
            var ls = new List<List<bool>>();
            foreach (var item in bits)
            {
                var x = item.ToList();
                x.Add(true);
                item.Add(false);
                ls.Add(item);
                ls.Add(x);
            }
             return CreateBits(ls, len, count);
        }
    }
}



Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

struct UnionFind {
    vector<int> parent;

    // Constructor
    UnionFind(int n) {
        parent.resize(n);
        rep(i, n) parent[i] = i;
    }

    // データxが属する木の代表元を返す
    int root(int x) {
        if (parent[x] == x) {
            return x;
        } else {
            parent[x] = root(parent[x]);
            return parent[x];
        }
    }

    // データxとyを同じ木にくっつける
    void connect(int x, int y) {
        int rx = root(x);
        int ry = root(y);

        if (rx == ry) return;
        parent[rx] = ry;
    }

    // データxとyが同じ木に属するか判定する
    bool check(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

struct Edge {
    int u;
    int v;
    int weight;

    Edge(int _u, int _v, int w) {
        u = _u;
        v = _v;
        weight = w;
    }

    bool operator >(const Edge other) const {
        return weight > other.weight;
    }

    bool operator ==(const Edge other) const {
        return weight == other.weight;
    }

    bool operator <(const Edge other) const {
        return weight < other.weight;
    }
};

vector<Edge> adj;

int main() {
    int n; cin >> n;
    for (int u = 0; u < n; u++) {
        for (int v = 0; v < n; v++) {
            int w; cin >> w;
            if (v > u && w != -1) adj.emplace_back(Edge(u, v, w));
        }
    }
    sort(adj.begin(), adj.end());

    // for (auto &edge: adj) {
    //     printf("(%d, %d, %d)\n", edge.u, edge.v, edge.weight);
    // }
    // cout << "-----" << endl;

    UnionFind tree(n);
    vector<Edge> s;
    for (auto &edge: adj) {
        // printf("check (u, v, w) = (%d, %d, %d)->", edge.u, edge.v, edge.weight);
        if (!tree.check(edge.u, edge.v)) {
            // printf("connect\n");
            s.emplace_back(edge);
            tree.connect(edge.u, edge.v);
        } else {
            // printf("don't connect\n");
        }
    }

    int ans = 0;
    for (auto &edge: s) {
        // printf("(%d, %d, %d)\n", edge.u, edge.v, edge.weight);
        ans += edge.weight;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define maxn 100005
#define mod 1000000009
#define ll long long
using namespace std;

typedef pair<int, int> P;

ll n;

int main()
{
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}

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

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

    vector<ll> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    ll sum = 0;
    rep(i, k) {
        sum += p[i];
    }

    cout << sum << endl;

    return 0;
}


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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if(n >= k){
    cout << x * k + y * (n - k) <<endl;
  }
  else{
    cout << x * n << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string N;
    int sum = 0;
    cin >> N;
    for (int i = 0; i < N.size(); i++)
    {
        if (N[i] == '2')
        {
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int d, g;
    cin >> d >> g;
    int p[d], c[d];
    rep(i, d) cin >> p[i] >> c[i];
    int anssum = inf;
    rep(i, (1 << d)) {
        int sum = 0, point = 0;
        rep(j, d) {
            if (i & (1 << j)) {
                sum += p[j];
                point += (j + 1) * 100 * p[j] + c[j];
            }
        }
        for (int j = d - 1; j >= 0; --j) {
            if (i & (1 << j)) continue;
            int c = 0;
            while (point < g && c != p[j]) {
                sum++;
                point += (j + 1) * 100;
                c++;
            }
            if (point >= g) break;
        }
        chmin(anssum, sum);
    }
    out(anssum);
}
/*
 d <= 10
 ボーナス全探索
 */


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d){
        cout << "Yes" << endl;
    }else{
        if(abs(a-b) <= d && abs(b-c) <= d){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
W = []
W.append(input())
for _ in range(N-1):
    new_W = input()
    if new_W in W:
        print("No")
        break
    if new_W[0] != W[-1][-1]:
        print("No")
        break
    W.append(new_W)
else:
    print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)

int main(){
    int a,b,c,d=0;
    cin >>a>>b>>c;
    if (a!=b)d++;
    if (b!=c)d++;
    if (a!=c)d++;
    if (d==0)d=1;
    cout << d <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c,d,hill[11],hills=0;
	
	for(a=1;a<=10;a++){
		scanf("%d",&hill[a]);
	}
	for(b=1;b<=9;b++){
		for(c=b+1;c<=10;c++){
			if(hill[b]<hill[c])hills=hill[b],hill[b]=hill[c],hill[c]=hills;
		}
	}
	for(d=1;d<=3;d++){
		printf("%d\n",hill[d]);
	}
	return 0;
} 

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

int main() {
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if ( a == b && b == c && c == a ){
    cout << "No" << endl;
  }else if ( a != b && b != c && c != a ){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,count=0, ans=0, left, right, mid;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for(int i=0; i<n-2; i++) {
        for(int j=i+1; j<n-1; j++) {
            left=j;
            right=n;
            while(right-left>1) {
                mid=(left+right)/2;
                if(a[i]+a[j]<=a[mid]) {
                    right=mid;
                }
                else {
                    left=mid;
                }
            }
            ans +=(left-j);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)


func nextInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	ok := 0
	yes := true
	no := true
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}
	m := nextInt()
	b := make([]int, m)
	for i := range b {
		b[i] = nextInt()
	}
	c := n
	if m < c {
		c = m
	}
	for i := 0; i < c; i++ {
		if b[i] > a[i] {
			ok = 1
			break
		}
		if a[i] > b[i] {
			no = false
			break
		}
		if a[i] != b[i] {
			yes = false
		}
	}
	if yes && no {
		if m > n {
			ok = 1
		}
	}
	fmt.Println(ok)
}


Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int a,b;
  cin>>a>>b;
  if(a<10 && b<10) ans(a*b);
  else ans(-1);
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
hash = Hash.new { |h, k| h[k] = 0 }
gets.split.map(&:to_i).each do |n|
  hash[n] += 1
end

ans = 0
hash.each do |k, v|
  ans += k * v
end

Q = gets.to_i
BCS = Q.times.map { gets.split.map(&:to_i) }

Q.times do |n|
  b, c = BCS[n]
  ans -= b * hash[b]
  ans += c * hash[b]
  hash[c] += hash[b]
  hash[b] = 0
  puts(ans)
end


Measured memory_bytes: 26204
a = [list(map(int, input().split())) for i in range(2)]

even = a[1][0::2]
odd = a[1][1::2]

evendic = {}
odddic = {}

evenmax = []
oddmax = []

ans = 0

for i in even:
    if i in evendic:
        evendic[i] += 1
    else:
        evendic[i] = 1
  
for i in odd:
    if i in odddic:
        odddic[i] += 1
    else:
        odddic[i] = 1

evennum = max(evendic.values())
oddnum = max(odddic.values())

for k, v in evendic.items():
    if v == evennum :
        evenmax.append(k)

for k, v in odddic.items():
    if v == oddnum:
        oddmax.append(k)

if len(set(even)) == 1 and len(set(odd)) == 1:
    if even == odd:
        ans = a[0][0] // 2

elif evennum == oddnum:
    if len(evenmax) >= 2 or len(oddmax) >= 2:
        ans = a[0][0] - evennum * 2
    elif max(evendic.items(), key = lambda x:x[1])[0] != max(odddic.items(), key = lambda x:x[1])[0]:
        ans = a[0][0] - evennum * 2
    else:
        ans = a[0][0] - evennum - max([sorted(odddic.values())[-2], sorted(evendic.values())[-2]])

else:
    if max(evendic.items(), key = lambda x:x[1])[0] != max(odddic.items(), key = lambda x:x[1])[0]:
        ans = a[0][0] - evennum - oddnum
    else:
        if evennum > oddnum:
            ans = a[0][0] - evennum - sorted(odddic.values())[-2]
        else:
            ans = a[0][0] - oddnum - sorted(evendic.values())[-2]

    
print(ans)

Measured memory_bytes: 106184
#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)
typedef long long ll;

int main() {
  int N, n, f = 0;
  cin >> N;
  n = N;
  while(n > 0) {
    f += n % 10;
    n /= 10;
  }
  cout << (N % f == 0 ? "Yes" : "No") << endl;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define spc        ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0);
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    ll t,n,m,a,b,d,e,i,j,k,x,y,z,cnt=0,cnt1=0,cnt2=0;
    bool flag = false;   /*vector<long long>v,v1;*/
    
    cin>>a>>b;
    string s;
    for(i=0;i<a;i++)
    {
        cin>>s;
        cout<<s<<endl;
        cout<<s<<endl;
    }
    

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    /*freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);*/

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
ll a[100100],s[100100],m,rc;

bool judge(ll x){
	int i;
	ll cnt = 0ll;
	for(i=0; i<n; ++i){
		cnt += (ll)(a+n-lower_bound(a,a+n,x-a[i]));
	}
	rc = cnt;
	return (cnt>=m);
}

int main(void){
	int i,p;
	ll ok=0ll,ng=(ll)(1e9),med,ans=0ll;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0; i<n; ++i){
		s[i+1] = s[i] + a[i];
	}
	while(ng-ok>1ll){
		med = (ok+ng)/2;
		if(judge(med)){
			ok = med;
		}else{
			ng = med;
		}
	}
	judge(ok); ans -= ok*(rc-m);
	for(i=0; i<n; ++i){
		p = (int)(lower_bound(a,a+n,ok-a[i])-a);
		ans += (s[n]-s[p]);
		ans += a[i]*(n-p);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
<?php
$x = str_split(trim(fgets(STDIN)));
$l = count($x);
for($i = 0;$i<8;$i++){
$a=$x;
$b =array_splice($a,$i,$l-7);
$imp = implode($a);
if($imp == 'keyence'){
echo 'YES';
exit;

}
}
echo 'NO';


Measured memory_bytes: 3828
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  int N,A;
  cin>>N>>A;
  cout<<((N%500<=A)?"Yes":"No")<<endl;
  return 0;
}


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

using namespace std;

typedef unsigned long long ull;

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

    cout << setprecision(6) << fixed;
    ull h, w, x, y;
    cin >> h >> w >> x >> y;

    cout << h*w/2.0 << " ";
    
    if(2*x==h and y*2==w) cout << 1;
    else cout << 0;
     
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)

def slowsolve(N, K):
    import itertools
    import math
    data = {}
    s = 0
    KK = [i for i in range(1, K + 1)]
    for p in itertools.product(KK, repeat=N):
        cdi = p[0]
        for c in p:
            cdi = math.gcd(cdi, c)
        s += cdi
        data.setdefault(cdi, 0)
        data[cdi] += 1
    print(data)
    return s


cache = {}
def solve(N, K):
    M = pow(10, 9) + 7
    ans = 0
    for i in range(K, 0, -1):
        P = pow(K // i, N, M)
        j = i + i
        while j <= K:
            P -= cache[j]
            j += i
        while P < 0:
            P += M

        cache[i] = P
        ans += i * P
        ans %= M
    return ans

if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    print(solve(N, K))


Measured memory_bytes: 20648
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
const int INF = 10000000;


int main(){

    int a, b;
    cin >> a >> b;

    int mid = abs(a - b);
    if(mid % 2) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    
    mid /= 2;

    cout << min(a, b) + mid << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
D, T, S = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]
#S = input()
#S = [input() for _ in range(N)]

if T * S >= D:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 65252
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	int a, b, x;
	cin >> x >> a >> b;
	x -= a;
	while(x>=b)
	{
		x -= b;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if (N != 100) {
			switch (D) {
			case 0:
				System.out.println(N);
				break;
			case 1:
				System.out.println(N + "00");
				break;
			default:
				System.out.println(N + "0000");
				break;
			}
		} else {
			switch (D) {
			case 0:
				System.out.println(101);
				break;
			case 1:
				System.out.println(101 + "00");
				break;
			default:
				System.out.println(101 + "0000");
				break;
			}
		}
	}
}


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

int main() {
    string s;
    cin >> s;
    int count = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'x'){
            count++;
        }
    }

    if(count >= 8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
int a[200000];
int b[200000];
map<int, int>mp;
signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0) b[i] = b[i - 1];
		b[i] += a[i];
		mp[b[i] % m]++;
	}
	mp[0]++;
	int ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans += (*it).second * ((*it).second - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] h = new long[N+1];
        Map<Long, List<Integer>> map1 = new HashMap<>();
        Map<Long, List<Integer>> map2 = new HashMap<>();
        for (int i = 1; i <= N; i++) {
            h[i] = scan.nextLong();
            long x1 = h[i] - i;
            List<Integer> list1 = map1.getOrDefault(x1, new ArrayList<>());
            list1.add(i);
            map1.put(x1, list1);
            long x2 = h[i] + i;
            List<Integer> list2 = map2.getOrDefault(x2, new ArrayList<>());
            list2.add(i);
            map2.put(x2, list2);
        }
        for (long x : map1.keySet()) {
            List<Integer> list = map1.get(x);
            list.sort(Comparator.naturalOrder());
        }
        for (long x : map2.keySet()) {
            List<Integer> list = map2.get(x);
            list.sort(Comparator.naturalOrder());
        }
        long ans = 0;
        for (int i = 1; i <= N; i++) {
            long x1 = h[i] - i;
            if (!map2.containsKey(-x1)) {
                continue;
            }
            List<Integer> list = map2.get(-x1);
            int left = 0;
            int right = list.size();
            while (left + 1 < right) {
                int mid = (left + right) / 2;
                int m = list.get(mid);
                if (i <= m) {
                    right = mid;
                } else {
                    left = mid;
                }
            }
            ans += left + 1;
        }
        for (int i = 1; i <= N; i++) {
            long x2 = h[i] + i;
            if (!map1.containsKey(-x2)) {
                continue;
            }
            List<Integer> list = map1.get(-x2);
            int left = 0;
            int right = list.size();
            while (left + 1 < right) {
                int mid = (left + right) / 2;
                int m = list.get(mid);
                if (m <= i) {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            ans += list.size() - right + 1;
        }
        System.out.println(ans/2);
    }
}


Measured memory_bytes: 134776
def BubbleSort(n, lst):
    for i in range(n):
        for j in range(n-1, i, -1):
            if lst[j][1] < lst[j-1][1]:
                lst[j-1], lst[j] = lst[j], lst[j-1]
    return lst

def SelectionSort(n, lst):
    for i in range(n):
        minj = i
        for j in range(i+1, n):
            if lst[j][1] < lst[minj][1]:
                minj = j
        if minj != i:
            lst[i], lst[minj] = lst[minj], lst[i]
    return lst

#バブルソートは必ず安定なので１つめのソート結果と比較することで
#O(N)で２つ目のソートの安定性を判定できる
def check(lst1, lst2):
    if lst1 == lst2:
        print("Stable")
    else:
        print("Not stable")

"""
def check(n, lst_o, lst):
    keeper = [[]]*10
    keeper2 = [[]]*10
    for i in range(n):
        keeper[int(lst_o[i][1])] = keeper[int(lst_o[i][1])] + [lst_o[i][0]]
        keeper2[int(lst[i][1])] = keeper2[int(lst[i][1])] + [lst[i][0]]
    if keeper == keeper2:
        print("Stable")
    else:
        print("Not stable")
"""

n = int(input())
lst = input().split()
lst1 = BubbleSort(n, lst.copy())
print(*lst1)
#check(n, lst.copy(), lst1)
print("Stable")
lst2 = SelectionSort(n, lst.copy())
print(*lst2)
check(lst1, lst2)
#check(n, lst.copy(), lst2)




Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string S;
    int K;
    cin >> S >> K;
    int N = S.size();
    set<string> s;
    //i文字の連続する部分文字列を全列挙
    rep2(i, 1, K){
        rep(j, N+1-i){
            string tmp = "";
            rep(k, i) tmp = tmp+S[j+k];
            s.insert(tmp);
        }
    }
    int i = 0;
    for(auto &e: s){
        i++;
        if(i == K) cout << e << endl;
    }
}

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

int h, w;

void check(vector<vector<char> >&s, int i, int j){
    int count = 0;  //爆弾の数
    int hdir[3] = {-1, 0, 1};
    int wdir[3] = {-1, 0, 1};
    if(s[i][j]=='#')return;
    rep(i_h, 3)	rep(j_w, 3){
	int movedi = i + hdir[i_h];
	int movedj = j + wdir[j_w];
	if(movedi < 0 || movedi >= h || movedj < 0 || movedj >= w)continue;
	if(s[movedi][movedj]=='#')count++;
    }
    s[i][j]='0'+count;
}

int main(){
    cin >> h >> w;
    vector<vector<char> >s(h, vector<char>(w));
    rep(i, h)	rep(j, w)   cin >> s[i][j];
    rep(i, h)	rep(j, w)   check(s, i, j);
    rep(i, h){
	rep(j, w){
	    cout << s[i][j];
	}
	cout << endl;
    }
}



Measured memory_bytes: 256
gets
h=gets.split.map(&:to_i)

a = h.each_cons(2).each_with_index.select{|(l,r),i| l<r }.map{|a,i|i}
r = [-1,*a,h.size-1].each_cons(2).map{|l,r|r-l}.max
p r-1

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

const ll MOD = 1e9+7;

ll repsq(ll n,ll p){
    if(p == 0) return 1;
    if(p & 1) return (n * repsq(n,p-1)) % MOD;
    else {
        ll t = repsq(n,p/2) % MOD;
        return (t * t) % MOD;
    }
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans = (repsq(2,n) - 1) % MOD;

    ll x_a = 1,x_b = 1;
    ll y_a = 1,y_b = 1;
    ll dis_a = 1,dis_b = 1;

    for(ll i=0;i<a;i++){
        x_a *= (n-i);
        x_a %= MOD;
        y_a *= (1+i);
        y_a %= MOD;
    }
    dis_a = x_a * repsq(y_a,MOD-2) % MOD;

    for(ll i=0;i<b;i++){
        x_b *= (n-i);
        x_b %= MOD;
        y_b *= (1+i);
        y_b %= MOD;
    }
    dis_b = x_b * repsq(y_b,MOD-2) % MOD;

    ans = (ans - dis_a + MOD) % MOD;
    ans = (ans - dis_b + MOD) % MOD;

    cout<< ans % MOD <<endl;
}

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

namespace id_0032cs
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp;
            var countRectangle = 0;
            var countDiamond = 0;
            while((tmp = Console.ReadLine()) != null)
            {
                var vs = tmp.Split(',').Select(int.Parse).ToArray();
                var isRectangle = vs[0] * vs[0] + vs[1] * vs[1] == vs[2] * vs[2];
                var isDiamond = vs[0] == vs[1];
                if (isRectangle) { countRectangle++; }
                if (isDiamond) { countDiamond++; }
            }
            Console.WriteLine(countRectangle);
            Console.WriteLine(countDiamond);
        }
    }
}



Measured memory_bytes: 9440
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     string s1,s3,s2;
     cin>>s1>>s2>>s3;
     if(s1[s1.size()-1]==s2[0] && s2[s2.size()-1]==s3[0]){
        cout<<"YES"<<endl;
     }
     else{
        cout<<"NO"<<endl;
     }

     return EXIT_SUCCESS;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int a,b;

  cin >> a >> b ;

  int n;

  if(b<10) n=a*10+b;//bが1桁
  else if(b<100) n=a*100+b;//bが2桁
  else n=a*1000+b;//bが3桁  
  
  bool rt=false;

  for(int i=1;i<=1000;i++){
    if(n==i*i) rt=true;
  }

  if(rt) cout << "Yes" << endl;
  else cout << "No" << endl;
 
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 100001;
		long[]k = new long[m];
		int N = sc.nextInt();
		long K = sc.nextLong();
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			long b = sc.nextInt();
			k[a] += b;
		}
		sc.close();
		long cnt = 0;
		for(int i = 1; i < m; i++) {
			cnt += k[i];
			if(cnt >= K) {
				System.out.println(i);
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 65456
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 768
S=input()
x,y=map(int, input().split())
N=len(S)
now=0
xs=[]
ys=[]
count=0
for i in range(N):
    if S[i]=="F":
        now+=1
    else:
        if count%2==0:
            xs.append(now)
        else:
            ys.append(now)
        count+=1
        now=0
    if S[i]=="F" and i==N-1:
        if count%2==0:
            xs.append(now)
        else:
            ys.append(now)
#print(xs,ys)
from collections import defaultdict
D=defaultdict(int)

xnow=xs.pop(0)
D[xnow]=1
for i in range(len(xs)):
    dx=xs[i]
    ds=D.keys()
    D=defaultdict(int)
    for v in ds:
        D[v+dx]=1
        D[v-dx]=1
D=dict(D)
#print(D)
xok=x in D


D=defaultdict(int)
D[0]=1
for i in range(len(ys)):
    dy=ys[i]
    ds=D.keys()
    D=defaultdict(int)
    for v in ds:
        D[v+dy]=1
        D[v-dy]=1
D=dict(D)
#print(D)
yok=y in D


if xok and yok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4576
#include <bits/stdc++.h>
// #include "/usr/local/include/cxx_pretty_print/cxx_pretty_print.hpp"

using namespace std;
/* type aliases */
using i32 = int32_t; using ui32 = uint32_t; using i64 = int64_t; using ui64 = uint64_t; using i128 = __int128;
using f32 = float;   using f64  = double;   using f80 = long double;
using PII = pair<i32, i32>; using PLL = pair<i64, i64>; using PFF = pair<f32, f32>; using PDD = pair<f64, f64>;
using VB  = vector<bool>;   using VS  = vector<string>;
using VI  = vector<i32>;    using VL  = vector<i64>;    using VF  = vector<f32>;    using VD  = vector<f64>;
using VVI = vector<VI>;     using VVL = vector<VL>;     using VVF = vector<VF>;     using VVD = vector<VD>;
using VPI = vector<PII>;    using VPL = vector<PLL>;    using VPF = vector<PFF>;    using VPD = vector<PDD>;
/* constants */
constexpr i64 mod = 1000000007;                                // 10^9+7
constexpr i64 inf = 9000000000000000000;                       // 9*10^18
/* macros */
#define MAX(c)        *max_element(ALL(c))
#define MIN(c)        *min_element(ALL(c))
#define SIZE(c)       (i64)((c).size())                        // unsined int (size_t) -> int64_t
#define ALL(c)        (c).begin(), (c).end()
#define RALL(c)       (c).rbegin(), (c).rend()
#define REP(i, n)     for (i64 i=0; i<(i64)(n); ++i)           // 0 to n-1
#define REPD(i, n)    for (i64 i=(i64)(n)-1; i>=0; --i)        // n-1 to 0
/* debug */
#define debug(x)      cerr << #x << ": " << (x) << '\n'
#define debugvec(v)   for (size_t _ = 0; _ < (v).size(); ++_) {cerr << #v << '[' << _ << "]: " << (v)[_] << '\n';}
/* useful output */
auto print = [](auto x) {cout << (x) << '\n';};
template <class T> void printvec(T v, string sep=" ", string end="\n") {REP(i, SIZE(v)-1) cout << v[i] << sep; cout << v[SIZE(v)-1] << end;}
/* useful input */
VS splitstr(string s, char delim=' ') {VS v; string buf; stringstream ss{s}; while (getline(ss, buf, delim)) v.push_back(buf); return v;}


i32 bisect(i32 n) {
    i64 left = 0;
    i64 right = n;
    while (right - left > 1) {
        i64 mid = left + (right - left) / 2;
        if (mid * (mid + 1) / 2 >= n) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return right;
}


void Main() {
    i64 n;
    cin >> n;
    while (n > 0) {
        i64 M = bisect(n);
        print(M);
        n -= M;
    }
}


signed main() {
    cin.tie(nullptr);                                         // cin と cout の tie を切り高速化
    cout << fixed << setprecision(15);                        // 浮動小数点数が 1e-006 のように表示されることを防ぐ
    Main();
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
    int a, b, c, i, flag;
    flag = 0;
    scanf("%d%d", &a, &b);
    if (1<=b && b<=9) {
        c = a*10 + b;
    } else if (10<=b && b<=99) {
        c = a*100 + b;
    } else {
        c = a*1000 + b;
    }
    for (i=1; i<=316; i++)
    {
        if (i*i == c) {
            flag = 1;
            break;
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//

int main() {
	cin >> K;
	vl A(32);
	A = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	//sort(A.begin(), A.end());
	cout << A[K-1];
}


Measured memory_bytes: 256