akhauriyash/Code-Regression huggingface dataset:
import numpy as np
n = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
C = np.array([a-b for a, b in zip(A, B)], dtype='int64')
C.sort()
cnt_neg = np.sum(C < 0)
cnt_pos = np.sum(C > 0)
sum_neg = -1 * np.sum(C[C < 0])
sum_pos = np.sum(C[C > 0])
if sum_pos - sum_neg < 0:
    print(-1)
elif sum_neg == 0:
    print(0)
else:
    C = C[C>0]
    C.sort()
    C = C[::-1]
    C = np.cumsum(C)
    print(cnt_neg + np.count_nonzero(C < sum_neg) + 1)

Measured memory_bytes: 42568
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
    double a,b,c;
    cin>>a>>b>>c;
    int yes=0;
    if(a==b&&a!=c)
        yes=1;
    if(a==c&&a!=b)
        yes=1;
    if(b==c&&a!=b)
        yes=1;
    if(yes)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;
unordered_map<int,bool> done;

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

    int n,x=0;cin>>n;
    int res=0;
    string a;cin>>a;
    for(int i=0;i<a.length();i++){
    	if(a[i]=='I'){
    		x++;
    	}else{
    		x--;
    	}
    	res=max(res,x);
    }

    cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const int mxN=1e5;
const ll mod = 1e9+7;

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

    vector<int> v(n);

    for(int i=0;i<n;i++) cin>>v[i];

    vector<int> dp(n,INT_MAX);
    dp[0]=0;

    for(int i=1;i<n;i++){
        for(int j=1;j<=min(i,k);j++){
            dp[i] = min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
        }
    }

    cout<<dp[n-1];
}

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

def main():
    n,m,x=map(int,input().split())
    C=[]
    A=[]
    for _ in range(n):
        c,*a=map(int,input().split())
        C.append(c)
        A.append(a)
    ans=float('inf')
    for i in range(1<<n):
        S=[0]*m
        tmp=0
        for j in range(n):
            if (i>>j)&1==0:
                continue
            tmp+=C[j]
            B=A[j]
            for k,b in enumerate(B):
                S[k]+=b
        if min(S)>=x:
            ans=min(ans,tmp)
    print(-1 if ans==float('inf') else ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 68624
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N;
	string S;
	cin >> N >> S;

	ll c[26] = {};

	ll ans=1;

	rep(i, N) {
		c[S[i] - 'a']++;
	}

	rep(i, 26) {
		ans *= c[i] + 1;
		ans %= MOD;
	}

	cout << ans - 1;
	

	
	system("PAUSE");

}





Measured memory_bytes: 760
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=5e5+4;
int n,m;
int root[N],sum[N*50],lc[N*50],rc[N*50];
int tim;
int nxt[N];
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
inline void pushup(int rt) {
	sum[rt]=sum[lc[rt]]+sum[rc[rt]];
}
inline void build(int &rt,int l,int r) {
	rt=++tim;
	if (l==r) return ;
	int mid=l+r>>1;
	build(lc[rt],l,mid);
	build(rc[rt],mid+1,r);
}
inline void modify(int &rt,int pre,int l,int r,int pos,int val) {
	rt=++tim;
	lc[rt]=lc[pre];
	rc[rt]=rc[pre];
	sum[rt]=sum[pre]+val;
	if (l==r) return ;
	int mid=l+r>>1;
	if (pos<=mid) modify(lc[rt],lc[pre],l,mid,pos,val);
	else modify(rc[rt],rc[pre],mid+1,r,pos,val);
	pushup(rt);
}
inline int query(int rt,int l,int r,int L) {
	if (l==r) return sum[rt];
	int mid=l+r>>1;
	if (mid>=L) return sum[rc[rt]]+query(lc[rt],l,mid,L);
	else return query(rc[rt],mid+1,r,L);
}
int main() {
//	freopen("f3.txt","r",stdin);
	n=read(),m=read();
	build(root[0],1,n);
	for (register int i=1;i<=n;++i) {
		int x=read();
		if (!nxt[x]) {
			modify(root[i],root[i-1],1,n,i,1);
		} else {
			int temp;
			modify(temp,root[i-1],1,n,nxt[x],-1);
			modify(root[i],temp,1,n,i,1);
		}
		nxt[x]=i;
	}
	while (m--) {
		int x=read(),y=read();
		printf("%d\n",query(root[y],1,n,x));
	}
	return 0;
}

