akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll nl, nm;

#define INF 1e10

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

  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ans = INF;
  
  if(2*c >= a+b){cout << a*x+b*y << endl; return 0;}
  else{ //2*c < a+b
    if(x > y){
      FOR(i, 1, x+1){      
	ll tmp = 2*c*i + (x-i)*a + max(0, (y-i))*b;
	ans = min(ans, tmp);
      }
    }
    else{
      FOR(i, 1, y+1){
	ll tmp = 2*c*i + (y-i)*b + max(0, (x-i))*a;
	ans = min(ans, tmp);
      }
    }    
  }

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


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

int main(int argc, const char * argv[]) {
    int a,b,c,d;
    
    cin >> a;
    cin >> b;
    cin >> c;
    
    if(a>b){
        d=a;
        a=b;
        b=d;
    }
    
    if(b>c){
        d=b;
        b=c;
        c=d;
    }
    
    if(a>b){
        d=a;
        a=b;
        b=d;
    }
    
    cout << a << " " << b << " " << c <<endl;
    
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








int main()
{
	
	long long int h;
	cin >> h;

	long long int ans = 0;
	long long int wk = 1;

	while (h > 0) {
		ans += wk;
		wk *= 2;

		h /= 2;





	}

	cout << ans << endl;

	return 0;

}



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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define _REP(i,m,n) for(int i =m; i <n; ++i)

#define INF 1000000000000
#define ll long long 

using namespace std;


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

    ll ans = INF;
    _REP(i,1,sqrt(n)+2){
        if(n%i == 0){
            ans = min((n/i+i),ans);
        }
    }
    ans -= 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head) << " ";
  print(tail...);
}

