akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#define N 550
using namespace std;
inline char gc(){
	static char now[1<<16],*S,*T;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0;char ch=gc();
	while (ch<'0'||ch>'9') ch=gc();
	while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
	return x;
}
struct node{
	int num,pos;
}data[N];
inline bool cmp(node a,node b){
	return a.num<b.num;
}
int cnt[N],ans[N*N],n,mark[N];
int main(){
//	freopen("agc.in","r",stdin);
	n=read();
	for (int i=1;i<=n;++i) data[i].num=read(),data[i].pos=i,mark[i]=data[i].num;
	sort(data+1,data+n+1,cmp);int nn=n*n;
	for (int i=1;i<=n;++i) cnt[i]=n;
	for (int i=1;i<=n;++i){
		int pos=data[i].pos;ans[data[i].num]=pos;cnt[pos]--;int tmp=data[i].num-1;int tot=pos-1;if (!tot) continue;
		for (int j=1;j<=tmp;++j){
			if (ans[j]) continue;
			ans[j]=pos;tot--;cnt[pos]--;if (tot==0) break;
		}if (tot>0){printf("No");return 0;}
	}
	int id=0;
	for (int i=1;i<=nn;++i){
		if (!ans[i]){id=0;
			if (!cnt[id]){
				for (int j=1;j<=n;++j){
				if(mark[j]<i&&cnt[j]) id=j;
				}
			}
			if (!id) {printf("No");return 0;}
			ans[i]=id;cnt[id]--;
		}
	}printf("Yes\n");
	for (int i=1;i<=nn;++i) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int n,m;
  cin >> n >> m;
  int s[m],c[m];
  rep(i,m)cin >> s[i] >> c[i];
  //rep(i,m)s[i]--;
  int sta;
  if(n!=1)sta = pow(10,n-1);
  else sta = 0;
  for(int i=sta;i<pow(10,n);i++){
    int t = i;
    int a[n];
    rep(i,n){
      a[i]=t%10;
      t/=10;
    }
    //rep(i,n) cout << a[i];
    bool flag = 1;
    rep(j,m){
      if(a[n-s[j]]!=c[j])flag=0;
    }
    if(flag==1){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
# AGC034 A-Kenken Race

import sys

N, A, B, C, D = map(int, input().split())
S = input()

if "##" in S[A-1:C+1] or "##" in S[B-1:D+1]:
    print("No")
    sys.exit()
    
if C < D:
    print("Yes")
else:
    if "..." in S[B-2:D+1]:
        print("Yes")
    else:
        print("No")

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

int main(){
  int n;
  cin >> n;
  
  int pi, s = 0, m = 0;
  for(int i = 0; i < n; i++){
      cin >> pi; s += pi;
      if(pi > m) m = pi;
  }
  
  cout << s - m/2 << endl;
  return 0;
}

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

int main() {
    string s;
    int count=700;
    cin >> s;

    for(int i=0;i<3;i++){
        if(s.at(i) == 'o'){
            count += 100;
        }
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

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


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    ll res = 0;
    vector<ll> a(n);
    vector<ll> b(n);
    for (int i = 0; i < n; i++)
         cin >> a[i] >> b[i];
    for (int i = n - 1; i >= 0; i--) {
        a[i] += res;
        ll mod = a[i] % b[i];
        if (mod != 0)
            res += b[i] - mod;    
    }
    cout << res << endl;
}   

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		long N, A, B;
		cin >> N >> A >> B;

		if( (A&1) == (B&1) ) {
			cout << (B-A)/2 << endl;
		}
		else {
			cout << min( A-1, N-B ) + 1 + (B-A-1)/2 << endl;
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

int main() {
  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  
  if( A+B > C+D ){
    cout << "Left" << endl;
  }else if( A+B == C+D ){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vector(vector<int> & a) {
	forn(i, (int)a.size()) {
		cout << a[i] << " ";
	}
	cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
	ll h;
	forn(i, n) {
		cin >> h;
		a.pb(h);
	}
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
vector<vector<int>> graph(MAXN);
vector<ll> dp(MAXN, 1);
vector<ll> fact(MAXN);
bool can = true;
ll k;
ll dfs(int v, int p = -1){
	ll res = 1;
	for (int to : graph[v]){
		if (to != p){
			res *= dfs(to, v);
			res %= MOD;
		}
	}
	//cout << v << " " << res << "\n";
	ll ch = graph[v].size();
	if (p != -1)--ch;
	ll kv = k;
	--kv;
	if (p != -1)--kv;
	//cout << v << " " << ch << " " << kv << "\n";
	while(ch--){
		res *= kv;
		res %= MOD;
		--kv;
	}
	//cout << v << " " << res << "\n";
	return res;
}
//#define DEBUG
int main(){
	FastIO;
	#ifdef DEBUG
		freopen("input.txt", "r", stdin);
	#endif // DEBUG
	ll n;
	cin >> n >> k;
	forn(i, n - 1){
		int a, b;
		cin >> a >> b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	ll prof = 1;
	for (ll i = 1; i <= k; ++i){
		prof *= i;
		prof %= MOD;
		fact[i] = prof;
	}
	ll ter = dfs(1);
	ter *= k;
	ter %= MOD;
	cout << ter << endl;
	return 0;
}


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

typedef long long ll;

int main(){
    int n; cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; i++)
    {
        ans = ans * i % (ll)(1e9+7);
    }
    cout << ans << endl;
    return 0;
}

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

string a;
string myans;
void dfs(int ans, int i, int lim, string s) {
    if(lim >= 3) {
        if(ans == 7) {
            myans = s;
        }
        return;
    }
    string s1 = s + "+" + a[i];
    string s2 = s + "-" + a[i];
    int ans1 = ans + (a[i] - '0');
    int ans2 = ans - (a[i] - '0');
    dfs(ans1, i + 1, lim + 1, s1);
    dfs(ans2, i + 1, lim + 1, s2);
}
void solve() {
    cin >> a;
    string t;
    t += a[0];
    dfs(a[0] - '0', 1, 0, t);
    cout << myans;
    cout << "=7";
}


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


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val (N, M, Q) = readInputLine().split(" ").map { it.toInt() }
    
    val sec = Array(N + 1) { IntArray(N + 1) }
    
    for (i in 1..M) {
        val (L, R) = readInputLine().split(" ").map { it.toInt() }
        for (j in 0..L) {
            sec[j][R]++
        }
    }
    
    for (i in 1..N) {
        for (j in 1..N) {
            sec[i][j] += sec[i][j - 1]
        }
    }
    
    for (i in 1..Q) {
        val (p, q) = readInputLine().split(" ").map { it.toInt() }
        println(sec[p][q])
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 82936
class UnionFind:
    def __init__(self, length):
        self.r = [-1] * length

    def root(self, x):
        rx = self.r[x]
        if (rx) < 0:
            return x

        return self.root(rx)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False
        r = self.r

        if r[x] > r[y]:
            x, y = y, x

        r[x] += r[y]
        r[y] = x

        return True

    def size(self, x):
        return -self.r[self.root(x)]

    def debug(self):
        print(self.r)


N, M = map(int, input().split())


relations = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    relations.unite(A-1, B-1)

max_ = -1
for i in range(N):
    max_ = max(relations.size(i), max_)

print(max_)


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

int main(){
	int n, k;
	long long cnt = 0;
	int tmp;
	cin >> n >> k;
	for(int i=k+1; i<=n; i++){
		tmp = 0;
		cnt += (i - k)*(n / i);
		//tmp += (i - k)*(n / i);

		cnt += max(0, n - i*(n / i) - max(k, 1) + 1);
		//cout << tmp << endl;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(void){
    int x, h;
  
    while(true){
        cin >> x >> h;
        if(x == 0 && h == 0) break;
  
        double S, s1, s2;
        s1 = x * x;
        s2 = x * sqrt(pow(0.5 * x, 2) + pow(h, 2)) * 0.5;
        S = s1 + s2 * 4;
  
        cout << fixed << setprecision(6) << S << endl;
    }
}



Measured memory_bytes: 3264
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
 int array[10];
 for(int i = 0; i < 10; i++){
  cin >> array[i];
 }
 sort(array, array+10);
 for(int i = 9; i >= 7; i--){
  cout << array[i] << endl;
 }

 return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;
 
public class Main {
	static final long MOD = 998244353L;
	//static final long INF = -1000000000000000007L;
	//static final long MOD = 1000000007L;
	//static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		long T = sc.nl();
		long A = sc.nl();
		long K = sc.nl();
		if (K >= T) {
			K -= T;
			T = 0;
		} else {
			T -= K;
			K = 0;
		}

		if (K >= A) {
			K -= A;
			A = 0;
		} else {
			A -= K;
			K = 0;
		}
		pw.println(T + " " + A);
		pw.close();
	}
	
	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}
	
	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) { 
		long ans = 1;
		x %= m;
		while (y > 0) { 
			if(y % 2 == 1) 
				ans = (ans * x) % m; 
			y /= 2;  
			x = (x * x) % m;
		} 
		return ans; 
	}
	
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr1[1]-arr2[1]; //ascending order
	          }
		});
		return array;
	}
    
    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] arr1, long[] arr2) {
				  return 0;
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn = 319;
const int MOD = 998244353;
ll dp[maxn][maxn][maxn];
string s; 
int k, ones, zeros;
vi numo, mino;

ll solve(int a, int b, int c){
	if(dp[a][b][c] != -1){
		return dp[a][b][c];
	}
	if(a == 0){
		return (b - c == numo[a]);
	}
	ll ans = 0;
	for(int i = 0; i <= b; i++){
		int nh = b - i; // i is in this column, nh in previous
		if(i - numo[a] > c) break;
		if(nh < mino[a-1]) continue;
		int nm = max(i - numo[a], 0);
		ans = (ans + solve(a-1,nh,c-nm))%MOD;
	}
	dp[a][b][c] = ans;
	//cout << a << " " << b << " " << c << " "  << dp[a][b][c] << endl;
	return ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	cin >> s;
	cin >> k;
	int n = sz(s);
	for(char c: s) if(c == '1') ones++;
	zeros = n - ones;
	rep(i,maxn) rep(j,maxn) rep(ii,maxn) dp[i][j][ii] = -1;
	numo.pb(0);
	for(char c: s){
		if(c == '1') numo.back()++;
		else numo.pb(0);
	}
	mino.resize(sz(numo));
	mino[0] = numo[0];
	for(int i = 1; i < sz(numo); i++){
		mino[i] = mino[i-1] + numo[i];
	}
	ll ans = 0;
	k = min(k, ones);
	rep(i,k+1){
		ans = (ans + solve(zeros,ones,i))%MOD;
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll combination(ll n, ll r) {
    if (n / 2 <= r) {
        r = n - r;
    }

    ll res = 1;
    for (ll i = 0; i < r; ++i) {
        res *= (n - i);
    }
    for (ll i = r; i > 0; --i) {
        res /= i;
    }

    return res;
}

int main() {

    ll n, p; cin >> n >> p;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll even = 0;
    ll odd = 0;
    for (ll i = 0; i < n; ++i) {
        if (a[i] % 2 == 0) {
            ++even;
        } else {
            ++odd;
        }
    }

    //奇数
    ll sum = 0;
    for (ll i = 1; i <= odd; i += 2) {
        ll com = combination(odd, i);
        com *= (ll)pow(2, even);
        sum += com;
    }

    if (p == 1) {
        cout << sum << endl;
    } else {
        cout << (ll)pow(2, n) - sum << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
int main(){
	int n ;
	cin >> n ;
	int m1 , m2 , m3 ;
	m1 = n % 10 ;
	n = n / 10 ;
	m2 = n % 10 ;
	n = n / 10 ;
	m3 = n ;
	if(m1 == 7 || m2 == 7 || m3 == 7)
		cout << "Yes" ;
	else
		cout << "No" ;
}

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

template<typename T>
struct BIT{//0-indexed
private:
  vector<T> data;
  const int n;
public:
  BIT(int sz) : data(sz+1,0), n(sz) {}
  BIT(vector<T> t) : data(t), n((int)t.size()) {}
  T sum(size_t i){//sum[0,i)
    //++i;
    T s = 0;
    while(i > 0){
      s += data[i];
      i -= i&(-i);
    }
    return s;
  }

  T sum(size_t i, size_t j){ return sum(j) - sum(i); }//sum[i,j)

  void add(int i, T x){
    ++i;
    assert(i > 0);
    while(i <= n){
      data[i] += x;
      i += i&(-i);
    }
  }
};

int main(){
  long long N, K, L;
  cin >> N >> K >> L;
  vector<int> A(N);
  for(int i = 0; i < N; ++i)
    cin >> A[i];
  vector<int> B = A;
  sort(B.begin(), B.end());
  B.erase(unique(B.begin(), B.end()),B.end());
  int M = B.size();
  int ok = -1, ng = M;
  long long T = (N-K+1)*(N-K+2)/2;
  while(ng-ok > 1){
    int m = (ok+ng)/2;
  // for(int m = 0; m < M; ++m){
    int c = B[m];
    vector<int> C(N+1);
    for(int i = 0; i < N; ++i)
      C[i+1] = (A[i] < c ? 1 : 0);
    for(int i = 1; i <= N; ++i)
      C[i] += C[i-1];
    // for(auto e : C)
    //   cerr << e << " ";
    // cerr << endl;
    BIT<int> bit(N+2);
    long long t = 0;
    for(int i = 0; i <= N; ++i){
      if(i >= K){
        bit.add(C[i-K],1);
      }
      t += bit.sum(max(0LL,C[i]-K+1),N);
    }
    // cerr << B[m] << " " << T-t << endl;
    if(T-t < L) ok = m;
    else ng = m;
  }
  cout << B[ok] << endl;
}



Measured memory_bytes: 5964
from collections import Counter
n,p=map(int,input().split())
s=input()[::-1]
a=0
t=0
d=1
m=[0]*p
m=[0]
for i in range(n):
  x=int(s[i])*d%p
  m.append((m[-1]+x)%p)
  d=(d*10)%p
c=Counter(m)
for i,j in c.items():
  a+=j*(j-1)//2

if p==2 or p==5:
  a=0
  for i in range(n):
    x=int(s[i])
    if x%p==0:
      a+=n-i
  print(a)
else:
  print(a)


Measured memory_bytes: 50732
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<int> uf, usz;
int nc;

void init(int n) {
	vector<int> uf_(n);
	vector<int> usz_(n, 1);
	uf = uf_;
	usz = usz_;
	nc = n;

	for (int i = 0; i < uf.size(); i++) {
		uf[i] = i;
	}
}

int find(int a) {
	return (uf[a] == a) ? a : uf[a] = find(uf[a]);
}

void union_(int a, int b) {
	a = find(a);
	b = find(b);

	if (a != b) {
		if (usz[a] >= usz[b]) {
			swap(a, b);
		}
		uf[a] = b;
		usz[b] += usz[a];
		nc--;
	}
}

int check(int a, int b) {
	return (find(a) == find(b)) ? 1 : 0;
}

int get_size(int a) {
	return usz[find(a)];
}

ll d[100000];
ll n, m;
ll f(ll index) {
	if (index >= n)return 1;
	else return 0;
}

int main() {
	cin >> n >> m;
	init(n);
	vector<ll> v;
	rep(i, 0, n) {
		ll a;
		cin >> a;
		v.pb(a);
	}
	rep(i, 0, m) {
		ll a, b;
		cin >> a >> b;
		union_(a, b);
	}
	if(nc==1){
		cout << 0 << endl;
		return 0;
	}
	ll n1 = (nc-1)*2;
	set<ll> se;
	rep(i,0,n){
		se.insert(find(i));
	}
	vector<ll> v1(all(se));
	map<ll,ll> ma;
	rep(i,0,v1.sz){
		ma[v1[i]]=i;
	}
	vector<vector<ll> > vv(nc,vector<ll>());
	rep(i,0,v.sz){
		vv[ma[find(i)]].pb(v[i]);
	}
	rep(i,0,vv.sz){
		sort(all(vv[i]));
	}
	vector<ll> v2;
	vector<ll> v3;
	ll n2 = 0;
	rep(i,0,vv.sz){
		rep(j,0,min(n1/2,(ll)vv[i].sz)){
			n2++;
			if(j==0)v2.pb(vv[i][j]);
			else v3.pb(vv[i][j]);
		}
	}
	sort(all(v2));
	sort(all(v3));
	if(n2<n1){
		cout << "Impossible" << endl;
	}
	else{
		ll ans = 0;
		rep(i,0,v2.sz){
			ans += v2[i];
		}
		rep(i,0,n1-v2.sz){
			ans += v3[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 20588
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class AHaiku {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;
        for (char x: s) if (x == ',') out << ' '; else out << x;
        out << el;
	}
};


int main() {
	AHaiku solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

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

    bool app[26] = {false};

    for(int i=0;i<s.size();++i){
        app[s[i] - 'a'] = true; 
        // char型は16進数のASCIIコード
        //　アルファベットは連続　→ 'a'で引けばaから何番目かが得られる

    }
    char answer;
    for(int i=0;i<26;++i){
        if(app[i] == false) {
            answer = 'a' + i;
            cout << answer << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

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

using namespace std;

const long long mod = 1000000007;

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

	int n, q;
	cin >> n >> q;
	int* s, *sortedS;
	s = new int[n];
	sortedS = new int[n];
	rep(i, n) {
		cin >> s[i];
		sortedS[i] = s[i];
	}
	sort(sortedS, sortedS + n);

	//あるleader以下のスコアを持つ人数のmultiset
	multiset<int> leader;

	rep(i, q) {
		string query;
		int x;
		cin >> query >> x;

		if (query == "ADD") {
			leader.insert(upper_bound(sortedS, sortedS + n, s[x - 1]) - 1 - sortedS);
		}
		else if (query == "REMOVE") {
			leader.erase(leader.find(upper_bound(sortedS, sortedS + n, s[x - 1]) - 1 - sortedS));
		}
		else {
			int r, l, mid, out;
			l = -1;
			r = 1000000000;
			if (leader.size() == 0) {
				out = n;
			}else{
                out = n - *leader.rbegin() - 1;
            }
			if (out > x) {
				cout << "NA" << "\n";
				continue;
			}

			while (r - l > 1) {
				//既に調べている部分の人数
				int invalid = 0;
				//ハブにされた人数の合計
				int sum = out;
				mid = (r + l) / 2;
				

				for (auto i = leader.begin(); i != leader.end(); ++i) {
					sum += max(0, (int)(lower_bound(sortedS, sortedS + n, sortedS[*i] - mid) - sortedS - invalid));
					invalid = *i + 1;
				}

				if (sum <= x) r = mid;
				else l = mid;
			}

			cout << r << "\n";
		}
	}
}



Measured memory_bytes: 10932
#include<bits/stdc++.h>//头文件
using namespace std;
string s;
bool c,f;
int main(){
    cin>>s;
    for(int i=0;s[i]!='\0';i++){
        if(s[i]=='C')c=true;
        if(s[i]=='F'&&c)f=true;
    }
    c&&f?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if ((a+b)>=c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
N, M = map(int, raw_input().split())
c = [0,2,5,5,4,5,6,3,7,6]
A = sorted(map(int, raw_input().split()))

D = [0] + [-1] * N * 9
a = [0, 0] * N

for i in range(1, N + 1):
    for j in A:
        p = i - c[j]
        if min(p, D[p], D[p] + 1 - D[i]) >= 0:
            D[i], a[i] = D[p] + 1, j

S, p = "", N
while p:
    S += str(a[p])
    p -= c[a[p]]
print S

Measured memory_bytes: 4100
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
 int main(){
     int a,b;
     cin >> a >> b;
     if(a>=13) cout << b;
     else if(6<=a) cout << b/2;
     else cout << '0';
 }

Measured memory_bytes: 256
/*
_____________________$$o____________________o$$$$$o__
___________________o$o_$$o____oo$$$$$$$oo______o$$$$o
______________$o________o$$$$$o___oo$$$$$$$o______$$$
______________$$$ooo________o$$$$o______o$$$$$o_____o
____________oo_____oo_____oo___o$$$$$______$$$$$$____
_________ooooo___$$o_$___oooooo___o$$$$o__o__o$$$$___
_______ooo__ooo$$$$o_$$ooooooooooo__o$$$o__oo_oo$$$o_
______oo_o$$o_$$_o$o_o$o__oooooooooo__o$$$o_oo__o$$$o
____oooooo$$$$o___oo__$$o_ooo_oooooooo__o$$o_ooo_o$$$
___ooooooo__o___oooo__$$ooooo$_oooooooo__o$$__ooo_$$$
_$$o_ooooo___o$$$$$o__o$o__o_$o__oooooooo_o$$o_oo__$$
_$$$o_ooo_________o$$_$$o____$$o_ooooooooo_$$$o_oo_$$
__oo________o$$o____o_$$o____o$ooooooooooo_o$$o_oo_o$
___o$$$$$$$$$$$$$o___$$$o____$$o_oooooooooo_$$$o_o_o$
________o__oo$$$$$o__$$$o____$$o____oooooo__$$$o_o_o$
_________$$$$$$$$$o__$$_____$$$o___________$$$oooooo_
__________o$$$$$$$o_________$$___________o$o___oooooo
___________o$$$$o_______________ooooo__oo$__ooo__oooo
________________________________ooo_$$oo___oooo$o____
________________________________oooo_$$$$$o___oo$$$o_
________________________________ooooo_o$$$$$o_____$$$
________________________________oooooo_o$$$$$$ooo___o
________________________________ooooooo__o$$$$$o_____
*/
#include<bits/stdc++.h>
#define ll long long
#define ft first
#define sd second
#define HageBaIO_KPOCCbI int LOL;scanf("%d", &LOL);for(int i = 0; i < LOL; i++)
using namespace std;
//BY |3 |<
const int dx[] = {1, 0, -1,  0};
const int dy[] = {0, 1,  0, -1};
//Where I am?
const ll N = 1e5 + 5;
const ll MOD = (1e9 + 7);
const ll MOD1 = 998244353;
const double PI = 3.14159265;
const int INF32 = 2e9;
const ll INF64 = 2e18;
//Don`t believe!!!//
int a, b, c;
void KEK(){
	scanf("%d%d%d", &a, &b, &c);
	printf("%d %d %d", c, a, b);
}
int main(){
	//HageBaIO_KPOCCbI
	KEK();
}
//TAUMAC, 9| BbIWEJI 3A TObOU!!!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



Measured memory_bytes: 256
#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;

int main(){
  int k;
  cin>>k;
  if(k<=9){
    cout<<k<<endl;
    return 0;
  }
  ll dp[100005];
  rep(i,9) dp[i]=i+1;
  int cnt=9,now=0;
  while(1){
    rep(j,3){
      if(dp[now]%10+(j-1)==-1||dp[now]%10+(j-1)==10)
	continue;
      cnt++;
      if(cnt==k){
	cout<<dp[now]*10+(dp[now]%10+(j-1))<<endl;
	return 0;
      }
      dp[cnt-1]=dp[now]*10+(dp[now]%10+(j-1));
    }
    now++;
  }
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int gcd(int x, int y) {
  int r;
  if(x < y) swap(x, y);
  while(y > 0) {
	r = x % y;
	x = y;
	y = r;
  }
  return x;
}
int main() {
  int x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int N,K,a,b;

int main(){
	cin>>N>>K;
	rep(i,K){
		cin>>a>>b;
		cout<<min(min(a-1,N-a),min(b-1,N-b))%3+1<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll bit[100010];
ll n;

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}



int main(void)
{
	ll h, w, a, b;

	cin >> h >> w >> a >> b;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (i < b && j < a)
			{
				cout << 1;
			}
			else if (i >= b && j >= a)
			{
				cout << 1;
			}
			else
			{
				cout << 0;
			}

			
		}
		cout << endl;
	}

	int www;
	cin >> www;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#define M 1000000

using namespace std;

int main() {

	int c, n;
	bool x[M];

	for(int i=2; i<=M; i++) {
		x[i]=false;
	}
	for(int i=2; i<1000; i++) {
		if(x[i])
			continue;
		for(int j=i*2; j<M; j+=i) {
			if(!x[j])
				x[j]=true;
		}
	}

	while(scanf("%d", &n)!=EOF) {
		c=0;
		for(int i=2; i<=n; i++) {
			if(!x[i])
				c++;
		}
		cout << c << endl;
	}
	

	return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define vii vector<ii>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);

int main()
{
	assem99;

	int arr[N];
	int n, k; cin >> n >> k;
	f(i, 0, n) cin >> arr[i];
	int ans = 0, cntr = 0;
	while (1)
	{
		ans++;
		cntr += k;
		if (cntr >= n)
		{
			cout << ans;
			break;
		}
		cntr--;
	}

	return 0;
}

Measured memory_bytes: 640
import numpy as np
from math import sqrt
from collections import defaultdict


def sieve(x):
    primes = []
    is_prime = np.ones(x + 1, bool)
    is_prime[0] = is_prime[1] = False
    for i in range(x + 1):
        if is_prime[i]:
            primes.append(i)
            is_prime[2*i::i] = False

    return primes


def prime_fact(x):
    mx = int(sqrt(x)) + 5
    primes = sieve(mx)
    pf = defaultdict(int)
    for e in primes:
        while x % e == 0:
            x //= e
            pf[e] += 1

    if x != 1:
        pf[x] += 1

    return pf


n = int(input())

pf = prime_fact(n)
ans = 0
for v in pf.values():
    i = 1
    while (i + 1) * (i + 2) // 2 <= v:
        i += 1

    ans += i

print(ans)


Measured memory_bytes: 31248
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 100005;

LL n,sum = 0,tot,cnt;
LL a[N],b[N];

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i]; a[0] = a[n];
	for(LL i = 1;i <= n;i ++){
		b[i] = a[i] - a[i - 1];
		sum += a[i];
	}
	if(sum % ((n * (n + 1)) / 2)){ cout << "NO\n"; return 0; }
	tot = sum / ((n * (n + 1)) / 2);
	for(LL i = 1;i <= n;i ++){
		b[i] = b[i] - tot;
		if(b[i] % n || b[i] > 0){ cout << "NO\n"; return 0; }
	}
	cout << "YES\n";
	return 0;
}

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

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (abs(a - b) <= (v - w) * t) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

struct S_UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  ll sum;
  
  S_UFT() {}

  void clear(int n) {
    for (int i = 0; i < n; i++)
      links[i] = i, ranks[i] = sizes[i] = 1;
    sum = 0;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }
  
  int merge(int i0, int i1, ll cost = 0) {
    int r0 = root(i0), r1 = root(i1);
    int mr;
    sum += cost * sizes[r0] * sizes[r1];
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

struct Edge {
  int a, b;
  ll c;

  bool operator<(const Edge& e) const { return c < e.c; }
};

/* global variables */

int n;
Edge edges[MAX_N - 1];
S_UFT suft;

/* main */

int main() {
  cin >> n;

  for (int i = 0; i < n - 1; i++)
    cin >> edges[i].a >> edges[i].b >> edges[i].c;
  sort(edges, edges + n - 1);

  suft.clear(n);

  for (int i = 0; i < n - 1; i++)
    suft.merge(edges[i].a, edges[i].b, edges[i].c);

  cout << suft.sum << endl;
  
  return 0;
}

Measured memory_bytes: 6652
/*
 * Author : Sadi
 * Mon 06/07/2020
 * 18:26:23.40
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

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

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int r;
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}


Measured memory_bytes: 3644
Sa=list(input())
Sb=list(input())
Sc=list(input())

nowcard=Sa.pop(0)

while True:
    if nowcard=='a':
        if Sa==[]:
            print('A')
            break
        nowcard=Sa.pop(0)
    elif nowcard=='b':
        if Sb==[]:
            print('B')
            break
        nowcard=Sb.pop(0)
    else:
        if Sc==[]:
            print('C')
            break
        nowcard=Sc.pop(0)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

int h, w;
vector<string> s;
vector<vector<char> > used;

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

int bfs(int x, int y) {
	queue<pair<pair<int, int>, int> > q;
	q.push({ { x, y }, 0 });
	used[x][y] = 1;
	int res = 0;
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int ex = p.first.first, ey = p.first.second;
		res = max(res, p.second);
		for (int i = 0; i < 4; ++i) {
			int nx = ex + dx[i], ny = ey + dy[i];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
			if (s[nx][ny] == '#') continue;
			if (used[nx][ny]) continue;
			used[nx][ny] = true;
			q.push({ {nx, ny}, p.second + 1 });
		}
	}

	return res;
}

int main() {
	cin >> h >> w;
	s.resize(h);
	for (int i = 0; i < h; ++i) cin >> s[i];
	int ans = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (s[i][j] == '#') continue;
			used.assign(h, vector<char>(w, 0));
			ans = max(ans, bfs(i, j));
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int A[5];
//---------------------------------------------------------------------------------------------------
void _main() {
	rep(i, 0, 5) cin >> A[i];
	
	vector<int> v;
	rep(i, 0, 5) v.push_back(i);
	int ans = inf;
	do {
		int t = 0;
		rep(i, 0, 5) {
			int vi = v[i];
			if (0 < t % 10) t = t - (t % 10) + 10;
			t += A[vi];
		}
		chmin(ans, t);
	} while (next_permutation(all(v)));

	cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * itikara.cpp
 *
 *  Created on: 2018/05/30
 *      Author: J01003
 */
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
char ch;
while(1){
	scanf("%c",&ch);
	if('a'<=ch&&ch<='z'){
		ch=ch-32;
	}
	else if ('A'<=ch&&ch<='Z'){
		ch=ch+32;
	}
	if(ch=='\n'){
		break;
	}
	printf("%c",ch);
}
printf("\n");
	return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
long double EPS = (long double)1e-7;
struct Point { long double px, py; };
Point r1[100], r2[100]; int n, m;
vector<pair<Point, int>>vec, vec2;
inline bool solve(Point a1, Point a2) {
	if (a1.px > a2.px)swap(a1, a2);
	if (a1.px == a2.px) {
		int colour = 0; bool r[3] = { false,false,false };
		for (int i = 0; i < vec2.size(); i++) {
			if (r[1] == true && r[2] == true)return false;
			if (colour == 0) {
				if (vec2[i].first.px < a1.px) { colour = 3 - vec2[i].second; }
				else if (vec2[i].first.px == a1.px) { r[vec2[i].second] = true; }
				else if (vec2[i].first.px > a1.px) { colour = vec2[i].second; }
			}
			else {
				if (colour != 3 - vec2[i].second && vec2[i].first.px < a1.px) { return false; }
				else if (vec2[i].first.px == a1.px) { r[vec2[i].second] = true; }
				else if (colour != vec2[i].second && vec2[i].first.px > a1.px) { return false; }
			}
		}
		if (r[1] == true && r[2] == true)return false;
		return true;
	}
	else {
		long double KT = (a2.py - a1.py) / (a2.px - a1.px);
		long double YY = a1.py - a1.px*KT;
		int colour = 0; bool r[3] = { false,false,false };
		for (int i = 0; i < vec2.size(); i++) {
			if (r[1] == true && r[2] == true)return false;
			long double height = YY + KT*vec2[i].first.px;
			if (colour == 0) {
				if (vec2[i].first.py < height) { colour = 3 - vec2[i].second; }
				else if (vec2[i].first.py == height) { r[vec2[i].second] = true; }
				else if (vec2[i].first.py > height) { colour = vec2[i].second; }
			}
			else {
				if (colour != 3 - vec2[i].second && vec2[i].first.py < height) { return false; }
				else if (vec2[i].first.py == height) { r[vec2[i].second] = true; }
				else if (colour != vec2[i].second && vec2[i].first.py > height) { return false; }
			}
		}
		if (r[1] == true && r[2] == true)return false;
		return true;
	}
}
int main() {
	while (true) {
		vec.clear(); vec2.clear(); cin >> n >> m; if (n == 0 && m == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> r1[i].px >> r1[i].py; vec2.push_back(make_pair(r1[i], 1));
			for (long double j = -1.0l; j <= 1.0l; j += 1.0l) {
				for (long double k = -1.0l; k <= 1.0l; k += 1.0l) {
					if (fabs(j) + fabs(k) > 1.9l)continue;
					vec.push_back(make_pair(Point{ r1[i].px + j*EPS,r1[i].py + k*EPS }, 1));
				}
			}
		}
		for (int i = 0; i < m; i++) {
			cin >> r2[i].px >> r2[i].py; vec2.push_back(make_pair(r2[i], 2));
			for (long double j = -1.0l; j <= 1.0l; j += 1.0l) {
				for (long double k = -1.0l; k <= 1.0l; k += 1.0l) {
					if (fabs(j) + fabs(k) > 1.9l)continue;
					vec.push_back(make_pair(Point{ r2[i].px + j*EPS,r2[i].py + k*EPS }, 2));
				}
			}
		}
		bool ans = false;
		for (int i = 0; i < vec.size(); i++) {
			for (int j = i + 1; j < vec.size(); j++) {
				if (fabs(vec[i].first.px - vec[j].first.px) + fabs(vec[i].first.py - vec[j].first.py) < EPS * 6)continue;
				bool p1 = solve(vec[i].first, vec[j].first);
				if (p1 == true) {
					ans = true; break;
				}
			}
		}
		if (ans == true)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;
using namespace boost::multiprecision;

int main(){
  int n;cin>>n;
  vector<int128_t>a(n);
  rep(i, n)cin>>a[i];

  for(auto c:a)if(c==0) {cout<<0<<endl; return 0;}

  int128_t result = 1;

  int c=0;
  rep(i, n){
    result *= a[i];
    if(result>1000000000000000000LL) {cout<<-1<<endl; return 0;}
  }

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 6440
#include "bits/stdc++.h" 
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
typedef long long ll;

ll L,R;

void solve(){
  ll min_v = INF;
  // int r = L / 2019;
  // L -= r * 2019;
  // R -= r * 2019;
  // if (R - L >= 2019)
  // {
  //   R = L + 2019;
  // }
  ll min_mod = 2019;
  for(ll i=L; i < R; i++){
    for(ll j=i+1; j <= R; j++){
      ll num = (i*j) % 2019;
      min_v = min(min_v, num);
      if(min_v == 0){
        // cout << i << ":" << j << endl;
        cout << min_v << endl;
        return ;
      }
    }
  }
  cout << min_v << endl;
}

int main(){
  cin >> L >> R;
  solve();
}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        cnt += 2
    elif a[i] == b[i]:
        cnt += 1
    elif b[i] == c[i]:
        cnt += 1
    elif c[i] == a[i]:
        cnt += 1
    else:
        cnt += 0
print(2 * n - cnt)

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

int main(){
    int n; cin >> n;
    set<int> d;
    rep(i,n){
        int tmp; cin >> tmp;
        d.insert(tmp);
    }
    put(d.size());
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll ans=0;
int n;
int i;
int main()
{
 int n,a,b;
 cin>>a>>b;
double suihou1=1.0*a/0.08;
int suihou2=b*10;
int ans;
if(suihou1-(int)suihou1>=0.5)
    ans=suihou1+1;
else
    ans=suihou1;
 
 double ans1=1300,ans2=1300,ans3=1300,ans4=1300;
 if(floor((ans)*0.1)==b)
    ans1=floor(ans);
    if(floor((suihou2)*0.08)==a)
        ans2=suihou2;
    ((int)min(ans1,min(ans2,min(ans3,ans4)))==1300)?cout<<"-1"<<endl:cout<<(int)min(ans1,min(ans2,min(ans3,ans4)))<<endl;
 
}

Measured memory_bytes: 256
n = int(input())
s = input()
_max = 0
for i in range(n):
    for j in range(i+1, n):
        if _max >= j-i:
            continue
        part = s[i:j]
        if part in s[j:]:
            _max = j-i
        else:
            break
print(_max)

Measured memory_bytes: 42332
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int n,m;
int main(){
  cin>>n>>m;
  vector<P> bc(m);
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  rep(i,m){
    cin>>bc[i].second;
    cin>>bc[i].first;
  }
  sort(bc.begin(),bc.end());
  reverse(bc.begin(),bc.end());

  sort(a.begin(),a.end());

  int pos=0,b=0;

  while(pos<n && b<m){
    if(bc[b].second==0) b++;
    else if(a[pos]<bc[b].first){
      a[pos]=bc[b].first;
      bc[b].second--,pos++;
    }
    else break;
  }
  ll ans=0;
  rep(i,n) ans+=a[i];

  cout<<ans<<endl;
  //rep(i,n) cout<<a[i]<<endl;

}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  vector<ii> a(n);
  for (auto &i : a) {
    cin >> i.sc >> i.fi;
  }
  sort(all(a));
  int time = 0;
  for (auto &i : a) {
    time += i.sc;
    if (time > i.fi) {
      cout << "No" << '\n';
      return;
    }
  }
  cout << "Yes" << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 6364
#include<iostream>
#define PI 3.14159265359
using namespace std;
int main(){
  int N,M,A;
  cin >> N >> M;
  for(int i = 0;i < M;i++){
  	cin >> A;
    N -= A;
    if(N < 0){
	  cout << -1 << endl;
      return 0;
    }
  }
  cout << N << endl;
}

Measured memory_bytes: 3636