akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc128/tasks/abc128_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 res = (A*3+P)/2;
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll A,P; cin >> A >> P;
    res = (A*3+P)/2;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    ll A[N];
    REP(i, N) cin >> A[i];

    sort(A, A + N);
    ll d[N];
    d[0] = A[0];
    REP(i, N - 1) d[i + 1] = A[i + 1] - A[i];
    sort(d, d + N);

    int itr = 0;
    while (d[itr] == 0) {
        itr++;
    }
    ll b = d[itr];
    ll a = (itr != N - 1)? d[itr + 1] : b;
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    cout << b << endl;
    return 0;
}


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


int main (void) {
  	string S;
  	cin >> S;
  	
  	if (S == "AAA" || S == "BBB") {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
comb = 0
c = Counter(a)
if n%2==0:
    i = 1 
else:
    if c[0]!=1:
        print(0)
        exit()
    c.pop(0)
    i = 2

for k in sorted(c):
    if i==k and c[k]==2:
        i+=2
        comb += 1
    else:
        print(0)
        exit()

print(2**comb%(10**9+7))

Measured memory_bytes: 55788
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
  vector<int> W(10);
  vector<int> K(10);
  for(int i = 0;i<10;i++){
    cin >> W.at(i);
  }
  for(int j = 0;j<10;j++){
    cin >> K.at(j);
  }
  sort(W.begin(),W.end());
  reverse(W.begin(),W.end());

  sort(K.begin(),K.end());
  reverse(K.begin(),K.end());

  cout << W.at(0)+W.at(1)+W.at(2) << " " << K.at(0)+K.at(1)+K.at(2) << endl;
}


Measured memory_bytes: 3152
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

import math
n = int(readline())
count = 0
for i in range(1, n + 1):
    if int(math.log10(i)) % 2  == 0:
        count +=1 
print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    int n, ans = 0;
    int a[100001];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for(int i = 0; i < n; i++){
        while(i < n - 1 && a[i] == a[i + 1]){
            i++;
        }
        if(i < n - 1 && a[i] < a[i + 1]){
            while(i < n - 1 && a[i] <= a[i + 1]){
                i++;
            }
        }
        else if(i < n - 1 && a[i] > a[i + 1]){
            while(i < n - 1 && a[i] >= a[i + 1]){
                i++;
            }
        }
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<set>
#include<iomanip>
using namespace std;

int main()
{
	int a,b,c=0;cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i/10000==i%10&&i/1000%10==i/10%10)
		{
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 150005;
const ll inf = 2e18;
int main () 
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    bool no=0;
    int n;
    cin>>n;
    int num;
    forr(i,0,n)
    {
        
        cin>>num;
        if ((num&1)==0)
        {
            if (num%3!=0 && num%5!=0)
                no=1;
        }
    }
    if (!no)
        cout<<"APPROVED\n";
    else
        cout<<"DENIED\n";
}


Measured memory_bytes: 256
use std::collections::HashSet;

use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        k: usize,
        d: [[u32]; k],
    }

    let snukes: HashSet<u32> = d.into_iter().flatten().collect();
    let ans = n - snukes.len();
    println!("{}", ans);
}


Measured memory_bytes: 2192
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if(a.equals("SSS")){
      System.out.println(0);
      return;
    }
    if(a.equals("RRR")){
      System.out.println(3);
      return;
    }
    if(a.equals("SRR") | a.equals("RRS") ){
      System.out.println(2);
      return;
    }
    System.out.println(1);
  }
  
}



