akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long n,a[100500],ans;
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
   cin>>a[i];
  for(int i=0;i<n;i++)
   if(a[i]%2==0)
   {
   	  while(a[i]%2==0)
   	  {
   	  	a[i]/=2;
   	  	ans++;
	  }
   }
 cout<<ans;
}

Measured memory_bytes: 384
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [a, b] <- readInts
  putStrLn $ solve (a, b)

solve :: (Int, Int) -> String
solve (a, b) =
  if (a - b) == 0 then "Draw"
    else if a == 1 || (a > b && b /= 1) then "Alice"
    else "Bob"

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


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

int main() {
  int a;
  cin >> a;
  for (int i=1;i<10;i++){
    if(a%i==0 && a/i<10){
    cout <<"Yes"<<endl;
      return 0;
    }
  }
  cout << "No" <<endl;
}

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

int n,a,b;
long long sum;

bool check(int num){
	int sum=0;
	while(num)
		sum+=num%10,
		num/=10;
	return a<=sum&&sum<=b;
}

int main(void){
	scanf("%d%d%d",&n,&a,&b);
	for(register int i=1;i<=n;i++)
		if(check(i))
			sum+=i;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
arr=list(map(int, input().split()))
if 0 in arr:
  print("0")
else:
  done=False
  mul=1
  for i in range(len(arr)):
    if mul*arr[i]<=int(1e18):
      mul*=arr[i]
    else:
      print("-1")
      done=True
      break
  if not done:
    print(mul)


Measured memory_bytes: 21788
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int n,W,pos[100600],w[105],v[105],sum;

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin >> n >> W;
    pos[0]=1;
    for(int i=1;i<=n;i++) cin >> w[i] >> v[i];
    for(int i=1;i<=n;i++) sum+=v[i];
    for(int i=1;i<=sum;i++) pos[i]=1e18;
    //rezolvarea aici
    for(int i=1;i<=n;i++){
        for(int j=sum;j>=0;j--){
            if(pos[j]>=1 && pos[j]<=1e18){
                pos[j+v[i]]=min(pos[j+v[i]],pos[j]+w[i]);
            }
        }
    }
    int ans=0;
    for(int j=sum;j>=1;j--){
        if(pos[j]-1<=W) ans=max(ans,j);
    }
    cout<<ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  if(((N-1)*(N-2))/2<K)
    cout<<-1<<endl;
  else{
  cout<<(N-1)+((N-1)*(N-2))/2-K<<endl;
    for(int i=2;i<=N;i++)
      cout<<1<<" "<<i<<endl;
    int a=(((N-1)*(N-2)))/2-K;
    int b=0;
    for(int k=3;k<=N;k++){
     if(b==a)
       break;
      else{
       for(int j=k-1;2<=j;j--){
       cout<<k<<" "<<j<<endl;
         b++; if(b==a)break;
       }
      }
    }
  }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define co(n) cout << n << endl;

int main() {
  int N;
  dl a;
  cin >> N;
  ve(dl) A(N);
  rep(i, N) {
    cin >> A.at(i);
  }
  rep(i, N) {
    a += 1 / A.at(i);
  }
  pr(10);
  co(1 / a);
}  

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

int xa, ya, wa, ha, xb, yb, wb, hb, w = 0, h = 0;

int main()
{
	cin >> xa >> ya >> wa >> ha >> xb >> yb >> wb >> hb;

	if (xa + wa > xb && xb + wb > xa)
		w = min(xa + wa, xb + wb) - max(xa, xb);

	if (ya + ha > yb && yb + hb > ya)
		h = min(ya + ha, yb + hb) - max(ya, yb);
	
	cout << wa * ha + wb * hb - w * h * 2 << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
	string ans;
	int t_hp, t_atk, a_hp, a_atk;
	int i;

	// input
	cin >> t_hp >> t_atk >> a_hp >> a_atk;

	// calc
	for ( i=0; i<10000; i++ )
	{
		a_hp -= t_atk;
		if (a_hp <= 0) {
			ans = "Yes";
			break;
		}
		t_hp -= a_atk;
		if (t_hp <= 0) {
			ans = "No";
			break;
		}
	}

	// output
	cout << ans;
	cout << endl;

	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<ll, int> P;
typedef vector<int> V;
typedef map<int, int> M;

double di(double ax, double ay, double bx, double by)
{
    return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}

//#####################
//Dijkstra
//#####################
struct edge
{
    int to;
    double cost;
};

int n;
vector<edge> g[112345];
long double dis[112345];

void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P>> que;
    fill(dis, dis + n + 1, INF);
    dis[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        int n_ = p.second;
        if (dis[n_] < p.first)
            continue;
        for (int i = 0; i < g[n_].size(); i++)
        {
            edge e = g[n_][i];
            if (dis[e.to] > dis[n_] + e.cost)
            {
                dis[e.to] = dis[n_] + e.cost;
                que.push(P(dis[e.to], e.to));
            }
        }
    }
}

int main()
{
    int xs, ys, xt, yt, N, x[1100], y[1100], r[1100];

    cin >> xs >> ys >> xt >> yt;

    cin >> N;

    REP(i, N)
    cin >> x[i + 1] >> y[i + 1] >> r[i + 1];

    x[0] = xs;
    y[0] = ys;
    r[0] = 0;

    x[N + 1] = xt;
    y[N + 1] = yt;
    r[N + 1] = 0;

    n = N + 2;

    REP(i, n)
    {
        for (int j = i + 1; j < n; j++)
        {
            double d = di(x[i], y[i], x[j], y[j]) - r[i] - r[j];
            d = max(0.0, d);
            g[i].push_back({j, d});
            g[j].push_back({i, d});
        }
    }

    dijkstra(0);

    cout << setprecision(20) << dis[n - 1] << endl;

    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  for(int i=1; i<s.size(); i++) {
    if(s.at(i-1) == s.at(i)) {
      s.erase(i-1,1);
      i--;
    }
  }
  
  cout << s.size() << endl;
}

Measured memory_bytes: 512
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char s;
    string ans="aiueo";
    cin>>s;
    rep(i,5){
        if(s==ans[i]){
            cout<<"vowel"<<"\n";
            return 0;
        }
    }
    cout<<"consonant"<<"\n";
}


