akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int k;
  cin >> k;
  queue<ll> qi;
  rep (i, 9) qi.push(i + 1);

  int cnt = 1;
  ll x = 0;
  while (true) {
    x = qi.front();
    qi.pop();

    if (cnt == k) break;

    if (x % 10 != 0) {
      qi.push(10 * x + x % 10 - 1);
    }
    qi.push(10 * x + x % 10);
    if (x % 10 != 9) {
      qi.push(10 * x + x % 10 + 1);
    }
    ++cnt;
  }

  cout << x << endl;

  return 0;
}


Measured memory_bytes: 5136
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	string s;cin>>s;
	ll n=s.length();
	vll v,ans;
	ll c=1;
	rep(i,1,n){
		if(s[i]==s[i-1])c++;
		else v.pb(c),c=1;
	}
	v.pb(c);
	// rep(i,0,v.size())cout<<v[i]<<" ";cout<<"\n";
	for(ll i=0;i<v.size();i+=2){
		ll a=v[i]%2,b=v[i+1]%2;
		ll t=(v[i]+v[i+1])/2;
		if(a^b){
			if(a){ans.pb(t+1);ans.pb(t);}
			if(b){ans.pb(t);ans.pb(t+1);}
		}
		else{
			ans.pb(t);ans.pb(t);
		}
	}
	ll x=0;
	// rep(i,0,ans.size())cout<<ans[i]<<" ";cout<<"\n";
	rep(i,0,n){
		if(s[i]=='R'&&s[i+1]=='L'){
			cout<<ans[x]<<" ";x++;
		}
		else if(s[i]=='L'&&s[i-1]=='R'){
			cout<<ans[x]<<" ";x++;
		}
		else cout<<0<<" ";
	}
	return 0;
}



Measured memory_bytes: 2628
//
//  main.cpp
//  ITP1_5-B
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, const char * argv[])
{

    int H,W;
    
    while (true) {
        cin >> H >> W;
        
        if ( H == 0 && W == 0) {
            break;
        }
        
        int i, j;
        for ( i = 0; i < H; i++ ){
            for ( j = 0; j < W; j++ ){
                if( j > 0 && j < W-1 && i > 0 && i < H-1){
                    printf(".");
                } else {
                    printf("#");
                }
            }
            printf("\n");
        }
        
        printf("\n");
    }
    
    return 0;
}

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

int main(){
   
   int N; int T;
   cin >> N >> T;
   
   vector<int> c;
   vector<int> t;
   
   int aux1, aux2;
   for (int i=0; i < N; i++) {
   	cin >> aux1 >> aux2;
   	c.push_back(aux1); t.push_back(aux2);
   }
   
   vector<int> pos_candidatos;
   for (int i=0; i < N; i++) {
   	if (t[i] <= T) pos_candidatos.push_back(i);
   }
   
   int aux = -1;
   for (int i=0; i < pos_candidatos.size(); i++) {
 	 aux = c[pos_candidatos[0]];
 	 if (c[pos_candidatos[i]] < aux) aux = c[pos_candidatos[i]];
   }
   for (int i=pos_candidatos.size()-1; i >= 0; i--) {
 	 if (c[pos_candidatos[i]] < aux) aux = c[pos_candidatos[i]];
   }
   
   if (aux == -1) cout << "TLE";
   else cout << aux;

   return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i - 1] >= a[i]) ++ans;
  }
  cout << ans << endl;
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll x, y;
    cin>>x>>y;
    if((2*x-y)%3)
    {
    	cout<<0<<endl;
    	return;
    }
    ll second=(2*x-y)/3;
    if((y-second)%2)
    {
    	cout<<0<<endl;
    	return;
    }
    ll first=(y-second)/2;
    if(second<0||first<0)
    {
    	cout<<0<<endl;
    	return;
    }
    ll fact1=1, fact2=1, fact3=1;
    forr1(i, first)
    {
    	fact1*=i;
    	fact1%=MOD;
    }
    forr1(i, second)
    {
    	fact2*=i;
    	fact2%=MOD;
    }
    forr1(i, first+second)
    {
    	fact3*=i;
    	fact3%=MOD;
    }
    ll ans=(fact3*modinverse(fact2))%MOD;
    ans%=MOD;
    ans*=modinverse(fact1)%MOD;
    ans%=MOD;
    cout<<ans<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3788
