akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(N);
    for(int i=0; i<N; i++)
    {
        int a, b;
        cin >> a >> b;
        AB.at(i) = make_pair(a, b);
    }

    sort(AB.begin(), AB.end());
    ll ans = 0;
    for(int i=0; i<N; i++)
    {
        if(AB[i].second < M)
        {
            M -= AB[i].second;
            ans += 1LL * AB[i].first * AB[i].second;
        }
        else
        {
            ans += 1LL * AB[i].first * M;
            break;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3904
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int main() {
  bool notPrime[100001];
  memset(notPrime, false, sizeof(notPrime));
  for (int i = 2; i*i <= 100000; i++) {
    for (int j = i+i; j <= 100000; j+=i) {
      notPrime[j] = true;
    }
  }
  vector <int> prime;
  for (int i = 2; i <= 100000; i++) {
    if (!notPrime[i]) {
      prime.push_back(i);
    }
  }
  while (true) {
    int x;
    cin >> x;
    if (x == 0) break;
    int sum = 0, ans = 0;
    int l, r;
    l = r = 0;
    while (r < prime.size() && prime[r] <= x) {
      sum += prime[r];
      while (sum > x && l < r) {
        sum -= prime[l];
        l++;
      }
      if (sum == x) ans++;
      r++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1416
let () =
  let s = read_line () in
  let t = read_line () in
  let s' = Array.init (String.length s) (fun i -> s.[i]) in
  let t' = Array.init (String.length t) (fun i -> t.[i]) in
  Array.sort compare s';
  Array.sort (fun x y -> compare y x) t';
  print_endline @@
    if String.init (Array.length s') (fun i -> s'.(i)) < String.init (Array.length t') (fun i -> t'.(i)) then "Yes" else "No"

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  vector<int> arr(3);
  for (int i = 0; i < 3; i++) {
    cin >> arr[i];
  }

  sort(arr.begin(), arr.end());
  
  cout << (arr[0] == 5 && arr[1] == 5 && arr[2] == 7 ? "YES" : "NO");
  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define MAX 101

int main(void){
  int r,c;
  int i,j;
  int buf;
  int ary[MAX][MAX]={0};

  scanf("%d",&r);
  scanf("%d",&c);

  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&ary[i][j]);
    }
  }

  for(i=0;i<r;i++){
    buf=0;
    for(j=0;j<c;j++){
      buf+=ary[i][j];
    }
    ary[i][j]=buf;
  }

  for(i=0;i<c;i++){
    buf=0;
    for(j=0;j<r;j++){
      buf+=ary[j][i];
    }
    ary[j][i]=buf;
  }

  buf=0;
  
  for(i=0;i<r;i++){
    buf+=ary[i][c];
  }

  ary[r][c]=buf;

  for(i=0;i<r+1;i++){
    for(j=0;j<c+1;j++){
      printf("%d",ary[i][j]);
      if(j!=c){
        printf(" ");
      }
    }
    printf("\n");
  }

  
  
  return 0;
}

Measured memory_bytes: 652
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int ans = INT_MIN;
int d[55], n, c[55], tmp[55];

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

void dfs(int i) {
  if (i == n) {
    c[n] = 0;
    for (int j = 0; j < n + 1; j++) tmp[j] = c[j];
    qsort(tmp, n + 1, sizeof(int), asc);
    
    int min = INT_MAX;
    for (int j = 0; j < n; j++)
      min = Min(min, tmp[j + 1] - tmp[j]);
    
    min = Min(min, 24 + tmp[0] - tmp[n]);
    ans = Max(ans, min);
    return;
  }
  c[i] = d[i];
  dfs(i + 1);
  c[i] = - d[i];
  dfs(i + 1);

  return;
}

int
main(int argc, char *argv[])
{
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &d[i]);

  if (n >= 24) printf("0\n");
  else if (n == 23) {
    int check[50] = {}, flag = 0;
    check[0]++;
    for (int i = 0; i < n; i++) {
      check[d[i]]++;
      if (check[d[i]] > 2) flag++;
    }
    if (flag > 0) printf("0\n");
    else printf("1\n");
  }
    
  else {
    dfs(0);
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll a, ans=0;
    cin>>a;
    ll arr[a], cnt[a+1];
    for (ll i=0; i<a; i++) cin>>arr[i], cnt[i]=0;
    cnt[a]=0;
    for (ll i=0; i<a; i++) cnt[arr[i]]++;
    for (ll i=1; i<=a; i++){
        if (cnt[i]<2) continue;
        ans+=(cnt[i]-1)*cnt[i]/2;
    }
    for (ll i=0; i<a; i++) cout<<ans-cnt[arr[i]]+1<<endl;
}

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

#define pii pair<int,int>
#define valid(nx,ny,r,c) nx>=0 && nx<r && ny>=0 && ny<c
int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1};

char cell[50][50];
int main() {
    int i,j,k,r,c;
    cin>>r>>c;
     for(i=0; i<r; i++)
        for(j=0; j<c; j++)
           cin>>cell[i][j];


    for(i=0; i<r; i++) {
        for(j=0; j<c; j++) {
            int cnt=0;
            if(cell[i][j]=='.') {
                for(k=0; k<8; k++) {
                    int nx=i+fx[k];
                    int ny=j+fy[k];
                    if(valid(nx,ny,r,c))
                    {
                        if(cell[nx][ny]=='#')
                        cnt++;
                    }

                }
                cell[i][j]=cnt+'0';
            }
        }
    }

    for(i=0; i<r; i++) {
        for(j=0; j<c; j++)
            cout<<cell[i][j];
        cout<<endl;
    }



    return 0;

}





Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int N, K, ans;
    cin >> N >> K;
    ans = N%K;
    if(ans!=0){
        cout << 1 << '\n';
    }else{
        cout << 0 << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {//xの親を求める
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {//xとyが連結しているか判定
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {//xとyを連結
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {//xを含む木のサイズを求める
        return -par[root(x)];
    }
};

int main() {
    int N,M,K;
    cin>>N>>M>>K;
    UnionFind uf(N);
    vector<vector<int>> friends(N,vector<int>(0));
    vector<vector<int>> block(N,vector<int>(0));
    rep(i,M){
        int a,b;
        cin>>a>>b;
        --a;--b;
        friends[a].pb(b);
        friends[b].pb(a);
        uf.merge(a,b);
    }
    rep(i,K){
        int c,d;
        cin>>c>>d;
        --c;--d;
        if(uf.issame(c,d)){
            block[c].pb(d);
            block[d].pb(c);
        }
    }
    rep(i,N){
        cout<<uf.size(i)-friends.at(i).size()-block.at(i).size()-1<<endl;
    }
}

Measured memory_bytes: 14760
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int N, K;
ll A[200000];
vector<P> p;
vector<ll> neg, pos;
const ll MOD = 1000000007;

ll inv(ll n){
    if(n == 1) return 1;
    else return MOD-inv(MOD%n)*(MOD/n)%MOD;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] < 0) {
            p.push_back(P(-A[i], -1));
            neg.push_back(-A[i]);
        }
        else {
            p.push_back(P(A[i], 1));
            pos.push_back(A[i]);
        }
    }
    sort(p.begin(), p.end(), greater<P>());
    sort(pos.begin(), pos.end(), greater<ll>());
    sort(neg.begin(), neg.end(), greater<ll>());
    int neg_cnt = 0, pos_cnt = 0;
    ll ans = 1;
    if(K == N){
        for(int i = 0; i < N; i++){
            ans *= A[i];
            ans %= MOD;
        }
        ans += MOD;
        ans %= MOD;
        cout << ans << endl;
        return 0;
    }
    if(pos.size() == 0){
        if(K%2 == 0){
            for(int i = 0; i < K; i++){
                ans *= neg[i]; ans %= MOD;
            }
            cout << ans << endl;
        }else{
            for(int i = 0; i < K; i++){
                ans *= neg[N-i-1]; ans %= MOD;
            }
            ans *= -1; ans += MOD; ans %= MOD;
            cout << ans << endl;
        }
        return 0;
    }
    if(neg.size() == 0){
        for(int i = 0; i < K; i++){
            ans *= pos[i]; ans %= MOD;
        }
        cout << ans << endl;
        return 0;
    }
    for(int i = 0; i < K; i++){
        P cur = p[i];
        if(cur.second == -1){
            neg_cnt++;
        }else{
            pos_cnt++;
        }
        ans *= cur.first;
        ans %= MOD;
    }
    // cout << pos_cnt << ' ' << neg_cnt << ' ' << ans << endl;
    if(neg_cnt%2 == 0){
        cout << ans << endl;
        return 0;
    }
    if(neg_cnt == neg.size() || pos_cnt == 0){
        ans *= inv(neg[neg_cnt-1]);
        ans %= MOD;
        ans *= pos[pos_cnt];
        ans %= MOD;
        cout << ans << endl;
        return 0;
    }
    if(pos_cnt == pos.size()){
        ans *= inv(pos[pos_cnt-1]);
        ans %= MOD;
        ans *= neg[neg_cnt];
        ans %= MOD;
        cout << ans << endl;
        return 0;
    }
    ll a = neg[neg_cnt-1], b = neg[neg_cnt];
    ll c = pos[pos_cnt-1], d = pos[pos_cnt];
    if(a*b > c*d){
        ans *= inv(c); ans %= MOD;
        ans *= b; ans %= MOD;
    }else{
        ans *= inv(a); ans %= MOD;
        ans *= d; ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
string S;
  cin >> S;
int ichi, ni;
  ichi = (S.at(0) - '0') * 10 + (S.at(1) - '0');
  ni = (S.at(2) - '0') * 10 + (S.at(3) - '0');
 
  if((ichi < 13) && (ichi > 0) && (ni < 13) && (ni > 0)) cout << "AMBIGUOUS" << endl;
  else if ((ichi > 0) && (ichi < 13)) cout << "MMYY" << endl;
  else if ((ni > 0) && (ni < 13)) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

#define U1 unsigned char
#define S1 char
#define	S4 int

S4 main()
{
	S4 s4_t_inning;
	S4 s4_t_runner;
	S4 s4_t_score;
	S4 s4_t_out;

	S4 s4_t_cmpResult;
	U1 u1_t_delimiter;
	U1 u1_tp_input[8];

	/* inning数の入力 */
	(void)scanf("%d%c", &s4_t_inning, &u1_t_delimiter);

	s4_t_runner = (S4)0;
	s4_t_score = (S4)0;
	s4_t_out = (S4)0;

	while (s4_t_inning > (S4)0)
	{
		(void)scanf("%s", u1_tp_input);

		s4_t_cmpResult = strcmp("HIT", u1_tp_input);
		if (s4_t_cmpResult == 0)
		{
			if (s4_t_runner == (S4)3)
			{
				s4_t_score++;
			}
			else
			{
				s4_t_runner++;
			}
		}

		s4_t_cmpResult = strcmp("HOMERUN", u1_tp_input);
		if (s4_t_cmpResult == 0)
		{
			s4_t_score += s4_t_runner + (S4)1;
			s4_t_runner = (S4)0;
		}

		s4_t_cmpResult = strcmp("OUT", u1_tp_input);
		if (s4_t_cmpResult == 0)
		{
			s4_t_out++;
			if (s4_t_out == (S4)3)
			{
				printf("%d\n", s4_t_score);
				s4_t_runner = (S4)0;
				s4_t_score = (S4)0;
				s4_t_out = (S4)0;
				s4_t_inning--;
			}
		}

	}

	return((S4)0);
}



Measured memory_bytes: 2096
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
   int n;
   cin>>n;
   VI a(n);
   rep(i,n) cin>>a[i];
   int cnt=1,ans=0;

   rep(i,n){
       if(a[i]==cnt){
           cnt++;
       }else{
           ans++;
       }
   }

   if(cnt==1) cout<<-1<<endl;
   else cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll dp[51][2607]={0};
	dp[0][0]=1;
	ll n,a;
	cin>>n>>a;
	vector<ll> x(n);
	FOR(i,0,n){
		cin>>x[i];
	}
	FOR(i,0,n){
		for(ll j=i;j>=0;j--){
			FOR(k,0,n*50+9){
				dp[j+1][k+x[i]] += dp[j][k]; 
			}
		}
	}
	ll ans = 0;
	FOR(i,1,n+1){
		ans+=dp[i][i*a];
	}
	pri(ans);
}

Measured memory_bytes: 1280
fn solve(wvs: Vec<(usize, usize)>, maxw: usize) -> usize {
    use std::cmp::max;
    let n = wvs.len();

    // dp[i][j]: j番目までの品物から重さの総和がi以下となるように選んだときの価値の総和の最大
    let mut dp = vec![vec![0; n + 1]; maxw + 1];

    for i in 1..(maxw + 1) {
        for j in 1..(n + 1) {
            let (w, v) = wvs[j - 1];
            if w > i {
                dp[i][j] = dp[i][j - 1];
            } else {
                dp[i][j] = max(dp[i][j - 1], dp[i - w][j - 1] + v);
            }
        }
    }

    dp[maxw][n]
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![(3, 30), (4, 50), (5, 60)], 8), 90);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, w) = parse_line!(usize, usize);
    let wvs = (0..n)
        .map(|_| parse_line!(usize, usize))
        .collect::<Vec<_>>();
    println!("{}", solve(wvs, w));
}