Measured memory_bytes: 35544
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a<b)
    {
      if(b<c)printf("%d %d %d\n",a,b,c);
    }
  if(a==b)
    {
      if(b==c)printf("%d %d %d\n",a,b,c);
    }
  if(b<a)
    {
      if(a<c)printf("%d %d %d\n",b,a,c);
      if(a==c)printf("%d %d %d\n",b,a,c);
    }
  if(c<a)
    {
      if(a==b)printf("%d %d %d\n",c,a,b);
      if(a<b)printf("%d %d %d\n",c,a,b);
    }
  if(b<c)
    {
      if(a==b)printf("%d %d %d\n",b,c,a);
      if(c<a)printf("%d %d %d\n",b,c,a);
    }
  if(a<c)
    {
      if(c==b)printf("%d %d %d\n",a,c,b);
      if(c<b)printf("%d %d %d\n",a,c,b);
    }
  if(a==c)
    {
      if(c<b)printf("%d %d %d\n",a,c,b);
    }
  if(c<b)
    {
      if(b<a)printf("%d %d %d\n",c,b,a);
    }
  if(c==b)
    {
      if(c<a)printf("%d %d %d\n",c,b,a);
    }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout<<"Possible"<< "\n";
  }else{
    cout << "Impossible"<< "\n";
  }
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> c(26);
	for (int i = 0; i < n; ++i) {
		++c[s[i] - 'a'];
	}
	int ans = 1;
	for (int i = 0; i < 26; ++i) {
		ans = (long long)(ans) * (c[i] + 1) % mod;
	}
	cout << (ans + mod - 1) % mod << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

int main() {
	ll h, w; cin >> h >> w;

	if (!(h % 3) || !(w % 3)) {
		cout << 0 << endl;
		return 0;
	}
	//vertical x 3
	ll ans = ((h > w) ? w : h);

	//vertical x 1, horizontal x 2
	ll s = MAX_L;
	rep(i, 1, h) {
		ll a = i * w;
		ll b = w / 2 * (h - i);
		ll c = (w / 2 + ((w & 1) ? 1 : 0)) * (h - i);
		ll maxS = max(a, max(b, c));
		ll minS = min(a, min(b, c));
		s = min(s, maxS - minS);
	}

	//vertical x 2, horizontal x1
	rep(i, 1, w) {
		ll a = i * h;
		ll b = h / 2 * (w - i);
		ll c = (h / 2 + ((h & 1) ? 1 : 0)) * (w - i);
		ll maxS = max(a, max(b, c));
		ll minS = min(a, min(b, c));
		s = min(s, maxS - minS);
	}
	cout << min(ans, s) << endl;

	return 0;
}