int main() {
  GI(N);
  GVI(T, N);
  GVI(A, N);
  vector<int> Tmax(N), Tans(N), Amax(N), Aans(N);
  FOR(i, N) {
    if (i == 0 || T[i] != T[i - 1]) {
      Tmax[i] = T[i];
      Tans[i] = T[i];
    } else {
      Tmax[i] = T[i];
    }
    if (i == N - 1 || A[i] != A[i + 1]) {
      Amax[i] = A[i];
      Aans[i] = A[i];
    } else {
      Amax[i] = A[i];
    }
  }
  ll ans = 1;
  FOR(i, N) {
    if (Aans[i] > Tmax[i] || Tans[i] > Amax[i]) {
      print(0);
      return 0;
    } else if (Aans[i] == 0 && Tans[i] == 0) {
      ll mn = min(Amax[i], Tmax[i]);
      ans = ans * mn % MOD;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
const int mod=100000;
struct edge{int to,cost;};
int d[5030][5030];
int d1[5030];
int c[5050],r[5050];
int n,k;
vector<int>G[5050];
vector<edge>V[5050];
void dijkstra1(int s){
  REP(i,n)d[s][i]=INF;
  priority_queue<P,vector<P>,greater<P> >Q;
  d[s][s]=0;
  Q.push(MP(0,s));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int v=p.second;
    if(d[s][v]<p.first)continue;
    REP(i,G[v].size()){
      int to=G[v][i];
      if(d[s][to]>d[s][v]+1){
        d[s][to]=d[s][v]+1;
        Q.push(MP(d[s][to],to));
      }
    }
  }
}
void dijkstra2(int s){
  fill(d1,d1+n,INF);
  priority_queue<P,vector<P>,greater<P> >Q;
  d1[s]=0;
  Q.push(MP(0,s));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int v=p.second;
    if(d1[v]<p.first)continue;
    REP(i,V[v].size()){
      edge e=V[v][i];
      if(d1[e.to]>d1[v]+e.cost){
        d1[e.to]=d1[v]+e.cost;
        Q.push(MP(d1[e.to],e.to));
      }
    }
  }
}
int main(){
  cin>>n>>k;
  REP(i,n)cin>>c[i]>>r[i];
  REP(i,k){
    int a,b;
    cin>>a>>b;a--;b--;
    G[a].PB(b);G[b].PB(a);
  }
  REP(i,n)dijkstra1(i);
  REP(i,n)REP(j,n){
    if(d[i][j]<=r[i])V[i].PB((edge){j,c[i]});
  }
  dijkstra2(0);
  cout<<d1[n-1]<<endl;
}

Measured memory_bytes: 224064
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
string t = "AKIHABARA";

string s;

int main() {
	cin >> s;
	int now = 0;
	for (int i = 0; i < s.size(); ++i) {
		while (now < t.size() && s[i] != t[now]) {
			if (t[now] == 'A')
				++now;
			else {
				cout << "NO\n";
				return 0;
			}
		}
		if (now == t.size()) {
			cout << "NO\n";
			return 0;
		}
		++now;
	}
	while (now < t.size()) {
		if (t[now] == 'A')
			++now;
		else {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000

using namespace std;

int main(){
    int n; cin >> n;
    int fx=0;
    int tmp=n;
    rep(i,9){
        fx += tmp % 10;
        tmp /= 10;
    }
    if (n%fx == 0) puts("Yes");
    else puts("No");
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define INF 1e9
using namespace std;


int main()
{
    int n;
    cin>>n;
    int ans=-1;
    for (int i = 0; i <= n; i++)
    {
        if(floor((double)i*1.08)==n){
            ans=i;
            break;
        }
    }
    if(ans==-1){
        cout<<":(";
    }else{
        cout<<ans;
    }

    return 0;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
count =[]
ans = []
line = q - k

for i in range(n):
  count.append(0)

for i in range(q):
  num = a[i]-1
  count[num] += 1;

for i in range(n):
  if( count[i] <= line):
    ans.append("No")
  else:
    ans.append("Yes")
p = '\n'.join(ans)
print(p)

Measured memory_bytes: 9760
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  const Int INF = 1e18;

  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  vector<map<Int, Int>> dp(2);
  auto touch=[&](auto &m,Int k){if(!m.count(k)) m[k]=-INF;};

  Int len=n;
  dp[0][0]=0;
  for(Int a:as){
    vector<map<Int, Int>> nx(2);
    for(Int u=0;u<2;u++){
      for(auto [k, v]:dp[u]){
        if(k+(len+1)/2<n/2) continue;
        // use
        if(u==0){
          touch(nx[1],k+1);
          chmax(nx[1][k+1],v+a);
        }
        // not
        touch(nx[0],k);
        chmax(nx[0][k],v);
      }
    }
    swap(dp,nx);
    len--;
  }

  touch(dp[0],n/2);
  touch(dp[1],n/2);
  cout<<max(dp[0][n/2],dp[1][n/2])<<endl;
  return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// グリッドグラフでのdfsでのseen配列
vector<vector<bool>> seen;
int H, W;
VS S;

void pathlen_dfs(int h, int w, i64 &black, i64 &white){
    seen[h][w] = true;
    if (S[h][w] == '#') ++black;
    else ++white;

    rep(i, 0, 4){
        int nh = h + dx[i], nw = w + dy[i];
        if (nh < 0 || nh >= H || nw < 0 || nw >= W || seen[nh][nw] || S[nh][nw] == S[h][w])
            continue;
        pathlen_dfs(nh, nw, black, white);
    }
}

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

cin >> H >> W;
S.assign(H, ""); rep(i, 0, H) cin >> S[i];
seen.assign(H, vector<bool>(W, false));
// 黒から白黒と進んで 白 で終わるパスの数
// 黒白交互に繋がる連結なグラフにおいて，黒から任意の白へのパスが存在する．
i64 cnt = 0;
rep(i, 0, H) rep(j, 0, W)
    if (!seen[i][j]) {
        i64 black = 0, white = 0;
        pathlen_dfs(i, j, black, white);
        cnt += black * white;
    }


cout << cnt << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
int n,a[100000],c[10],cnt=0,minans=0,maxans=0;
int main()
{
    memset(c,0,sizeof(c));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=1&&a[i]<=399)
        {
            c[1]=1;
        }else if(a[i]>=400&&a[i]<=799)
        {
            c[2]=1;
        }else if(a[i]>=800&&a[i]<=1199)
        {
            c[3]=1;
        }else if(a[i]>=1200&&a[i]<=1599)
        {
            c[4]=1;
        }else if(a[i]>=1600&&a[i]<=1999)
        {
            c[5]=1;
        }else if(a[i]>=2000&&a[i]<=2399)
        {
            c[6]=1;
        }else if(a[i]>=2400&&a[i]<=2799)
        {
            c[7]=1;
        }else if(a[i]>=2800&&a[i]<=3199)
        {
            c[8]=1;
        }else
        {
            cnt++;
        }
    }
    int flag=0;
    for(int i=1;i<=8;i++)
    {
        if(!c[i])flag++;
    }
    for(int i=1;i<=8;i++)
    {
        if(c[i])minans++;
    }
    maxans=minans+cnt;
    if(flag==8)minans=1,maxans=cnt;
    printf("%d %d\n",minans,maxans);
    return 0;
}


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

using namespace std;

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

    bool a_hp_flag = true;
    bool c_hp_flag = true; 

    while(a_hp_flag > 0 || c_hp_flag > 0){
        C = C - B;
        if(C <= 0){
            c_hp_flag = false;
            break;
        } 

        A =  A - D;
        if(A <= 0){
            a_hp_flag = false;
            break;
        } 
    } 

    if(a_hp_flag == false){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(ll i=j;i<k;i+=in)
#define DF(i,j,k,in) for(ll i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); it++)
#define fitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2;it+=in)
#define Dfeach(it,l) for (auto it = l.end()-1; it != l.begin()-1; it--)
#define Dfitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2-1;it-=in)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const ll MOD=1000000007;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll k;
string S;
cin>>k>>S;
if(S.length()<=k) cout<<S;
else {
   F(i,0,k,1) cout<<S[i];
   cout<<"...";
}
return 0;
}


Measured memory_bytes: 3604
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n==2 || n==3 || n==5 || n==7) true
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> {
        val m = readInt; isPrime(m)
      }
    })
  }
}

