akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll n; cin >> n;
    string ans = "";
    while(n>0){
        if(n % 26 == 0) {ans = 'z' + ans; n--;}
        else ans = (char)( 'a' + (n%26) - 1) + ans;
        n/=26;
    }
    cout << ans;
    //cout << (char) ('a' + 25);
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    int n;cin>>n;
    float div = n/1.08;
    //cout<<div;
    int top = ceil(div);
    int down = floor(div);
    if(floor(top*1.08) == n){
        cout<<top;
    }else if(floor(down*1.08) == n){
        cout<<down;
    }else{
        cout<<":(";
    }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
bool prime(int p) {
	for (int i = 2;i <= sqrt(p);i++) {
		if (p%i==0)return false;
	}
	return true;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int main() {
	int n, m, d;
	cin >> n >> m >> d;
	if (d == 0)printf("%.12lf\n", (double) 1 / n * (m - 1));
	else printf("%.12lf\n", (double)2 * (n - d) / n / n * (m - 1));
	return 0;
}


Measured memory_bytes: 256
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))

d = 0
for i in range(0,len(a)-1):
  d = max(d,a[i+1]-a[i])
  
s = a[0]+k-a[-1]
d = max(s,d)
print(k-d)

Measured memory_bytes: 25840
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>
 
using namespace std;
 


int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
 
	int n, k;
	cin >> n >> k;

	int ans = 1;
	while (n--) {
		ans = min(ans + k, ans * 2);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)

MOD = 10**9 + 7
dp = [[0 for _ in range(13)] for _ in range(N)]  # dp[i][j]: S[i]までみて13で割ってjあまるものの個数

# 初期値
if S[0] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(S[0])] = 1

# dpテーブル更新式
for i in range(1, N):
    if S[i] == "?":
        for si in range(10):
            for j in range(13):
                dp[i][(j*10 + si)%13] += dp[i-1][j]
                dp[i][(j*10 + si)%13] %= MOD
    else:
        si = int(S[i])
        for j in range(13):
            dp[i][(j*10 + si)%13] += dp[i-1][j]
            dp[i][(j*10 + si)%13] %= MOD

print(dp[N-1][5])


Measured memory_bytes: 66140
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	int d, i;
	while (cin >> d) {
		int s = 0;
		for (i = 1; i < 600 / d; i++) {
			s += d * i * d * i * d;
		}
		cout << s <<endl;
	}

	return 0;
}

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