Measured memory_bytes: 256
// Karm Karta ja, Phal Ki Chinta na Kar:)
#include <bits/stdc++.h>
using namespace std;
#include<stdio.h>
typedef long long int ll;
#define INF 1e18+3
#define M 1000000007
#define PI 3.14159265358979323846
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
            return (((r%m)*(r%m))%m);
        else
            return (((((r%m)*a)%m)*r)%m);
    }
}
int main()
{
   ll N;
   cin>>N;
   if(N%2==1)
    cout<<0;
   else
   {
     ll res=0;
     ll Z=N/2;
     ll num=N/2;
     while(num/5>0)
     {
         res+=(num/5);
         num/=5;
     }
     ll f=0;
     while(Z/2>0)
     {
         f+=(Z/2);
         Z/=2;
     }
     f+=(N/2);

     cout<<min(f,res);

   }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int ans=0;
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      int z=S-x-y;
      if(z>=0 && z<=K){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from math import floor, log
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
S = input()
U = S + S[::-1]
Sp = sorted([ U[i:i+N] for i in range(N+1)])[0]
n = 0
while Sp[n] == Sp[0]:
    n += 1

if K > int(floor(log(N/n)/log(2))) + 1:
    print(Sp[0]*N)
else:
    m = n * (2**(K-1))
    if m >= N:
        print(Sp[0]*N)
    else:
        print(Sp[0]*m + Sp[n:n+N-m])


Measured memory_bytes: 136540
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1000141919
#define MOD 1000000007
inline void chmin(int &x,int v){if(x>v)x=v;}

int N, X, D;
int A[50], C[50];
vector<int> G[50];

void dfs(int x) {
  C[x] = 1;
  for (int t : G[x]) {
    dfs(t);
    C[x] += C[t];
    A[x] = min(A[x]+A[t], INF);
  }
}

const int MAX = 5000;
int dp[2][MAX+1];
int W[30];
void decomp(int a) {
  // w<=2
  rep(k, 30) {
    if (a >= 1<<k) W[k]++, a -= 1<<k;
    else break;
  }
  rep(k, 30) if ((a>>k)&1) W[k]++;
}

int f(int Y) {
  rep(j, MAX+1) dp[0][j] = INF;
  dp[0][0] = 0;
  int m = INF;
  for (int k=29; k>=0; k--) {
    rep(j, MAX+1) dp[1][j] = INF;
    rep(j, MAX+1) if (2*j+((Y>>k)&1) <= MAX) chmin(dp[1][2*j+((Y>>k)&1)], dp[0][j]);
    swap(dp[0], dp[1]);

    rep(i, N) {
      int w = i==0?1:W[k];
      int a = min(0LL+INF, 1LL*A[i]<<k);
      if (w == 0 || a == INF) continue;
      rep(_, w) rep(j, MAX+1) {
        chmin(j>=C[i]?dp[0][j-C[i]]:m, dp[0][j]+a);
      }
    }
  }
  m = min(m, dp[0][0]);
  //cout<<"f("<<Y<<")="<<m<<"\n";
  return m;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> X >> D;
  rep(i, N) {
    cin >> A[i];
    if (i != 0) {
      int p; cin >> p; p--;
      G[p].pb(i);
    }
  }
  dfs(0);
  decomp(D);
  //rep(i, N) cout<<C[i]<<"->"<<A[i]<<"\n";

  int lo = 0, hi = 1e9+10;
  while (hi-lo>1) {
    int mid = (lo+hi)/2;
    if (f(mid) <= X) lo = mid;
    else hi = mid;
  }
  cout << lo << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
	int h,w;
	cin>>h>>w;
	int cnt=0;
	char tab[h][w];
	rep(i,h) {
		rep(j,w) {
			cin>>tab[i][j];
			if(tab[i][j]=='#') cnt++;
		}
	}
	if(cnt==(h+w-1)) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  const K = parseInt(input[1], 10);
  const X = parseInt(input[2], 10);
  const Y = parseInt(input[3], 10);
 
  var sum = 0;
  for (var i = 1; i <= N; i++) {
    if (i <= K) {
      sum += X;
    } else if (i > K) {
      sum += Y;
    }
  }
  console.log(sum);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>

using namespace std;
int main()
{
	int a,b;
	 std::cin >> a; 
	 std::cin >> b;
	 int c;
	 if(a<b){
	  c = b + b -1;
	  }else if(b<a){
	  c = a + a -1;
	  }else{
	  c = a + a;
	  }
	  cout << c;
}

Measured memory_bytes: 256
N = int(input())
X = [50] * 26
for _ in range(N):
    S = input()
    for i in range(26):
        X[i] = min(X[i], S.count(chr(97+i)))

ANS = ""
for i in range(26):
    ANS += chr(97+i) * X[i]
print(ANS)

Measured memory_bytes: 3060
import sys
from collections import deque

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()


class Node:
    def __init__(self, begin, end):
        self.begin = begin
        self.end = end
        self.left = self.right = self.parent = None
        self.val = 0


class SegmentTree:
    INF = 2 ** 60

    def __init__(self, size):
        self.root = Node(0, size)
        self.leaves = [None] * size

        queue = deque()
        queue.append(self.root)

        while len(queue) > 0:
            node = queue.popleft()

            if node.end - node.begin == 1:
                self.leaves[node.begin] = node
            else:
                mid = (node.begin + node.end) // 2
                node.left = Node(node.begin, mid)
                node.right = Node(mid, node.end)
                node.left.parent = node.right.parent = node
                queue.append(node.left)
                queue.append(node.right)

    def update(self, index, val):
        node = self.leaves[index]
        node.val = val
        while node.parent is not None:
            node = node.parent
            node.val = node.left.val | node.right.val

    def val(self, begin, end, node=None):
        if node is None:
            return self.val(begin, end, self.root)
        if begin <= node.begin and node.end <= end:
            return node.val
        if node.end <= begin or end <= node.begin:
            return 0
        return self.val(begin, end, node.left) | self.val(begin, end, node.right)


N = int(input())
S = list(input())
Q = int(input())
tree = SegmentTree(N)
for i, c in enumerate(S):
    tree.update(i, 1 << (ord(c) - ord('a')))
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        i, c = query[1:]
        i = int(i) - 1
        tree.update(i, 1 << (ord(c) - ord('a')))
    else:
        l, r = map(int, query[1:])
        print(bin(tree.val(l - 1, r)).count('1'))


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

int main()
{
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++)
    cin >> S[i];

  sort(S.begin(), S.end());
  string res = "";
  for (auto &s : S)
    res += s;

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int a;
  cin>>a;
  vector<int>b(a+1);
  lp(i,a)cin>>b.at(i+1);
  vector<int>c(a+1);
  for(int i=a;i>0;--i){
    int d=0;
    for(int j=i+i;j<=a;j+=i){
      d^=c.at(j);
    }
    c.at(i)=d^b.at(i);
  }
  vector<int>ans;
  for(int i=1;i<=a;i++){
    if(c.at(i))ans.push_back(i);
  }
  cout<<ans.size()<<endl;
  lp(i,ans.size()){
    if(i==ans.size()-1)cout<<ans.at(i)<<endl;
    else cout<<ans.at(i)<<" ";
  }
}

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	A, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	B, _ := strconv.Atoi(sc.Text())
	if (A >= 1 && A <= 9) && (B >= 1 && B <= 9) {
		fmt.Println(A * B)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		int[] tri = new int[3];
		boolean flag = false;
		int N = scan.nextInt();
		for(int i = 0; i < N; i++){
			for(int j = 0; j < 3; j++){
				tri[j] = scan.nextInt();
			}
			for(int j = 0; j < tri.length - 1; j++){
				for(int k = tri.length - 1; k > j; k--){
					if(tri[j] < tri[k]){
						int big = tri[k];
						tri[k] = tri[j];
						tri[j] = big;
					}
				}
			}
			if(Math.pow(tri[0], 2) == Math.pow(tri[1], 2) + Math.pow(tri[2], 2)){
				flag = true;
			} else{
				flag = false;
			}
			list.add(flag? "YES" : "NO");
		}
		for(String s : list){
			System.out.printf("%s\n", s);
		}
	}
}

Measured memory_bytes: 34792
#include <stdio.h>
 
using namespace std;
 
int main(){
   int m,f,r;
   char grade;
   while(true){
       scanf("%d %d %d",&m,&f,&r);
       if(m == -1 && f == -1 && r == -1) break;
       if(m == -1 || f == -1){
           grade = 'F';
       }else if(m+f >= 80){
           grade = 'A';
       }else if(m+f >= 65){
           grade = 'B';
       }else if(m+f >= 50){
           grade = 'C';
       }else if(m+f >= 30){
           grade = (r >= 50)? 'C':'D';
       }else{
           grade = 'F';
       }
       printf("%c\n",grade);
   }
}


Measured memory_bytes: 2680
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N, A, B;
int P[MAX_N];

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

  cin >> N >> A >> B;
  rep(i, N) cin >> P[i];


  int c1 = 0, c2 = 0, c3 = 0;
  for (int i = 0; i < N; ++i) {
      if (P[i] <= A) ++c1;
      else if (P[i] <= B) ++c2;
      else ++c3;
  }


  cout << min(c1, min(c2, c3)) << endl;

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <set>
using namespace std;
typedef long long ll;

ll p, q;

void solve() {
	ll M = p * p + q * q;
	int cnt = 0;
	for(int m = 0; m * m <= M; m++) {
		for(int n = 0; n * n <= M; n++) {
			ll a = m * m + n * n;
			if(a < 1) continue;
			if((m * p + n * q) % a == 0 && abs(m * q - n * p) % a == 0)
				cnt++;
		}
	}
	if(cnt * 2 <= 8) cout << "P" << endl;
	else cout << "C" << endl;
}

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

	int t;
	cin >> t;
	for(int i = 0; i < t; i++) {
		cin >> p >> q;
		solve();
	}
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
using namespace std;

ll a, b, c, d, n, v[5], ans;


int main(){
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    cin >> n;

    v[1] = a * 8;
    v[2] = b * 4;
    v[3] = c * 2;
    v[4] = d;
    sort(v+1,v+5);
    ans = n / 2 * v[1];
    n %= 2;
    v[1] = a * 4;
    v[2] = b * 2;
    v[3] = c;
    sort(v+1,v+4);
    ans += n * v[1];
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 1000000000

void func()
{
    ll k;
    string s;
    cin>>k>>s;
    ll n=s.length();
    if(n<=k){
        cout<<s<<"\n";
    }
    else{
        string t=s.substr(0,k);
        t=t+"...";
        cout<<t<<"\n";
    }
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s;
    int w;
    cin >> s >> w;
    rep(i, s.size()) {
        if (i%w == 0) cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int count=0;
  int flag = 0;
  cin >> N;
  
  vector<int> a(N);
  
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  for(int i=1;i<N;i++){
    flag = 0;
    for(int j=(i-1);j >=0 ;j--){
      if(a[i] >= a[j]){
        flag++;
      }
    }
    if(flag == i){
      count++;
    }
  }
  cout << count+1 << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  int a=0,s=n+1;
  for(int i=0;i<n;i++)
  {
  if(s>arr[i])
  {
  a++;
    s=arr[i];
  }
    
  }
  cout<<a;
}


Measured memory_bytes: 1024
h,w,d=map(int,input().split())
field=[[]]*(h*w)
for i in range(h):
	x=list(map(int,input().split()))
	for j in range(w):
		field[x[j]-1]=[i,j]
dis=[10**20]*(h*w)
for i in range(d):
	dis[i]=0
for i in range((h*w)):
	if i>=d:
		dis[i]=dis[i-d]+abs(field[i][0]-field[i-d][0])\
		+abs(field[i][1]-field[i-d][1])
q=int(input())
for i in range(q):
	l,r=map(int,input().split())
	print(dis[r-1]-dis[l-1])


Measured memory_bytes: 17128
N = int(input())
A = list(map(int, input().split()))
B = [[0 for i in range(N)]for j in range(60)]
M = 1000000007
ans = [0 for i in range(60)]
sumB = [[0 for i in range(N)]for j in range(60)]
for j in range(N):
  for i in range(60):
    B[i][j] = A[j]>>i & 1
    sumB[i][j] = A[j]>>i & 1
    if j > 0:
      sumB[i][j] += sumB[i][j-1]
for i in range(1, N):
  for j in range(60):
    if B[j][-i]==0:
      ans[j] += sumB[j][-(i+1)]
    else:
      ans[j] += N-i-sumB[j][-(i+1)]
a = 0
for i in range(60):
  a += (ans[i]*pow(2, i, M))%M
  a %= M
print(a)

Measured memory_bytes: 473852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
 
int main(){
    string S, T;
    cin >> S >> T;
    string res = "No";
    REP(i, S.size()) {
        if (S==T) {
            res = "Yes";
            break;
        }
        S = S.substr(S.size()-1, 1) + S.substr(0, S.size()-1);
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
int n,m,fa[maxn],d[maxn];
int a[maxn],b[maxn];
ll f[maxn],g[maxn];
bool vis[maxn];
int tot,nxt[maxn*2],head[maxn],to[maxn*2];
bool cmp(int x,int y) { return a[x]<a[y]; }
void add(int x,int y) {
	tot++; nxt[tot]=head[x];
	head[x]=tot; to[tot]=y;
}
int find(int x) {
	if (fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void merge(int x,int y) {
	y=find(y);
	if (x==y) return;
	fa[y]=x;
	g[x]+=g[y];
	f[x]=min(f[x],max(f[y],a[x]-g[y]));
}
int main() {
//	freopen("1.txt","r",stdin);
	read(n); read(m);
	for (int i=1;i<=n;i++) {
		read(a[i]); read(b[i]);
		a[i]=max(0,a[i]-b[i]);
		fa[i]=i; d[i]=i;
		f[i]=a[i]; g[i]=b[i];
	}
	sort(d+1,d+n+1,cmp);
	int x,y;
	for (int i=1;i<=m;i++) {
		read(x); read(y);
		add(x,y); add(y,x);
	}
	for (int i=1;i<=n;i++) {
		x=d[i];
		vis[x]=1;
		for (int j=head[x];j;j=nxt[j]) {
			y=to[j];
			if (vis[y]) merge(x,y);
		}
	}
	printf("%lld\n",f[find(1)]+g[find(1)]);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 5376
#include <stdio.h>
#include <memory.h>
void f(int now,int rest,int list[],int p){
int i;
list[p]=now;
if(rest==0){
for(i=0;i<=p;i++){
if(i>0){
printf(" ");
}
printf("%d",list[i]);
}
puts("");
}
for(i=rest;i>0;i--){
if(i>now){
continue;
}
f(i,rest-i,list,p+1);
}
}
int main(void){
int n,i,list[301];
while(1){
scanf("%d",&n);
if(n==0){
break;
}
memset(list,0,sizeof(list));
for(i=n;i>0;i--){
f(i,n-i,list,0);
}
}
return 0;
}

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

int main()
{
	int H, W;
	cin >> H >> W;
	int c[10][10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	int res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int A;
			cin >> A;
			if (A != -1) {
				res += c[A][1];
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string s;
vector<int> x, y;
bool F[2][40000], *f = F[0] + 20000, *g = F[1] + 20000, *t;
int main() {
    cin >> s;
    s = s + 'T';
    int flag = 0, len = 0, sumx = 0, sumy = 0, X, Y;
    cin >> X >> Y;
    for (unsigned i = 0; i < s.length(); i++) {
        if (s[i] == 'T') {
            if (flag)
                y.push_back(len), sumy += len;
            else
                x.push_back(len), sumx += len;
            len = 0;
            flag = !flag;
        } else
            len++;
    }
    g[x[0]] = 1;
    for (unsigned i = 1; i < x.size(); i++) {
        if (!x[i]) continue;
        for (int j = -sumx; j <= sumx; j++) f[j] = g[j + x[i]] | g[j - x[i]];
        t = f;
        f = g;
        g = t;
    }
    if (!g[X]) {
        cout << "No" << endl;
        return 0;
    }
    memset(F, 0, sizeof(F));
    g[0] = 1;
    for (unsigned i = 0; i < y.size(); i++) {
        if (!y[i]) continue;
        for (int j = -sumy; j <= sumy; j++) f[j] = g[j + y[i]] | g[j - y[i]];
        t = f;
        f = g;
        g = t;
    }
    if (!g[Y]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 384
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second



int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    map<ll, ll> M;
    rep (i, N) {
        ll a, b;
        cin >> a >> b;
        M[a] += b;
    }
    ll k = 0;
    ll ans = -1;
    for (auto it : M) {
        if (k >= K) break;
        ans = it.fst;
        k += it.snd;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void){

	double a,b;
	while(cin >> a >> b){
		if(a<35.50 && b<71.0)cout << "AAA" << endl;
		else if(a<37.50 && b<77.0)cout << "AA" << endl;
		else if(a<40.0 && b<83.0)cout << "A" << endl;
		else if(a<43.0 && b<89.0)cout << "B" << endl;
		else if(a<50.0 && b<105.0)cout << "C" << endl;
		else if(a<55.0 && b<116.0)cout << "D" << endl;
		else if(a<70.0 && b<148.0)cout << "E" << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main(){
  int N=1,b=0,t,j;
  double a,v,y,i;
  while(cin >> a){
    N=1;
    b=0;
    i=a/9.8;
    y=4.9*i*i;
    while(b<y){
      b=5*N-5;
      N++;
    }
    N--;
    cout << N << endl;
  }
}

Measured memory_bytes: 1224
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
now = 7
ans = 1
while True:
    now %= k
    if now == 0:
        print(ans)
        exit()
    ans += 1
    now = now*10 + 7

Measured memory_bytes: 9104
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct UnionFind {
	vector<int> par; // 親を指すvector,-par[親]は木のサイズ
	UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
	int root(int x) { // 親をたどる&データの整理
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	bool unite(int x, int y) { // データの結合
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	bool same(int x, int y) {return root(x) == root(y);} // 所属判定
	int size(int x) {return -par[root(x)];} // 木のサイズ
};

const int N = 1e5+4;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vi x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];
	UnionFind uft(N<<1);
	rep(i, n) uft.unite(x[i], y[i]+N);
	map<int, vvi> mp;
	map<int, int> cnt;
	rep(i, n) {
		int r = uft.root(x[i]);
		if(!mp.count(r)) {
			mp[r].assign(2, vi());
		}
		mp[r][0].emplace_back(x[i]);
		mp[r][1].emplace_back(y[i]);
		cnt[r]++;
	}

	ll ans = 0;
	for(P x:cnt) {
		vi &v0 = mp[x.first][0];
		vi &v1 = mp[x.first][1];
		sort(all(v0));
		sort(all(v1));
		v0.erase(unique(all(v0)), v0.end());
		v1.erase(unique(all(v1)), v1.end());
		ans += ll(v0.size())*ll(v1.size())-x.second;
	}

	cout << ans << endl;
}

Measured memory_bytes: 5996
use std::io;
use std::io::Result;
use std::convert;


fn main() -> Result<()> {
    let mut s = String::new();
    let ls = io::stdin().read_line(&mut s)? - 1;
    let input: Vec<u32> = s.split_whitespace().map(|x| x.parse::<u32>().unwrap() ).collect();
    if input[1] * input[2] >= input[0] {
        println!("Yes");
    } else {
        println!("No");
    }

    Ok(())
}


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

int main() {
	// your code goes here
	int a, b;
	cin>>a>>b;
	if(a>0) {
		cout<<"Positive";
	}
	else if(b<0) {
		if((b-a+1)%2==0) {
			cout<<"Positive";
		}
		else {
			cout<<"Negative";
		}
	}
	else if(a<=0 && b>=0) {
		cout<<"Zero";
	}
	return 0;
}

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

using namespace std;
using ll = long long;


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

    sum += (b / c - (a - 1) / c) + (b / d - (a - 1) / d) - (b / lcm(c,d) - (a - 1) / lcm(c,d));
    cout << (b-a+1)-sum << endl;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;
const double pi = acos(-1);

const int maxN=1e5;

void solve(){
    string s;
    cin>>s;
    string ans="";
    for(int i=0;i<(int)s.size();i++) {
        if(s[i]=='B'&&ans.size()>0)ans.pop_back();
        else if(s[i]=='1')ans+='1';
        else if(s[i]=='0')ans+='0';
    }
    cout<<ans<<"\n";
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>//for cin cout endl
#include <cstdlib>//for abs()
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF=1LL<<60;//1LL is integer one in LongLong
int N;
long long h[110000];
long long dp[110000];
int main(){

    int N,K;cin>>N>>K;
    for (int i =0 ; i<N;++i)cin>>h[i];

    for (int i=0;i<110000;++i)dp[i]=INF;//initialize dp array
    dp[0]=0;

    for (int i=0;i<N;++i){
        for (int j=1;j<=K;++j){
            chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        };
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1920
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto N = s[1];
    auto A = iota(N).map!(_ => readln.split.map!(to!int).array).array;

    auto dp = new int[](H+1);
    dp[] = 1 << 29;
    dp[0] = 0;

    foreach (i; 0..H) foreach (a; A) {
        if (i + a[0] <= H) dp[i + a[0]] = min(dp[i + a[0]], dp[i] + a[1]);
        else dp[H] = min(dp[H], dp[i] + a[1]);
    }

    dp[H].writeln;
}

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

int main() {
    vector<int> dish(5);
    int min_d = 10;
    int min_i;
    rep(i, dish.size()){
        cin >> dish.at(i);
        if(min_d > dish.at(i)%10 && dish.at(i)%10>=1){
            min_d = dish.at(i)%10;
            min_i = i;
        }
    }

    int ans=0;
    for(int i=0; i<dish.size(); i++){
        if(dish.at(i)%10==0) ans+=dish.at(i);
        else if(i==min_i) ans+=dish.at(i);
        else {
            ans += dish.at(i) - dish.at(i)%10 + 10;
        }
    }

    cout << ans << endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(std::vector<long long> A){
    cout << (A[0] + A[1] + A[2] < 22 ? "win" : "bust") << endl; 
}

int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>
#include <sstream>
 
#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 7;
const ll infll = (ll)1e+17 + 7;
 
 
#include <time.h>
 
const int maxN = 100001;
 
int n, d;
std::vector<P>g[maxN];
std::vector<int>alive;
 
 
bool used[maxN];
P dfs(int v) {
    used[v] = true;
 
    P ret = P(0, v);
    for (int i = 0; i < g[v].size(); i++) {
        int u = g[v][i].first;
        int w = g[v][i].second;
        if (used[u]) continue;
        P tmp = dfs(u);
        ret = std::max(ret, P(w + tmp.first, tmp.second));
    }
    return ret;
}
 
int main() {
    std::cin >> n;
 
    for (int i = 0; i < n - 1; ++i) {
        int a, b, c;
        std::cin >> a >> b >> c;
        g[a].push_back(P(b, c));
        g[b].push_back(P(a, c));
    }
 
    int v = dfs(0).second;
    for (int i = 0;i < n; ++i)used[i] = false;
    std::cout << dfs(v).first << std::endl;
    return 0;
 
}

Measured memory_bytes: 13000
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

int main() {
	for (;;) {
		string A; cin >> A;
		if (A == "0") break;
		string B, C; cin >> B >> C;
		int n = A.length();
		vector<ll> dp(2); dp[0] = 1;
		for (int i = n - 1; i >= 0; i--) {
			vector<ll> _dp(2);
			int x = (i == 0 ? 1 : 0);
			for (int a = x; a <= 9; a++) {
				for (int b = x; b <= 9; b++) {
					if (A[i] != '?' && A[i] != '0' + a) continue;
					if (B[i] != '?' && B[i] != '0' + b) continue;
					for (int k = 0; k <= 1; k++) {
						int c = a + b + k;
						if (c % 10 < x) continue;
						if (C[i] != '?' && C[i] != '0' + c % 10) continue;
						_dp[c / 10] += dp[k];
					}
				}
			}
			_dp[0] %= MOD; _dp[1] %= MOD;
			dp = _dp;
		}
		cout << dp[0] << endl;
	}
}

Measured memory_bytes: 1208
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    double t,x;
    cin >> t >> x;
    cout << t/x << endl;
}

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


int main() {
	int A, B, number;
	cin >> A >> B >> number;

	vector<int> vResult;
	for (int i = 1; i <= A && i <= B; ++i)
	{
		if (A % i == 0 && B % i == 0)
		{
			vResult.push_back(i);
		}
	}

	sort(vResult.begin(), vResult.end());
	reverse(vResult.begin(), vResult.end());

	cout << vResult.at(number-1) << endl;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

string s;
int L;
inline void solve(){
  IN(s);
  L=s.size();
  OUT(s[0]+to_string(L-2)+s[L-1]);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
    mask = 1 << i
    count = sum(1 for j in a if mask & j == 0)
    ans += count * (n-count) * pow(2,i,mod)
print(ans % mod)


Measured memory_bytes: 42156
#include<stdio.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	int n,m,a,t;
	S(d, n), S(d, m);
	while(m--){
		S(d, a);
		while(a)t = n, n = a, a = t%a;
	}
	P(s, n == 1 ? "Yes":"No");
	return 0;
}

Measured memory_bytes: 596
// ALDS_1_2_B Selection Sort

#include <iostream>
#define NMAX	100

void swap(int *array, int a, int b){
	int tmp;

	tmp = array[a];
	array[a] = array[b];
	array[b] = tmp;

	return;
}

int main(int argc, char *argv[]){
	int N;
	int A[NMAX];
	int swap_cnt = 0;

	std::cin >> N;
	for(int i=0 ; i<N ; i++){
		std::cin >> A[i];
	}

	for(int i=0 ; i<N ; i++){
		int jmin = i;
		for(int j=i+1 ; j<N ; j++){
			if(A[jmin] > A[j]){
				jmin = j;
			}
		}
		if(jmin != i){
			swap(A, jmin, i);
			swap_cnt++;
		}
	}

	for(int i=0 ; i<N-1 ; i++){
		std::cout << A[i] << " ";
	}
	std::cout << A[N-1] << std::endl;
	std::cout << swap_cnt << std::endl;

	return 0;
}



Measured memory_bytes: 3120
/* 
 * Project: NOMURA Programing Contest B - Postdocs
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/30
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
using namespace std;

char t[200000];
int k;

void solve() {

    for (int i=0;i<strlen(t);i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    printf("%s\n", t);

}

int main() {

    scanf("%s", t);

    solve();

}

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

int A[105];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    bool flg = true;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) flg = false;
        }
    }
    if (flg) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256