Measured memory_bytes: 3616
import Control.Monad
import Data.List
import Data.Maybe

query :: Int -> Bool
query n = not $ null $ do
  x <- [0..n `div` 7]
  let (y,r) = (n - 7 * x) `divMod` 4
  guard $ y >= 0 && r == 0

main :: IO ()
main = do
  n <- read <$> getLine
  putStrLn $ if query n then "Yes" else "No"

Measured memory_bytes: 508
a=int(input())
if a in range(400,600):
    print(8)
elif a in range(600,800):
    print(7)
elif a in range(800,1000):
    print(6)
elif a in range(1000,1200):
    print(5)
elif a in range(1200,1400):
    print(4)
elif a in range(1400, 1600):
    print(3)
elif a in range(1600, 1800):
    print(2)
elif a in range(1800, 2000):
    print(1)

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

int main(){
  int N; cin >> N;
  vector<pair<int,int>> a(N);
  for(int i = 0; i < N; i++){ cin >> a[i].first; a[i].second = i+1;}
  
  sort(a.begin(),a.end());
  
  for(int i = 0; i < N; i++){ cout << a[i].second << " ";}
  cout << endl;
  return 0;}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin>>N>>K;
    vll a(N);
    rep(i,N) cin>>a[i];
    FOR(i,K,N-1){
        if (a[i]>a[i-K]){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 4776
#include<iostream>
using namespace std;
int main()
{
	long long int k,d,z,gs=0;
	cin>>z;
	for(int i=0;i<z;i++)
	{
		cin>>k>>d;
		gs+=(max(k,d)-min(k,d))+1;
	}
	cout<<gs;
	return 0;
}

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

Measured memory_bytes: 1008
#include<stdio.h>
#include<string.h>


void change(char *str){
    int len=strlen(str);
    int i;
    for(i=0;i<len;i++){
        if('a'<=str[i]&&str[i]<='z')
        str[i]-=32;
    }
}
    
    
int main (void){
    char t[10000],key[10000],eofstr[]={"END_OF_TEXT"};
    int ans=0;
    
    scanf("%s",key);
    change(key);
    
    while(1){
        scanf("%s",t);
        if(strcmp(t,eofstr)==0){
        break;
        }
        change(t);
        
        if(strcmp(t,key)==0)    
        ans++;
        
    }
    
    printf("%d\n",ans);
    return(0);
}


Measured memory_bytes: 2048
#include<iostream>
#include<string>
using namespace std;
int main() {
	int ans = 0;
	string s;
	while (getline(cin, s)) {
		int n = 0;
		for (int i = 0; i < s.size(); i++) {
			if      (s[i] == '1')n = n * 10 + 1;
			else if (s[i] == '2')n = n * 10 + 2;
			else if (s[i] == '3')n = n * 10 + 3;
			else if (s[i] == '4')n = n * 10 + 4;
			else if (s[i] == '5')n = n * 10 + 5;
			else if (s[i] == '6')n = n * 10 + 6;
			else if (s[i] == '7')n = n * 10 + 7;
			else if (s[i] == '8')n = n * 10 + 8;
			else if (s[i] == '9')n = n * 10 + 9;
			else if (s[i] == '0')n = n * 10 + 0;
			else {
				ans += n;
				n = 0;
			}
		}
		ans += n;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		int D = stdIn.nextInt();
		while(true) {
			C -= B;
			if(C <= 0) {
				break;
			}
			A -= D;
			if(A <= 0) {
				break;
			}
		}
		if(A <= 0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 35832
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
string s;
int n;
signed main(){
    cin>>n>>s;
    int l=s.size();
    rep(i,l){
        int c=s[i]-'A';
        c+=n;
        if(c>25)c-=26;
        char ch='A'+c;
        cout<<ch;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
sel='B'

if sel=='A':
    S=input()
    if S[2]==S[3] and S[4]==S[5]:
        print('Yes')
    else:
        print('No')

if sel=='B':
    X=int(input())
    ans=0
    ans+=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

if sel=='C':
    K,N=map(int,input().split())
    A=[int(i) for i in input().split()]
    d=[A[0]+K-A[-1]]
    for i in range(N-1):
        d.append(A[i+1]-A[i])
    d.sort()
    print(K-d[-1])

# if sel=='D':




Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	s64 X0;
	u64 K, D;
	cin >> X0 >> K >> D;

	s64 X = abs(X0);

	if(X / D > K) {
		X = X - D * K;
	} else {
		u64 XpD = X / D;
		X = X - D * XpD;
		K = K - XpD;
		X = X - (K % 2) * D;
	}
	
	cout << abs(X) << endl;
	return 0;
	
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt = 1e15;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int j=0;j<2;j++){
    ll cnt1 = 0,s = 0;
  	for(int i=0;i<n;i++){
    	s += a[i];
    	int k = (1-2*(i%2))*(1-2*j);
    	if(s*k<=0){
          cnt1 += 1-k*s;
          s = k;
        }
     }
    cnt = min(cnt1,cnt);
  }
  cout << cnt << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i) >> B.at(i);
    }
    int c = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] == B[i]) {
            c++;
        } else {
            c = 0;
        }
        if(c == 3) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
int A[100000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int64_t ans=A[0]-1;
    int blocker=1;
    for(int i=1;i<N;i++){
        if(A[i]==blocker+1){
            blocker++;
        }else{
            if(A[i]%(blocker+1)){
                ans+=A[i]/(blocker+1);
            }else if(A[i]/(blocker+1)){
                ans+=A[i]/(blocker+1)-1;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	int mod = c % a;

	int sum = 0;
	for (int i = 0; i < a; i++)
	{
		sum = i * b;
		sum%=a;
		if ((mod + sum) % a == 0){cout<<"YES"<<endl; return 0;}
	}
	cout<<"NO"<<endl;


return 0;
}

Measured memory_bytes: 3456
package main

import "fmt"

func main() {
	var w, h, x, y int
	fmt.Scan(&w, &h, &x, &y)

	c := 1
	if x+x != w || y+y != h {
		c = 0
	}
	fmt.Printf("%f %d", float64(w*h)/2, c)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int kMaxN = 1001;

int n, m, x, y, h, w;

struct E {
  int x, y;
};

vector<vector<int>> a(kMaxN, vector<int>(kMaxN, -1));

queue<E> q, e;

int ne[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

void Change(int i, int j, int v) {
  a[i][j] = v;
  E note = {i, j};
  q.push(note);
  e.push(note);
}

int main() {
  cin >> n >> m >> x >> y >> h >> w;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '#') {
        a[i][j] = -2;
      }
    }
  }
  Change(x, y, 0);
  while (!q.empty()) {
    while (!q.empty()) {
      x = q.front().x, y = q.front().y;
      e.push(q.front());
      q.pop();
      for (int i = 0; i < 4; i++) {
        int nx = x + ne[i][0], ny = y + ne[i][1];
        if (nx > 0 && nx <= n && ny > 0 && ny <= m && a[nx][ny] == -1) {
          Change(nx, ny, a[x][y]);
        }
      }
    }
    while (!e.empty()) {
      x = e.front().x, y = e.front().y;
      e.pop();
      for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
          int nx = x + i, ny = y + j;
          if (nx > 0 && nx <= n && ny > 0 && ny <= m && a[nx][ny] == -1) {
            a[nx][ny] = a[x][y] + 1;
            E note = {nx, ny};
            q.push(note);
          }
        }
      }
    }
  }
  cout << a[h][w];
  return 0;
}

Measured memory_bytes: 7588
N,M = map(int,input().split())
Ali = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

Ali.sort()
BC.sort(key=lambda x:x[1],reverse=True)
i = 0
j = 0

while i<N and j<M:
  if Ali[i]>=BC[j][1]:
    break
  Ali[i] = BC[j][1]
  i += 1
  BC[j][0] -= 1
  if BC[j][0] == 0:
    j += 1

print(sum(Ali))

Measured memory_bytes: 33048
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

int t;
long long n, a, b, c, d;

set<long long> st;
map<long long, long long> dp;

long long solve (long long m) {
	if (st.count(m)) return dp[m];
	long long ans = 0ll;
	if (m) {
		ans = solve(m / 2) + a + d * (m % 2);
		ans = min(ans, solve(m / 3) + b + d * (m % 3));
		ans = min(ans, solve(m / 5) + c + d * (m % 5));
		if (m / 2 + 1 < m) ans = min(ans, solve(m / 2 + 1) + a + d * (2 - m % 2));
		if (m / 3 + 1 < m) ans = min(ans, solve(m / 3 + 1) + b + d * (3 - m % 3));
		if (m / 5 + 1 < m) ans = min(ans, solve(m / 5 + 1) + c + d * (5 - m % 5));
		double val = (double)d * (double)m;
		if (val <= 1e18) ans = min(ans, d * m);
	}
	st.insert(m), dp[m] = ans;
	return ans;
}

int main () {
	scanf("%d", &t);
	while (t--) {
		st.clear(), dp.clear();
		scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
		printf("%lld\n", solve(n));
	}
	return 0;
}

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

int main(){
  vector<int> A(3);
  cin >>A.at(0)>>A.at(1)>>A.at(2);
  
  int count1=0;
  int count2=0;
  for(int i=0;i<3;i++){
    if(A.at(i)==5){
      count1++;
    }else{
      count2++;
    }}
    
    if(count1==2 && count2==1){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, x, num;
	int i, j, k;
	
	while (1) {
		num = 0;
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)
			break;
		
		for (i = 1; i <= n - 2; i++)
			for (j = i + 2; j <= n; j++)
				for (k = i + 1; k <= j - 1; k++)
					if ((i + j + k) == x)
						num++;
		printf("%d\n", num);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<sstream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stack>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
ll n, d, a, bot, top, s, ans1, ans2;
struct node{
	ll x, h;
	friend bool operator<(node a, node b)
	{
		return a.x < b.x;
	}
}monst[200005], que[400005];
int main()
{	
	while (~scanf("%lld%lld%lld", &n, &d, &a))
	{
		d *= 2;
		ans1 = ans2 = s = bot = top = 0;
		for (int i = 0; i < n; i++)
		{
			scanf("%lld%lld", &monst[i].x, &monst[i].h);
		}
		sort(monst, monst + n);
		for (int i = 0; i < n; i++)
		{
			if (bot != top)
			{
				while (que[bot].x + d < monst[i].x && bot != top)
				{
					s -= que[bot].h;
					bot++;	
				}	
			}
			ll num = (monst[i].h - 1) / a + 1 - s;
			if (num > 0)
			{
				ans1 += num;
				que[top].x = monst[i].x;
				que[top].h = num;
				top++;
				s += num;	
			}
		}
		printf("%lld\n", ans1);
	}
}

Measured memory_bytes: 8448
#include <iostream>
using namespace std;
int main(){
    int n[201]={};
    int ya;
    for(int num=1;num<=200;num+=2){
        ya=0;
        for(int ch=1;ch<=num;ch++){
            if(num%ch==0)ya++;
        }
        n[num]=ya;
        // cout<<num<<":::"<<ya<<endl;
    }
    int N,ans=0;
    cin>>N;
    for(int j=1;j<=N;j+=2){
        if(n[j]==8)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read(){int x;scanf("%d",&x);return x;}
const int N=100007;
vector<int>e[N];int ans[N],a[N];
int main()
{
    int n,m,num=0;cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>a[i],ans[i]=1;
    for(int i=1,u,v;i<=m;++i) cin>>u>>v,e[u].push_back(v),e[v].push_back(u);
    for(int i=1;i<=n;++i) for(int j:e[i]) ans[i]&=a[i]>a[j];
    for(int i=1;i<=n;++i) if(ans[i]) ++num;
    cout<<num;
}


Measured memory_bytes: 9548
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll x,y,n,m,o;
vl a,b,c;
int main(){FAST;
cin>>x>>y>>n>>m>>o;
for(ll i=1;i<=n;++i){
  ll f;cin>>f;
  a.pb(f);
}
for(ll i=1;i<=m;++i){
  ll f;cin>>f;
  b.pb(f);
}
for(ll i=1;i<=o;++i){
  ll f;cin>>f;
  c.pb(f);
}
sort(rall(a));
sort(rall(b));
sort(rall(c));
a.resize(x);
b.resize(y);
reverse(all(a));
reverse(all(b));
ll cur1 = 0;
ll cur2 = 0;
ll cur3 = 0;
while(cur3<o){
  if(cur1<x and cur2<y){
    if(a[cur1]<c[cur3] and b[cur2]<c[cur3]){
      if(a[cur1]<b[cur2]){
        a[cur1++] = c[cur3];
      }
      else if(b[cur2]<a[cur1]){
        b[cur2++] = c[cur3];
      }
      else{
        a[cur1++] = c[cur3];
      }
    }
    else if(a[cur1]<c[cur3]){
      a[cur1++] = c[cur3];
    }
    else if(b[cur2]<c[cur3]){
      b[cur2++] = c[cur3];
    }
  }
  else if(cur1<x){
   if(a[cur1]<c[cur3]){
      a[cur1++] = c[cur3];
    } 
  }
  else if(cur2<y){
    if(b[cur2]<c[cur3]){
      b[cur2++] = c[cur3];
    }
  }
  cur3++;
}

ll ans = 0;
for(ll i=0;i<x;++i)ans+=a[i];
for(ll i=0;i<y;++i)ans+=b[i];
cout<<ans;
return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

#define int ll
void solve()
{
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	int cul=0;
	int ans=1000;
	rep(i,n){
		ans+=cul*a[i];
		cul=0;
		if(i<n-1&&a[i]<a[i+1]){
			cul+=ans/a[i];
			ans-=cul*a[i];
		}
	}
	cout<<ans;
}
#undef int
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back



int main(){
    ios_base::sync_with_stdio(false);
    //freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    vector<ll> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(),v.end());
    bool flag = false;
    if(v[0] == v[1] && v[1] != v[2]) flag = true;
    if(v[2] == v[1] && v[1] != v[0]) flag = true;
    if(flag) cout << "Yes";
    else cout << "No";

    return 0;
}

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

int main()
{
  int a,b;cin>>a>>b;
  if(a>b)swap(a,b);
  if(a==1&&b==2)cout<<3<<endl;
  else if(a==1&&b==3)cout<<2<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 256
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  n,m,c = list(map(int,input().split()))
  b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  a = [list(map(int,input().split())) for i in range(n)]
  count = 0
  lis = []
  
  for i in range(n):
    ans = c
    for j in range(m):
      ans += a[i][j]*b[j]
    if ans > 0:
      count += 1
  print(count)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int counter=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i))
            counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 3912
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	ll N=in(),A=in(),B=in();
	auto V=vecin<ll>(N);
	ll maxV = *max_element(ALL(V));

	ll OK=(ll)ceil(maxV/(double)(B));
	ll NG=0;
	while(abs(NG-OK)>1){
		ll mid = (OK+NG)/2LL;

		ll sum=0;
		for(auto& x:V){
			sum += max((ll)ceil((x-B*mid)/((double)(A-B))),0LL);
		}

		if(sum<=mid){
			OK = mid;
		}
		else{
			NG = mid;
		}
	}
	out(OK);
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	
	sort(p.begin(), p.end());
	int sum=0;
	rep(i,k) sum+= p[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3628
k, a, b = map(int, input().split())
if a >= b - 2 or a > k:
  print(int(k+1))
elif (k-a+1)%2 == 0:
  print(int((b-a)*(k-a+1)//2 + a))
else:
  print(int((b-a)*(k-a)//2 + 1 + a))

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
typedef long long ll;
ll n, a, b, l, r=1e9, m, ans, h[100005];

bool f(ll p) {
	ll i, c=0;
	for(i=0; i<n; i++)
		c += h[i]>p*b ? (h[i]-p*b+a-1)/a : 0;
	return c<=p;
}

int main() {
	scanf("%lld%lld%lld", &n, &a, &b);
	a -= b;
	for(ll i=0; i<n; i++) scanf("%lld", &h[i]);
	while(l<r) {
		m = (l+r) / 2;
		if(f(m)) r = m;
		else l = m+1;
	}
	printf("%lld", r);
	return 0;
}

Measured memory_bytes: 896
class Q1029
  def simulate n,m
    if 0 < n
      up = gets.split(" ").map{|x| x.to_i}
    else up = []
    end
    if 0 < m
      down = gets.split(" ").map{|x| x.to_i}
    else down = []
    end
    up.concat(down).sort!
    max = up[0]
    for i in 0..up.length-2 
      t = up[i + 1] - up[i]
      max = max < t ? t : max
    end
    puts max
    #puts up
  end
  def doIt
    arg = gets.split(" ").map{|x| x.to_i}
    while (0 < arg[0] + arg[1])
      simulate arg[0],arg[1]
      arg = gets.split(" ").map{|x| x.to_i}
    end
  end
end
 
Q1029.new.doIt

Measured memory_bytes: 5948
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        boolean ans = solve(N);
        System.out.println(ans? "Yes" : "No");
    }

    private static boolean solve(int N) {
        int sn = 0;

        int value = N;
        while (value > 0) {
            sn += value %10;
            value /= 10;
        }


        return N%sn == 0;
    }

}


Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,m;
  cin >> n >> m;
  int a[n];
  rep(i,n)cin >> a[i];
  priority_queue<ll> q;
  rep(i,n)q.push(a[i]);
  rep(i,m){
    ll x=q.top();
    q.pop();
    q.push(x/2);
  }
  ll ans=0;
  while(!q.empty()){
    ll x=q.top();
    q.pop();
    ans+=x;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1784
import sys
N = int(input())
s, f = [], []
for i in range(N):
    s.append(int(input()))
if sum(s)%10 != 0:
    print(sum(s))
else:
    s.sort()
    for i in range(N):
        f.append(s[i]%10)
    for i, x in enumerate(f):
        if x != 0:
            print(sum(s)-s[i])
            sys.exit()
    print(0)

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

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

  int ans = 0;

  if (A > B){
    ans += B;
  } else {
    ans += A;
  }
  
  if (C > D){
    ans += D;
  } else{
    ans += C;
  }

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	uniqueness := "yes"
	for i := range s {
		for j := range s {
			if i == j {
				continue
			}
			if s[i] == s[j] {
				uniqueness = "no"
				break
			}
		}
		if uniqueness == "no" {
			break
		}
	}

	fmt.Println(uniqueness)
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(void) {
  int i, num = 0;
  int A, B, T;
  
  cin >> A;
  cin >> B;
  cin >> T;
  
  for(i = A; i < T + 0.5; i = i + A) {
    num += B;
  }
  
  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int H = 1, x = 0, sum = 0;
    cin >> H;
    x = log2(H);
    sum = pow(2, x + 1) - 1;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    // input
int N; cin >> N ;
vector <int > V ( N );
for ( int i = 0; i < N ; ++ i ) {
cin >> V [ i ];
}
vector <int > C ( N );
for ( int i = 0; i < N ; ++ i ) {
cin >> C [ i ];
}
// compute
int ans = 0;
for ( int i = 0; i < N ; ++ i ) {
if ( V [ i ] > C [ i ]) {
ans += V [ i ] - C [ i ];
}
}
// output
cout << ans << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  int n, k;
  cin >> n >> k;
  vector<mint> d(k + 1);
  for(int i = 1; i <= k; ++i) {
    d[i] = k / i;
    d[i] = d[i].pow(n);
  }

  for (int i = k; i >= 1; --i) {
    for (int j = i * 2; j <= k; j += i) {
      d[i] -= d[j];
    }
  }
  mint ans = 0;
  for (int i = 1; i <= k; ++i) {
    ans += d[i] * i;
  }
  cout << ans << endl;

}

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

int main() {
  typedef long long ll;
  ll a, b, k;
  cin >> a >> b >> k;
  ll lo = a / k * k, hi = b / k * k; // hi safe
  if (lo < a) lo += k;
  ll ans = max(0ll, (hi - lo) / k + 1);
  cout << ans << endl;
}

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

#define lugan "LCS"
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _io ios_base::sync_with_stdio(0);   cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 3e3+7;
const int oo = 1e9+7;

inline void initf()
{
    freopen(lugan".inp", "r", stdin);
    freopen(lugan".out", "w", stdout);
}

string s, t;
int dp[N][N];
int T[N][N];

void solve()
{
    getline(cin, s);
    getline(cin, t);
    T[0][0] = -1;
    for (int i=0; i<s.size(); i++)
    {
        for (int j=0; j<t.size(); j++)
        {
            if (s[i] == t[j])
            {
                dp[i+1][j+1] = dp[i][j] + 1;
                T[i+1][j+1] = j;
            }
            else
            {
                if (dp[i][j+1] > dp[i+1][j])
                {
                    dp[i+1][j+1] = dp[i][j+1];
                    T[i+1][j+1] = T[i][j+1];
                }
                else
                {
                    dp[i+1][j+1] = dp[i+1][j];
                    T[i+1][j+1] = T[i+1][j];
                }
            }
        }
    }
    int ix = s.size(), jx = t.size();
    string res;
    while (ix > 0 && jx > 0)
    {
        ///cout << ix << ' '    << jx << ' ' << s[ix-1] << ' ' << t[jx-1] << endl;
        if (s[ix-1] == t[jx-1])
        {
            ///cout << s[ix-1];
            res += s[ix-1];
            ix--; jx--;
        }
        else
        {
            if (dp[ix-1][jx] > dp[ix][jx-1])
            {
                ix--;
            }
            else jx--;
        }
    }
   reverse(all(res));
   cout << res;
}

int main()
{
    _io
    solve();
    return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto isValid(vector<int>v){
    vector<int>st = {1,10,11,12,13};
    if(v.back() - v.front() == 4 or v == st)return true;
    else return false;
}
signed main(){
    vector<int>v(5);
    char gomi;
    while(cin >> v[0] >> gomi >> v[1] >> gomi >> v[2] >> gomi >> v[3]  >> gomi >> v[4]){
        sort(all(v));
        auto u = v;
        u.erase(unique(all(u)),u.end());
        if(u.size() == 2){
            if(v.front() != v[1] or v.back() != v[3]){
                cout << "four card" << endl;
            } else {
                cout << "full house" << endl;
            }
        } else if(u.size() == 5 and isValid(v)){
            
            cout << "straight" << endl;
            
        }else if(u.size() == 3){
            
            bool flag = false;
            rep(i,v.size())
                if(i and i+1 != v.size() and v[i-1] == v[i] and v[i] == v[i+1]) flag = true;
            
            if(flag)cout << "three card" << endl;
            else cout << "two pair" << endl;
            
        } else if(u.size() == 4){
            cout << "one pair" << endl;
        }
        else cout << "null" << endl;
    }
}





Measured memory_bytes: 3140
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    sum = 500*i
    if sum == x:
        count += 1
    else:
        for j in range(b+1):
            sum_100 = 100*j
            if sum + sum_100 == x:
                count += 1
            else:
                for k in range(c+1):
                    sum_50 = 50*k
                    if sum + sum_100 + sum_50 == x:
                        count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

int main()
{
	uint32_t n,a;
	cin >> n >> a;

	if ((n % 500) <= a) {
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
	//	std::cout << "Hello World!\n"; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
  ld N,M,D;
  ld SUM = 0;
  cin >> N >> M >> D;
  if(N==1){
    if(D==0){
      cout << M-1 << endl;
    }
    else{
      cout << 0 << endl;
    }
    return 0;
  }
  ll A = max(0LL,(ll)N-2*(ll)D);
  SUM = (A*2+N-A)/N/N*(M-1);
  if(D==0){
    SUM/=2;
  }
  cout << stpr(10) << SUM << endl;
}

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

#define ll long long

ll int arr[3005];
ll int dp[3005][3005][2];

ll int kil(int l, int r, int player)
{
  if(l == r)
  {
    if(player)
      return arr[l];
    return -arr[l];
  }

  if(dp[l][r][player] != -1)
    return dp[l][r][player];

  if(player)
  {
    dp[l][r][player] = -1e15;
    dp[l][r][player] = max(dp[l][r][player], kil(l+1, r, 1-player) + arr[l]);
    dp[l][r][player] = max(dp[l][r][player], kil(l, r-1, 1-player) + arr[r]);
  }
  else
  {
    dp[l][r][player] = 1e15;
    dp[l][r][player] = min(dp[l][r][player], kil(l+1, r, 1-player) - arr[l]);
    dp[l][r][player] = min(dp[l][r][player], kil(l, r-1, 1-player) - arr[r]);
  }

  return dp[l][r][player];
}

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

  memset(dp, -1, sizeof dp);

  int n, k, res;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>arr[i];

  cout<<kil(0, n-1, 1)<<endl;

  return 0;
}


Measured memory_bytes: 141568
import heapq
import sys

def solve(k):
    if k < 10:
        return k
    
    heap = [1,2,3,4,5,6,7,8,9]
    heapq.heapify(heap)

    for i in range(k-1):
        lunlun = heapq.heappop(heap)
        lastDigit = lunlun  % 10
        # print lunlun
        heapq.heappush(heap, (lunlun*10) + lastDigit)

        if lastDigit == 0:
            newlunlun = (lunlun * 10) + 1
            heapq.heappush(heap, newlunlun)    
        elif lastDigit == 9:
            newlunlun = (lunlun * 10) + 8
            heapq.heappush(heap, newlunlun)  
        else:
            newlunlun1 = (lunlun * 10) + lastDigit + 1
            newlunlun2 = (lunlun * 10) + lastDigit - 1
            heapq.heappush(heap, newlunlun1)
            heapq.heappush(heap, newlunlun2)

    return heapq.heappop(heap)

k = input()
# k = 100000
print(solve(int(k)))

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

int main() {
	int r,c;cin>>r>>c;
	int a[101][101]={};
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)cin>>a[i][j];
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)a[i][c]+=a[i][j];
	for(int i=0;i<c;i++)for(int j=0;j<r;j++)a[r][i]+=a[j][i];
	for(int i=0;i<r;i++)a[r][c]+=a[i][c];
	for(int i=0;i<=r;i++)
	{
		for(int j=0;j<=c;j++)
		{
			if(j)cout<<" ";
			cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

int main() {
    int th, ta, mh, ma;
    cin >> th >> ta >> mh >> ma;
    while (true) {
        mh -= ta;
        if (mh <= 0) {
            cout << "Yes" << endl;
            return 0;
        }

        th -= ma;
        if (th <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> A(H, vector<char>(W));
  vector<vector<char>> B(H + 2, vector<char>(W + 2, '0'));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
      if (A.at(i).at(j) == '#') {
        for (int k = i; k < i + 3; k++) {
          for (int l = j; l < j + 3; l++) {
            B.at(k).at(l)++;
          }
        }
      } 
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) == '#') {
        B.at(i + 1).at(j + 1) = '#';
      }
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cout << B.at(i).at(j);
    }
    cout << endl;
  }
}

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

using namespace std;

long yukurid(long a ,long b){
    if(a>b){
        swap(a,b);
    }
    if(b%a == 0){
        return(a);
    }else{
        return(yukurid(a,b%a));
    }
}

long LCM(long a ,long b){
    return a*b/yukurid(a,b);
}

int main(){
    long a,b;
    cin >> a >> b;
    cout << LCM(a,b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int costL=0, costR=0;
    for(int i=0; i<m; ++i){
        int a;
        cin >> a;
        if(a<x){
            ++costL;
        } else{
            ++costR;
        }
    }

    cout << (costL < costR ? costL : costR) << "\n";
    return 0;
}

Measured memory_bytes: 256