Measured memory_bytes: 67000
using System;

namespace ALDS1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            // ??\???
            int n = Int32.Parse(Console.ReadLine());
            var a = new int[n];
            var input = Console.ReadLine().Split(' ');

            if(input.Length != n)
            {
                Console.WriteLine("input.length != n");
                return;
            }

            for (int i = 0; i < n; i++)
            {
                a[i] = Int32.Parse(input[i]);
            }

            insertionSortAndShow(a);
        }

        private static void insertionSortAndShow(int[] array)
        {
            showArray(array);
            int n = array.Length;
            for(int i = 1; i<n;i++)
            {
                int v = array[i];
                int j = i - 1;
                while(j>=0&&array[j]>v)
                {
                    array[j + 1] = array[j];
                    j--;
                }
                array[j + 1] = v;
                showArray(array);
            }
        }

        private static void showArray(int[] array)
        {
            for(int i=0;i<array.Length;i++)
            {
                if(i==array.Length-1)
                {
                    Console.Write("{0}", array[i]);
                    break;
                }
                Console.Write("{0} ", array[i]);
            }
            Console.WriteLine();
        }

    }
}

Measured memory_bytes: 9356
#include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  int N;
  scanf(" %d ", &N);
  
  for (int i = 0; i < N; i++) {
    coor c[4];
    for (int j = 0; j < 4; j++) {
      double x, y;
      scanf(" %lf %lf ", &x, &y);
      c[j] = coor(x, y);
    }
    
    if (cross(c[1] - c[0], c[3] - c[2]) == 0) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

string s;

int getLen(int start, int end) {
  int len = 0;
  for (int i=start;i<=end;i++) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      len++;
    } else {
      return 0;
    }
  }
  return len;
}

void solve() {
  int maxLen = 0;
  for (int i=0;i<s.size();i++) {
    for (int j=0;j<s.size();j++) {
      maxLen = max(maxLen, getLen(i, j));
    }
  }
  cout << maxLen << endl;
}

