akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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;
	}
}
long long COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	string s;
	cin >> s;
	rep(i, s.size())cout << 'x';
	ggr
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

// dijkstra法ライブラリここから-----------------------------------------------------------------------------//

const int MAX_V = 500009;
typedef pair<int, ll> P;
vector<P> d(MAX_V);  // 結果格納　intは親　到達不可能なら-1, INF
vector< vector <P> > graph(MAX_V);


void dijkstra(int s) {
    priority_queue< P, vector<P>, greater<P> > que;
    for(int i = 0; i < d.size(); ++i) {
        d.at(i) = P(-1, INF);
    }
    que.push(make_pair(s, 0ll));
    d.at(s) = P(s, 0);
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.first;
        if(p.second > d.at(v).second) continue;
        for(int i = 0; i < graph.at(v).size(); ++i) {
            P edge = graph.at(v).at(i);
            if(d.at(edge.first).second > d.at(v).second + edge.second) {
                d.at(edge.first).second = d.at(v).second + edge.second;
                d.at(edge.first).first = v;
                que.push(make_pair(edge.first, d.at(edge.first).second));
            }
        }
    }
}


int main(){
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    rp(i, 0, H) {
        cin >> s.at(i);
    }

    rp(i, 0, H) {
        rp(j, 0, W) {
            if(s[i][j] == '#') continue;
            if(i >= 1) {
                if(s[i-1][j] == '.') graph[i*W+j].emplace_back((i-1)*W+j, 1ll);
            }
            if(i < H-1) {
                if(s[i+1][j] == '.') graph[i*W+j].emplace_back((i+1)*W+j, 1ll);
            }
            if(j >= 1) {
                if(s[i][j-1] == '.') graph[i*W+j].emplace_back(i*W+j-1, 1ll);
            }
            if(j < W-1) {
                if(s[i][j+1] == '.') graph[i*W+j].emplace_back(i*W+j+1, 1ll);
            }
        }
    }
    ll res = 0ll;
    rp(i, 0, H) {
        rp(j, 0, W) {
            if(s[i][j] == '#') continue;
            dijkstra(i*W+j);
            rp(k, 0, H*W) {
                if(d[k].second != INF) chmax(res, d[k].second);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 22572
#include<iostream>
using namespace std;
int main() {
	long long n; cin >> n;
	bool b = true; int cnt = 0;
	while (n >= 10) {
		if (n % 10 != 9)b = false;
		n /= 10;
		cnt++;
	}
	if (!b)n--;
	cout << cnt * 9 + n << endl;
	return 0;
}

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

int main(){
	long  a,b,c,d;
	cin >> a >> b >> c >> d;
	long  sum1 = a * b;
	long  sum2 = c * d;
    cout << fixed;
	if(sum1 > sum2){
		cout << sum1;
	}else{
		cout << sum2;
	}
	return 0;
}

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

int main() {
	string a;

	cin >> a;
	int b = 0;
	for(int i = 1; i < 4; ++i) {
		if(a[0] == a[i]) {
			b = i;
			break;
		} else if(i == 3) {
			cout << "No" << endl;
			return 0;
		}
	}
	if(b == 1) {
		if(a[2] == a[3] && a[0] != a[2]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else if(b == 2) {	
		if(a[1] == a[3] && a[0] != a[1]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else if(b == 3) {
		if(a[2] == a[1] && a[0] != a[2]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
}



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

int main(){

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

    if(a%3==0||b%3==0||(a+b)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
vector<P> g[100010];
vector<int> cent;
ll cnt[100010];
ll res=0;

void dfs(ll v,ll pre){
  cnt[v]=1;
  bool ok=true;
  for(P e : g[v]){
    ll nv=e.fi;
    if(nv==pre)continue;
    dfs(nv,v);
    if(cnt[nv]>N/2)ok=false;
    cnt[v]+=cnt[nv];
  }
  for(P e : g[v]){
    if(e.fi==pre){
      res+=e.se*min(cnt[v],N-cnt[v])*2;
    }
  }
  if(N-cnt[v]>N/2)ok=false;
  if(ok)cent.push_back(v);
}

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

  cin>>N;
  rep(i,N-1){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    g[a].push_back(P(b,c));g[b].push_back(P(a,c));
  }
  dfs(0,-1);
  assert((int)cent.size()==1||(int)cent.size()==2);

  if(cent.size()==2){
    ll u=cent[0],v=cent[1];
    if(cnt[u]<cnt[v])swap(u,v);
    for(P e : g[u]){
      if(e.fi!=v)continue;
      res-=e.se*min(cnt[v],N-cnt[v])*2;
      res+=e.se*(N-1);
      break;
    }
  }else{
    ll mn=INF;
    for(P e : g[cent[0]]){
      minch(mn,e.se);
    }
    res-=mn;
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 18048
#include<stdio.h>
#include<math.h>
int main(void){
	int N,T,A,i,min=10000000,ans=-1;
	scanf("%d %d %d",&N,&T,&A);
	int H[N+1];
	for(i=1;i<=N;i++) scanf("%d",&H[i]);
	
	for(i=1;i<=N;i++){
		if(abs(1000*T-H[i]*6-1000*A)<min){
			min=abs(1000*T-H[i]*6-1000*A);
			ans=i;
		}
	}
	
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 150000;
const int M = 500;
const int MOD = 1e9 + 7;
const int alpha = 26;
const double PI = acos(-1);
ll n, k;
ll ans = 0;
ll a[N];
ll b[N];

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n >> k;
    for (int i = 0; i < k; i++) cin >> a[i], ans += a[i];
    if (ans > n)
    {
        cout << -1;
        return 0;
    }
    cout << n - ans;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int main() {
	int n;
	scanf( "%d", &n );
	map<string, int> m;
	for ( int i = 0; i < n; i++ ) {
		string s;
		int a;
		cin >> s >> a;
		m[ s ] += a;
	}
	vector<pair<pair<int, string>, int> > vp;
	for ( map<string, int>::iterator i = m.begin(); i != m.end(); ++i ) {
		vp.push_back( make_pair( make_pair( i->first.size(), i->first ), i->second ) );
	}
	sort( vp.begin(), vp.end() );
	for ( int i = 0; i < vp.size(); i++ ) {
		printf( "%s %d\n", vp[ i ].first.second.c_str(), vp[ i ].second );
	}
	return 0;
}

Measured memory_bytes: 1288
#include <stdio.h>

int main() 
{
	int a,b,c;
	int i = 0;
	scanf("%d %d %d",&a ,&b ,&c);
	
	if(a+b+c != 17)
	{
		printf("NO");
	}
	else 
	{
		if(a != 5)
		{
			if(a != 7)
			{
				printf("NO");
				return 0;
			}
		}
		else
		{
			if(b != 5)
			{
				if(b != 7)
				{
					printf("NO");
					return 0;
				}
			}
			else 
			{
				if(c != 5)
				{
					if(c != 7)
					{
						printf("NO");
						return 0;
					}
					
				}
			}
		
		}
	printf("YES");
	return  0;
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    int q;
    cin >> s >> q;
    bool rev_flg = false;
    deque<char> d;
    int n = s.size();
    rep(i, n) d.push_back(s[i]);
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            rev_flg = !rev_flg;
        }
        else if (t == 2) {
            int f;
            char c;
            cin >> f >> c;
            if ((f == 1) && !rev_flg || (f == 2) && rev_flg) {
                d.push_front(c);
            }
            else if ((f == 1) && rev_flg || (f == 2) && !rev_flg) {
                d.push_back(c);
            }
        }
    }
    if (rev_flg) {
        reverse(d.begin(), d.end());
    }
    for (auto dd: d) {
        cout << dd;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3980
#include <stdio.h>
#include <ctype.h>

int main(int argv, char *argc[]){
    char answer[100] = {0}, target[100] = {0};
    int x, y, buf, flag=0;
    
    gets(answer);
    gets(target);
    
    
    for(x=0; '\0'!=answer[x]; x++){
        for(y=0, buf=x; target[y]==answer[buf] ||
             '\0'==target[y] || '\0'==answer[buf];){
            
            if('\0'== target[y]){
                flag=1;
                break;
            }
            
            if('\0'== answer[buf]){
                buf = 0;
                
                continue;
            }
            
            buf++;
            y++;
            
        }
    }
    
    if(1 == flag) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf( "%d %d", &a, &b );
	
	if( a < b )
	{
		printf( "a < b\n" );
	}
	else if( a > b )
	{
		printf( "a > b\n" );
	}
	else if( a == b )
	{
		printf( "a == b\n" );
	}
	
	return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int n;
	static String s1, s2;
	static char[] c = {'m', 'c', 'x', 'i'};
	static int[] val = {1000, 100, 10, 1};
	
	static int parse(String str) {
		int ret = 0;
		for(int i = 0; i < 4; i++) {
			int pos = str.indexOf(c[i]);
			if (pos > 0 && Character.isDigit(str.charAt(pos - 1))) {
				ret += Integer.parseInt(str.substring(pos - 1, pos)) * val[i];
			} else if(pos >= 0) {
				ret += val[i];
			}
		}
		return ret;
	}
	
	static String unparse(int num) {
		String ret = "";
		for(int i = 0; i < 4; i++) {
			int num_ = num / val[i];
			if(num_ > 1) {
				ret += String.valueOf(num_) + c[i];
			} else if(num_ == 1) {
				ret += c[i];
			}
			
			num = num % val[i];
		}
		return ret;
	}
	
	public static void main(String[] args) {
		n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			s1 = sc.next();
			s2 = sc.next();
			System.out.println(unparse(parse(s1) + parse(s2)));
		}
	}
}

Measured memory_bytes: 12000
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

def f(x):
    return '0'*(6-div10(x))+str(x)

N,M=mint()
S=dict()
for i in range(M):
    p,y=mint()
    S.setdefault(p,[])
    S[p].append((y,i))
ans=[0]*M
for p in S:
    S[p].sort()
    for j in range(len(S[p])):
        y,i=S[p][j]
        ans[i]=f(p)+f(j+1)
lprint(ans)

Measured memory_bytes: 110924
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

//string dp[10010];

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

	char* s = new char[N + 10];
	cin >> s;

	vector<INT> l(1);
	l[0] = 0;

	if (s[0] == '1')
	{
		l.push_back(0);
	}

	for (size_t i = 1; i < N; i++)
	{
		if (s[i - 1] != s[i])
		{
			l.push_back(i);
		}
	}
	l.push_back(N);

	INT maxLen = 0;

	for (size_t i = 0; i < l.size(); i += 2)
	{
		int startPos = max(0, (int)i - 1);
		int endPos = min(l.size() - 1, i + K * 2);

		INT score = l[endPos] - l[startPos];

		if (score > maxLen)
		{
			maxLen = score;
		}
	}

	cout << maxLen << endl;
	return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  vector<ll>veco(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<a-1;i++){
    if(vec.at(i)>=vec.at(i+1)){
      veco.at(i)=1;
    }
  }
  vector<ll>ve(0);
  for(ll i=0;i<a;i++){
    if(veco.at(i)==0){
      ve.push_back(i);
    }
  }
  ll b=ve.at(0);
  for(int i=1;i<ve.size();i++){
    b=max(b,ve.at(i)-ve.at(i-1)-1);
  }
  cout<<b<<endl;
}
    
  


Measured memory_bytes: 5676
n=gets.to_i
xyh=[]
for _ in 1..n
  xyh<<(gets.split.map &:to_i)
end
for cx in 0..100
  for cy in 0..100
    lo=10**18
    ex=nil
    ok=true
    for x,y,h in xyh
      d=(x-cx).abs+(y-cy).abs
      if h==0
        lo=[lo,d].min
      else
        if ex.nil?
          ex=h+d
        elsif ex!=h+d
          ok=false
          break
        end
      end
    end
    if ok&&ex&&ex<=lo
      puts [cx,cy,ex]*' '
      exit
    end
  end
end


Measured memory_bytes: 1788
class Facts

  def initialize(mod=10**9+7, n_max=1)
    @mod = mod
    @n_max = n_max
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    setup_table(n_max) if 1 < @n_max
  end

  def cmb(n,r)
    return 0 if r < 0 || n < r
    setup_table(n) if @n_max < n
    @fact[n] * (@factinv[r] * @factinv[n-r] % @mod) % @mod
  end

  def factorial(n)
    setup_table(n) if @n_max < n
    @fact[n]
  end

  def hom(n,k)
    cmb(n+k-1, k)
  end

  def prm(n,k)
    setup_table(n) if @n_max < n
    @fact[n] * @factinv[n-k] % @mod
  end

  private
    # O(t)
    def setup_table(t)
      (@n_max+1).upto(t) do |i|
        @fact.push( @fact[-1] * i % @mod )
        @inv.push( -@inv[@mod % i] * (@mod / i) % @mod )
        @factinv.push( @factinv[-1] * @inv[-1] % @mod )
      end
      @n_max = t
    end
end

# ABC132 Blue and Red Balls 2020/5/13 hom  nHk
# ABC145 2020/5/6
# ABC156 Roaming 2020/5/11 AC
# ABC167 E - Colorful Blocks 2020/5/11 AC

require 'bigdecimal'

n, a, b = gets.to_s.split.map{|t|t.to_i}
v       = gets.to_s.split.map{|t|t.to_i}.sort.reverse

f = Facts.new(100000000000000003)

s = v[0, a].sum
ave_f = s / ( a * 1.0 )
ave_i = ave_f.round

puts ave_f  

cnt = v.count(v[a-1])
idx = v.index(v[a-1])

if s == v[0] * a 
  cnt = v.count(v[a-1])
  idx = v.index(v[a-1])
  
  start = a - idx
  goal  = [b - idx, cnt].min
  
  ans = 0
  start.upto(goal) do |i|
    ans += f.cmb(cnt, i)
  end
  
  puts ans
else
  puts f.cmb(cnt, a-idx)
end

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

using namespace std;

int main(){
  int N,K; cin>>N>>K;
  int ans=-1;
  for(int bit=0;bit<(1<<N);bit++){
    vector<int> A;
    for(int i=0;i<N;i++){
      if(bit&(1<<i)){
        A.push_back(i);
      }
    }
    int num=1,index=0;
    for(int i=0;i<N;i++){
      if(index<A.size()){
        if(A[index]==i){
          num*=2;
          index++;
        }
        else num+=K;
      }
      else num+=K;
    }
    if(ans<0||ans>num){
      ans=num;
    }
  }

  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

int main()
{
int N,K ;
string S ;
cin >> N>>K >>S;
N=S.size();
K=K-1 ;
if (S.at(K)== 'A')
    S.at(K)= 'a';
else if (S.at(K)== 'B')
    S.at(K)= 'b';
    else if (S.at(K)== 'C')
    S.at(K)= 'c';

    cout <<S ;






    return 0;
}


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

int main(){
	std::string s; cin >> s;
	
	int pos = 0, c = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'g'){
			if(pos){
				pos--; c++;
			}else{
				pos++;
			}
		}else if(s[i] == 'p'){
			if(pos){
				pos--;
			}else{
				pos++; c--;
			}
		}
	}
	
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	if (n > m)swap(n, m);
	if (n == 1 && m == 1) {
		cout << 1 << endl;
	}
	else if(n == 1){
		cout << m - 2 << endl;
	}
	else {
		cout << (n - 2)*(m - 2) << endl;
	}
	return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector <int>A(N);

    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }

    float x = float(sum) / float((4 * M));
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if(A.at(i) >= x) {
            cnt++;
        }
    }

    if(cnt >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iterator>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

vector<vector<P>> vv;
vector<ll> dist;

void dfs(ll now, ll par, ll cost)
{
  dist[now] = cost;
  for (auto& to : vv[now]) {
    if (to.FI != par) dfs(to.FI, now, cost + to.SE);
  }
}

int main()
{
  int N; cin >> N;
  vv = vector<vector<P>>(N);
  dist = vector<ll>(N);
  REP(i, N - 1) {
    ll x, y, c;
    cin >> x >> y >> c;
    x--, y--;
    vv[x].PB(MP(y, c));
    vv[y].PB(MP(x, c));
  }
  ll Q, K;
  cin >> Q >> K;
  K--;
  dfs(K, -1, 0);
  REP(i, Q) {
    ll x, y;
    cin >> x >> y;
    x--, y--;
    cout << (dist[x] + dist[y]) << endl;
  }
  return 0;
}

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

ll mod = 1e9 + 7;

ll mpow(ll x, ll n){ //x^n(mod mod) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }
    vector<ll> a(N);
    rep(i, N){
        a[i] = A[i];
    }
    map<int, int> l;
    vector<int> check(1001);
    for (int i = 2; i < 1001; i++){
        if(check[i] != 0)continue;
        for (int j = i*i; j < 1001; j+=i){
            check[j] = 1;
        }
        int cnt = 0;
        rep(k, N){
            int cntnow = 0;
            while(a[k] % i == 0){
                a[k] /= i;
                cntnow++;
            }
            cnt = max(cnt, cntnow);
        }
        l[i] = cnt;
    }

    rep(i, N){
        if(a[i] != 1){
            l[a[i]] = 1;
        }
    }

    ll lc = 1;
    for (auto p : l){
        int key = p.first;
        int value = p.second;
        rep(i, value){
            lc *= key;
            lc %= mod;
        }
    }

    ll ans = 0;
    rep(i, N){
        ans += lc * mpow(A[i], mod-2);
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4044
from math import *

A,B,C,D=map(int,input().split())
mc=B//C-(A-1)//C
md=B//D-(A-1)//D
cd=(C*D)//gcd(C,D)
mcd=B//cd-(A-1)//cd
print(B-A+1-mc-md+mcd)


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

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e7 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

long long lp[N];
vector<long long> pr;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	for(long long i = 2; i <= N; i++){
		if(lp[i] == 0){
			lp[i] = i;
			pr.push_back(i);
		}
		for(long long j = 0; j < ll(pr.size()) && pr[j] <= lp[i] && i * pr[j] <= N; j++){
			lp[i * pr[j]] = pr[j];
		}
	}
	
	long long n, i; cin >> n;
	for(i = n; i != lp[i]; i++){};
	cout << i;
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main(){
  long long a, b, x;
  cin >> a >> b >> x;
  //ここまで入力

  long long s, g;

  //左端
  if(a%x ==0)  
    s = a/x;
  else
    s = (a+x)/x;

  //右端
  g = b/x;

  cout << g-s+1 << endl;
  



  return 0;
}


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

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int base = 100, money;
  int cnt = 0;
  cin >> money;
  while (money > base){
    base *= 1.01;
    cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 3576
#include<cstdio>
#include<vector>
#include<stack>
using namespace std;
int n,m,parent[100001],iri[100001],a,b,jun[100001],parent2[100001];
vector<int> to[100001],from[100001],ans;
stack<int> st;
int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n+m-1;i++){
        scanf("%d %d",&a,&b);
        to[a].push_back(b);
        from[b].push_back(a);
        iri[b]++;
    }
    for(int i=1;i<=n;i++){
        if(iri[i]==0){
            st.push(i);
        }
    }
    while(st.size()){
        int i =st.top();
        st.pop();
        ans.push_back(i);
        for(int j=0;j<to[i].size();j++){
            iri[to[i][j]]--;
            if(iri[to[i][j]]==0){
                st.push(to[i][j]);
            }
        }
    }
    for(int i=0;i<ans.size();i++){
        //printf("%d\n",ans[i]);
        jun[ans[i]]=i+1;
        for(int j=0;j<from[ans[i]].size();j++){
            if(parent2[ans[i]]<jun[from[ans[i]][j]]){
                parent2[ans[i]]=jun[from[ans[i]][j]];
                parent[ans[i]]=from[ans[i]][j];
            }
        }
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",parent[i]);
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

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

bool ok[111111];

signed main(){
    int X;cin>>X;
    ok[0]=true;
    for(int i=1;i<=X;i++){
        for(int j=100;j<=105;j++)if(i-j>=0)ok[i]|=ok[i-j];
    }
    if(ok[X])cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int X;
vector<int> Sieve(){
    bool is_prime[X+10];
    vector<int> prime;
    fill(is_prime,is_prime+X+10,true);
    for(int i=2;i<=X;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=i;j<=X;j+=i) is_prime[j]=false;
        }
    }
    return prime;
}


int main(){
    cin >> X;
    vector<int> prime;
    bool c=true;
    prime=Sieve();
    int x=X;
    if(prime[prime.size()-1]==X){
        cout << X << endl;
        return 0;
    }
    /*
    for(int i=0;i<prime.size();i++){
         cout << prime[i] << " ";
    }
    cout << endl;
    */

    while(c){
        for(int i=0;i<prime.size();i++){
            if(x%prime[i]==0){
                x++;
                c=true;
                break;
            }
            else c=false;
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll N, M;
std::string S, T;

ll gcd( ll a, ll b )
{ return b ? gcd(b,a%b) : a; }

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

std::vector<char> vs;

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

  ll L = lcm(N,M);

  rep( i, M ) if( N*i % M == 0 && T[i] != S[N*i/M] )
  {
    puts("-1");

    return 0;
  }

  printf( "%lld\n", L );

  return 0;
}

Measured memory_bytes: 512
n,m,c=map(int,input().split())
b=list(map(int,input().split()))

ans = 0

for i in range(n):
    a = list(map(int,input().split()))
    x = c
    for j in range(m):
        x += a[j]*b[j]
    if x > 0:
        ans += 1
print(ans)

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 505;

typedef pair<int,int>   ii;

struct Edge {
    int v, c;
    Edge(int _v,int _c) : v(_v), c(_c)  {}
};

vector<Edge> E;
vector<int>  g[N];

int addEdge(int u,int v,int c)  {
    g[u].pb(sz(E)); E.pb(v,c);
    g[v].pb(sz(E)); E.pb(u,0);

    return  sz(E) - 1;
}

int S, T;
int d[N];
int p[N];

bool bfs()  {
    for(int i = 0 ; i <= T ; ++i)
        d[i] = -1,
        p[i] = 0;

    queue<int>  q;
    q.push(S);  d[S] = 0;

    while (q.size())    {
        int u = q.front();  q.pop();
        for(int i : g[u])   {
            int v = E[i].v;
            if (E[i].c == 0)    continue;
            if (d[v] < 0)   {
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }

    return  d[T] >= 0;
}

int dfs(int u,int F)    {
    if (u == T || F == 0)   return  F;
    for(int &i = p[u] ; i < sz(g[u]) ; ++i)  {
        int j = g[u][i];
        int v = E[j].v;
        if (E[j].c == 0 || d[v] != d[u] + 1)
            continue;
        int res = dfs(v,min(E[j].c,F));
        if (res)    {
            E[j].c -= res;  j ^= 1;
            E[j].c += res;  return  res;
        }
    }
    return  0;
}

int MaxFlow()   {
    while (bfs())
    while (dfs(S,N));

    int ans = 0;

    for(int i : g[T])
        ans += E[i].c;

    return  ans;
}

int a[N][N];
set<int> R[N];

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

    int n;  cin >> n;
    int m;  cin >> m;

    S = 0;
    T = n + n + 1;

    for(int i = 1 ; i <= n ; ++i)
        addEdge(S,i,1),
        addEdge(i + n,T,1);

    for(int i = 1 ; i <= n ; ++i)
    for(int j = 1 ; j <= m ; ++j)   {
        int x;  cin >> x;
        R[i].insert(x);

        addEdge(i,(x + m - 1) / m + n,1);
    }

    for(int t = 1 ; t <= m ; ++t)   {
        assert(MaxFlow() == n);

        for(int i = 0 ; i < sz(E) ; i += 2) if (E[i ^ 1].c) {
            if (E[i].v == T || E[i].v <= n) {
                E[i].c = 1;
                E[i ^ 1].c = 0;
            }
            else    {
                E[i ^ 1].c = 0;
                int u = E[i ^ 1].v;
                int v = E[i].v - n - 1;

                a[u][t] = *R[u].upper_bound(v * m);
                R[u].erase(a[u][t]);
            }
        }
    }
    for(int i = 1 ; i <= n ; ++i, cout << "\n")
    for(int j = 1 ; j <= m ; ++j)
        cout << a[i][j] << " ";

    for(int j = 1 ; j <= m ; ++j)   {
        vector<int> vec;
        for(int i = 1 ; i <= n ; ++i)
            vec.pb(a[i][j]);

        sort(all(vec));

        for(int i = 1 ; i <= n ; ++i)
            a[i][j] = vec[i - 1];
    }
    for(int i = 1 ; i <= n ; ++i, cout << "\n")
    for(int j = 1 ; j <= m ; ++j)
        cout << a[i][j] << " ";
}

Measured memory_bytes: 1276
main = do
  li <- getLine
  let [n,k] = map read $ words li
  let ans = compute n k
  print ans

{-
n >= k のとき n mod k になる
n < k のときは まずk-nになり、次に k-(k-n) = n に戻る。
そのいずれかの小さい方が答え。
-}

compute :: Int -> Int -> Int
compute n k
  | n >= k = compute (mod n k) k
  | True   = min n (k-n)


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

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

  string s[n]={};
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  string temp = "";
  for (int i = 0; i < n-1; i++) {
    if (s[i] > s[i+1]) {
      temp = s[i];
      s[i] = s[i+1];
      s[i+1] = temp;
      i = -1;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << s[i];
  }
  cout << endl;
}


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

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
vector<int> score;
void dfs(const Graph &G, int v)
{
  seen[v] = true; // v を訪問済にする

  // v から行ける各頂点 next_v について
  for (auto next_v : G[v])
  {
    if (seen[next_v])
      continue;     // next_v が探索済だったらスルー
    score[next_v] += score[v];
    dfs(G, next_v); // 再帰的に探索
  }
}

int main()
{
  // 頂点数と辺数
  int N, Q;
  cin >> N >> Q;

  // グラフ入力受取 (ここでは無向グラフを想定)
  Graph G(N);
  for (int i = 0; i < N - 1; ++i)
  {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }

  score.assign(N, 0);    // 全スコアを0に初期化
  seen.assign(N, false); // 全頂点を「未訪問」に初期化
  for (int q = 0; q < Q; q++)
  {
    int p, x;
    cin >> p >> x;
    score[--p]+=x;
  }
  dfs(G, 0);
  for (int i = 0; i < N; i++)
  {
    cout << score[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
int X;
int N;
bool p[101];
int tmp;
int main() {
  cin >> X >> N;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    p[tmp] = true;
  }
  int Y;
  if (!p[X]) {
    cout << X << endl;
    return 0;
  }
  for (int i = 1; true; i++) {
    Y = X - i;
    if (!p[Y]) {
      cout << Y << endl;
      break;
    }
    Y = X + i;
        if (!p[Y]) {
      cout << Y << endl;
      break;
    }

  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string>S(N);
  vector<int>P(N);
  for(int i=0; i<N; i++){
    cin >> S.at(i) >> P.at(i);
  }
  
  vector<pair<string, int>>SP(N);
  for(int i=0; i<N; i++){
    SP.at(i) = make_pair(S.at(i), 100-P.at(i));
  }
  
  sort(SP.begin(), SP.end());
  
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(S.at(j)==SP.at(i).first && 100-P.at(j)==SP.at(i).second){
        cout << j+1 << endl;
      }
    }
  }
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b;
    cin >> a >> b;
    if (a + b >= 10) {
        cout << "error" << endl;
    }else{
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n;
  cin >> n;
  unsigned int a[100001]={};
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  reverse(a, a+n);
  long long int x[2]={};
  int k=0;
  for(int i=1; i<n; i++){
    if(a[i-1]==a[i]){
      x[k]=a[i];
      if(x[1]!=0){
        break;
      }
      k++;
      i++;
    }
  }
  cout << x[0]*x[1] << endl;
  return 0;


}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding Space*/
ll C[51][51]; // C[n][k] -> nCk
void comb_table(int N){
  for(int i=0;i<=N;++i){
  for(int j=0;j<=i;++j){
    if(j==0 or j==i){
      C[i][j]=1LL;
    }else{
      C[i][j]=(C[i-1][j-1]+C[i-1][j]);
    }
  }
  }
}
 
map<ll,ll> m;
vector<ll> v;
double ans_v = 0;
 
ll F(ll num){
  map<ll,ll> tm;
  tm = m;
  auto itr = tm.rbegin();
  while(1){
    if(num - (*itr).SEC > 0){
      num -= (*itr).SEC;
      itr++;
      continue;
    }else{
      return C[(*itr).SEC][num];
    }
  }
}
 
int main(){
  int n,a,b; cin >> n >> a >> b;
  comb_table(50);
  rep(i,n){ll in; cin >> in; m[in]++; v.pb(in);}
  
  sort(v.rbegin(),v.rend());
  ll sum = 0;
  rep(i,a){sum += v[i];}
  for(int i = a+1; i <= b; i++){
    ll t_ans = 0;
    rep(j,i) t_ans += v[j];
    if(t_ans*a != sum*i){
      b = i - 1;
      break;
    }
  }
  ll ans = 0;
  for(int i = a; i <= b; i++)
    ans += F(i);
 
  cout << fixed << setprecision(20)<<double(sum)/double(a) << endl;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *NIL;
Node *root;

Node * find(Node *u, int k){
  while (u != NIL && k != u->key){
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeMinimum(Node *x){
  while (x->left != NIL) x = x->left;
  return x;
}

Node * treeSuccessor(Node *x){
  return treeMinimum(x->right);
}

void treeDelete(Node *z){
  Node *y, *x;
  if (z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if (y->left != NIL) x = y->left;
  else x = y->right;

  if (x != NIL) x->parent = y->parent;

  if (y->parent == NIL){
    root = x;
  } else {
    if (y->parent->left == y) y->parent->left = x;
    else y->parent->right = x;
  }

  if (y != z) z->key = y->key;

  free(y);
}

void insert(int k){
  Node *x = root;
  Node *y = NIL;
  Node *z;

  z = (Node*)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if (y == NIL){
    root = z;
  }  else {
    if (z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node *u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);
  for (i=0; i<n; i++){
    cin >> com;
    if (com[0] == 'f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    } else if (com == "insert"){
      scanf("%d", &x);
      insert(x);
    } else if (com == "delete"){
      scanf("%d", &x);
      treeDelete(find(root, x));
    } else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 22064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    bool ok = true;
    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < N; j++) {
            if (a[j] % 2 == 0) {
                a[j] = a[j] / 2;
            } else {
                ok = false;
                break;
            }
        }
        if (!ok) {
            break;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;
using Pos = std::pair<int, int>;
//cout<<fixed<<std:cout<<fixed<<setprecision(2)<<Max<<endl;
constexpr int mod = 1e9 + 7;

vector<vector<int>> Edges;
vector<char> memo;

bool dfs(int node, int& size, char prev_color=0){
    ++size;
    if(prev_color==0){
        memo[node]=1;
    }else{
        memo[node]=prev_color*-1;
    }

    bool ans=false;
    for(const auto& val:Edges[node]){
        if(memo[val]==0){
            ans|=dfs(val,size,memo[node]);
        }else{
            if(memo[val]==memo[node])ans=true;
        }
    }

    return ans;
}

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

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


    long long iso_num=0;
    long long bi_num=0;
    long long not_bi_num=0;

    for(int i=0;i<N;++i){
        int size=0;
        if(memo[i]==0){
            bool is_bi=dfs(i,size);
            if(is_bi)++not_bi_num;
            else{
                if(size==1)++iso_num;
                else ++bi_num;
            }
        }
    }

    cout<<iso_num*(2*N-iso_num)+2*bi_num*bi_num+not_bi_num*not_bi_num+2*bi_num*not_bi_num<<endl;

    return 0;
}

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

int main() {
  int n, x, i, d = 0, ans = 1;
  cin >> n >> x;
  
  vector<int> l(n);
  for(i = 0; i < n; i++){
    cin >> l.at(i);
  }
  
  for(i = 0; i < n; i++){
    d += l.at(i);
    if(d <= x){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    xy = [tuple(map(int, input().split())) for _ in range(n)]
    sum_v = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if i != j:
                sum_v += math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2)
    print(sum_v * 2 / n)

if __name__ == '__main__':
    main()

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

int main() {
int s;
cin >>s;
vector<int> che(10e6);
long long ans =1;
while(1){
  if(che.at(s-1)==1){
    cout << ans << endl;
    break;
  }
  che.at(s-1)+=1;
  if(s%2==0)s/=2;
  else s =3*s+1;
ans++;
}
}





Measured memory_bytes: 39296