int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		vector<bool> v(n+1,true);
		for(int i=2; i<=sqrt(n); i++){
			if(v[i]){
				for(int j=2; i*j<=n;j++){
						v[i*j]=false;
				}
			}
		}
		for(int i=2;i<=n;i++){
			if(v[i]==true)
				cnt++;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3180
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
using namespace std;

int main()
{
    int n, g;
    cin >> n >> g;
    vector<int> score(n), p(n), c(n);
    for(int i=0; i<n; ++i){
        score[i] = 100 * (i + 1);
        cin >> p[i] >> c[i];
    }

    int ans = INT_MAX;
    for(int i=0; i<(1<<n); ++i){
        bitset<10> bs(i);
        int rest = g;
        int cnt = 0;
        for(int j=0; j<n; ++j){
            if(bs[j]){
                rest -= score[j] * p[j] + c[j];
                cnt += p[j];
            }
        }

        for(int j=n-1; j>=0; --j){
            if(!bs[j]){
                int x = min(p[j], (max(0, rest) + score[j] - 1) / score[j]);
                rest -= score[j] * x;
                cnt += x;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

const string pos = "POSSIBLE";
const string imp = "IMPOSSIBLE";

int gcd(int a, int b){
    if(a == 0) return b;
    return gcd(b%a, a);
}

string solve(int N, int K, vector<int> &A){
    int mx = *max_element(A.begin(), A.end());
    if(K > mx) return imp;

    for(int i=0; i<N; i++)
        if(K == A[i]) return pos;

    int g = A[0];
    for(int i=1; i<N; i++) g = gcd(g, A[i]);

    if(K % g == 0) return pos;
    else return imp;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    cout << solve(N, K, A) << endl;

    return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N; 
  ll sum = 0;
  for (ll i = 1; i <= N; i++) {
    for (ll j = 1; j <= N / i; j++) {
      sum += i * j;
    }
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  if(N<=104){ cout << 0 << endl;}
  if(N>=105 && N<=134){ cout << 1 << endl;}
  if(N>=135 && N<=164){ cout << 2 << endl;}
  if(N>=165 && N<=188){ cout << 3 << endl;}
  if(N>=189 && N<=194){ cout << 4 << endl;}
  if(N>=195){ cout << 5 << endl;}
}

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

int main(){

    string s;
     char t[26]={'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'};
    int count=0,ans=0,i,j;
    cin>>s;

    for (i=0; i<26; i++)
    {
        for (j=0; j<26; j++)
        {
            if (s[j]==t[i])
            {
                count=count+1;
                if (count>1)
                    ans=1;
            }

        }
        count=0;
    }
    
    if (ans>=1) {
        cout<<"no"<<endl;
    }
    else
        cout<<"yes"<<endl;
    
    return 0;
  }


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<random>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

mt19937_64 engine(20200628);

int D;
int C[26];
int S[365][26];
int T[365];

int M;
int qq[100011], qd[100011];

int last[26];

VI se[26];
int initial_score() {
    int cur = 0;

    REP (c, 26) {
	last[c] = -1;
	se[c].push_back(-1);
    }

    REP (i, D) {
	int t = T[i];
	last[t] = i;
	se[t].push_back(i);

	cur += S[i][t];
	REP (c, 26) cur -= C[c] * (i - last[c]);
    }
    
    REP (c, 26) {
	se[c].push_back(D);
    }
    return cur;
}


/*
int score(int day) {
    int cur = 0;

    REP (c, 26) {
	last[c] = -1;
	se[c].push_back(-1);
    }

    REP (i, day) {
	int t = T[i];
	last[t] = i;

	cur += S[i][t];
	REP (c, 26) cur -= C[c] * (i - last[c]);
    }
    return cur;
}
*/

/*
void solve() {
    REP (day, D) {
	int best = 0, bestc = 0;
	REP (c, 26) {
	    T[day] = c;
	    int s = score(day+1);
	    if (best < s) {
		best = s;
		bestc = c;
	    }
	}
	T[day] = bestc;
	// eprintf("%d\n", best);
    }
}
*/

int tri(int n) {
    return n * (n-1) / 2;
}

int modify_diff(int d, int q) {
    int p = T[d];
    if (p == q) return 0;
    T[d] = q;

    int ret = 0;

    int pos = lower_bound(se[p].begin(), se[p].end(), d) - se[p].begin();
    int left = se[p][pos-1], right = se[p][pos+1];
    ret -= C[p] * (tri(right - left) - tri(d - left) - tri(right - d));
    ret -= S[d][p];
    se[p].erase(se[p].begin() + pos);

    pos = lower_bound(se[q].begin(), se[q].end(), d) - se[q].begin();
    left = se[q][pos-1];
    right = se[q][pos];
    ret += C[q] * (tri(right - left) - tri(d - left) - tri(right - d));
    ret += S[d][q];
    se[q].insert(se[q].begin() + pos, d);

    return ret;
}

void solve() {
    const int LOOP = 100000;
    REP (i, D) T[i] = engine() % 26;
    int cur = initial_score();
    REP ($, LOOP) {
	int day = engine() % D, type = engine() % 26;
	int old = T[day];
	int diff = modify_diff(day, type);
	if (diff >= 0) {
	    cur += diff;
	} else {
	    modify_diff(day, old);
	}

    }
    // eprintf("%d\n", cur);
}

void output() {
    REP (d, D) printf("%d\n", T[d]+1);
}

void MAIN() {
    scanf("%d", &D);
    REP (c, 26) scanf("%d", C+c);
    REP (i, D) REP (c, 26) scanf("%d", S[i]+c);

    solve();
    output();
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;  
  
  if ((a + b) % 2 == 1){
    cout << (a + b) / 2 + 1 <<endl;
  }
  else {
    cout << (a + b) / 2 << endl;
  }
}
 

Measured memory_bytes: 3616
N, M = map(int, input().split())
S = [input().split() for _ in [0]*M]

for i in range(1000):
    if len(str(i)) != N:
        continue
    for s, c in S:
        if str(i)[int(s)-1] == c:
            continue
        else:
            break
    else:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll p[100010], q[100010], r[100010];
priority_queue<ll, vector<ll>, greater<ll>> pq;

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	for(int i=0; i<A; ++i) cin >> p[i];
	for(int i=0; i<B; ++i) cin >> q[i];
	for(int i=0; i<C; ++i) cin >> r[i];
	sort(p, p+A, greater<>());
	sort(q, q+B, greater<>());
	sort(r, r+C, greater<>());
	ll ans=0;
	for(int i=0; i<X; ++i){
		ans += p[i];
		pq.push(p[i]);
	}
	for(int i=0; i<Y; ++i){
		ans += q[i];
		pq.push(q[i]);
	}
	for(int i=0; i<C; ++i){
		if(pq.top()<r[i]){
			ans += r[i]-pq.top();
			pq.pop();
		}
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4724
n,K = list(map(int, input().split()))
seq = []
d = {}
for _ in range(n):
    a,b = list(map(int, input().split()))
    if a in d.keys():
        d[a] += b
    else:
        d[a] = b
c = 0
for k in sorted(d.keys()):
    ans = k
    # print(ans,k,c)
    c += d[k]
    if c >= K:
        ans = k
        break
print(ans)


Measured memory_bytes: 10600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define mp make_pair
// GCD inbuilt func: __gcd(a,b)
// LCM formula: (a*b)/__gcd(a,b)

int co;
void Dfs(const vector<int> v[], vector<bool>& visited, int x){
    if(!visited[x]){
        visited[x]=true;
        co++;
        for(int i=0;i<v[x].size();i++){
            Dfs(v,visited,v[x][i]);
        }
    }
    return;
}

void UndirGraph(vector<int> v[], int x, int y){
    v[x].push_back(y);
    v[y].push_back(x);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // CODE goes here
    int n,m;
    cin >> n >> m;
    set<pair<int,int>> q;
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        if(!q.count(mp(x,y)) && !q.count(mp(y,x))) q.insert(mp(x,y));
    }
    vector<int> v[n+1];
    for(auto &x:q) UndirGraph(v,x.first,x.second);
    vector<bool> visited;
    for(int i=0;i<n+1;i++) visited.push_back(false);
    int maxi=0;
    for(int i=1;i<n+1;i++){
        co=0;
        Dfs(v,visited,i);
        maxi=max(co,maxi);
    }
    cout << maxi;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(100002, 0);
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        a[n]++;
        a[n+1]++;
        a[n+2]++;
    }
    int ans = 0;
    for (int x : a) ans = max(ans, x);
    cout << ans<< "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	string s,ans;
	cin >> s;
	if (s == "Sunny")ans = "Cloudy";
	else if (s == "Cloudy")ans = "Rainy";
	else ans = "Sunny";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#055A

#1.入力をちゃんと受け取ること
x=input()
syoku=int(x)

#2.結果を出力する
gokei=syoku*800

if syoku // 15  != 0 :
    print(gokei-200*(syoku//15))
else :
    print(gokei)

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

//OJ freopen Template
//void OJF(const char* inp, const char* out) {
//	 freopen(inp, "r", stdin);
//	 freopen(out, "w", stdout);
//}

signed main()
{
	//OJF("*.inp", "*.out");
	fastio();
	int n; cin >> n;
	string s;
	cin >> s;
	if (s.length() % 2) {
		cout << "No";
		return 0;
	}
	if (s.substr(0, s.length() / 2) == s.substr(s.length() / 2, s.length() / 2)) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,cnt=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s.substr(i,3)=="ABC"){
      ++cnt;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

struct edge{
  int u;
  int v;
  int cost;
};

class UnionFind{
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;

    //作る時はParentの値を全て-1にする
    //こうするとずべてバラバラになる
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているのか調べる
    int root(int A){
      if(Parent[A]<0) return A;
      return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
      return -Parent[root(A)];//親を取ってきたい
    }

    //AとBをくっつける
    bool connect(int A,int B){
      //AとBを直すつつなぐのではなく、root(A)にroot(B)をくっつける)
      A = root(A);
      B = root(B);
      if(A==B){
        //すでにくっついているからくっつけない
        return false;
      }
      //大きい方(A)に小さい方(B)をくっつけたい
      //大小が逆だったらひっくり返しちゃう
      if(size(A)<size(B)) swap(A,B);

      //Aのサイズを更新する
      Parent[A] += Parent[B];
      //Bの親をAに変更する
      Parent[B] = A;

      return true;
    }
  };


bool comp(const edge& e1,const edge& e2){
  return e1.cost < e2.cost;
}

edge es[MAX];
int V,E;                  //頂点数と辺数
// 小さい順に閉路になっていなければ追加するという手法
int kruskal(){
  sort(es, es + E, comp); //edge.costが小さい順にソートする
  UnionFind Uni(V);
  int res = 0;
  for (int i = 0; i < E; i++){
    edge e = es[i];
    if(Uni.root(e.u) != Uni.root(e.v)) {
      Uni.connect(e.u , e.v);
      res += e.cost;
    }
  }
  return res;
}

int main(){
  cin >> V >> E;
  rep(i,E){
    ll a, b, c; cin >> a >> b >> c;
    es[i].u = a; es[i].v = b; es[i].cost = c;
    es[i].u = b; es[i].v = a; es[i].cost = c;
  }

  ll ans = kruskal();
  cout << ans << endl;

}



Measured memory_bytes: 4312
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int sum=0;
    for(int i=1;i<=n;i++) {
      sum=sum+i;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21332
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 100000;
int a[3];
int mv[N];
int n;

int x, y;
void get() 
{
	char str[3];
	scanf("%s", str);
	x = str[0] - 'A';
	y = str[1] - 'A';
}

int main() 
{
	scanf("%d%d%d%d", &n, a, a + 1, a + 2);
	if (a[0] + a[1] + a[2] == 1) {
		for (int i = 0; i < n; ++i) {
			get();
			if (!a[x] && !a[y]) {
				printf("No\n");
				return false;
			}
			mv[i] = y;
			if (a[y]) {
				mv[i] = x;
				swap(x, y);
			}
			a[x] = 0;
			a[y] = 1;
		}
	}
	else if (a[0] + a[1] + a[2] == 2) {
		get();
		for (int i = 0; i < n; ++i) {
			bool toget = true;
			if (!a[x] && !a[y]) {
				printf("No\n");
				return false;
			}
			if (a[x] == 2) {
				mv[i] = y;
				a[y] = a[x] = 1;
			}
			else if (a[y] == 2) {
				mv[i] = x;
				a[y] = a[x] = 1;
			}
			else if (a[x] && !a[y]) {
				mv[i] = y;
				swap(a[x], a[y]);
			}
			else if (!a[x] && a[y]) {
				mv[i] = x;
				swap(a[x], a[y]);
			}
			else {
				if (i == n - 1) mv[i] = x;
				else {
					if (x > y) swap(x, y);
					int x_ = x;
					int y_ = y;
					get();
					if (x > y) swap(x, y);
					toget = false;
					if (x != x_ || y != y_) {
						int same = x_ == x || x_ == y ? x_ : y_;
						mv[i] = same;
						a[x_] = a[y_] = 0;
						a[same] = 2;
					}
					else {
						mv[i] = x;
						a[x] = 2;
						a[y] = 0;
					}
				}
			}
			if (i < n - 1 && toget) get();
		}
	}
	else {
		for (int i = 0; i < n; ++i) {
			get();
			if (!a[x] && !a[y]) {
				printf("No\n");
				return 0;
			}
			if (a[x] > a[y]) swap(x, y);
			mv[i] = x;
			++a[x];
			--a[y];
		}
	}
	printf("Yes\n");
	for (int i = 0; i < n; ++i) printf("%c\n", 'A' + mv[i]);
	return 0;
}


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



long long memo[10000000];

long long solve(long long M){
    //cout <<  M << endl;
    if(M ==1){
        return 1;
    }else{
        // if(N*M*solve(N-1,M-1)==0)cout << N << endl;
        return memo[M]=(((M*M)%1000000007)*solve(M-1))%1000000007;
    }
    

    
}


int main(void){
    long long N,M;
    cin >> N >> M;
    if(N<M)swap(N,M);
    if(abs(N-M)>1){
        cout << 0 << endl;
        return 0;
    }else if(abs(N-M)==1){
        cout << (N*solve(M))%1000000007<<endl;
        return 0;
    }else{
        cout << (2*solve(M))%1000000007<<endl;
        return 0;
    }
}


Measured memory_bytes: 2560
N, T = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

arr = [List[i] for i in range(N) if List[i][1]<=T]

if arr==[]:
    print('TLE')
else:
    ans = min(arr, key=lambda x: x[0])[0]
    print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;

    vector<int> ans(n*n+1, 0);
    priority_queue<P, vector<P>, greater<P>> pq;
    queue<int> q;

    rep(i, n){
        int x;
        cin >> x;

        ans[x] = i+1;
        rep(j, i){
            pq.emplace(x - 1, i + 1);
        }
    }

    for(int i = 1; i <= n * n; i++){

        if(ans[i] != 0){
            rep(j, n - ans[i]){
                q.push(ans[i]);
            }

            continue;
        }

        if(not pq.empty() && pq.top().first < i){
            cout << "No" << endl;
            return 0;
        }

        if(not pq.empty()){
            ans[i] = pq.top().second;
            pq.pop();
            continue;
        }

        if(not q.empty()){
            ans[i] = q.front();
            q.pop();
            continue;
        }

        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    for(int i = 1; i < n * n; i++){
        cout << ans[i] << " ";
    }
    cout << ans[n*n] << endl;

    return 0;
}


Measured memory_bytes: 6128
import sys
input = sys.stdin.readline

N = list(map(int, list(input())[: -1]))
dp = [0] * (len(N) + 1)
dp2 = [0] * (len(N) + 1)
#print(sum(N))
dp2[1] = max(N[0] - 1, 0)
for i in range(len(N)):
  dp[i + 1] = N[i] + dp[i]
  if i > 0:
    dp2[i + 1] = dp2[i] + 9
    if N[i] > 0: dp2[i + 1] = max(dp[i] + N[i] - 1, dp2[i + 1])
print(max(max(dp), max(dp2)))

Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>

int main (void){

    int a=0,b=0;
    int d=0,r=0;
    double f=0.0;

    scanf("%d %d",&a,&b);
    
    if(a<1 || 1000000000<a) return -1;
    if(b<1 || 1000000000<b) return -1;
    
    d = a / b;
    r = a % b;
    f = (double)a/b;
    
    printf("%d %d %.5f\n",d,r,f);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long A, B;
	cin >> A >> B;
	if (A == 1 or B % A == 0) {
		cout << -1 << endl;
		return 0;
	}
	long long r = (B + A - 1) / A + 1;
	long long l = (B - 1) / (A - 1);
	long long N = A * (l + 1);
	if (l + 1 < r) {
		cout << A * (l + 1) << endl;
		return 0;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3104
n,l=map(int,raw_input().split())
a=map(int,raw_input().split())
fknot=0
for i in xrange(n-1):
    if a[i]+a[i+1]>=l:
        fknot=i+1
if fknot==0:
    print("Impossible")
else:
    print("Possible")
    for i in xrange(n-1,fknot,-1):
        print(i)
    for i in xrange(1,fknot):
        print(i)
    print(fknot)

Measured memory_bytes: 11340
#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair
#define f first
#define s second

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/
// https://atcoder.jp/contests/abc154/tasks/abc154_d

int n;
int k;
ld oof;
ld p[200002];
ld maxSum;
ld currVal;

int main(){
    IOS;
    cin >> n >> k;
    F0R(i,n){
        cin >> oof;
        p[i] = (oof + 1)/2;
        if(i > 0) p[i] += p[i-1];
    }
    maxSum = p[k-1];
    for(int i = k; i < n; i++){
        maxSum = max(maxSum, p[i] - p[i-k]);
    }
    cout << fixed << setprecision(7) << maxSum;
    return 0;
}

Measured memory_bytes: 3456
n = int(input())
Adj = [[0 for i in range(n)] for i in range(n)]
 
for i in range(n):
    u = list(map(int, input().split()))
    if u[1] > 0:
        for i in u[2: 2 + u[1]]:
            Adj[u[0] - 1][i - 1] = 1
 
color = [0] * n
d = [0] * n
f = [0] * n
time = 0
def dfs(u):
    global time
    color[u - 1] = 1
    time += 1
    d[u - 1] = time
    for i in range(1, n+1):
        if Adj[u - 1][i - 1] == 1 and color[i - 1] == 0:
            dfs(i)
    color[u - 1] = 2
    time += 1
    f[u - 1] = time

for i in range(1, n+1):
    if color[i-1] == 0:
        dfs(i)
for i in range(n):
    print("{} {} {}".format(i+1,d[i],f[i]))

Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long> l(n);
  for(int i=0;i<n;i++)cin>>l[i];
  long long ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[k]+l[j]>l[i] && l[i]!=l[j] && l[j]!=l[k] && l[i]!=l[k])ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
using namespace std;

int main(){
	const int MAX_n = 1000000;
	int n;
	bool prime[MAX_n];
	int res;
	
	for(int i = 0; i < MAX_n; i++) prime[i] = false;
	
	for(int i = 2; i < MAX_n; i++){
		if(!prime[i]){
			//printf("%d\n", i);
			for(int j = i + i; j < MAX_n; j += i){
				prime[j] = true;
				
			}
		}
	}
	
	//for(int i = 0; i < MAX_n; i++) if(prime[i]) printf("%d\n", i);
	
	while((scanf("%d", &n)) != EOF){
		res = 0;
		
		for(int i = 2; i <= n; i++){
			if(!prime[i]){ res++; }
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

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

int f(int n) {
  if (n < 10) {
    return n;
  }
  return n % 10 + f(n/10);
}

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

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


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long n, long long k, std::vector<long long> h){
    sort(ALL(h));
    int sum=0;
    REP(i,0,n-k){
        sum+=h[i];
    }
    cout<<sum<<endl;
}

// 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)
signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int total[30]={},total2[30]={},panjang,n;
string input,ans="";
int nilai(char a){
	return a-'a';
}
int main()
{
	for(int i=0;i<26;i++)
		total[i]=100;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>input;
		for(int j=0;j<26;j++)
			total2[j]=0;
		panjang=input.length();
		for(int j=0;j<panjang;j++)
			total2[nilai(input[j])]++;
		for(int j=0;j<26;j++)
			total[j]=min(total[j],total2[j]);
	}
	for(int i=0;i<26;i++)
	{
		while(total[i]>0)
			ans+=i+'a',total[i]--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define deb(x) cout << "LINE: " << __LINE__ << " " << #x << ": " << x << endl;
#define STDIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define lu int64_t

using namespace std;

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

    int h, n, x;
    size_t a = 0;
    cin >> h >> n;
    for(int i = 0; i < n; i++)
	{
		cin >> x;
		a += x;
	}

	if(a < h)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int A,B,C,X;
    scanf("%d %d %d",&A,&B,&C);
    if(A<B){
        X=B;
        B=A;
        A=X;
    }else if(C<B){
        X=B;
        B=C;
        C=X;
    }else if(A<C){
        X=C;
        C=A;
        A=X;
    }
    printf("%d\n",10*A+C+B);
    return 0;
}

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

vector<vector<int> >G;
int N,M;

typedef pair<int,int>P;

P make_edge(int e1, int e2){
  if(e1 > e2)swap(e1,e2);
  return P(e1,e2);
}

bool check(set<P>&st,int now,int& size){
  if(st.size() == size){
    return true;
  }
  for(int i = 0 ; i < G[now].size() ; i++){
    int to = G[now][i];
    P edge = make_edge(now,to);
    if(st.count(edge))continue;
    st.insert(edge);
    if(check(st,to,size))return true;
  }
  return false;
}

int main() {
  cin >> N >> M;
  for(int i = 0 ; i < N ; i++){
    G.push_back(vector<int>());
  }

  for(int i = 0 ; i < M ; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int count = 0;
  set<P>already_checked;

  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < G[i].size() ; j++){
      set<P>st;
      int to = G[i][j];
      P edge = make_edge(i,to);
      if(already_checked.count(edge))continue;
      already_checked.insert(edge);
      st.insert(edge);
      set<P>pre_st = st;
      bool flag = !check(st,to,M);
      st = pre_st;
      flag = (!check(st,i,M) || flag);
      if(flag){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.List
import Control.Monad

main = do
  q <- readLn
  replicateM_ q solve

solve :: IO ()
solve = do
  [a, b] <- sort . map read . words <$> getLine :: IO [Integer]
  print $ case () of 
            _
              | a == b -> 2*a - 2
              | a+1 == b -> 2*a - 2
              | otherwise ->
                let
                  c = floor $ sqrt $ fromIntegral (a*b)
                  c' = if c*c == a*b then c-1 else c
                in
                  if c'*(c'+1) >= a*b
                    then 2*c' - 2
                    else 2*c' - 1

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    auto score = [&](int i) {
        if (T[i] == 'r') return P;
        else if (T[i] == 's') return R;
        else return S;
    };
    long long res = 0;
    for (int k = 0; k < K; ++k) {
        bool last = false;
        for (int i = k; i < N; i += K) {
            if (i >= K && T[i-K] == T[i] && last) last = false;
            else res += score(i), last = true;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3856
#include <iostream>
using namespace std;
 
int main() {
    //入力を受け取る
    int D, T, S;
    cin >> D >> T >> S;
 
    //高橋君の移動時間を計算する
    double time = (double)D / S;
 
    //Tとtimeの大小関係に応じて出力をする
    if (T >= time) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

typedef long long ll;


int main(){
  int n;
  cin >> n;
  vector< pair<int, int> > vv;
  rep(i,n){
    int tem;
    cin >> tem;
    vv.push_back(mp(tem,i+1));
  }
  sort(all(vv));
  vector<int> v;
  rep(i,n){
    v.push_back(vv[i].second);
  }
  vector<int> b, a;
  b.push_back(v[0]-1);
  a.push_back(1);
  for(int i=1;i<n;i++){
    int tem = v[i]-(a[i-1]+1);
    if(b[i-1]<tem+1){b.push_back(b[i-1]-1);a.push_back(v[i]-b[i-1]+1);}
    else {b.push_back(tem); a.push_back(v[i]-tem);}
  }
  int offset = 1-b[n-1];
  rep(i,n){
    b[i] += offset; 
  }
  rep(i,n){
    cout << a[i] << " ";
  }
  cout << "\n";
  rep(i,n){
    cout << b[i] << " ";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 1148
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int k; cin >> k;

    REP(i, k) {
        cout << "ACL";
    }

    print("");
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/



int main()
{
    ll n,i;
    cin>>n>>i;
    if(n%i!=0)
        cout<<n/i+1<<endl;
    else
        cout<<n/i<<endl;
    return 0;
}
































Measured memory_bytes: 256
# A
li = list(input().split())
map_ = {'A':10 , 'B':11, 'C':12, 'D':13, 'E':14, 'F':15}
intli = [map_[i] for i in li]

if intli[0]<intli[1]:
    print('<')
elif intli[0]>intli[1]:
    print('>')
else:
    print('=')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;

int n,k,q,p[N];
int a[N],mn[N][N],ans=0x3f3f3f3f;
vector<int> s,buf;
void solve() {
	int pvt=-1;
	sort(p+1,p+1+n,[&](int x,int y) {return a[x]<a[y];});
	for(int i=1; i<=n; i++) {
		pvt = a[p[i]];
	//	cout << "now pvt: "<<a[p[i]]<<endl;
		for(int j=1; j<=n; j++) {
			if(a[j]<pvt) {
				sort(buf.begin(),buf.end(),greater<int>());
				while(buf.size()>=k) {
					s.push_back(buf.back());
					buf.pop_back();
				} buf.clear();
			} else buf.push_back(a[j]);
		}
		sort(buf.begin(),buf.end(),greater<int>());
		while(buf.size()>=k) {
			s.push_back(buf.back());
			buf.pop_back();
		} buf.clear();
		sort(s.begin(),s.end());
	//	for(int i=0; i<s.size(); i++) cout << s[i] << ' '; puts("");
		if(s.size()>=q) {
		//	cout <<"tmp "<< s[q-1] << endl;
			ans = min(s[q-1]-pvt, ans);
		} else break;
		s.clear();
	}
	cout << ans << endl;
}
int main() {
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	for(int i=1; i<=n; i++) {
		mn[i][i] = a[i],p[i]=i;
		for(int j=i+1; j<=n; j++) {
			mn[i][j]=min(mn[i][j-1],a[j]);
		}
	}
	solve();
	return 0;
}

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

int main()
{
    string sa,sb,sc;
    cin >> sa >> sb >> sc;

    char ans,next = 'a';
    while(1){
        if(next == 'a'){
            if(sa.length() == 0){ans = 'A';break;}
            next = sa[0];
            sa.erase(sa.begin());
        }else if(next == 'b'){
            if(sb.length() == 0){ans = 'B';break;}
            next = sb[0];
            sb.erase(sb.begin());
        }else{
            if(sc.length() == 0){ans = 'C';break;}
            next = sc[0];
            sc.erase(sc.begin());
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  // 入力受け取り
  string S, ret, ret1, ret2;
  cin >> S;
  
  if (S[0] == '0' && '1' <= S[1]) ret1 = "AMBIGUOUS";
  else if (S[0] == '1' && '0' <= S[1] && S[1] <= '2') ret1 = "AMBIGUOUS";
  else ret1 = "YYMM";
  
  if (S[2] == '0' && '1' <= S[3]) ret2 = "AMBIGUOUS";
  else if (S[2] == '1' && '0' <= S[3] && S[3] <= '2') ret2 = "AMBIGUOUS";
  else ret2 = "MMYY";
  
  if (ret1 == "AMBIGUOUS" && ret2 == "AMBIGUOUS") ret = "AMBIGUOUS";
  else if (ret1 == "YYMM" && ret2 == "AMBIGUOUS") ret = "YYMM";
  else if (ret1 == "AMBIGUOUS" && ret2 == "MMYY") ret = "MMYY";
  else ret="NA";
  
  cout << ret << endl;   
  return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let h = read::<usize>();
    let w = read::<usize>();
    let ss = (0..h)
        .map(|_| read::<String>().chars().collect::<Vec<_>>())
        .collect::<Vec<_>>();

    let mut ans = true;
    for i in 0..h {
        for j in 0..w {
            if ss[i][j] == '#' {
                let mut any = false;

                if i > 0 && ss[i - 1][j] == '#' {
                    any = true
                }
                if j > 0 && ss[i][j - 1] == '#' {
                    any = true
                }
                if i < h - 1 && ss[i + 1][j] == '#' {
                    any = true
                }
                if j < w - 1 && ss[i][j + 1] == '#' {
                    any = true
                }

                ans &= any
            }
        }
    }
    println!("{}", if ans { "Yes" } else { "No" })
}


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

using namespace std;
bool q[10];
int main()
{
    bool chk=true;
    string s;
    int len, i, mn=100, j, k, n, x;
    cin >> s >> k;
    for(i=0;i<k;i++)
    {
        scanf("%d",&n);
        q[n]=true;
    }
    len=s.size();
    for(i=1;i<=9;i++) if(!q[i]) mn=min(mn,i);
    for(i=0;i<len;i++)
    {
      //  cout<<s[i]-'0'<<endl;
        if(q[s[i]-'0'])
        {
            for(j=s[i]-'0';j<=9;j++)
            {
                if(!q[j])
                {
                    for(x=0;x<i;x++) printf("%c",s[x]);
                    printf("%d",j);
                    for(++i;i<len;i++) !q[0] ? printf("0") : printf("%d",mn);
                    printf("\n");
                    exit(0);
                }
            }
            printf("%d",mn);
            for(i=0;i<len;i++) !q[0] ? printf("0") : printf("%d",mn);
            printf("\n");
            exit(0);
        }
    }
    cout<<s<<endl;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N;
    cin >> N;
    vvll D(N, vll(2, 0));
    rep(i, N) rep(j, 2) cin >> D[i][j];

    ll count = 0;
    rep(i, N){
        if(D[i][0]==D[i][1]) ++count;
        else count = 0;
        if(count>=3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3664
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

n=l()[0]
A=[list(input()) for i in range(n)]
d={}
for i in range(n):
    x=tuple(sorted(A[i]))
    if(x not in d):
        d[x]=0
    d[x]+=1
ans=0
for ks in d:
    ans+=(d[ks]*(d[ks]-1)//2)
print(ans)


Measured memory_bytes: 46800