Measured memory_bytes: 246936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k=1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u==p) continue;
        if (k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}
int main() {
    int x; cin >> x;
    int p = x % 100;
    int d = x /100;
    int ans = 0;
    if (p <= d * 5) {
        ans = 1;
    }
    cout << ans << endl;

}


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

using namespace std;

int main()
{
    int x;
    while (cin >> x) {
        if (x >= 1800)
            cout << "1" << endl;
        else if (x >= 1600)
            cout << "2" << endl;
        else if (x >= 1400)
            cout << "3" << endl;
        else if (x >= 1200)
            cout << "4" << endl;
        else if (x >= 1000)
            cout << "5" << endl;
        else if (x >= 800)
            cout << "6" << endl;
        else if (x >= 600)
            cout << "7" << endl;
        else if (x >= 400)
            cout << "8" << endl;
    }
    return 0;
}


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


struct P
{
    //string r;
    long long x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
              return y>a.y;
    }
};


vector<int> v[1555];
//bitset<4001000> b;
int a,c,i,b,k,n,d,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[111222];

int o[113555];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,-1,1,-1,1},dz[10]={0,0,0,0,1,-1};

long long x,y,mod=1000000007;
long long z;
int j[200];
P u[110000];
//stack<int> s;
//queue<long long> q;
queue<int> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;
//string r;
char r[310][222];
//deque<int> de;

bool as(P a,P b)
{
    return (long long)a.x*b.y<(long long)b.x*a.y;
//    return 0;
}


int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    a++;
    for(int t=1;t<=a;t++)
        l[t]+=l[t-1]+max(o[t]-o[t-1],o[t-1]-o[t]);
    for(int t=1;t<a;t++)
    {
        printf("%d\n",l[a]-max(o[t]-o[t-1],o[t-1]-o[t])-max(o[t+1]-o[t],o[t]-o[t+1])+max(o[t+1]-o[t-1],o[t-1]-o[t+1]));
    }
}


Measured memory_bytes: 2048
//A Blackjack
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SUN")
    cout<<7<<endl;
  else if(s=="MON")
    cout<<6<<endl;
  else if(s=="TUE")
    cout<<5<<endl;
  else if(s=="WED")
    cout<<4<<endl;
  else if(s=="THU")
    cout<<3<<endl;
  else if(s=="FRI")
    cout<<2<<endl;
  else
    cout<<1<<endl;
}

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

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int M = 2019;

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    string S;
    cin >> S;
    int N = S.size();
    vector<int64_t> dp(M, 0);
    int64_t ans = 0;

    for (int i = 0; i < N; i++) {
        vector<int64_t> next_dp(M, 0);

        for (int m = 0; m < M; m++)
            next_dp[(10 * m + S[i] - '0') % M] += dp[m];

        next_dp[S[i] - '0']++;
        dp = next_dp;
        ans += dp[0];
    }

    cout << ans << endl;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n;
    cin >> n;

    string s;
    set<string> s_set;
    rep(0, n) {
        cin >> s;
        s_set.insert(s);
    }

    cout << (s_set.size() == 4 ? "Four" : "Three") << endl;
}

int main() {
    solve();

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;

  // (ここで2次元配列を宣言)
  vector<vector<char>> Table(H,vector<char>(W));
  
  for (int i= 0; i<H; i++){
    for(int j= 0; j<W; j++) {
	  cin >> Table.at(i).at(j);
	}
  }
  
  // compress
  vector<bool> row(H, false);
  vector<bool> col(H, false);
  for (int i= 0; i<H; i++){
    for(int j= 0; j<W; j++) {
	  if (Table.at(i).at(j) =='#') {
		row[i] = true;
		col[j] = true;
	  }
    }
  }
  
	cerr << ' ';
	for (int i = 0; i < H; i++) 	cerr << col[i];
	cerr << endl;
	for (int i = 0; i < H; i++) 	cerr << row[i] << endl;
	
	
  for (int i=0; i<H; i++) {
  	if (row[i] == true) {
	  	for (int j=0; j<W; j++) {
		  	if (col[j] == true) {
				cout << Table.at(i).at(j);
			}
	  	}
	cout << endl;
  	}
  }
}



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

//mod
const int mod = 1e9 + 7;
int powmod(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}
int inverce(int x) {
	return powmod(x, mod - 2);
}

