akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  int a;
  int A,B,O,AB;
  char k;
  string b;

  A = B = AB = O = 0;

  while(cin >> a >> k >> b){
    if(b == "A"){
      A++;
    }
    if(b == "B"){
      B++;
    }
    if(b == "AB"){
      AB++;
    }
    if(b == "O"){
      O++;
    }
  }

  printf("%d\n%d\n%d\n%d\n", A, B, AB, O);

  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
        int div;
        ll sum;

        while(cin >> div){
                sum = 0;
                for(int i = div;i<=600-div;i+=div){
                        sum += i*i*div;
                }

                cout << sum << endl;
        }

        return 0;
}

Measured memory_bytes: 1156
def main():
    #print = out.append
    ''' Cook your dish here! '''
    m = get_int()
    sm = 0
    smc = 0
    for _ in range(m):
        a, b = get_list()
        sm += a*b
        smc += b
    print(smc-1 + ((sm-1)//9))

''' Coded with love at India by Satyam Kumar '''
import sys
#from collections import defaultdict
import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 93072
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2512
sx, sy, tx, ty = map(int, input().split())
t = ''
for i in range(ty-sy):
    t += 'U'
for i in range(tx-sx):
    t += 'R'
for i in range(ty-sy):
    t += 'D'
for i in range(tx-sx):
    t += 'L'

t += 'L'
for i in range(ty-sy+1):
    t += 'U'
for i in range(tx-sx+1):
    t += 'R'
t += 'DR'
for i in range(ty-sy+1):
    t += 'D'
for i in range(tx-sx+1):
    t += 'L'
t += 'U'
print(t)


Measured memory_bytes: 3064
//
//  1187.cpp
//  
//
//  Created by Minote Tomoki on 2015/06/04.
//
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef struct {
    int m;
    int t;
    int p;
    int j;
} data;

typedef struct {
    int team;
    int time;
    int collect;
} status;

status judge(vector<data> team,int num) {
    int que_time[10]={0};
    
     status result = {num};
    
    for(auto k:team) {
//        que_time[k.p-1]+=k.m;
        if(k.j==0) {
            result.collect++;
            result.time+=k.m + que_time[k.p-1];
        }
        else {
            que_time[k.p-1]+=20;
        }
        
    }
//    cout << result.time << endl;
//    cout << result.collect << endl;
    
//    cout << result.time << endl;
    
    return result;
}

bool cmp(const status& left, const status& right) {
    if ( left.collect == right.collect) {
        if(left.time == right.time) {
            return left.team > right.team;
        }
        else {
            return left.time < right.time;
        }
    }
    return left.collect > right.collect;
}

bool eq(const status& left, const status& right) {
    if(left.collect == right.collect && left.time == right.time) return true;
    else return false;
}

int main(void) {
    int M,T,P,R;
    int m,t,p,j;
    
    while(cin >> M >> T >> P >> R, M|T|P|R) {
    
        vector<data> dat(R);
        vector<vector<data>> team(T);
        vector<status> result;
    
        for(int i=0;i<R;i++) {
            cin >> m >> t >> p >> j;
            data d={m,t,p,j};
            team[t-1].push_back(d);
        }
    
        int k=1;
        for(auto i:team){
            status tmp = judge(i,k++);
            result.push_back(tmp);
            //cout << tmp.time << "," << tmp.collect << endl;
        }
        
        
        //for(int i=0;i<T;i++) { cout << result[i].collect << endl; }
        sort(result.begin(),result.end(),cmp);
        for(int i=0;i<team.size();i++){
            cout << result[i].team;
            if(i<team.size()-1) {
                if(eq(result[i],result[i+1])) cout << "=";
                else cout << ",";
            }
        }
        cout << endl;
    }
    
    return 0;
}

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

int main(){
    int n, b, f, r, v;
    int t[5][4][11] = {};
    
    // input
    cin >> n;
    for(int i = 0; i < n;i++){
        cin >> b >> f >> r >> v;
        t[b][f][r] += v;
    }
    
    //output
    for(int i = 1;i < 5;i++){
        for(int j = 1;j < 4;j++){
            for(int k = 1;k < 11;k++){
                cout << " " << t[i][j][k];
            }
            cout << endl;
        }
        if(i == 4){
        }
        else{
            for(int x = 0;x < 20;x++){
                cout << "#";
            }
            cout << endl;
        }
    }
    
    return 0;
    
}



Measured memory_bytes: 3112
<?php
fscanf(STDIN, "%d %d", $N, $M);
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d", $P, $Y);
    $X = sprintf("Z%06d%010d", $P, $Y);
    $arr[] = $X;
}
asort($arr);
$prev = 'Z000000000000';
$cnt = 0;
$ans = [];
foreach ($arr as $k => $v) {
    $p1 = substr($v, 1, 6);
    $prev_p1 = substr($prev, 1, 6);
    if ($p1 !== $prev_p1) {
        $cnt = 1;
    } else {
        $cnt++;
    }
    $ans[$k] = sprintf("%06d%06d", $p1, $cnt);
    $prev = $v;
}
ksort($ans);
echo implode(PHP_EOL, $ans);


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

int main(){
  int sum=700;
  string s;
  cin >> s;
  if(s[0]=='o') sum+=100;
  if(s[1]=='o') sum+=100;
  if(s[2]=='o') sum+=100;
  cout << sum << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////


int main() {
    string t; cin >> t;
    rep(i, 0, sz(t)){
        if(t[i] == '?') t[i] = 'D';
    }
    co(t);

    return 0;
}


Measured memory_bytes: 3724
#include<iostream>
int main()
{
	while (true)
	{
		long double x[4], y[4];
		for (int i = 0; i < 4; i++)
		{
			std::cin >> x[i] >> y[i];
		}
		if (std::cin.eof())
		{
			break;
		}
		std::cout << (y[0] == y[1] && x[2] == x[3] || y[2] == y[3] && x[0] == x[1] || (y[1] - y[0]) / (x[1] - x[0]) * (y[3] - y[2]) / (x[3] - x[2]) == -1 ? "YES" : "NO") << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    map<string,int> mp;
    int n;
    cin >> n;
    int mx=0;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
        mx = max(mx,mp[s]);
    }
    for(auto i : mp){
        if(mx==i.second) cout << i.first << endl;
    }

}

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;

long long sgn(long long x) {
    if (x == 0) {
        return x;
    }

    return x / abs(x);
}

int n, a[MAX_N + INDEX];

long long getAns(int sgni) {
    long long ps = 0, res = 0;
    for (int i = 1; i <= n; i++) {
        ps += a[i];

        if (sgn(ps) != sgni) {
            switch (sgni) {
                case 1:
                    res -= ps - 1;

                    ps = 1;

                    break;

                case -1:
                    res += ps + 1;

                    ps = -1;

                    break;
            }
        }

        sgni *= -1;
    }

    return res;
}

long long ans;

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    ans = min(getAns(1), getAns(-1));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>>field(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> field[i][j];
			if (j != 0 && j != W - 1)field[i][j] = !field[i][j];
			if (i)field[i][j] = !field[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < H; ++i) {
		int num = 0;
		if (W == 1)ans += field[i][0];
		else if (find(field[i].begin(), field[i].end(), 0) != field[i].end()) {
			ans += count(field[i].begin(), field[i].end(), 1) + 1;
		}
		else {
			ans += W - 1;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3204
/* ex4_1
TKC001*/

#include<stdio.h>

int main(void){
    int tree_num, look_num, observer_num;

    //入力
    scanf("%d", &tree_num);
    scanf("%d", &look_num);

    // 監視員は一人で2*look_nun+1本の木を見る。
    //tree_num / (2*look_num+1)が割り切れるならば商が答え、割り切れないならば監視員はもう1人要る。
    if (tree_num % (2*look_num+1) == 0)
    {
        observer_num = tree_num / (2*look_num+1);
    }else{
        observer_num = tree_num / (2*look_num+1) + 1;
    }

    //出力    
    printf("%d", observer_num);

    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
    stack<int> S;
    S.push(r);
    color[r] = c;
    while(!S.empty()){
        int u=S.top();
        S.pop();

        for(int i=0; i<G[u].size(); i++){
            int v=G[u][i];
            if(color[v] == NIL){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor(){
    int id=1;
    for(int i=0; i<n; i++) color[i] = NIL;
    for(int u=0; u<n; u++){
        if(color[u] == NIL) dfs(u, id++);
    }
}

int main(){
    int s, t, m, q;

    cin >> n >> m;

    for(int i=0; i<m; i++){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for(int i=0; i<q; i++){
        cin >> s >> t;
        if(color[s] == color[t]){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8916
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	string s[3];
	rep(i, 3) cin >> s[i];
	
	char t[3];

	rep(i, 3) t[i] = s[i][0] - 'a' + 'A';

	rep(i, 3) cout << t[i];
	
	system("PAUSE");
}


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

int countmine(string around)
{
  int mine = 0;
  for(int i = 0; i < around.size(); i++) {
    if(around.at(i) == '#') mine ++;
  }
  return mine;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  
  for(int hi = 0; hi < H; hi++) {
    for(int wj = 0; wj < W; wj++) {
      cin >> data.at(hi).at(wj);
    }
  }
  
  for(int hi = 0; hi < H; hi++) {
    for(int wj = 0; wj < W; wj++) {
      string around = "";
      int result = 0;
      
      if(data.at(hi).at(wj) == '.') {
        for(int ai = -1; ai <= 1; ai++) {
          for(int aj = -1; aj <= 1; aj++) {
            if((hi + ai) < 0 || (hi + ai) >=H || (wj + aj) < 0 || (wj + aj) >=W) continue;
            else around += data.at(hi + ai).at(wj + aj);
          }
        }
        result = countmine(around);
        data.at(hi).at(wj) = '0'+result;
      }
      cout << data.at(hi).at(wj);
    }
    cout << endl;
  }  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

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

int main(){
  ll N,K,Q;
  cin >> N >> K >> Q;
  ll A[100010]={};
  ll tmp;
  rep(i,Q){
    cin >> tmp;
    A[tmp-1]++;
  }
  
  //rep(i,N) cout << A[i] << endl;
  
  rep(i,N){
    if(K-Q+A[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int x = max({a, b, c});
    out((a + b + c) + x * pow(2, k) - x);
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll a,b;cin >>a>>b;
    ll d=b-a+1;
    ll f=0;
    ll tmp;
    ll ans=0;
    if(d%2==1){
        if(((d-1)/2)%2==1)f=1;
        if(a%2==1){
           ans=a^f;
        }
        else {
            ans=b^f;
        }
    }
    else {
        if(a%2==1){
            if(((d-2)/2)%2==1)f=1;
            ans=((a^b)^f);
        }
        else if(a%2==0){
            d/=2;
            if(d%2==1)ans=1;
            else ans=0;
        }
    }
    cout <<ans <<endl;
    return 0;
}

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1) cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1) cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD=1000000007;
const int INF=INT_MAX/3-1;
const double EPS=1e-9;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


bool isnprime[1000000];

int main(){
    isnprime[0]=1;
    isnprime[1]=1;
    for(int i=2;i<1000000;i++)
        if(!isnprime[i])
            for(int j=i*2;j<1000000;j+=i)
                isnprime[j]=1;
    int n,p;
    while(cin>>n>>p,n!=-1){
        vi prime(p);
        int count=0;
        for(int i=n+1;i<1000000 && count<p;i++)
            if(!isnprime[i]){
                prime[count]=i;
                count++;
            }

        vi sum(p*(p+1)/2);
        count=0;
        REP(i,p)
            for(int j=i;j<p;j++)
                sum[count]=prime[i]+prime[j],count++;
        sort(ALL(sum));
        cout<<sum[p-1]<<endl;


    }


return 0;
}

Measured memory_bytes: 4088
#include <stdio.h>
#include<string.h>
int main()
{
    int test,i,x,y,z,diff=999999;
   char s[1000];
   
   scanf("%s",s);
   
   diff=99999999;
   for(i=0;i<strlen(s)-2;i++)
    {
        x=s[i]-48;
        x*=100;
        x+=(s[i+1]-48)*10;
        x+=(s[i+2]-48)*1;
       
        if(abs(x-753)<diff)
        {
            diff=abs(753-x);
        }
        
     
     
      
        
    }
   
    printf("%d\n",diff);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int n,i,min,max,num[10001];
    long sum=0;
    scanf("%d",&n);
    for(i = 0;i < n; i++ ){
        scanf("%d",&num[i]);
    }
    min=num[0];
    max=num[0];
    for(i = 0;i < n; i++ ){
        sum = sum + num[i];
        if(min > num[i]){
            min = num[i];
        }
        if(max < num[i]){
            max = num[i];
        }
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& e : a) {
        cin >> e;
        e--;  // zero indexed.
    }

    int MAX = 100010;
    bool reached = false;
    int cur = 0;
    int count = 0;
    for (int i = 0; i < MAX; i++) {
        count++;
        cur = a[cur];
        if (cur == 1) {
            reached = true;
            break;
        }
    }

    if (reached) {
        cout << count << "\n";
    } else {
        cout << -1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;

void solve(long long N, long long K, std::vector<long long> A,
           std::vector<long long> B) {
  ll ans = 0;
  rep(j, 0, N) {
    if ((K | A[j]) == K) {
      ans += B[j];
    }
  }

  rep(i, 0, 30) {
    if (!(K >> i & 1)) {
      continue;
    }

    ll mask = (1LL << i) - 1;
    ll kb = (K & ~(1LL << i)) | mask;

    ll tmp = 0;
    rep(j, 0, N) {
      if ((kb | A[j]) == kb) {
        tmp += B[j];
      }
    }

    ans = max(ans, tmp);
  }
  print(ans);
}

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


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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

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

    int sum_a = accumulate(a.begin(), a.end(), 0);

    cout << (sum_a >= h ? "Yes" : "No") << endl;
}


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

int main(void)
{
	int l;
	char str[20];
	char t;
	int i, j;

	scanf("%s", str);

	l = strlen(str);
	for(i = 1; i < l; i++){
		for(j = 0; j < l - i; j++){
			t = str[j];
			str[j] = str[j+1];
			str[j+1] = t;
		}
	}

	printf("%s\n", str);

	return 0;
}

Measured memory_bytes: 524
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
using namespace std;

int main() {
    int x, y; bool a = 0, b = 0, c = 0, d = 0;
    cin >> x >> y;
    if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
        cout << "Yes";

    else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
        cout << "Yes";
    else
        cout << "No";

        return 0;
}

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



//defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;




//typedefs...
typedef pair<ll,ll>pll;

//const..
const ll fx[]={0,1,0,-1};
const ll fy[]={1,0,-1,0};
const ll mod=1e9+7;

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/
//to remove suffix of a number from a set of string
/*
for(int k=1; k<j.size(); k++)
                if(temp.count(string(j.begin()+k,j.end())))
					temp.erase(string(j.begin()+k,j.end()));
 */

void oka()
{
   ll n,k,x,y;
   cin>>n>>k>>x>>y;
   if(k>=n)
   {
       cout<<n*x<<endl;
       tata
   }
   cout<<k*x+y*(n-k)<<endl;



}
/*I'll paint it on the walls
     cause I'm the one at fault
    I'll never fight again and
         this is how it ends .*/






int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    run

    oka();




}

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

template<class Type>
Type solve(Type res = Type()){
    ll S,W; cin >> S >> W;
    if(W >= S) return "unsafe";
    else return "safe";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

char rb[21][21];
bool ch[21][21]={0};
int x,y,h,w,ans;
int d[4]={0,1,0,-1};

void solve(int nx,int ny);

int main(){
  int i,j;
  while(1){
    cin >> w >> h;
    if(w+h==0)break;
    ans = 0;
    for(i=0;i<h;i++)for(j=0;j<w;j++)ch[i][j]=0;
    for(i=0;i<h;i++)for(j=0;j<w;j++){
	cin >> rb[i][j];
	if(rb[i][j]=='@'){
	  x=i;
	  y=j;
	  ch[i][j]=1;
	  rb[i][j]='#';
	}
      }
    solve(x,y);
    cout << ans+1 << endl;
  }
  return 0;
}

void solve(int nx,int ny){
  int nex,ney,i;
  for(i=0;i<4;i++){
    nex = nx+d[i];
    ney = ny+d[i^1];
    if(nex>=0&&nex<h&&ney>=0&&ney<w&&rb[nex][ney]=='.'&&ch[nex][ney]==0){
      ans++;
      ch[nex][ney]=1;
      rb[nex][ney]='#';
      solve(nex,ney);
    }
  }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) (a).size() 
#define rep(i,n) for(int i=0;i<n;i++)
#define fors(i,s) for(int i=0;i<s.size();i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	int a[n],b[n],c[n-1];
	rep(i,n){
		cin>>a[i];
		a[i]--;
	}
	rep(i,n){
		cin>>b[i];
	}
	rep(i,n-1){
		cin>>c[i];
	}
	int ans=0;
	rep(i,n){
		ans+=b[a[i]];
		if(i>0){
			if(a[i]==a[i-1]+1){
				ans+=c[a[i-1]];
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int i=1;
	while(1){
		if(i%2){
			c-=b;
		}else{
			a-=d;
		}
		if(c<=0){
			cout<<"Yes";
			return 0;
		}else if(a<=0){
			cout<<"No";
			return 0;
		}
		i++;
	}
}

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

#define ll long long int

int main(){
  ll n,k,q;
  cin >> n >> k >> q;
  map<ll,ll> m;
  for(int i=0;i<q;i++){
    ll a;
    cin >> a;
    m[a]++;
  }
  for(int i=1;i<=n;i++){
      int x = k-(q-m[i]);
      if(x>0){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
  }
}


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

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  int n;
  cin>>n;
  int h[n];
  for(int i = 0;i < n;i++)
  {
    cin>>h[i];
  }
  vector<int> dp(n,1e9+5);
  dp[0]=0;
  
  for(int i = 0;i < n;i++)
  {
    int p = i;
    for(int j = p+1;j<p+3;j++)
    {
      if(j<n)
      {
        dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
      }
      
    }
  }
  cout<<dp[n-1]<<"\n";
  
 return 0; 
}

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

int main(int argc, const char * argv[]) {
    string S, T;
    cin >> S >> T;
    
    // S
    size_t s_size = S.size();
    if (1 > s_size || 10 < s_size) {
        cout << "No";
        return 0;
    }
    
    // T
    size_t t_size = T.size();
    if (t_size != (s_size + 1)) {
        cout << "No";
        return 0;
    }
    
    string t_substr = T.substr(0, s_size);
    if (S != t_substr) {
        cout << "No";
        return 0;
    }
    
    std::cout << "Yes\n";
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    vec.at(A - 1)++;
    vec.at(B - 1)++; 
  }
  for (int i = 0; i < N; i++){
    cout << vec.at(i) << endl;
  }  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;

int main()
{
	cin >> s;
	s[5] = s[13] = ' ';
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,a,b,c,d,cnt;
	scanf("%lld %lld %lld",&n,&a,&b);
	c=n/(a+b);
	cnt=a*c;
	d=n%(a+b);
	if(d>a)
	{
		printf("%lld",cnt+a);
	}
	else
	{
		printf("%lld",cnt+d);
	}
}

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

int main() {
  int n; cin>>n;
  string s,t,u; cin>>s>>t>>u;
  int sum=0;
  for(int i=0;i<n;i++){
    if(s[i]!=t[i] && t[i]==u[i] && s[i]==u[i]) sum++;
    if(s[i]==t[i] && t[i]!=u[i] && s[i]==u[i]) sum++;
    if(s[i]==t[i] && t[i]==u[i] && s[i]!=u[i]) sum++;
    if(s[i]!=t[i] && t[i]!=u[i] && s[i]==u[i]) sum++;
    if(s[i]!=t[i] && t[i]==u[i] && s[i]!=u[i]) sum++;
    if(s[i]==t[i] && t[i]!=u[i] && s[i]!=u[i]) sum++;
    if(s[i]!=t[i] && t[i]!=u[i] && s[i]!=u[i]) sum+=2;
  }
  cout<<sum<<endl;
}

    
  


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N,M;
int H[100000];
vector<int> R[100001];

int main(){
    cin>>N>>M;
    rep(i,N) cin>>H[i];
    rep(i,M){
        int a,b;
        cin>>a>>b;
        R[a].push_back(b);
        R[b].push_back(a);
    }

    int ans=0;
    repn(i,N){
        bool b=true;
        rep(j,R[i].size()){
            if(H[i-1]<=H[R[i][j]-1]) b=false;
        }
        if(b) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 9108
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll a[N];
  ll sum = 0;
  for(int i=0;i<N;++i) {
    cin>>a[i];
    sum += a[i];
  }
  for(int i=1;i<N;++i) {
    a[i] += a[i-1];
  }
  ll ans = big;
  for(int i=0;i<N-1;++i) {
    ans = min(ans, abs(a[i]-(sum-a[i])));
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

struct UnionFind {
    //number of parents(par[i] = i => root)
    vector <int> par;
    //rank of tree
    vector <int> size;

    UnionFind(int n) : par(n), size(n, 1) {
        //initialize
        rep(n, i) par[i] = i;
    }

    //find root (keiroasshuku at the same time)
    int root(int x){
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //unite
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (size[x] > size[y]) swap(x, y);
        par[x] = y;
        size[y] += size[x];
    }

    //same tree?
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

void solve(void){
    int N, K, L;
    cin >> N >> K >> L;
    UnionFind ufr(N), uft(N);
    rep(K, i) {
        int p, q;
        scanf("%d %d\n", &p, &q);
        p--; q--;
        ufr.unite(p, q);
    }
    rep(L, i) {
        int p, q;
        scanf("%d %d\n", &p, &q);
        p--; q--;
        uft.unite(p, q);
    }
    map <P, int> ans;
    rep(N, i) ans[P(ufr.root(i), uft.root(i))]++;
    rep(N, i) printf("%d ", ans[P(ufr.root(i), uft.root(i))]);
    putchar('\n');
}

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


Measured memory_bytes: 15104
/* In the name of Allah */

#include<bits/stdc++.h>
using namespace std;
int arr[200];

int main(){
	
int n,k;
cin >> n >> k;
while(k--){
	int x;
	cin >> x;
	while(x--){
		int z;
		cin >> z;
		arr[z]++;
	}
}
	int sum = 0;
	for(int i = 1; i <= n; i++){
		if(arr[i] == 0){
			sum ++;
		}
	}
	cout << sum;
	return 0;
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n, m;
    cin >> n >> m;
    vector<set<ll>> G(n);
    for(ll i=0; i<m; i++) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].insert(b);
        G[b].insert(a);
    }

    vector<set<ll>> iG(n);
    for(ll i=0; i<n; i++)
        for(ll j=0; j<n; j++) {
            if(i == j) continue;
            if(!G[i].count(j))
                iG[i].insert(j);
        }

    vector<pair<ll,ll>> v; // cnt, zc
    {
        ll cnt = 0, zc = 0;
        auto dfs = [&](auto dfs, ll cur, ll pre, ll idx, map<ll,ll> &visited) {
            if(visited.count(cur)) {
                if((visited[cur]^idx)&1) return false;
                return true;
            }
            if(~idx&1) zc++;
            cnt++;
            visited[cur] = idx;

            for(auto &v: iG[cur]) {
                if(v == pre) continue;
                if(!dfs(dfs, v, cur, idx^1, visited)) return false;
            }
            return true;
        };

        bool ok = true;
        set<ll> visited;
        for(ll i=0; i<n; i++) {
            if(visited.count(i)) continue;
            map<ll,ll> m;
            ok &= dfs(dfs, i, -1, 0, m);
            v.push_back({cnt, zc});
            cnt = 0, zc = 0;
            for(auto &t: m)
                visited.insert(t.first);
        }
        if(!ok) {
            cout << -1 << endl;
            return 0;
        }
    }

    bitset<1000> bs;
    bs[0] = 1;
    for(auto &t: v) {
        ll c, zc;
        tie(c, zc) = t;
        bs = (bs << zc) | (bs << (c-zc));
    }

    ll r = 1e9;
    for(ll i=0; i<1000; i++) {
        if(!bs[i]) continue;
        r = min(r, i*(i-1)/2 + (n-i)*(n-i-1)/2);
    }
    cout << r << endl;
}


Measured memory_bytes: 23296
#import"cstdio"
long long n,m;
void d(long long a,int f){if(a<=n)m+=f==7,a*=10,d(a+3,f|1),d(a+5,f|2),d(a+7,f|4);}
main(){scanf("%lld",&n);d(0,0); printf("%lld\n",m);}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;
using ll = long long int;
const ll LONGINF = 1LL << 60;

ll N, dp[2020][2020];
pair<ll, ll> A[2020];

int main() {
    scanf("%lld", &N);
    for(int i=0; i<N; i++) {
        ll v; scanf("%lld", &v);
        A[i] = make_pair(v, i);
    }
    sort(A, A + N);
    reverse(A, A + N);

    fill(dp[0], dp[N+1], -LONGINF);
    dp[0][0] = 0;
    for(int i=0; i<N; i++) {
        ll v, k; tie(v, k) = A[i];
        for(int l=0; l<=i; l++) {
            int r = i - l;
            {
                int d = abs(k - l);
                dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + v * d);
            }
            {
                int d = abs(k - (N - 1 - r));
                dp[i+1][l  ] = max(dp[i+1][l  ], dp[i][l] + v * d);
            }
        }
    }

    ll ans = -LONGINF;
    for(int i=0; i<=N; i++) ans = max(ans, dp[N][i]);
    printf("%lld\n", ans);
    return 0;
}


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

char a[105];

int main()
{
    int len,i;
    scanf(" %s", a);
    len=strlen(a);
    for(i=0;i<len;i++)if(a[i]=='C')break;
    for(;i<len;i++)if(a[i]=='F')break;
    if(i==len)printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;
typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    int X[N], Y[N], H[N];
    int tx, ty, th;
    REP(i, N) {
        cin >> X[i];
        cin >> Y[i];
        cin >> H[i];
        if (H[i] > 0) {
            tx = X[i];
            ty = Y[i];
            th = H[i];
        }
    }

    const int M = 101;
    int ax = -1;
    int ay = -1;
    int ah = -1;
    REP(i, M) {
        REP(j, M) {
            int cx = i;
            int cy = j;
            int ch = th + abs(tx - cx) + abs(ty - cy);
            bool ok = true;
            REP(k, N) {
                if (max(0, ch - abs(X[k] - cx) - abs(Y[k] - cy)) != H[k]) {
                    ok = false;
                }
            }
            if (ok) {
                ax = cx;
                ay = cy;
                ah = ch;
            }
            if (ax != -1) break;
        }
        if (ax != -1) break;
    }
    cout << ax << " " << ay << " " << ah << endl;
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner scn = new Scanner(System.in);
    String nm = scn.nextLine();
    String nStr = nm.split(" ",0)[0];
    String mStr = nm.split(" ",0)[1];
    int n = Integer.parseInt(nStr);
    int m = Integer.parseInt(mStr);

    int[] toshi = new int[n];
    for(int i=0; i<m; i++){
      String oneLine = scn.nextLine();
      String fromStr = oneLine.split(" ",0)[0];
      String toStr = oneLine.split(" ",0)[1];

      int from = Integer.parseInt(fromStr);
      int to = Integer.parseInt(toStr);

      toshi[from-1] ++;
      toshi[to-1] ++;
    }

    for(int i=0; i<n; i++){
      System.out.println(toshi[i]);
    }

  }
}

Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

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

        final int N = sc.nextInt();

        final int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
        }

        int a = W[0];
        int b = 0;
        for (int i = 1; i < N; i++) {
            b += W[i];
        }

        int ans = Math.abs(a - b);

        for (int i = 1; i < N-1; i++) {
            a += W[i];
            b -= W[i];
            ans = Math.min(ans, Math.abs(a - b));
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22100
a = input()[:-1]
while True:
    if len(a) % 2 != 0:
        a = a[:-1]
    else:
        b = True
        for i in range(len(a) // 2):
            if a[i] != a[i + len(a) // 2]:
                b = not b
                a = a[:-1]
                break
        if b:
            print(len(a))
            exit()


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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(),t.rend());
  if(s < t){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

ll dp[2][2][100];
int main() {
    init();

    string s; int d; cin >> s >> d;
    int n = s.length();
    VI k(n);
    FOR(i, 0, n)k[i] = s[i] - '0';

    dp[0][0][0] = 1;
    FOR(i, 0, n){
        FOR(small, 0, 2)FOR(m, 0, d)dp[(i + 1) & 1][small][m] = 0;
        FOR(small, 0, 2)eFOR(x, 0, (small ? 9 : k[i]))FOR(m, 0, d) {
            (dp[(i + 1) & 1][small | (x < k[i])][(m + x) % d] += dp[i & 1][small][m]) %= mod;
        }
    }

    cout << (dp[n & 1][0][0] + dp[n & 1][1][0] - 1 + mod) % mod << "\n";
}


Measured memory_bytes: 256
from heapq import *
h = []




INF = 1e9

n = int(input())
a = []
for i in range(n):
    b = list(map(int, input().split()))
    index = b[0]
    k = b[1]
    tmp = []
    for j in range(k):
        tmp.append(b[2*j+2:2*j+4])
    a.append(tmp)


def dijkstra(s):
    d = [INF] * n
    d[s] = 0

    heappush(h, (d[s], s))

    while h:
        pop = heappop(h)
        if pop[0] == INF:
            continue
        for node in a[pop[1]]:
            if d[pop[1]] + node[1] < d[node[0]]:
                d[node[0]] = d[pop[1]] + node[1]
                heappush(h, (d[pop[1]] + node[1], node[0]))

    return d
d = dijkstra(0)
for i in range(n):
    print(i, d[i])


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

int main() {
	string s;
	cin >> s;
	string check[] = {"AKIHABARA",
			"AKIHABAR", "AKIHABRA", "AKIHBARA", "KIHABARA",
			"AKIHABR", "AKIHBAR", "AKIHBRA", "KIHABAR", "KIHABRA", "KIHBARA",
			"AKIHBR", "KIHABR", "KIHBAR", "KIHBRA",
			"KIHBR"};
	for(string i : check){
		if(s.compare(i) == 0){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  int d[n] = {};
  FOR(i, 1, n) {
    FOR(j, i + 1, n + 1) {
      if(j <= x || y <= i) {
        d[j - i]++;
      } else if(i <= x && y <= j) {
        int dis = x - i + j - y + 1;
        d[dis]++;
      } else if(x <= i && j <= y) {
        int dis = min(j - i, i - x + y - j + 1);
        d[dis]++;
      } else if(i < x) {
        int dis = min(j - i, y - j + x - i + 1);
        d[dis]++;
      } else {
        int dis = min(j - i, j - y + i - x + 1);
        d[dis]++;
      }
    }
  }
  FOR(i, 1, n) {
    cout << d[i] << endl;
  }
  return 0;
}


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

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    ll dp[N][3];
    ll tmpx,tmpy,tmph;
    
    for(ll i = 0; i < N; i++){
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
        if(dp[i][2] != 0){
            tmpx = dp[i][0];
            tmpy = dp[i][1];
            tmph = dp[i][2];
        }
    }

    ll ansx = -1;
    ll ansy = -1;
    ll ansh = -1;
    for(ll x = 0; x <= 100; x++){
        for(ll y = 0; y <= 100; y++){
            ll H = abs(x - tmpx) + abs(y - tmpy) + tmph;
            bool flg = true;
            for(ll k = 0; k < N; k++){
                ll tmp = H - abs(x - dp[k][0]) - abs(y - dp[k][1]);
                if(tmp <= 0) tmp = 0;
                if(tmp == dp[k][2]){
                    continue;
                } else { 
                    flg = false;
                    break;
                }
            }
            if(flg){
                ansx = x; 
                ansy = y;
                ansh = H;
                break;
            } else { 
                continue;
            }
        }
    }
    cout << ansx << " " << ansy << " " << ansh << endl;

}


Measured memory_bytes: 256
def Judge(x,y):
    sum=1
    for i in range(y):
        if x[i]==0:
            return 0
    for i in range(y):
        sum*=x[i]
        #print(sum)
        if sum>10**18:
            return -1
    return sum

n=int(input())
a=list(map(int,input().split()))

c=Judge(a,n)
print(c)

Measured memory_bytes: 21656