Measured memory_bytes: 98556
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str

def is_bingo(row, B):
    count = 0 
    for b in B:
        if b in row:
            count += 1
    if count >= 3:
        return True
    else:
        False

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    A = np.asarray(A)
    isbingo = False

    for row in A:
        if is_bingo(row, b):
            isbingo = True

    for col in A.T:
        if is_bingo(col, b):
            isbingo = True

    for diag in [np.diag(A), np.diag(np.fliplr(A))]:
        if is_bingo(diag, b):
            isbingo = True

    if isbingo:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21824
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    vector<vector<int> > dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
    int i=n,j=m;
    vector<char> c;
    while(i && j){
        if(s[i-1]==t[j-1]){
            c.pb(s[i-1]);
            i--,j--;
        }
        else if(dp[i][j]==dp[i-1][j])
            i--;
        else
            j--;
    }
    reverse(c.begin(),c.end());
    for(auto p:c)
        cout<<p;
    return 0;
}

Measured memory_bytes: 73568
#include <iostream>

int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;
    int cake_num = 0;
    bool is_exist = false;

    while(true)
    {
        int donut_num = 0;
        while(true)
        {
            int cost = donut_num * 7 + cake_num * 4;
            if(cost == n)
            {
                std::cout << "Yes" << std::endl;
                return 0;
            }
            if(cost > n)
            {
                break;
            }
            donut_num++;
        }
        cake_num++;
        if(cake_num * 4 > n)
        {
            break;
        }
    }
    std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,k,d,i,ans=0;
    int left[10]={0};
    cin>>n>>k;
    for (i=0;i<k;i++)
    {
        cin>>d;
        left[d]++;
    }
    i=n;
    int tp;
    while (1)
    {
        tp=i;
        int f=0;
        while (tp)
        {
            f+=left[tp%10];
            tp/=10;
        }
        if (!f)
        {
            ans=i;
            break;
        }
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  [x, a, b] <- map (read::String -> Int) . words <$> getLine
  let distA = abs (x - a)
      distB = abs (x - b)
  putStrLn $ if distA < distB then "A" else "B"


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()

using namespace std;



int main(){
	// freopen("input.text" , "r" , stdin);
	// freopen("output.text" , "w" , stdout);
	int n ; cin >> n;
	if(n >= 30){
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3588
import copy
N,G=map(int,input().split())
pc=[]
for i in range(N):
  pc.append(list(map(int,input().split())))
ans=10**10
for i in range(2**N):
  tmp=0
  tmp2=0
  l=[]
  for j in range(N):
    if i>>j&1:
      w=pc[j]
      p,c=w[0],w[1]
      tmp+=100*(j+1)*p+c
      tmp2+=p
    else:
      l.append(j)
  if tmp>=G:
    ans=min(ans,tmp2)
  else:
    pc_=copy.copy(pc)
    while tmp<G:
      index=l.pop(-1)
      w=pc_.pop(index)
      p,c=w[0],w[1]
      if 100*(index+1)*p+c+tmp<G:
        tmp+=(100*(index+1)*p+c)
        tmp2+=p
      elif 100*(index+1)*p+tmp<G<=100*(index+1)*p+c+tmp:
        tmp=G
        tmp2+=p
      else:
        val=(G-tmp)//(100*(index+1))
        if (G-tmp)%(100*(index+1))==0:
          tmp2+=val
        else:
          tmp2+=(val+1)
        tmp=G
    ans=min(ans,tmp2)
print(ans)

Measured memory_bytes: 3572
X = int(input())
if X <=599:
  print(8)
elif X <= 799:
  print(7)
elif X <= 999:
  print(6)
elif X <= 1199:
  print(5)
elif X <= 1399:
  print(4)
elif X <= 1599:
  print(3)
elif X <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9176
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BCountABC {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        string S;
        cin >> S;

        int num = 0;
        REP(i, S.size() - 2) {
            if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') num++;
        }
        cout << num << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BCountABC solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N;
int a[212345];

int main() { 
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	priority_queue<pii, vector<pii>, greater<pii> > pq;
	REP(i, N) pq.push(pii(a[i], i));
	
	set<int> ss;
	ll ans = 0;
	while (!pq.empty()) {
		int x = pq.top().fi;
		int p = pq.top().se;
		pq.pop();
		
		set<int>::iterator ub = ss.lower_bound(p);
		if (ub == ss.end()) {
			if (ss.size() >= 1) {
				set<int>::iterator lb = ss.end();
				--lb;
				
				ans += (ll)(p - *lb) * (N - p) * x;
			}
			else {
				ans += (ll)(p + 1) * (N - p) * x;
			}
		}
		else if (ub != ss.begin()) {
			set<int>::iterator lb = --ub;
			ub++;
			
			ans += (ll)(p - *lb) * (*ub - p) * x;
		}
		else {
			ans += (ll)(p + 1) * (*ub - p) * x;
		}
		
		ss.insert(p);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

const int MD = 1000000007;

int main() {
	int n; cin >> n;
	int x = 0, ans = 0;
	while (n--) {
		int a; cin >> a;
		ans = (ans + (long long) x * a % MD) % MD;
		x = (x + a) % MD;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  
  s[k-1] += 32;
  cout << s << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...) std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v)
{
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v)
{
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    os << (i > 0 ? "," : "") << v[i];
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> h(n); std:: cin >> h;
  auto prv = 0;
  auto tmp = 0;
  auto ret = 0;
  for (auto x : h) {
    if (prv >= x) tmp++;
    else {
      cmx(ret, tmp);
      tmp = 0;
    }
    prv = x;
  }
  cmx(ret, tmp);
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 640
n = int(input())
ary = []
for i in range(n):
	a, b = map(int, input().split())
	ary.append([a,b])
ary.sort(key=lambda x:x[1])
s = 0
for i in ary:
	s += i[0]
	if s <= i[1]:
		continue
	else:
		print ("No")
		exit()
print ("Yes")

Measured memory_bytes: 38044
x, n = map(int, input().split())
p = list(map(int, input().split()))

if x not in p:
    print(x)
else:
    for i in range(1, n + 1):
        if x - i not in p:
            print(x - i)
            break
        elif x + i not in p:
            print(x + i)
            break

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

int N;
long long K;
vector<int> A, T;

int main()
{
  cin >> N >> K;
  A.resize(N + 1);
  for (int i = 1; i <= N; i++)
  {
    cin >> A.at(i);
  }
  T.resize(N + 1, -1);
  int timer = 0;
  int next = 1;
  int loop_size, q;
  while (1)
  {
    if (T.at(next) != -1)
    {
      loop_size = timer - T.at(next);
      q = T.at(next);
      break;
    }
    T.at(next) = timer;
    next = A.at(next);
    timer++;
  }
  int loop_times = 0;
  if (K < q)
  {
    loop_times = K;
  }
  else
  {
    loop_times = ((K - q) % loop_size) + q;
  }
  int ans = 1;
  for (int i = 0; i < loop_times; i++)
  {
    ans = A.at(ans);
  }
  cout << ans << endl;
}



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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int n; cin >> n;
    vi spf(n + 1, -1);
    spf[1] = 1;
    for(int i = 2; i <= n; i++){
        if(spf[i] != -1)
            continue;
        spf[i] = i;
        if(i * 1ll * i > n)
            continue;
        for(int j = i * i; j <= n; j += i){
            if(spf[j] == -1)
                spf[j] = i;
        }
    }
    ll sum = 0;
    vl dp(n + 1);
    dp[1] = 1;
    for(int i = 1; i <= n; i++){
        if(i == 1)
            sum++;
        else{
            int x = i;
            int d = spf[x];
            int cnt = 0;
            while(x % d == 0){
                x /= d;
                cnt++;
            }
            dp[i] = dp[x] * (cnt + 1);
            sum += dp[i] * i;
        }
    }
    cout << sum << '\n';
    
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
// 	precompute();
	for(int i = 1; i <= t; i++){
	   // cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 120420
#include <algorithm>
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_map<int, bool> m;
  while (cin >> N) {
    m[N] = !m[N];
  }
  cout << count_if(begin(m), end(m), [](auto &p) { return p.second; }) << endl;
}


Measured memory_bytes: 7276
n,k=map(int,input().split())
if k==1:
    print(0)
    exit()
a=list(map(int,input().split()))
k-=1
n-=1
c=(1<<k)-1
b=10**18
while c<1<<n:
    w=a[0]
    t=0
    f=1
    for i in range(n):
        if c>>i&1:
            t+=max(0,w-a[i+1]+1)
            w=max(a[i+1],w+1)
        else:
            if a[i+1]>w:
            	f=0
            	break
    if f:
        b=min(b,t)
    x=c&-c
    y=c+x 
    c=((c&~y)//x>>1)|y 
print(b)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll vv[222222], n, T, ans;

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll i; cin>>n>>T;
	for(i=1 ; i<=n ; i++) cin>>vv[i];
	for(i=1 ; i<=n-1 ; i++) ans+=min(T,vv[i+1]-vv[i]);
	ans+=T; cout<<ans; return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
ll n, a, b; ll sanada[1919];
signed main() {
	ll cnt = 0;
	cin >> n >> a >> b;
	rep(i, n)cin >> sanada[i];
	rep(i, n) {
		if (sanada[i] >= a && sanada[i] < b)cnt++;
	}
	cout << n - cnt << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,mo=1e9+7;
int a[N],inv[N],s[N];
signed main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	inv[1]=1; for(int i=2;i<=n;i++) inv[i]=1LL*(mo-mo/i)*inv[mo%i] %mo;
	s[1]=1;for(int i=2;i<=n;i++) s[i]=(s[i-1]+inv[i])%mo;
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=(ans+1LL*(s[n-i+1]+s[i]-1)%mo*a[i])%mo;
	}
	for(int i=1;i<=n;i++)
		ans=1LL*ans*i%mo;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"strings"
)

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

	letters := strings.Split(s, "")

	cnt := 0
	answer := 0
	for i := 0; i < len(letters)-1; i++ {
		if letters[i] == "A" {
			cnt++
			continue
		}
		if letters[i] == "B" && letters[i+1] == "C" {
			answer += cnt
			i++
			continue
		}
		cnt = 0
	}

	fmt.Println(answer)
}


Measured memory_bytes: 5248
while line = gets
  value = line.chomp
  list = value.split
  a = list[0].to_i
  b = list[1].to_i
  result = a + b
  keta = 1
  while((result / 10) != 0)
    result /= 10
    keta += 1
  end
  puts keta
end



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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define int ll
const ll MAX_N = 1 << 13;
int n;
vl dat(2 * MAX_N - 1);

void init(int n_) {
	n = 1;
	while (n < n_) 
		n *= 2;
	for (int i = 0; i < 2 * n - 1; i++)
		dat[i] = inf;
}

//k番目の値をaに変更
void update(int k, int a) {
	k += n - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

//[a,b)の最小値を求める
//後ろのほうの引数は計算の簡単のための引数
//kは接点の番号,l,rはその接点が[l,r)に対応していることを表す
//従って、外からはquery(a,b,0,0,n)としてよぶ
int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) {
		return inf;
	}
	if (a <= l && r <= b) {
		return dat[k];
	}
	else {
		ll ul = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll ur = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(ul, ur);
	}
}

signed main() {
	int _n, x, i, j;
	scanf("%lld%lld", &_n, &x);
	vi a(_n);
	for (i = 0; i < _n; i++) {
		scanf("%lld", &a[i]);
	}
	init(2 * _n);
	for (i = 0; i < _n; i++) {
		update(i, a[i]);
		update(i + _n, a[i]);
	}
	ll ans = INF;
	for (i = 0; i < _n; i++) {
		ll res = 0;
		res += i*x;
		for (j = 0; j < _n; j++) {
			res += query(j, j + i + 1, 0, 0, n);
		}
		ans = min(ans, res);
	}
	for (i = 0; i < _n; i++) {
		ll res = 0;
		res += i*x;
		for (j = _n; j < 2*_n; j++) {
			res += query(j - i, j + 1, 0, 0, n);
		}
		ans = min(ans, res);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 512
n,t=map(int,input().split())
a=list(map(int,input().split()))
from collections import defaultdict
ans = defaultdict(int)
nowmin=1+10**9
nowmax=0
for i in range(n):
    if a[i]<nowmin:
        nowmin=a[i]
    if a[i]>nowmin:
        profit=a[i]-nowmin
        ans[profit]+=1
        if profit>nowmax:nowmax=profit
print(ans[nowmax])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc101_c() {
	ll N, K;
	ll ans = 0;
	cin >> N >> K;

	vector<ll> A(N);
	ll min = INF;
	rep(i, N) {
		cin >> A[i];
	}

	ans = ceil((double)(N - 1) / (K - 1));

	cout << ans << "\n";
}

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

	solve_abc101_c();

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 20
#define INF 1000000000
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n;
vector<string> in;
void read()
{
	string buf;
	cin >> buf;

	string cur = "";
	REP(i,0,(int)buf.length()-1)
	{
		if(buf[i]>='0' && buf[i]<='9') cur += buf[i];
		else
		{
			if(cur.length()) in.PB(cur);
			cur = buf[i];
			in.PB( cur );
			cur = "";
		}
	}
	if(cur.length()) in.PB(cur);
}
int main()
{
	bool a1=false, a2=false;
	read();
	RI(n);

	//1
	int op=0, x;
	LL cur=0, tmp;
	FOR(i,in)
	{
		if((*i)[0]>='0' && (*i)[0]<='9')
		{
			tmp = atoi(i->c_str());
			if(op==0) cur = cur + tmp;
			else      cur = cur * tmp;
			if(cur >= INF) break;
		}
		else
		{
			if(*i == "+") op=0;
			else op=1;
		}
	}
	a1 = (n==cur);


	//2
	vector<LL> vec;
	op = 0;
	FOR(i,in)
	{
		if(*i=="+") op=0;
		else if(*i=="*") op=1;
		else
		{
			x = atoi(i->c_str());
			if(op==1)
			{
				tmp = vec.back();
				vec.pop_back();
				tmp *= x;
				if(tmp >= INF) tmp = INF;
				vec.PB(tmp);
			}
			else
			{
				vec.PB(x);
			}
		}
	}

	cur = 0;
	cur = accumulate(vec.begin(), vec.end(), cur);
	a2 = (n==cur);

	if(a1 && a2) puts("U");
	if(!a1 && !a2) puts("I");
	if(a1 && !a2) puts("L");
	if(!a1 && a2) puts("M");
	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
#define N 100
int main()
{
  int a[N],i,j,n,b,c=0;
  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j]<a[j-1]){
	b=a[j];
	a[j]=a[j-1];
	a[j-1]=b;
	c++;
      }
    }
  }
  for(i=0;i<n-1;i++)
  printf("%d ",a[i]);

  printf("%d\n%d\n",a[n-1],c);
  return 0;
}

      
      
      
		    
    
    



Measured memory_bytes: 2140
#include <iostream>

using namespace std;

const int N = 100;
int dp[1 + N][2];
int a[1 + N];

int main() {
    int n;
    cin >> n;
    dp[0][0] = 1;
    for ( int i = 1; i <= n; i ++ ) {
        cin >> a[i];
        int ev = 2, od = 1;
        if ( a[i] % 2 == 0 )
            swap( ev, od );
        dp[i][0] = dp[i - 1][0] * od;
        dp[i][1] = dp[i - 1][1] * 3 + dp[i - 1][0] * ev;
    }
    cout << dp[n][1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int v[maxn];
int main() {
  int n, k, q; cin >> n >> k >> q;
  for (int i = 1; i <= n; i++) v[i] = k - q;
  while (q--) {
    int a; cin >> a;
    v[a]++;
  }
  for (int i = 1; i <= n; i++)
    puts(v[i] > 0 ? "Yes" : "No");
}

Measured memory_bytes: 1024
#include <cstdio>

template<int N, typename T, T M>
struct factorial_mod
{
	T mod[N + 1];
	T inv_mod[N + 1];

	constexpr factorial_mod() : mod(), inv_mod()
	{
		mod[0] = 1;
		for (int i = 0; i < N; ++i)
		{
			mod[i + 1] = (mod[i] * (i + 1)) % M;
		}
		inv_mod[N] = power(mod[N], M - 2);
		for (int i = N - 1; i >= 0; --i)
		{
			inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
		}
	}

	constexpr T power(T a, T b)
	{
		T r = 1;
		while (b > 0)
		{
			if ((b & 1) != 0) r = (r * a) % M;
			a = (a * a) % M;
			b >>= 1;
		}
		return r;
	}

	constexpr T comb(T n, T r) const
	{
		if (r < 0 || r > n || n < 0) return 0;
		return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
	}
};

constexpr factorial_mod<100001, long long, 1000000007> fmod;
int found[100000];

int main()
{
  int n;
  scanf("%d", &n);
  long long l, r;
  for (int i = 0; i < n + 1; ++i)
  {
    int a;
    scanf("%d", &a);
    if (found[a - 1] != 0)
    {
      l = found[a - 1];
      r = i + 1;
      break;
    }
    else found[a - 1] = i + 1;
  }
  for (long long k = 1; k <= n + 1; ++k)
  {
    long long a = fmod.comb(n + 1, k) - fmod.comb(n + 1 - r + l - 1, k - 1);
    if (a < 0) a += 1000000007;
    printf("%lld\n", a);
  }
  return 0;
}

Measured memory_bytes: 1536
def main():
    import numpy as np

    card = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    for _ in range(n):
        b = int(input())
        card = np.where(card == b, 0, card)

    is_bingo = False
    is_row_bingo = np.sum(card, axis=0).min() == 0
    is_column_bingo = np.sum(card, axis=1).min() == 0
    is_diag_bingo1 = np.sum(np.diag(card)) == 0
    is_diag_bingo2 = np.sum(np.diag(np.fliplr(card))) == 0

    print('Yes' if is_row_bingo or is_column_bingo or is_diag_bingo1 or is_diag_bingo2 else 'No')


if __name__ == '__main__':
    main()


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

using namespace std;

const int N = 2e5 + 5;

int n;
string a , b ;

int main()
{
    cin>>n>>a>>b;
    for(int i = 0;i<n;i++)
        cout<<a[i]<<b[i];
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

int N,M;

vector<int> G[100005];
int flag[100005];
PI ans[100005];


int main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        if(flag[v]==1)continue;
        flag[v]=1;
        PI res=PI(IINF,IINF);
        for(int i=0;i<G[v].size();++i){
            int nv=G[v][i];
            //cout<<nv<<endl;
            if(v==0)que.push(nv);
            else if(flag[nv]==1)chmin(res,PI(ans[nv].first+1,nv));
            else que.push(nv);
        }
        if(v==0)ans[v]=PI(0,0);
        else ans[v]=res;
        //cout<<ans[v].first<<" "<<ans[v].second<<endl;
    }
    for(int i=0;i<N;++i){
        if(ans[i].first==IINF){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<N;++i)cout<<ans[i].second+1<<endl;
}

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


int main(){

    long long n, a, b; cin >> n >> a >> b;
    long long ans = 0;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 1; i < n; i++){
        ans += min(b, a*(x[i] - x[i - 1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
//ll a[2000000],b[200000],c[200000];
ll a[2000];
ll b[20000];
int main()
{
    ll m,n,k=1,s=0,e=0;
    scanf("%lld %lld",&n,&m);
    k=1;
    s=m*1900;
    e=(n-m)*100;
    s+=e;
    for(ll i=1;i<=m;i++)
    {
        k*=2;
    }
    printf("%lld",k*s);
    return 0;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

    cin>>n;
    if(n>=30)
       cout<<"Yes\n";
    else
       cout<<"No\n";


    //code
    return 0;
}




Measured memory_bytes: 50512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3652