//comb
const int factMax = 2e6;
int fact[factMax + 1];
void initializeFact() {
	fact[0] = 1;
	for (int i = 1; i <= factMax; i++)
		fact[i] = (long long) fact[i - 1] * i % mod;
}
int comb(int n, int k) {
	if (k < 0 || n - k < 0)
		return 0;
	int denom = (long long) fact[k] * fact[n - k] % mod;
	return (long long) fact[n] * inverce(denom) % mod;
}

int n, k;
string s;

long long ans = 0, t;

int main() {
	initializeFact();
	cin >> k >> s;
	n = s.size();

	for (int i = 0; i <= k; ++i) {

		t = (long long) comb(i + n - 1, i) * powmod(25, i) % mod;
		t = t * powmod(26, k - i) % mod;
		ans = (ans + t) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 13072
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define sum(a) accumulate(a.begin(),a.end(),0LL)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    string s, t; cin >> s >> t;

    ll ans = 0;
    for(long long i = 0; i < s.size()-t.size()+1; i++){
        ll cnt = 0;
        for(long long j = 0; j < t.size(); j++){
            if(s[i+j] == t[j]){
                cnt++;
            }
        }
        ans = max(ans,cnt);
    }
    if(s != t) put(t.size()-ans);
    else put(0);
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int cnt = 0;
		for (int i = 0;; i++) {
			if (Math.pow(k, i) > n) {
				break;
			}
			cnt++;
		}
		System.out.println(cnt);
	}
}




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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

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



int main() {
	fastio();

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

	cout << max(0, a - 2 * b);

	return 0;
}

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

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

    int ans = 0;
    rep(i, n) {
        int a, cnt = 0;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            cnt++;
        }
        ans += cnt;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	int ans = 0;
	string t = "CODEFESTIVAL2016";
	for(int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int yx[][] = new int [10][10];
		while(true){
			try{
				String str[] = sc.nextLine().split(",");
				int x = Integer.parseInt(str[0]);
				int y = Integer.parseInt(str[1]);
				int ink = Integer.parseInt(str[2]);
				yx[y][x]++;
				if(ink >= 1){
					if(y > 0){
						yx[y-1][x]++;
					}if(y < 9){
						yx[y+1][x]++;
					}if(x > 0){
						yx[y][x-1]++;
					}if(x < 9){
						yx[y][x+1]++;
					}if(ink >= 2){
						if(y > 0 && x > 0){
							yx[y-1][x-1]++;
						}if(y < 9 && x > 0){
							yx[y+1][x-1]++;
						}if(y > 0 && x < 9){
							yx[y-1][x+1]++;
						}if(y < 9 && x < 9){
							yx[y+1][x+1]++;
						}if(ink == 3){
							if(y > 1){
								yx[y-2][x]++;
							}if(y < 8){
								yx[y+2][x]++;
							}if(x > 1){
								yx[y][x-2]++;
							}if(x < 8){
								yx[y][x+2]++;
							}
						}
					}
				}
			}catch(Exception g){
				int max = 0;
				int zero = 0;
				for(int i = 0;i < 10;i++){
					for(int j = 0;j < 10;j++){
						if(yx[i][j] > max){
							max = yx[i][j];
						}if(yx[i][j] == 0){
							zero++;
						}
					}
				}
				System.out.println(zero);
				System.out.println(max);
				System.exit(0);
			}
		}
	}
    public static void main(String[] args) {
    	new Main().doIt();
    }
}

Measured memory_bytes: 17200
//Littleboy123 Template 1.6
#include <bits/stdc++.h>
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(n) printf("%d\n", (n))
#define COUTLL(n) printf("%lld\n", (n))
#define CIN(n) scanf("%d", &(n))
#define CINLL(n) scanf("%lld", &(n))
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void infile(){
	freopen("input.in", "r", stdin);
}