function main(input) {
  input=input.trim()
  const a = parseInt(input.split(" ")[0], 10);
  const op = input.split(" ")[1];
  const b = parseInt(input.split(" ")[2], 10);
  if(op=="+"){
    console.log(a+b);
  }else{
    console.log(a-b);
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int a, b, c, x, y;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> a >> b >> c >> x >> y;
    int t = max(x, y);
    ll res = 1e18;
    FOR(i,0,t) {
        ll price = 2LL * i * c;
        int X = max(0, x - i);
        int Y = max(0, y - i);
        price += (ll) X * a + Y * b;
        res = min(res, price);
    }
    cout << res;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[3];
    a[0] = n % 10;
    n /= 10;
    a[1] = n%10;
    n /= 10;
    a[2] = n%10;
    switch(a[0]) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        case 3:
            cout << "bon";
            break;
        default:
            break;
    }

    return 0;
}


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

 int N,X;
  cin>>N>>X;
  vector <int> L(N);
  for(int i=0;i<N;i++)
    cin>>L.at(i);
  vector <int> D(N+1);
  D.at(0)=0;
  for(int i=1;i<=N;i++)
    D.at(i)=D.at(i-1)+L.at(i-1);
  
  int ans=0;
  for(int i=0;i<=N;i++){
  if(D.at(i)<=X)
    ans++;
  } cout<<ans<<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
// review
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXQ = 110;

int q;
ll a[MAXQ], b[MAXQ];

bool check(int index, ll numOfPair) {
  ll mid = (a[index] + numOfPair + 1) / 2;
  return mid * (a[index] + numOfPair - mid) < a[index] * b[index];
}

void solve() {
  for (int i=0;i<q;i++) {
    if (a[i] > b[i]) {
      swap(a[i], b[i]);
    }
    if (a[i] == b[i]) {
      cout << 2 * (a[i] - 1) << endl;
      continue;
    }
    ll low = 0, high = b[i];
    while (high - low > 1) {
      ll mid = (low + high + 1) / 2;
      if (check(i, mid)) {
        low = mid;
      } else {
        high = mid;
      }
    }
    cout << (a[i] - 1 + low - 1) << endl;
  }
}

int main() {
  cin >> q;
  for (int i=0;i<q;i++) {
    cin >> a[i] >> b[i];
  }
  solve();
}


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