int main() {
  cin >> s;
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
ll nck(ll n , ll k ,ll m=1e9+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}
long long fact(long long n , long long m = 1e9+7)
{
    long long a = 1 ;
    if(n==0 || n==1)
    {
        return(1) ;
    }
    while(n>0)
    {
        a = (a%m * n%m)%m ;
        n-- ;
    }
    return(a) ;
}
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y,s;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    char ch,chr ;
    ll a1,a2,b1,b2 ;
    cin>>p>>q ;
    r = (double)(p/q) ;
    cout<<r ;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char P[21][21];
int i,j,C,R,dx[4]={0,0,-1,1},dy[4]={-1,1,0,0},f[20][20][16][4]={0};

int s(int py,int px,int m,int d,int dp)
{
	if(dp>10000||f[py][px][m][d])
		return 0;
	f[py][px][m][d]=1;
	switch (P[py][px])
	{
	case '<':return s(py,(px-1+C)%C,m,2,dp+1);
	case '>':return s(py,(px+1+C)%C,m,3,dp+1);
	case '^':return s((py-1+R)%R,px,m,0,dp+1);
	case 'v':return s((py+1+R)%R,px,m,1,dp+1);
	case '_':return m==0?s(py,(px+1+C)%C,m,3,dp+1):s(py,(px-1+C)%C,m,2,dp+1);
	case '|':return m==0?s((py+1+R)%R,px,m,1,dp+1):s((py-1+R)%R,px,m,0,dp+1);
	case '?':return s(py,(px+1+C)%C,m,3,dp+1)|s(py,(px-1+C)%C,m,2,dp+1)|s((py+1+R)%R,px,m,1,dp+1)|s((py-1+R)%R,px,m,0,dp+1);
	case '.':return s((py+dy[d]+R)%R,(px+dx[d]+C)%C,m,d,dp+1);
	case '@':return 1;
	case '+':return s((py+dy[d]+R)%R,(px+dx[d]+C)%C,(m+1+16)%16,d,dp+1);
	case '-':return s((py+dy[d]+R)%R,(px+dx[d]+C)%C,(m-1+16)%16,d,dp+1);
	default:return s((py+dy[d]+R)%R,(px+dx[d]+C)%C,P[py][px]-'0',d,dp+1);
	}
}

int main()
{
	scanf("%d%d\n",&R,&C);
	for(i=0;i<R;gets(P[i++]));
	puts(s(0,0,0,3,0)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 1296
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition) cout << "Yes" << '\n'; else{ cout << "No" << '\n'; }
#define YES(condition) if(condition) cout << "YES" << '\n'; else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition) cout << "yes" << '\n'; else{ cout << "no" << '\n'; }




int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    ll alice = 0, wheson = 0;
    REP(i, n){
        ((i + 1) & 1? alice : wheson) += a[i];
    }
    cout << alice - wheson << endl;
}


Measured memory_bytes: 256
/* code by AbhiTaker
         ____
        /    \
       /  __  \              _______      __       _   _    _____    _____
      /  /  \  \            |__   __|    /  \     | | / /  |  ___|  |  _  \
     /  /____\  \     ___      | |      / /\ \    | |/ /   | |__    | |_)  )
    /  /______\  \   |___|     | |     / /__\ \   |   /    |  __|   |    _/
   /  /        \  \            | |    / /----\ \  | |\ \   | |___   | |\ \
  /__/          \__\           |_|   /_/      \_\ |_| \_\  |_____|  |_| \_\
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000
ll a[N];

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   ll n,i,tot=0;
   cin>>n;
   for(i=1; i<=n; i++)
    {
        cin>>a[i];
        tot += abs(a[i]-a[i-1]);
    }
    tot += abs(a[n]);

    for(i=1; i<=n; i++)
    {
        ll ans = tot - (abs(a[i]-a[i-1]) + abs(a[i]-a[i+1])) + abs(a[i+1] - a[i-1]);
        cout<<ans<<"\n";
    }
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	if (s =="ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}


Measured memory_bytes: 3528
r,c,k = map(int,input().split())
dp = [[[0]*(c+1) for _ in range(r+1)] for _ in range(4)]
g = [[0]*(c+1) for _ in range(r+1)]
for _ in range(k):
    a,b,v = map(int,input().split())
    g[a][b] = v

for i in range(r+1):
    for j in range(c+1):
        for m in range(4):
            tmp  =dp[m][i][j]
            if i+1<=r:
                dp[0][i+1][j] = max(tmp,dp[0][i+1][j])
                dp[1][i+1][j] = max(dp[1][i+1][j],tmp + g[i+1][j])
            if j+1<=c:
                dp[m][i][j+1] = max(dp[m][i][j+1],tmp)
                if m<3:
                    dp[m+1][i][j+1] = max(dp[m+1][i][j+1],tmp + g[i][j+1]) 
ans = 0
for m in range(4):
    ans = max(ans,dp[m][-1][-1])
print(ans)
 

Measured memory_bytes: 431284
#include <bits/stdc++.h>
#include <cassert>
#define mod 100000007LL
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
int n;
LL ans;
char s[105];
map<pii,LL> p;
inline int rd() {int r;scanf("%d",&r);return r;}

void dfs1(int dep,LL x,LL y) {
	if (dep > n) {
		p[pii(x, y)]++;
		return ;
	}

	dfs1(dep+1, (x*28LL+s[dep]-'a'+1)%mod, y);
	dfs1(dep+1, x, (y*28LL+s[dep]-'a'+1)%mod);
}

void dfs2(int dep,LL x,LL y) {
	if (dep == n) {
		ans += p[ pii(x, y) ];
		return ;
	}
	
	dfs2(dep-1, (x*28+s[dep]-'a'+1)%mod, y);
	dfs2(dep-1, x, (y*28+s[dep]-'a'+1)%mod);
}

int main() {
	n = rd();
	scanf("%s",s+1);
	dfs1(1,0,0);
	dfs2(2*n,0,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 33024
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> S;
    for (int i = 0; i < N; ++i) {
        int t;
        std::cin >> t;
        S.push_back(t);
    }

    boost::multi_array<bool, 2> mat(boost::extents[N+1][N*100+1]);

    for (auto p = mat.origin(); p < (mat.origin() + mat.num_elements()); ++p) {
        *p = false;
    }

    std::unordered_set<int> points;

    auto f = [&mat, N, &S, &points](auto F, int i, int sum) -> void {
        if (mat[i][sum]) {
            return;
        }
        if (i == N) {
            points.insert(sum);
            return;
        }
        mat[i][sum] = true;

        F(F, i+1, sum);
        F(F, i+1, sum+S[i]);
    };

    f(f, 0, 0);

    int ma = 0;
    for (auto p: points) {
        if (p % 10 != 0) {
            ma = std::max(ma, p);
        }
    }
    cerr << endl;

    std::cout << ma << std::endl;

    return 0;
}


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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(a) "(" << #a << ": " << (a) << ")"

template<typename T>
void chmin(T &x, T y) { x = min(x, y); }

template<typename T>
void chmax(T &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;
typedef tuple<int,int> P;

const int INF = INT_MAX/2 - 1;
const double EPS = 1e-14;
const int dx[4] = {0, 1, 0, -1}; // {-1,  0,  1, -1, 1, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0}; // {-1, -1, -1,  0, 0,  1, 1, 1};

const lli PRIMEMAX = 100000;
int FACTOR[PRIMEMAX];
vector<int> Primes;
void sieve() {
  FACTOR[0] = FACTOR[1] = -1;
  for (lli n = 2; n < PRIMEMAX; ++n) {
    if (FACTOR[n] != 0) continue;
    Primes.push_back(n);
    lli kn = n * n;
    while (kn < PRIMEMAX) { FACTOR[kn] = n; kn += n; }
  }
}

bool is_prime(int n) {
  if (n < PRIMEMAX) return FACTOR[n] == 0;
  for (int p : Primes) {
    if (p * p > n) break;
    if (n % p == 0) return false;
  }
  return true;
}

void solve(int a, int b, int m) {
  lli len = Primes.size(), ans = -1;
  lli pp = 0, qq = 0;
  FOR(i, 0, len) {
    FOR (j, i, len) {
      lli p = Primes[i], q = Primes[j];
      if (p * q > m || a * q > b * p) break;
      if (ans < p * q) {
        pp = p, qq = q, ans = p * q;
      }
    }
  }
  cout << pp << " " << qq << endl;
}

int main() {
  cout << fixed << setprecision(10);
  sieve();
  int a, b, m;
  while (cin >> m >> a >> b and b) {
    solve(a, b, m);
  }
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main(void){
	int i, j, temp;
	int array[3];
	scanf("%d %d %d", &array[0], &array[1], &array[2]);
	for(i = 0;i < 2;i++){
		for(j = 0;j < 2;j++){
			if(array[j + 1] < array[j]){
				temp = array[j];
				array[j] = array[j + 1];
				array[j + 1] = temp;
			}
		}
	}
	printf("%d %d %d\n", array[0], array[1], array[2]);
	return 0;
}

Measured memory_bytes: 596
import numpy as np

_,*_t=[list(map(int,i.split())) for i in open(0)]
n=_[0]
m=_[1]
x=_[2]
t=np.array(_t)
v=9000000


def checkAchieve(nums):
  for i in range(1,m+1):
    if nums[i]<x:
      return False
  return True


tmp=np.sum(t,axis=0)
if not checkAchieve(tmp):
  print(-1)
  exit()

  
def makeBoolList(nums):
  ls=[]
  sNums=str(nums)
  for i in range(len(sNums)):
    if sNums[i]=="0":
      ls.append(False)
    else:
      ls.append(True)
  return ls


for i in range(1,2 ** n):
  sc=format(i,'b').zfill(n)
  bSc=makeBoolList(sc)
  sumPicks=np.sum(t[bSc,:],axis=0)
  if not checkAchieve(sumPicks):
    continue
  v=min(v,sumPicks[0])

  
print(v)

Measured memory_bytes: 27308
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();
        int c = scn.nextInt();
        String answer = "No";
        if(a+b>=c) answer = "Yes";
        System.out.println(answer);
    }
}


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

using namespace std;

int main()
{
	long long a,b,c;
	cin >> a >> b >> c;
	long long x=min(a,c);
	a-=x; c-=x;
	b-=min(c,b);
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  vl d;
  inputv(d,n);
  sort(d.begin(),d.end());
  ll ans = 1;
  for(ll i=1;i<n;i++){
    if(d[i] != d[i-1]){
      ans++;
    }
  }
  cout << ans;
    
 return 0;
}


Measured memory_bytes: 256
num = gets.to_i
c = 0
def prime
	n = gets.to_i
	if n == 2
		return true
	end
	if n%2 == 0
		return false
	end
	i = 3
	while i*i <= n
		if n%i == 0
			return false
		end
		i += 2
	end
	return true
end
num.times do 
	if prime
		c += 1
	end
end
puts c


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

int main() {
  vector<pair<string,int>> var{{"AC",0},{"WA",0},{"TLE",0},{"RE",0}};
  int n;
  cin>>n;
  while(n--){
    string s;
    cin>>s;
    auto it =find_if(var.begin(),var.end(),[&s](const pair<string,int>& p){return p.first==s;});
    (*it).second++;

  }
  auto itr=var.begin();
  for(;itr!=var.end();itr++){
    cout<<(*itr).first<<" x "<<(*itr).second<<endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const LL N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
LL dp[3000][3000][4],n,m,array1[3000][3000],k;
LL solve(LL i,LL j,LL rows){
    if(i==n-1&&j==m-1){
       if(rows==3){
        return 0;
       }
       return array1[i][j];
    }
    if(i>=n||j>=m){
        return -OO;
    }
    if(dp[i][j][rows]!=-1){
        return dp[i][j][rows];
    }
    if(rows>=3){
        return dp[i][j][rows]=max(solve(i+1,j,0),solve(i,j+1,rows));
    }
    else{
        LL choice1=array1[i][j]+solve(i+1,j,0);
        LL choice2=array1[i][j]+solve(i,j+1,rows+1);
        LL choice3=solve(i+1,j,0);
        LL choice4=solve(i,j+1,rows);
        return dp[i][j][rows]=max(max(choice1,choice2),max(choice3,choice4));
        }
}
int main()
{
memset(dp,-1,sizeof(dp));
scanf("%lld %lld %lld",&n,&m,&k);
while(k--){
    LL row,column,value;
    scanf("%lld %lld %lld",&row,&column,&value);
    array1[--row][--column]=value;
}
printf("%lld",solve(0,0,0));
 
 
 
    return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v(0) {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<TEN(9) + 7>;


int D;
string s;

Mint dp[10100][101][2];
bool vis[10100][101][2];
Mint solve(int p, int d, int f) {
    if (p == -1) {
        if (d == 0) return Mint(1);
        return Mint(0);
    }
    if (vis[p][d][f]) return dp[p][d][f];
    vis[p][d][f] = true;
    int c = s[p] - '0';
    Mint sm = 0;
    for (int i = 0; i <= 9; i++) {
        if (f && c < i) break;
        sm += solve(p - 1, (d + i) % D, f && (c == i));
    }
    return dp[p][d][f] = sm;
}

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

    cin >> s >> D;
    reverse(s.begin(), s.end());
    cout << solve(int(s.size()) - 1, 0, 1) - 1 << endl;
    return 0;
}


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

int x[55];

long long dp[55][5005];

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

    for(int i = 1; i <= N; i ++){
        scanf("%d", &x[i]);
        x[i] -= A;
    }

    memset(dp, 0, sizeof(dp));
    dp[0][2500] = 1;
    for(int i = 1; i <= N; i ++){
        for(int j = 0; j <= 5000; j ++){
            dp[i][j] = dp[i-1][j];
            if(j >= x[i]){
                dp[i][j] += dp[i-1][j-x[i]];
            }
            //printf("dp[%d][%d]=%lld\n", i, j, dp[i][j]);
        }
    }

    printf("%lld", dp[N][2500]-1);
    return 0;
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Read();
		int l = int.Parse(input[0]);
		int r = int.Parse(input[1]);
		int d = int.Parse(input[2]);

		int ld = (l-1)/d;
		int rd = r/d;
		Write(rd-ld);
	}

	static string[] Read()
	{
		return Console.ReadLine().Split(' ');
	}

	static void Write(object o)
	{
		Console.WriteLine(o.ToString());
	}
}



Measured memory_bytes: 27328
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a,b;
    cin>>a>>b;
    bool ok=false;
    if(a%3==0)ok=true;
    if(b%3==0)ok=true;
    if((a+b)%3==0)ok=true;
    cout<<(ok==true?"Possible":"Impossible")<<endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto S1 = scanString;
  auto S2 = scanString;
  foreach(i;0..3)if(S1[i]!=S2[2-i])end("NO");end("YES");
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cnt0 = 0

a0 = a%10
if a0 == 0:
    cnt0 += 1
b0 = b%10
if b0 == 0:
    cnt0 += 1
c0 = c%10
if c0 == 0:
    cnt0 += 1
d0 = d%10
if d0 == 0:
    cnt0 += 1
e0 = e%10
if e0 == 0:
    cnt0 += 1

a1 = a//10
b1 = b//10
c1 = c//10
d1 = d//10
e1 = e//10

cnt1 = (a1+b1+c1+d1+e1)*10

if cnt0 == 4 or cnt0 ==5:
    print(a+b+c+d+e)
else:
    A = [a0,b0,c0,d0,e0]
    A.sort()
    print(cnt1 + (5-cnt0-1)*10 + A[cnt0])

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long long h;
    cin >> n >> h;
    priority_queue<long long> pq;
    long long ma = 0;
    for(int i = 0; i < n; i++){
        long long a, b;
        cin >> a >> b;
        ma = max(a, ma);
        pq.push(b);
    }
    long long ans = 0;
    while(h > 0 && !pq.empty()){
        long long p = pq.top();
        pq.pop();
        if(ma < p){
            ans++;
            h -= p;
        }
        else break;
    }
    if(h > 0) ans += (h + ma - 1) / ma;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
import sys
from itertools import permutations

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, C = map(int, readline().split())
    D = [0] * C
    for i in range(C):
        D[i] = list(map(int, readline().split()))
    G = [0] * N
    for i in range(N):
        G[i] = [int(s) - 1 for s in readline().split()]

    cost = [[0] * C for _ in range(3)]
    for x in range(N):
        for y in range(N):
            color = G[x][y]
            cost_current = cost[(x + y) % 3]
            for i in range(C):
                cost_current[i] += D[color][i]

    ans = INF
    for c1, c2, c3 in permutations(range(C), 3):
        if ans > cost[0][c1] + cost[1][c2] + cost[2][c3]:
            ans = cost[0][c1] + cost[1][c2] + cost[2][c3]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 11588
n = int(input())
money = 1000
stock = 0
(*a,) = map(int, input().split())

for i in range(n - 1):
    if a[i] < a[i + 1]:
        stock += money // a[i]
        money = money % a[i]
    elif a[i] > a[i + 1]:
        money += stock * a[i]
        stock = 0
    else:
        pass
money += stock * a[-1]
print(money)

Measured memory_bytes: 9128
#!python3.8
# -*- coding: utf-8 -*-
# abc163/abc163_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    A = i2nn()
    hw = sum(A)
    play = N - hw
    if play >= 0:
        print(play)
    else:
        print(-1)
    return

main()


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

const int N = 1e5;

long long calc(long long a, long long b) {
    if (a%2 == b%2) {
        return (b-a)/2;
    } else if (b-a == 1) {
        return b-1;
    } else {
        long long x = b-a;
        return a-!(x&1)+x/2;
    }
}

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    cout << min(calc(a, b), calc(n-b+1, n-a+1));
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int gcd(int a,int b){
  int r=a%b;
  while(r>0){
    a=b;b=r;r=a%b;
  }
  return b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int g;
  scanf("%d",&g);
  for(int i=1;i<n;i++){
    int a;
    scanf("%d",&a);
    g=gcd(g,a);
  }
  printf("%d\n",g);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    
    const double pi = acos(-1);
    double atheta =  pi / 2 - (pi * h / 6 + pi * m / 360);
    double btheta =  pi / 2 - (pi * m / 30);
    auto za = polar((double)a, atheta);
    auto zb = polar((double)b, btheta);
    cout << fixed << setprecision(15) << abs(za - zb) << endl;
    // cout << fixed << setprecision(15) << sqrt(a*a + b*b - 2*a*b*cos(atheta - btheta)) << endl;

    // double ax = a * cos(atheta), ay = a * sin(atheta);
    // double bx = b * cos(btheta), by = b * sin(btheta);
    // double ans = hypot(ax - bx, ay - by);
    // cout << fixed << setprecision(15) << ans << endl;

}

Measured memory_bytes: 4088
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	r := []rune(s)

	if len(r) >= 6 && r[2] == r[3] && r[4] == r[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
n, m = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
d = {}
# 1 = 2 = 0.5
d[2] = [1]
# 7 = 3 = 2.3 
d[3] = [7]
# 4 = 4 = 1
d[4] = [4]
# 5 = 5 = 1
# 3 = 5 = .6
# 2 = 5 = .4
d[5] = [5, 3, 2]
# 9 = 6 = 1.5
# 6 = 6 = 1
d[6] = [9, 6]
# 8 = 7 = 1.1...
d[7] = [8]
enable = [False] * 10
for a in l:
  enable[a] = True
memo = {}
def f(nokori, current):
#  print(nokori, current)
  k = (nokori, current)  # 順不同
  if k in memo:
    return memo[k]
  if nokori == 0:
    return current
  if nokori < 0:
    return -1
  temps = []
  for key, nums in list(d.items())[::-1]:
    # print(key, nums, type(nums))
    for num in nums:
      if enable[num]:
        if nokori-key != 0 and current % 10 != 0 and current % 10 < num:
          continue
        temps.append(f(nokori-key, current*10+num))
        break
  memo[k] = max(temps)
  return memo[k]

# pre
hoge = False
for key, nums in list(d.items()):
    # print(key, nums, type(nums))
    for num in nums:
      if enable[num]:
        hoge = True
        break
    if hoge:
      break
cs = []
while n > 50:  #
  n -= key
  cs.append(str(num))
num_ans = str(f(n, 0))
print(''.join(sorted(list(num_ans) + cs)[::-1]))

Measured memory_bytes: 12780
#include <bits/stdc++.h>
// #include <experimental/iterator>

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* debug */
// auto debug = std::experimental::make_ostream_joiner(std::cout, " ");

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n, a[] = {3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199};

int main(){
	cin >> n;
	Int count = 0;
	RC(i, sizeof(a) / sizeof(a[0])){
		RC(j, i){
			Int tmp = a[i] * a[j] * a[j] * a[j];
			if(tmp <= n){
				++count;
			}
		}
	}
	RC(i, sizeof(a) / sizeof(a[0])){
		RC(j, i){
			RC(k, j){
				Int tmp = a[i] * a[j] * a[k];
				if(tmp <= n){
					++count;
				}
			}
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    long long d;
    int n, i, count = 0;
    int x[200000];
    int y[200000];

    scanf("%d %lld", &n, &d);
    for(i = 0; i < n; i++) {
        scanf("%d %d", &x[i], &y[i]);
    }

    for(i = 0; i < n; i++) {
        if(((long long)x[i] * x[i]) + ((long long)y[i] * y[i]) <= (long long)d * d) count++;
    }

    printf("%d", count);

    return 0;
}

Measured memory_bytes: 3296