void outfile(){
	freopen("output.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
	if(b == 0)
		return 1;
	if(b == 1)
		return a;
	ll tmp = modex(a, b/2, mod);
	tmp = (tmp * tmp) % mod;
	if(b & 1)
		tmp = (tmp * a) % mod;
	return tmp;
}

//End of template

int n;
ll arr[3005];
pair<ll, ll> memo[3005][3005];

pair<ll, ll> dp(int l, int r){
	if(l > r)
		return {0, 0};
	pair<ll, ll> salah = {-1, -1};
	if(memo[l][r] != salah){
		return memo[l][r];
	}
	int gantian = 0;
	if(((n-r-1)+l) & 1){
		gantian = 1;
	}
	pair<ll, ll> one, two, ans1, ans2;
	if(gantian & 1){
		one = mp(0, arr[r]);
		two = mp(0, arr[l]);
		ans1 = dp(l, r-1);
		ans2 = dp(l+1, r);
		one.fi += ans1.fi;
		one.se += ans1.se;
		two.fi += ans2.fi;
		two.se += ans2.se;
		if(one.fi - one.se > two.fi - two.se){
			memo[l][r] = two;
		}
		else{
			memo[l][r] = one;
		}
	}
	else{
		one = mp(arr[r], 0);
		two = mp(arr[l], 0);
		ans1 = dp(l, r-1);
		ans2 = dp(l+1, r);
		one.fi += ans1.fi;
		one.se += ans1.se;
		two.fi += ans2.fi;
		two.se += ans2.se;
		if(one.fi - one.se > two.fi - two.se){
			memo[l][r] = one;
		}
		else{
			memo[l][r] = two;
		}
	}
	return memo[l][r];
}

int main(){
	init();
	
	cin >> n;
	FOR(i, 0, n){
		cin >> arr[i];
	}
	FOR(i, 0, 3005){
		FOR(j, 0, 3005){
			memo[i][j] = {-1, -1};
		}
	}
	pair<ll, ll> ans = dp(0, n-1);
	cout << ans.fi - ans.se << nl;
	return 0;	
}

Measured memory_bytes: 141696
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N;
    cin >> N;
    map<string, int64_t>d;
    for (int64_t i=0; i<N; i++) {
        string s;
        cin >> s;
        if (d.count(s) > 0) {
            d[s] += 1;
        } else {
            d[s] = 1;
        }
    }

    int64_t count = 0;
    for (auto x : d) {
        if (x.second > count) {
            count = x.second;
        }
    }

    vector<string>s;
    for (auto x : d) {
        if (x.second == count) {
            s.emplace_back(x.first);
        }
    }

    sort(s.begin(), s.end());
    int64_t ms = s.size();
    for (int64_t i=0; i < ms; i++) {
        cout << s[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 28020
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

int solve() {
  int N, X, Y, S = 0, t;
  cin >> N >> X >> Y;
  rep(i, 0, N - 2) cin >> t, S ^= t;

  int D = (X + Y - S) / 2;
  if ((X + Y - S) % 2 || D < 0 || D & S || D > X) return -1;

  int a = D;
  int b = D;
  rrep(i, 0, 50) {
    int p = 1LL << i;
    if ((D & p) != 0) continue;
    if ((S & p) == 0) continue;
    if ((a | p) <= X) {
      a |= p;
    } else {
      b |= p;
    }
  }
  assert((a & b) == D);
  assert((a ^ b) == S);
  assert(X + Y - (X ^ Y) == (X & Y) * 2);
  assert(a + b == X + Y);
  if (!(1 <= a && a <= X && b >= Y)) return -1;
  return X - a;
}
signed main() {
  cout << solve() << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3696
K,N = map(int,input().split())
A_list = list(map(int,input().split()))
sa = []
for i in range(1,N):
    sa.append(abs(A_list[i]-A_list[i-1]))
sa.append(K-A_list[-1] + A_list[0])
print(sum(sa)-max(sa))


Measured memory_bytes: 26444
N = int(input())
A, B = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
L = 0
M = 0
for i in range(N):
  if A+1 > P[i]:
    L += 1
  elif A < P[i] <B + 1:
    M += 1
  else:
    break
print(min(M, L, N - M - L))

Measured memory_bytes: 3064
from math import sin,cos,pi
N,L=map(int,input().split())
S=N*(N-1)*(N-2)/6
T=[int(input())*pi/L for _ in range(N)]
print(sum([sum([cos((T[i]+T[j]))*(N+2*(i-j))for j in range(i+1, N)])for i in range(N)])/S,sum([sum([sin((T[i]+T[j]))*(N+2*(i-j))for j in range(i+1,N)])for i in range(N)])/S)

Measured memory_bytes: 3572
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
    double w;
   cin>>w;
   cout<<2*w*3.141592<<endl;
   
}


Measured memory_bytes: 3816
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s,t;
  cin>>s;
  cin>>t;
  vi a(26,0),b(26,0);
  rep(i,s.size()) a[s[i]-'a']++;
  rep(i,t.size()) b[t[i]-'a']++;
  s="";
  t="";
  rep(i,26){
    while(a[i])s+=('a'+i),a[i]--;
    while(b[i])t=(char)('a'+i)+t,b[i]--;
  }
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

const int NMAX = 100;
const int AMAX = 9999999;

const int BLACK = 2;
const int GRAY = 1;
const int WHITE = 0;

int A[NMAX][NMAX];
int c[NMAX];
int d[NMAX];
int n;

void dijkstra() {
	while (true) {
		int minv, minu;
		minv = AMAX;
		minu = -1;
		for (int i = 0; i < n; i++) {
			if (d[i] == AMAX || c[i] == BLACK) continue;
			minv = min(d[i], minv);	
			if (d[i] == minv) minu = i;
		}
		if (minu == -1 || minv == AMAX) return;

		c[minu] = BLACK;

		for (int i = 0; i < n; i++) {
			if (A[minu][i] <= 0 || c[i] == BLACK) continue;

			if (d[i] > d[minu] + A[minu][i]) {
				d[i] = d[minu] + A[minu][i];
				c[i] = GRAY;
			}
		}
	}
}

int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		c[i] = WHITE;
		d[i] = AMAX;
		int u, k;
		scanf("%d %d", &u, &k);

		for (int j = 0; j < k; j++) {
			int v, c;
			scanf("%d %d", &v, &c);
			A[u][v] = c;
		}
	}

	d[0] = 0;
	dijkstra();

	for (int i = 0; i < n; i++) {
		printf("%d %d\n", i, d[i]);
	}

	return 0;
}



Measured memory_bytes: 3208
#   FizzBuzzSum

total = 0
n = int(input())
for i in range(1, n + 1):
    if not ((i % 5 == 0) or (i % 3 == 0)):
        total = total + i
print(total)
#   Fizz:(i%3==0)
#   Buzz:(i%5==0)
#   FizzBuzz:(i%3==0)and(i%5==0)
#   ベン図を描けば一目瞭然

Measured memory_bytes: 9164
N, M = map(int,input().split())
Store = [tuple(map(int,input().split())) for i in range(N)]
Store.sort()

buy = 0
ans = 0

for price, num in Store:
    if buy+num < M:
        buy += num
        ans += price * num
    else:
        ans += (M - buy) * price
        break
print(ans)

Measured memory_bytes: 17284
#include <bits/stdc++.h>
using namespace std;
int m, n;
char s[10];
int cnt[4];
/*
AC x 3
WA x 1
TLE x 2
RE x 0

*/

int main( ){
    while( scanf( "%d", &n ) != EOF ){
        cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
        for( int i = 0; i < n; i++ ){
            scanf( "%s", s );
            if( !strcmp(s, "AC") )
                cnt[0]++;
            else if( !strcmp( s, "WA" ) )
                cnt[1]++;
            else if( !strcmp( s, "TLE" ) )
                cnt[2]++;
            else if( !strcmp( s, "RE" ) )
                cnt[3]++;
        }
        printf( "AC x %d\n", cnt[0] );
        printf( "WA x %d\n", cnt[1] );
        printf( "TLE x %d\n", cnt[2] );
        printf( "RE x %d\n", cnt[3] );
    }
    return 0;
}


Measured memory_bytes: 3836
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 200100;
const int MAX_C = 30;
int N;
string A;
int dp[MAX_N];
int nxt[MAX_N][MAX_C];
int restore[MAX_N];
int main() {
  cin >> A;
  N = A.size();
  for (int j = 0; j < MAX_C; j++){
      nxt[N][j] = N;
  }
  for (int i = N-1; i >= 0 ; i--){
      dp[i] = INF;
      for (int j = 0; j < MAX_C; j++){
          nxt[i][j] = nxt[i + 1][j];
          if (A[i] - 'a' == j){
              nxt[i][j] = i;
          }
      }
  }
  memset(restore, -1, sizeof(restore));
  dp[N] = 1;
  for (int i = N-1; i >= 0; i--){
      for (char j = 'a'; j <= 'z'; j++){
          const int p = j - 'a';
          if (dp[nxt[i][p] + 1] + 1 < dp[i]){
              restore[i] = p;
              dp[i] = dp[nxt[i][p] + 1] + 1;
          }
      }
  }
  int res = dp[0];
  int pos = 0;
  string result = "";
  while (result.size() < res){
      if (restore[pos] != -1){
          result += char('a' + restore[pos]);
          pos = nxt[pos][restore[pos]] + 1;
      }else{
          pos++;
      }

  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 25604
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
D = defaultdict(int)

for s in S:
  D[s] += 1

saidai = max(D.values())
ans = [k for k, v in D.items() if v == saidai]
for x in sorted(ans):
  print(x)


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

#define ll long long

const int MOD = 1e9 + 7;

ll sum(ll x) {
    ll ret = x * (x + 1) / 2;
    ret %= MOD;
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n; 
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        ll bef = 0, loop = 0;
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                if (j > i) {
                    bef++;
                }
                loop++;
            }
        }
        ans += (bef * k) % MOD; ans %= MOD;
        ans += (loop * sum(k - 1)) % MOD; ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string n;
    cin >> n;
    int ans = 0;
    REPS(c, n) {
        int i = (int)(c - '0');
        ans += i;
    }
    cout << (ans % 9 == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
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;}

ll n;
ll f(ll a, ll b) {
    return max(to_string(a).size(), to_string(b).size());
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    ll ans = to_string(n).size();
    erep(i, 1, (ll)sqrt(n)) {
        if (n%i == 0) {
            ans = min(ans, f(i, n/i));
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

struct mod_util {
  vector<long long> fac,finv,inv;
  int mod = -1;
  void init(int n , int mod){
    fac.resize(n);
    finv.resize(n);
    inv.resize(n);
    this->mod = mod;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[0] = 0;
    inv[1] = 1;
    for(int i=2;i<n;i++){
      fac[i] = fac[i-1] * i % mod;
      inv[i] = mod - inv[mod%i] * (mod / i) % mod;
      finv[i] = finv[i-1] * inv[i] % mod;
    }
  }

  long long nCk(int n, int k){
      assert(mod != -1);

      if(n < k)return 0;
      if(n < 0 || k < 0)return 0;

      return fac[n] * (finv[n-k] * finv[k] % mod) % mod;
  }

  long long nPk(int n, int k){
    assert(mod != -1);

    if(n < k)return 0;
    if(n < 0 || k < 0)return 0;

    return fac[n] * finv[n-k] % mod;
  }

  // a^x を modで割った余り
  int pow_mod(int a , int x , int mod){
    long long res = 1;
    long long pow = a;
    while(x > 0){
      if(x & 1){
        res *= pow;
        res %= mod;
      }

      pow *= pow;
      pow %= mod;
      x >>= 1;
    }
    return (int)res;
  }
};

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

  int n,a,b;

  cin >> n >> a >> b;

  mod_util mu;

  mu.init(b+1,MOD);

  int pow2 = mu.pow_mod(2,n,MOD);


  ll modA = 1;
  ll modB = 1;
  for(int i=0;i<a;i++){
    modA *= (n-i);
    if(modA >= MOD){
      modA = modA%MOD;
    }
  }

  modA = modA*mu.finv[a]%MOD;

  for(int i=0;i<b;i++){
    modB *= (n-i);
    if(modB >= MOD){
      modB = modB%MOD;
    }
  }

  modB = modB*mu.finv[b]%MOD;

  cout << (pow2 + (MOD-modA) + (MOD - modB) -1)%MOD << endl; 

  return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define module 1000000007


int main(){
    IOS;
   int n;
   cin>>n;
   vector<pair<int,int>>v;
   int A;
   for(int i=1;i<=n;i++){
       cin>>A;
       v.push_back({A,i});
   }
   sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
      cout<<v[i].second<<" ";
  }
return 0;    
}


Measured memory_bytes: 1780
N = int(input())
a = list(map(int,input().split(" ")))

for i in range(N):
    v = a[i]
    j = i - 1
    while(j >= 0) and (a[j]>v):
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    b = [str(n) for n in a]
    print(" ".join(b))
        


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


int main() {
 int N;
 int K;
  int ichi;
  cin >> N >> K;
int ans = 1+((N-1)/(K-1));
  if ( (N-1)%(K-1)==0){
    ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys


def main():
    input = sys.stdin.buffer.readline
    k = int(input())
    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,
    ]
    print(a[k - 1])


if __name__ == "__main__":
    main()


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



int main(){
  string a,b;
  cin>>a>>b;
  
  int cnt=0;
  rep(i,3){
    if(a[i]==b[i]) cnt++;
  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 3572
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int  N;
  cin>>N;
  int ans=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    int k=2;
    for(int j=0;j<30;j++){
      if(a%k!=0){
        ans+=j;
        break;
      }
      k=k*2;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            Console.WriteLine(6 - a - b);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) 
                {
                    return inputStream.Dequeue();
                }

                string[] tmp = _stream.ReadLine().Split(_separator);
                
                for (int i = 0; i < tmp.Length; ++i)
                {
                    inputStream.Enqueue(tmp[i]);
                }
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn judge(s: &[u8], t: &[u8],) -> bool {
    let mut memo: HashMap<u8, u8> = HashMap::new();
    let mut used: HashMap<u8, u8> = HashMap::new();

    for i in 0..s.len() {
        if let Some(c) = memo.get(&s[i]).cloned() {
            if c != t[i] {
                return false;
            }
        } else if let Some(c) = used.get(&t[i]).cloned() {
            return false;
        } else {
            memo.insert(s[i], t[i]);
            used.insert(t[i], s[i]);
        }
    }
    return true;
}

fn main() {
    let line = read_line();
    let s = line.trim().as_bytes(); 
    let line = read_line();
    let t = line.trim().as_bytes();

    if judge(s, t) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int x1,x2,x3,x4,n;
    scanf("%d",&n);
    x1=n/1000;
    x2=(n/100)%10;
    x3=(n/10)%10;
    x4=n%10;
    if((x1==x2&&x2==x3)||(x2==x3&&x3==x4))
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import sys
import math
import bisect

def solve(A):
    n = len(A)
    B = []
    for i in range(1, n + 1):
        B.append(i)
    if A == B:
        return True
    for i in range(n):
        for j in range(i + 1, n):
            A[i], A[j] = A[j], A[i]
            if A == B:
                return True
            A[i], A[j] = A[j], A[i]
    return False

def main():
    n = int(input())
    A = list(map(int, input().split()))
    if solve(A):
        print('YES')
    else:
        print('NO')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
s = str(input())

a='Yes'
for i in range(len(s)):
  if (i+1)%2 ==1:
    if s[i] not in ['R', 'U', 'D']:
      a='No'
      break
  else:
    if s[i] not in ['L', 'U', 'D']:
      a ='No'
      break

print(a)

Measured memory_bytes: 2940
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int> > v(M);
    int P, Y;
    REP(i, M)
    {
        cin >> P >> Y;
        v[i] = tie(Y, i, P);
    }
    sort(v.begin(), v.end());
    vector<int> cnts(N);
    cnts.assign(N, 0);
    vector<pair<int, int> > ans(M);
    REP(i, M)
    {
        int j;
        tie(Y, j, P) = v[i];
        ans[j] = make_pair(P, ++cnts[P - 1]);
    }
    REP(i, M)
    {
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    return 0;
}


Measured memory_bytes: 3840
N=int(input())

l=["a"]

a=ord("a")

for i in range(N-1):
    la=[]
    for j in l:
        b=ord(max(j))
        for k in range(a,b+2):
            la.append(j+chr(k))
    l=la

for i in l:
    print(i)

Measured memory_bytes: 12984
#include<bits/stdc++.h>
#define fori(x,a,b) for (int x=a;x<=b;x++)
using namespace std;
const int maxn = 3010;
double a[maxn];
double dp[maxn][maxn];
int main ()
{
    int n;
    cin>>n;

    fori(i,0,n-1) cin>>a[i];

    dp[0][0] = 1;
    fori(i,1,n)
    {
        dp[i][0] = (1.0-a[i]);
        dp[0][i] = 0.0;
    }

    fori(i,1,n)
    {
        fori(j,0,n)
        {
            if (j==0)
            {
                // bat dau tu 0;
                dp[i][j] = (1.0-a[i-1])*dp[i-1][j];
            }
            else
            {
                dp[i][j] = a[i-1]*dp[i-1][j-1] + (1.0-a[i-1])*dp[i-1][j];
            }
        }
    }
    double ans=0.0;
    fori(i,n/2+1,n)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans;
}


Measured memory_bytes: 74292
N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0
for _ in range(N):
    tmp = input()
    if tmp == "AC":
        AC += 1
    elif tmp == "WA":
        WA += 1
    elif tmp == "TLE":
        TLE += 1
    else:
        RE += 1

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

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

using namespace std;

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

void solve() {
    int n, m;
    cin >> n >> m;

    vector<pair<int, int> > intrs;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        intrs.push_back({u, v});
    }

    sort(intrs.begin(), intrs.end(), cmp);

    int ans = 0;
    pair<int, int> last = {-1, -1};
    for (const auto &i : intrs) {
        if (i.first >= last.second) {
            ans++;
            last.first = i.second - 1;
            last.second = i.second;
        }
    }

    cout << ans;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);

typedef std::pair<int, int> P;

template<typename T>
void print_array(T *A_, s32 size) {
  //printf("%d\n", size);
  if( size != 0 ) {
    for(int i = 0; i < size - 1; ++i) {
      printf("%d ", A_[i]);
    }
    printf("%d\n", A_[size - 1]);
  }
}

int MCXI_to_int(std::string str) {
  int a = 1;
  int res = 0;
  
  for(int i = 0; i < (int)str.size(); ++i) {
    if( '2' <= str[i] and str[i] <= '9' ) {
      a = str[i] - '0';
    }
    else {
      switch( str[i] ) {
      case 'm' :
        res += a * 1000;
        break;
      case 'c' :
        res += a * 100;
        break;
      case 'x' :
        res += a * 10;
        break;
      case 'i' :
        res += a;
        break;
      default :
        assert(0);
      }
      a = 1;
    }
  }

  return res;
}

int pow10(int x) {
  int res = 1;
  for(int i = 0; i < x; ++i) {
    res *= 10;
  }
  return res;
}

std::string int_to_MCXI(int x) {
  std::string num = std::to_string(x);
  std::reverse(num.begin(), num.end());

  std::string res;
  for(int i = (int)num.size() - 1; i >= 0; --i) {
    if( num[i] == '0' ) continue;
    if( num[i] != '1' ) res += num[i];
    switch( i ) {
    case 3 :
      res += "m";
      break;
    case 2 :
      res += "c";
      break;
    case 1 :
      res += "x";
      break;
    case 0 :
      res += "i";
      break;
    }
  }

  return res;
}

int main() {

  int n;
  std::cin >> n;

  for(int i = 0; i < n; ++i) {
    std::string str1, str2;
    std::cin >> str1 >> str2;

    int num1, num2;
    num1 = MCXI_to_int(str1);
    num2 = MCXI_to_int(str2);
    //std::cerr << "num 1 : " << num1 << "  num2 : " << num2 << std::endl;

    std::cout << int_to_MCXI( num1 + num2 ) << std::endl;
  }  
  
  return 0;
}

Measured memory_bytes: 1232
a, b, c = map(int, input().split())
k = int(input())
ans = 0
for i in range(10000):
    if a < b and b < c:
        break
    else:
        if a < b:
            c *= 2

        else:
            b *= 2

    ans += 1

if ans <= k:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define maxn 1000119
int num[maxn],tree[maxn],booll[maxn],nnn[maxn],N,ww;;
//num数组保存原数列，tree树状数组，nnn保存结果
struct tt
{
    int l,r;//左右边界
    int pos;//原位置（因为我们要离线排序后处理）
};
tt ask[maxn];
bool cmp(tt x,tt y)
{ 
    return x.r<y.r;
    //快排大法好，没有什么是快排解决不来哦
    //实在不行就加上一个cmp
}
int lowbit(int n) 
{
    return n&(-n);
    //树状数组核心操作×1
}
void add(int n,int now)
{
    while(n<=N)
    {
        tree[n]+=now;
        n+=lowbit(n);
    }
    //树状数组核心操作×2-->更新操作
}
int sum(int n)
{
    int ans=0;
    while(n!=0)
    {
        ans+=tree[n];
        n-=lowbit(n);
    }
    return ans;
    //树状数组核心操作×3———>查询操作
}
int main()
{
        scanf("%d",&N);
  		scanf("%d",&ww);
        for(int i=1;i<=N;i++)
            scanf("%d",&num[i]);
        for(int i=1;i<=ww;i++)
        {
            scanf("%d%d",&ask[i].l,&ask[i].r);
            ask[i].pos=i; //存储初始位置
        }
        sort(ask+1,ask+1+ww,cmp);//按r排序
        int next=1;
        for(int i=1;i<=ww;i++)
        {
            for(int j=next;j<=ask[i].r;j++)
            {
                if(booll[num[j]]) 
                    add(booll[num[j]],-1);
                 //之前打过标记，在之前的位置加上-1，保证无重复
                add(j,1);
                booll[num[j]]=j;
            }
            next=ask[i].r+1;
            //更新下一次查询的位置
            nnn[ask[i].pos]=sum(ask[i].r)-sum(ask[i].l-1);
            //按询问编号存储每组询问的结果
        }
    for(int i=1;i<=ww;i++)
      cout<<nnn[i]<<endl;
    return  0;
}

Measured memory_bytes: 17396