int main(){
  int A, B;
  string S;
  cin >>A >> B >> S;
  int ans=0;
  for(int i=0; i<A; i++){
    if(S.at(i)>='0' && S.at(i)<='9') ans++;
  }
  if(S.at(A)=='-') ans++;
  for(int i=A+1; i<A+B+1; i++){
    if(S.at(i)>='0' && S.at(i)<='9') ans++;
  }
  if(ans==A+B+1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
// atcoder/abc081/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;
    int mn = 1 << 29;
    each (i, a) {
      int x = (i ^ 1) ? 0 : (1 << 29);
      for (int j = 0; j < 30; ++j) {
        if (i & (1 << j)) break;
        x = j + 1;
      }
      setmin(mn, x);
    }
    cout << mn << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,x = readInts()
A = sorted(readInts())
cnt = 0
#print(A)
for i in range(n):
    if x > A[i] and not i == n-1:
        cnt += 1
        x -= A[i]
    elif x == A[i]:
        cnt += 1
        break
print(cnt)


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

ll comb(ll n, ll k) {
//  if(k==n) return 1;
  ll ret=1;
  for(ll i=n; i>=n-k+1; i--) {
    ret*=i;
  }
  for(ll i=1; i<=k; i++) {
    ret/=i;
  }
  return ret;
}

ll aCb(ll a, ll b) {
  if(b==0 || a==b) return 1;
  return aCb(a-1,b-1)+aCb(a-1,b);
}

ll po(ll b, ll e) {
  if(e==0) return 1;
  if(e%2==0) {
    ll t = po(b,e/2);
    return t*t;
  }
  return b*po(b,e-1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n,p;
  //cout << comb(10,10) << endl;
  // rep(i,5) {
  //   rep(j,i+1) {
  //     cout << "comb(" << i << "," << j <<")=" <<comb(i,j) << endl;
  //   }
  // } 
  cin>>n>>p;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll o=0,e=0;
  rep(i,n) {
    if(a[i]%2==0) {
      e++;
    } else o++;
  }
  ll ans=0;
  for(ll k=p; k<=o; k+=2) {
    // ans+=comb(o,k);
    ans+=aCb(o,k);
  }
  cout << ans*po(2,e) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MOD 1000000009+7

int main(){
	int N,M,i,j,ans=0,tmp;
	scanf("%d",&N);
	char s[N][10];
	for(i=0;i<N;i++){
		scanf("%s",&s[i][0]);
	}
	scanf("%d",&M);
	char t[M][10];
	for(i=0;i<M;i++){
		scanf("%s",&t[i][0]);
	}
	
	for(i=0;i<N;i++){
		tmp=0;
		for(j=i;j<N;j++){
			if(strcmp(s[i],s[j])==0)tmp++;
		}
		for(j=0;j<M;j++){
			if(strcmp(s[i],t[j])==0)tmp--;
		}
		if(tmp>ans)ans=tmp;
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

//Ice Maze
public class Main{

	int w, h, si, sj, gi, gj, INF = 1<<29, res;
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	int[] ice, hit;
	int[][] id, dist;
	char[][] m;
	boolean[][] v;
	
	void mark(int i, int j, int x){
		id[i][j] = x;
		ice[x]++;
		for(int k=0;k<4;k++){
			int ni = i+d[k][0], nj = j+d[k][1];
			if(m[ni][nj]=='X'&&id[ni][nj]==0)mark(ni, nj, x);
		}
	}
	
	boolean f(int i, int j, int depth, int pi, int pj){
		if(res < depth+dist[i][j])return false;
		if(gi==i && gj==j){
//			res = Math.min(res, depth);
			return true;
		}
		for(int k=0;k<4;k++){
			int ni = i+d[k][0], nj = j+d[k][1];
			if(ni!=pi&&nj!=pj&&v[ni][nj])return false;
		}
		for(int k=0;k<4;k++){
			int ni = i+d[k][0], nj = j+d[k][1];
			if(!v[ni][nj]&&m[ni][nj]!='#'){
				if(ice[id[ni][nj]]>>1 >= hit[id[ni][nj]]+1){
					hit[id[ni][nj]]++;
					v[ni][nj] = true;
					if(f(ni, nj, depth+1, i, j))return true;
					v[ni][nj] = false;
					hit[id[ni][nj]]--;
				}
			}
		}
		return false;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		ice = new int[144];
		hit = new int[144];
		dist = new int[14][14];
		m = new char[14][14];
		v = new boolean[14][14];
		for(;;){
			w = sc.nextInt(); h = sc.nextInt();
			if((w|h)==0)break;
			for(int i=0;i<h+2;i++)for(int j=0;j<w+2;j++){
				dist[i][j] = INF;
				v[i][j] = false;
				m[i][j] = '#';
			}
			for(int i=1;i<=h;i++){
				char[] c = sc.next().toCharArray();
				for(int j=1;j<=w;j++){
					m[i][j] = c[j-1];
					if(m[i][j]=='S'){
						m[i][j] = '.'; si = i; sj = j;
					}
					if(m[i][j]=='G'){
						m[i][j] = '.'; gi = i; gj = j;
					}
				}
			}
			Arrays.fill(ice, 0);
			ice[0] = INF;
			id = new int[h+2][w+2];
			int ID = 1;
			for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
				if(m[i][j]!='X'||id[i][j]>0)continue;
				mark(i, j, ID);
				if(ice[ID]==1){
					m[i][j] = '#';
				}
				ID++;
			}
			dist[gi][gj] = 0;
			Queue<int[]> que = new LinkedList<int[]>();
			que.add(new int[]{gi, gj});
			while(!que.isEmpty()){
				int V[] = que.poll();
				int pi = V[0], pj = V[1];
				for(int k=0;k<4;k++){
					int ni = pi+d[k][0], nj = pj+d[k][1];
					if(m[ni][nj]!='#'&&dist[ni][nj]==INF){
						dist[ni][nj] = dist[pi][pj]+1;
						que.add(new int[]{ni, nj});
					}
				}
			}
			res = 0;
			Arrays.fill(hit, 0);
			v[si][sj] = true;
			while(!f(si, sj, 0, -1, -1)){
				Arrays.fill(hit, 0);
				for(int i=0;i<h+2;i++)for(int j=0;j<w+2;j++)v[i][j]=false;
				v[si][sj] = true;
				res++;
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

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

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

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



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

  if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }else if(a+b<c+d){
    cout<<"Right"<<endl;
  }else{
    cout<<"Left"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m;
    cin >> n >> m;
    vp ab(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i] = P(a, b);
    }
    sort(ab.begin(), ab.end());
    ll ans = 0;
    for (P p : ab) {
        ans += (ll)p.fi * min(m, (ll)p.se);
        m -= p.se;
        if (m <= 0) break;
    }
    cout << ans << endl;
}

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

int main(void){
    string s;
    cin >> s;
    int S = 0;
    int i = 0;
    while(s[i] >= '0' && s[i] <= '9'){
        S += (s[i] - '0');
        i++;
    }

    int N = 0;
    int keisuu = 1;
    for(int j = s.length()-1; j >= 0; j--){
        N += keisuu * (s[j] - '0');
        keisuu *= 10;
    }

    if(N % S == 0)
        cout << "Yes" << endl;
    else if(N % S != 0)
        cout << "No" << endl;

    return 0;
}



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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

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

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

ll N, A, B;
vector<ll> V;
map<ll, int> cnt;

ll cmb(int n, int k) {
  if (n < 2 * k)
    k = n - k;

  ll m = 1;
  REP(i, 1, k + 1) {
    m = m * (n - i + 1) / i;
  }

  return m;
}

ll solve(int nselect) {
  int s;
  for (s = nselect - 1; s >= 0; --s) {
    if (V[s] != V[nselect-1])
      break;
  }

  if (s != 0)
    s++;

  ll n = cnt[V[nselect - 1]];
  ll k = nselect - s;

  return cmb(n, k);
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cin >> N >> A >> B;

  rep(i, N) {
    ll vv;
    cin >> vv;
    V.push_back(vv);
    cnt[vv]++;
  }

  sort(V.rbegin(), V.rend());

  double av = accumulate(V.begin(), V.begin() + A, 0.0) / A;
  cout << fixed << setprecision(10) << av << endl;

  ll npattern = 0;
  for (int i = A; i <= B; i++) {
    if (V[i-1] != V[0] && i != A)
      break;
    npattern += solve(i);
  }

  cout << npattern << endl;
  return 0;
}

Measured memory_bytes: 384
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9 + 7;

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

	vector<pair<string, int>> res(n);
	map<string, int> idx;
	string s;
	int p;
	REP(i, n) {
		cin >> s >> p;
		res[i] = make_pair(s, (100 - p));
		idx[s+to_string(100-p)] = i;
	}
	SORT(res);

	REP(i, n) {
		cout << idx[res[i].first + to_string(res[i].second)]+1 << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long long int N;
	scanf("%lld", &N);
	
	int i;
	long long int sum = 0;
	for(i = 0; i < N; i++) {
		long long int n;
		scanf("%lld", &n);
		sum += n;
	}
	printf("%lld\n", sum/N);
	
	return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        StringTokenizer st=new StringTokenizer(br.readLine());
        int[] a=new int[n];
        for(int i=0;i<n;i++){ a[i]=Integer.parseInt(st.nextToken()); }
        Arrays.parallelSort(a);
        int count=1;
        int index=0;
        ArrayList<Integer> list=new ArrayList<>();
        while(index<n){
            while(index<n-1&&a[index]==a[index+1]){
                count++;
                if(count==3){ count=1; }
                index++;
            }list.add(count);
            index++;
            count=1;
        }
        count=0;
        for(int i=0;i<list.size();i++){if(list.get(i)==2)count++;}
        System.out.println((count%2==0) ? list.size():list.size()-1);
        
    }
    
}

Measured memory_bytes: 23036
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
int n,k;
int a[100005];
ll dp[100005];
ll go(int index)
{
    if(index>=n )
        return 0;

    if(dp[index]!=-1)
        return dp[index];
    ll x=1e10;
    frr(1,i,k)
    {
        if(index+i<=n)
            x=min(x,abs(a[index]-a[index+i])+go(index+i));
    }
    return dp[index]=x;

}
void solve()
{
	// int n;
    cin>>n>>k;
    // int a[n+1];
    frr(1,i,n)  cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<go(1)<<"\n";

}
int main() 
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 12548
n, m = gets.split.map(&:to_i)
AB = []
n.times do
    AB << gets.split.map(&:to_i)
end
ans = 0    
AB.sort_by{|ab| ab[0]}.each do |price, number|
    num_purchase = [m, number].min
    ans += price * num_purchase
    m -= num_purchase
end
p ans

Measured memory_bytes: 12664
#!/usr/bin/env python3
import itertools

n = int(input())

must = set(["3", "5", "7"])
count = 0

for i in itertools.product("0357", repeat=10):
    num = int("".join(i))
    set_ = set(list(str(num)))
    if 0 in set_:
        continue
    if set_ != must:
        continue

    if int("".join(i)) <= n:
        # print(int("".join(i)))
        count += 1
    else:
        break
print(count)


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

string A, B, C;

int main() {
    cin >> A >> B >> C;

    if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// by Isaunoya
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct io {
	char buf[1 << 25 | 3], *s;
	int f;
	io() { f = 0, buf[fread(s = buf, 1, 1 << 25, stdin)] = '\n'; }
	io& operator >> (int&x) {
		for(x = f = 0; !isdigit(*s); ++s) f |= *s  == '-';
		while(isdigit(*s)) x = x * 10 + (*s++ ^ 48);
		return x = f ? -x : x, *this;
	}
};

signed main() {
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
#endif
	io in;
	int a, b, c, d;
	in >> a >> b >> c >> d;
	int ta = ((c + b - 1) / b);
	int tb = ((a + d - 1) / d);
	if(ta <= tb) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}


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

int main() {
  ll n,p;
  cin >> n >> p;
  
  ll ki=0,gu=0;
  vector<ll>a(n);
  for(ll i=0; i<n; i++){
    cin >> a[i];
    if(a[i]%2==1)ki++;
    else gu++;
  }
  
  ll kiki=0;
  for(ll i=1; i<=ki; i+=2){
    ll c=1,d=1;
    for(ll j=0; j<i; j++){
       c*=ki-j;
       d*=i-j;
      if(c%2==0 && d%2==0) c/=2,d/=2;
      if(c%3==0 && d%3==0) c/=3,d/=3;
      if(c%5==0 && d%5==0) c/=5,d/=5;
    }
     kiki+=c/d;
  }
  
  ll all=pow(2,n);
  
  ll ans=0;
  if(p==1) ans=pow(2,gu)*kiki;
  else ans=all-pow(2,gu)*kiki;
  
  cout << ans << endl;
  
  return 0;
  
}


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

using namespace std;

int main(int argc, char *argv[])
{
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int x, y;
    while (cin >> x >> y, x || y) {
        if (x > y) {
            swap(x,y);
        }
        cout << x << ' ' << y << endl;
    }
    return 0;
}



Measured memory_bytes: 3040
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v[111111];
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (m >= a) v[a].push_back(b);
  }

  long long ans = 0;
  priority_queue<int> q;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      // cout << i << ":" << v[i][j] << endl;
      q.push(v[i][j]);
    }
    if (!q.empty()) {
      ans += q.top();
      // cout << ans << endl;
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
#define LL long long
#define INF 0x3f3f3f3f

const int MAXN = 1e5 + 5;
const LL MOD = 1e9+7;

int main() 
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(n*a,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  vector<bool>prime(100010);
  prime[2]=true;
  for(int i=3;i<=100005;i+=2){
    bool flag=true;
    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){
	flag=false;break;
      }
    }
    if(flag)prime[i]=true;
  }
  int ans[100010]={};
  for(int i=3;i<100000;i++){
    if((prime[i]&&prime[(i+1)/2])||i==2017)ans[i]=ans[i-1]+1;
    else ans[i]=ans[i-1];
  }

  int q;cin>>q;
  for(int i=0;i<q;i++){
    int l,r;cin>>l>>r;
    cout<<ans[r]-ans[l-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    rep(i,A) cin >> p[i];
    rep(i,B) cin >> q[i];
    rep(i,C) cin >> r[i];

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end());

    X--; Y--; C--;
    int Cmax = C;
    while ((X >= 0 || Y >= 0) && C >= 0) {
        if (X < 0) {
            if (q[Y] >= r[C]) break;
            else {
                Y--;
                C--;
            }
        } else if (Y < 0) {
            if (p[X] >= r[C]) break;
            else {
                X--;
                C--;
            }
        } else {
            if (p[X] >= r[C] && q[Y] >= r[C]) break;
            if (p[X] >= q[Y]) Y--;
            else X--;
            C--;
        }
    }
    long long ans = 0;
    for (int i = 0; i <= X; i++) ans += p[i];
    for (int i = 0; i <= Y; i++) ans += q[i];
    for (int i = C + 1; i <= Cmax; i++) ans += r[i];

    cout << ans << endl;

    
    return 0;
}

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

int main() {
    int n, licznik = 0;
    string s;
    cin >> n;
    cin >> s;

    if (n%2 == 1) {
        cout << "No";
        return 0;
    }

    string t1 = s.substr(0, n/2);
    string t2 = s.substr(n/2, n/2);

    if (t1 == t2) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

namespace ABCTemplate_B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var b = new ProblemB();
        }
    }

    public class ProblemB
    {
        public ProblemB()
        {
            // 整数の入力
            int x = int.Parse(Console.ReadLine());
            int num500 = x / 500;
            var point500 = num500 * 1000;

            var rest = x - num500 * 500;

            int num5 = rest / 5;
            var point5 = num5 * 5;

            //出力
            Console.WriteLine(point500 + point5);
        }
    }
}


Measured memory_bytes: 13140
using System;

public class Program
{
    private static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var initialDebt = 100000;
        for (var i = 0; i < n; ++i)
        {
            initialDebt += initialDebt * 5 / 100;
            if (initialDebt % 1000 > 0)
            {
                initialDebt += 1000 - initialDebt % 1000;
            }
        }

        Console.WriteLine(initialDebt);
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

#define x(p) real(p)
#define y(p) imag(p)

const double eps=1e-8;
const double inf=1e12;
typedef complex<double> P;

namespace std{
  bool operator<(const P& a,const P& b){
    return x(a)==x(b)?y(a)<y(b):x(a)<x(b);
  }
}
double cross(const P& a,const P& b){
  return y(conj(a)*b);
}
double dot(const P& a,const P& b){
  return x(conj(a)*b);
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

P projection(const L& l,const P& p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*x(c/b);
}
P reflection(const L& l,const P& p){
  return p+2.0*(projection(l,p)-p);
}
//// counter-clockwise
int ccw(P a,P b,P c) {
  b=b-a;c=c-a;
  if(cross(b,c)>0) return +1;       // counter clockwise
  if(cross(b,c)<0) return -1;       // clockwise
  if(dot(b,c)<0)   return +2;       // c--a--b on line
  if(norm(b)<norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L& l,const L& m){
  return abs(cross(l[1]-l[0],m[1]-m[0]))>eps;
}
bool intersectSS(const L& s,const L& t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0&&ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

int main(){
	cin.sync_with_stdio(false);
  int q;
  cin>>q;
  while(q--){
    P p[4];
    rep(i,4){
      double x,y;
      cin>>x>>y;
      p[i]=P(x,y);
    }
    if(intersectSS(L(p[1],p[0]),L(p[2],p[3])))cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 3332
#include <iostream>
using namespace std;
string a, s;

void f(int p, int q, string b) {
	if(p==4) {
		if(q==7) s = b + "=7";
		return;
	}
	f(p+1, q+a[p]-'0', b + "+" + a[p]);
	f(p+1, q-a[p]+'0', b + "-" + a[p]);
}

int main() {
	string b;
	cin>>a;
	b = a[0];
	f(1, a[0]-'0', b);
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    n = 25 - n;
    cout << "Christmas";
    while (n--)
        cout << " Eve";
    return 0;
}

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

using namespace std;

using int64 = long long;

template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH1 = RollingHash< 1000000007 >;
using RH2 = RollingHash< 1000000009 >;
using Pi = pair< unsigned, unsigned >;

vector< int > get_span(string w) {
  vector< int > span(w.size());
  RH1 latte(w);
  RH2 malta(w);
  for(int i = 1; i < w.size(); i++) {
    Pi p(latte.get(0, i), malta.get(0, i));
    for(int j = i + i; j <= w.size(); j += i) {
      if(Pi(latte.get(j - i, j), malta.get(j - i, j)) == p) {
        span[j - 1] = true;
      } else {
        break;
      }
    }
  }
  return span;
}


int main() {

  string w;
  cin >> w;


  auto latte = get_span(w);
  reverse(begin(w), end(w));
  auto malta = get_span(w);
  reverse(begin(malta), end(malta));

  if(latte.back() == 0) {
    cout << 1 << endl;
    cout << 1 << endl;
    return 0;
  }

  int ret = 0;
  for(int i = 0; i + 1 < w.size(); i++) {
    if(!latte[i] && !malta[i + 1]) ++ret;
  }

  if(ret > 0) {
    cout << 2 << endl;
    cout << ret << endl;
    return 0;
  }

  bool same = true;
  for(int i = 1; i < w.size(); i++) {
    if(w[i - 1] != w[i]) same = false;
  }

  if(same) {
    cout << w.size() << endl;
    cout << 1 << endl;
    return 0;
  }

  // えーこういう場面どうするんや　人生終わり
  throw 0;
}

Measured memory_bytes: 12932
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

class Stack {
public:
    void push(string s) {
        v.push_back(s);
    }

    string pop() {
        if (is_empty()) {
            cerr << "Stack is empty.";
        }
        string s = v[v.size() - 1];
        v.pop_back();
        return s;
    }

    bool is_empty() {
        return v.empty();
    }

private:
    vector<string> v = vector<string>();

};

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

    string line, s, t;
    Stack st = Stack();
    getline(cin, line);
    stringstream x(line);
    while (getline(x, s, ' ')) {
        if (s == "+") {
            int n2 = stoi(st.pop());
            int n1 = stoi(st.pop());
            string ss = to_string(n1 + n2);
            st.push(ss);
        } else if (s == "-") {
            int n2 = stoi(st.pop());
            int n1 = stoi(st.pop());
            string ss = to_string(n1 - n2);
            st.push(ss);
        } else if (s == "*") {
            int n2 = stoi(st.pop());
            int n1 = stoi(st.pop());
            string ss = to_string(n1 * n2);
            st.push(ss);
        } else {
            st.push(s);
        }
    }
    cout << st.pop() << "\n";
}




Measured memory_bytes: 3244
S = sorted(list(str(input())))
l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in range(len(l)):
  if not l[i] in S:
    print(l[i])
    break
  if i == len(l) - 1:
    print('None')

Measured memory_bytes: 5100
import heapq as hq
from collections import Counter
N,K = map(int,input().split())
t_d = []
for _ in range(N):
    t,d = map(int,input().split())
    t_d.append([t,d])
t_d = sorted(t_d, key=lambda x:-x[1])
kiso = 0
neta = Counter()
stack = []
for t,d in t_d[:K]:
    kiso += d
    neta[t] += 1
    hq.heappush(stack,[d,t])
ans = kiso + len(neta)**2
for t,d in t_d[K:]:
    if neta[t] > 0 : continue
    while(stack):
        d0,t0 = hq.heappop(stack)
        if neta[t0] > 1:
            kiso += d - d0
            neta[t0] -= 1
            neta[t] += 1
            ans = max(ans, kiso+len(neta)**2)
            break
print(ans)


Measured memory_bytes: 34068
r,c=map(int,input().split())
a=[];s=[0]*(c+1)
for _ in [0]*r:a+=[list(map(int,input().split()))];a[-1]+=[sum(a[-1])];s=[x+y for x,y in zip(s,a[-1])]
for b in a+[s]:print(*b)


Measured memory_bytes: 6232
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;

signed main(){
  string s;
  cin >> s;
  int n = s.size();
  if (n % 2 == 1){
    cout << "No" << endl;
    return 0;
      }
  for (int i = 0; i < n; i+=2)
    if (not (s[i] == 'h' and s[i + 1] == 'i')){
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
using namespace std;
const int N=1e5+10;
typedef pair<int,int> pr;
map<pr,int> mp;
multiset<int> b[N];
queue<pr> q;
typedef multiset<int>::iterator it;
int f[N];
int find(int x){
    return !f[x]?x:f[x]=find(f[x]);
}
void link(int x,int y){
    b[x].insert(y),b[y].insert(x);
}
pr mkpr(int x,int y){
    if(x>y) swap(x,y);
    return make_pair(x,y);
}
int main()
{
    int n;
    scanf("%d",&n);
    fo(i,1,n*2-2){
        int x,y;
        scanf("%d %d",&x,&y);
        link(x,y);
        pr t=mkpr(x,y);
        ++mp[t];
        if(mp[t]==2) q.push(t);
        if(mp[t]>2) return printf("NO"),0;
    }
    fo(ch,2,n){
        if(q.empty()) return printf("NO"),0;
        int x=0,y=0;
        for(;x==y;x=find(q.front().first),y=find(q.front().second),q.pop());
        if(b[x].size()>b[y].size()) swap(x,y);
        f[x]=y;
        for(it i=b[x].begin();i!=b[x].end();i++){
            int v=find(*i);
            b[v].erase(b[v].find(x));
            if(v==y) continue;
            link(v,y);
            pr t=mkpr(v,y);
            ++mp[t];
            if(mp[t]==2) q.push(t);
        }
        b[x].clear();
    }
    printf("YES");
}
///////////////////////

Measured memory_bytes: 38912
import itertools
weight=[int(2**i) for i in range(10)]
while True:
	try:
		x=int(input())
		num=x
		a=[]
		while num!=0:
			for i in range(10):
				if num-weight[9-i]>=0:
					num-=weight[9-i]
					a.append(weight[9-i])
		for i in reversed(range(1,len(a))):
			print(a[i] ,end=" ")
		print(a[0])
	except EOFError:
		break



Measured memory_bytes: 5632
n = int(input())
a_list = list(map(int, input().split()))
a_list = [-1] + a_list
b_list = list(map(int, input().split()))
b_list = [-1] + b_list
c_list = list(map(int, input().split()))
c_list = [1] + c_list
m = 0
for i in range(1, n+1):
  m += b_list[a_list[i]]
  if i >= 2:
    if a_list[i-1] + 1 == a_list[i]:
      m += c_list[a_list[i-1]]
print(m)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;
const ll d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int main(){
    ll n;
    cin>>n;
    ll v[600][3];
    for(ll i=0;i<555;i++){
        for(ll j=0;j<3;j++){
            v[i][j]=0;
        }
    }
    for(ll i=0;i<n-1;i++){
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    for(ll i=0;i<n;i++){
        ll time = 0;
        for(ll j=i;j<n-1;j++){
            ll k=(time-v[j][1]+v[j][2]-1)/v[j][2];
            time=v[j][1]+max(k,0LL)*v[j][2];
            time+=v[j][0];
            //cout<<"i"<<i<<'j'<<j<<"time"<<time<<endl;
        }
        cout<<time<<endl;
    }
}


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

int c[99];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int a; cin >> a;
			c[a]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++)
		if (c[i] == n)
			ans++;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	S, T = list(input().split())
	ans = ""
	for i in range(N):
		ans += S[i] + T[i]
	print(ans)


if __name__ == '__main__':
	main()

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> v(n+1);

    for(int i=0; i<n; i++){
        if(s[i] == '#') v[i+1]++;
    }
    for(int i=0; i<n; i++) v[i+1] += v[i];

    int ans = 1e9;
    for(int i=0; i<=n; i++){
        ans = min(ans, v[i] + (n-i) - (v[n] - v[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 200005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

mint dp[105][500005];
mint cusum[105][500005];

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

  set<int> s;
  for(int i=1; (ll)i * (ll)i <= N; i++){
    s.insert(i);
    s.insert(N/i);
  }
  vector<int> x(s.begin(), s.end());
  
  unordered_map<int,int> m;
  rep(i,x.size()){
    m[x[i]] = i;
  }

  unordered_map<int,int> c;
  int prev = 0;
  rep(i,x.size()){
    c[i] = x[i] - prev;
    prev = x[i];
  }

  rep(i,x.size()){
    dp[0][i] = mint(c[i]);
    cusum[0][i] = dp[0][i] + (i-1>=0?cusum[0][i-1]:0);
  }
  REP(i,1,K){
    rep(j,x.size()){
      int v = x[j];
      int w = N/v;
      int wi = m[w];
      mint sum = cusum[i-1][wi];
      dp[i][j] = mint(c[j]) * sum;
      cusum[i][j] = dp[i][j] + (i-1>=0?cusum[i][j-1]:0);
    }
  }

  mint ret(0);
  rep(i,x.size()){
    ret += dp[K-1][i];
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 833444
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;


int main() {
	int n , m;
	cin >> n >> m;
	
	vector<vector<int>> ship(n);

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		if(a !=1  &&b != n){
			continue;
		}
		a--;
		b--;
		ship[a].emplace_back(b);
		ship[b].emplace_back(a);
		
	}

	
	bool canGo = false;
	for (int i = 1; i < n - 1;i++) {
		if (ship[i].size() >=2) {
			canGo = true;
			break;
		}
	}

	cout << (canGo ? "POSSIBLE" : "IMPOSSIBLE") << endl;

}

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

int main () {
  
  int H, W;
  cin >> H >> W;
  
  vector<string> board(H);
  for (int i = 0; i < H; i++) cin >> board[i];
  
  // 左の個数
  
  vector<vector<int>> left(H, vector<int>(W));
  
  for (int i = 0; i < H; i++) {
    
    left[i][0] = 0;
    
    for (int j = 0; j < W - 1; j++) {
      if (board[i][j] == '.') {
        left[i][j + 1] = left[i][j] + 1;
      }
      else {
        left[i][j + 1] = 0;
      }
    }
    
  }
  
  // 右の個数
  
  vector<vector<int>> right(H, vector<int>(W));
  
  for (int i = 0; i < H; i++) {
    
    right[i][W - 1] = 0;
    
    for (int j = W - 1; j > 0; j--) {
      if (board[i][j] == '.') {
        right[i][j - 1] = right[i][j] + 1;
      }
      else {
        right[i][j - 1] = 0;
      }
    }
    
  }
  
  // 上の個数
  
  vector<vector<int>> up(H, vector<int>(W));
  
  for (int j = 0; j < W; j++) {
    
    up[0][j] = 0;
    
    for (int i = 0; i < H - 1; i++) {
      if (board[i][j] == '.') {
        up[i + 1][j] = up[i][j] + 1;
      }
      else {
        up[i + 1][j] = 0;
      }
    }
    
  }
  
  // 下の個数
  
  vector<vector<int>> down(H, vector<int>(W));
  
  for (int j = 0; j < W; j++) {
    
    left[H - 1][j] = 0;
    
    for (int i = H - 1; i > 0; i--) {
      if (board[i][j] == '.') {
        down[i - 1][j] = down[i][j] + 1;
      }
      else {
        down[i - 1][j] = 0;
      }
    }
    
  }
  
  // 答え
  
  int ans = 0;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (board[i][j] == '.' && ans < 1 + left[i][j] + right[i][j] + up[i][j] + down[i][j]) {
        ans = 1 + left[i][j] + right[i][j] + up[i][j] + down[i][j];
      }
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 67200