akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a, b, ab, x, y, M, m;
    cin >> a >> b >> ab >> x >> y;
    M = max(x, y);
    m = min(x, y);
    cout << min({a*x + b*y, ab*M*2,
                    ab*m*2 + (x > y ? a*(x-m) : b*(y-m))}) << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans=0;
    ans+=n/25;
    n%=25;
    ans+=n/10;
    n%=10;
    ans+=n/5;
    n%=5;
    ans+=n;
    cout << ans << endl;
}


Measured memory_bytes: 3076
from sys import stdin
import string
from itertools import groupby

n = int(stdin.readline().rstrip())
s = list(stdin.readline().rstrip())
s.sort()
lin = []
for key, value in groupby(s):
    lin.append(len(list(value)))
point = 1
for i in lin:
    point *= i+1
    point %= 10**9+7
print(point-1)

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
#define B 33000
ll n,m,r,l,dp[40005][105],dq[40005][105],s[40005],ans;
int main(void){
	cin>>n>>m;
	while((r+1LL)*(r+1LL)<=n)r++;
	if(r*(r+1LL)<=n)l=r;
	else l=r-1;
	for(ll i=1;i<=l;i++)s[i]=n/i-n/(i+1);
	for(ll i=1;i<=r;i++)dp[i][0]=1;
	for(ll i=1;i<=l;i++)dq[i][0]=s[i];
	for(ll i=1;i<m;i++){
		for(ll j=1;j<=r;j++)dp[j][i-1]=(dp[j][i-1]+dp[j-1][i-1])%M;
		for(ll j=1;j<=l;j++)dq[j][i]=dp[j][i-1]*s[j]%M;
		for(ll j=l-1;j>=1;j--)dq[j][i-1]=(dq[j][i-1]+dq[j+1][i-1])%M;
		for(ll j=1;j<=r;j++)dp[j][i]=(dp[r][i-1]+dq[j][i-1])%M;
	}
	for(ll i=1;i<=r;i++)ans=(ans+dp[i][m-1])%M;
	for(ll i=1;i<=l;i++)ans=(ans+dq[i][m-1])%M;
	cout<<ans<<endl;
}

Measured memory_bytes: 53376
def divisor(n): 
    i = 1
    table = []
    while i*i<=n:
        if n%i==0:
            table.append([i,n//i])
        i+=1
    return table

N = int(input())
m = N

if len(divisor(N))==1:
  print(N-1)

else:
  for i,j in divisor(N):
    m = min(m,i+j)
  print(m-2)

Measured memory_bytes: 9196
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;

const int maxn = 1e5+5;
int a[maxn],b[maxn];
int d[maxn];
int n,m;
int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	while(scanf("%d",&n)!=EOF) {
		m=0;
		for(int i=0;i<n;i++) scanf("%d",&a[i]);
		for(int i=0;i<n;i++) scanf("%d",&b[i]);
		ll own=0,ans=0;
		for(int i=0;i<n;i++) {
			if(a[i]<b[i]) own+= b[i]-a[i],ans++;
			else {
				d[m++]=a[i]-b[i];
			}
		}
		sort(d,d+m);
		reverse(d,d+m);
		for(int i=0;i<m;i++) {
			if(own<=0) break;
			own-=d[i];
			ans++;
		}
		if(own>0) ans=-1;
		cout<<ans<<endl;
	}
	return 0;
}








Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+7 + 9)




//cout<<fixed<<setprecision(10);
int main(){
    int n,m;
    cin>>n>>m;
    cout<<max(0,n-2*m)<<endl;

    return 0;
}



Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        char[] seq = f.readLine().toCharArray();
        int r = 0;
        int max = 0;
        for (int i = 0; i < seq.length; i++) {
            if (seq[i] == 'R') r++;
            else  r = 0;
            max = Math.max(r, max);
        }

        out.println(max);
        out.close();
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,m,s;
  cin>>n>>m>>s;
  vector<vvll> edge(n);
  REP(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    u--;
    v--;
    edge[u].push_back({v,a,b});
    edge[v].push_back({u,a,b});
  }

  vll c(n),d(n);
  REP(i,n)cin>>c[i]>>d[i];


  s=min(s,n*50);
  priority_queue<pll,vpl,greater<pll>> que;
  que.push(pll(0,s));
  vvll ds(n,vll(n*50+1,LLINF));
  ds[0][s]=0;

  while(!que.empty()){
    pll p=que.top();
    que.pop();
    ll t=p.FI;
    ll v=p.SE/10000;
    ll m=p.SE%10000;

    if(ds[v][m]<t)
      continue;

    if(m+c[v]<=n*50 && t+d[v]<ds[v][m+c[v]]){
      ll nt=t+d[v];
      ll nv=v;
      ll nm=m+c[v];
      pll np;
      np.FI=nt;
      np.SE=nv*10000+nm;

      ds[nv][nm]=nt;
      que.push(np);
    }

    for(auto e:edge[v]){
      ll nv=e[0];
      ll nm=m-e[1];
      ll nt=t+e[2];
      if(nt<ds[nv][nm] && 0<=nm){
        ds[nv][nm]=nt;
        pll np;
        np.FI=nt;
        np.SE=nv*10000+nm;
        que.push(np);
      }
    }
  }


  REP1(i,n){
    ll ans=LLINF;
    REP(j,ds[i].size())ans=min(ans,ds[i][j]);
    cout<<ans<<endl;
  }


}



Measured memory_bytes: 6300
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;
const int mod = 1e9 + 7;

int n;
string cmp;
int dp[3010][3010];
int pref[3010][3010];
void add(int& a, int b){
    a += b;
    while(a >= mod){
        a -= mod;
    }
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> n;
    cin >> cmp;
    //dp[i][j] number of ways to put numbeers in prefix of size i such that the last one is j
    dp[1][1] = 1;
    int len = cmp.size();
    
    for(int len = 2; len <= n; len++){
        //pref on dp[len - 1]
        for(int i = 1; i <= len - 1; i++){
            pref[len - 1][i] = (pref[len - 1][i - 1] + dp[len -1][i]) % mod;
        }
        
        for(int b = 1; b <= len; b++){
            int L;
            int R;
            if(cmp[len - 2] == '<'){
                L = 1;
                R = b - 1;
            }
            else{
                L = b;
                R = len - 1;
            }
            if(L <= R){
                add(dp[len][b], pref[len - 1][R] - pref[len - 1][L - 1] + mod);
            }
            //for(int L)
            //////// pref sum
        }
    }
    int answer = 0;
    for(int b = 1; b <= n; b++){
        add(answer, dp[n][b]);
    }
    
    cout << answer;
}



Measured memory_bytes: 69632
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Integer>ans  = new ArrayList<>();
		
		int cou = 0;
		for(int i=a; i<a+k; i++) {
			if(i<=b){		
			      ans.add(i);
			      	cou++;
			}
		}
		for(int i=b; i>b-k; i--) {
			if(i>=a) {
				if(!ans.contains(i)){		
				      ans.add(i);
				      	cou++;
				}
			}
		}
		Collections.sort(ans);
		for(int i=0; i<cou; i++) {
		System.out.println(ans.get(i));
	}
}
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int d[K];
  map<int, int> a;

  rep(i,K) {
    cin >> d[i];

    rep(j,d[i]) {
      int tmp;
      cin >> tmp;
      if (a.count(tmp)) {
        continue;
      }
      else {
        a[tmp]++;
      }
    }
  }
  cout << N - a.size() << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>

using namespace std;
int main(){
	int a,b,c,d,e,ans;
	cin>>a>>b>>c>>d>>e;
	ans=min(a,min(b,c))+min(d,e)-50;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 1160
const stdin: string[] = [];

function main() {
    const input = stdin[0].split(" ");
    const [n, m] = input;

    const N = parseInt(n, 10);
    const M = parseInt(m, 10);
    let cnt = 0;

    if (N > 1) {
      cnt += combi(N);
    }
    if (M > 1) {
      cnt += combi(M);
    }

    console.log(cnt);
}

function fact(n: number) {
    let number = 1;
    for (let i = 1; i <= n; i ++) {
      number *= i;
    }
    return number;
}

function combi(n: number) {
    return fact(n) / ( fact(2) * fact(n - 2) )
}

require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
}).on("line", _ => {
    stdin.push(_);
}).on("close", () => main());



Measured memory_bytes: 7628
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll maxn=1e5+3100;
const ll mod=1e9+7;
const ll inf=1e9+500;

ll a[maxn];

int main(){
    ll n;
    cin>>n;
    if(n>1){
        ll ans=0;
        for(ll i=1;i<=n;i++){
            cin>>a[i];
        }
        bool dor=0;
        while(1){
            ll ans=0;
            for(ll i=1;i<=n;i++){
                ans+=a[i]-1;
            }
            if(ans%2==1){
                if(dor==0){
                    cout<<"First\n";
                }else{
                    cout<<"Second\n";
                }
                return 0;
            }
            ll dd=0;
            for(ll i=1;i<=n;i++){
                if(a[i]%2==1 && dd==0 && a[i]>1){
                    dd=1;
                    a[i]--;
                }
            }
            ll gc=a[1];
            for(ll i=2;i<=n;i++){
                gc=__gcd(gc,a[i]);
            }
            if(gc%2==1){
                if(dor==0){
                    cout<<"Second\n";
                }else{
                    cout<<"First\n";
                }
                return 0;
            }
            for(ll i=1;i<=n;i++){
                a[i]/=gc;
            }
            dor=!dor;
        }
    }
    if(n==1){
        cout<<"Second";
        return 0;
    }
}


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

int main(){

  int S=0,h,m,s;

  if(0<=S<=86400){
    cin >>S;
    m=S/60;
    s=S%60;
    h=m/60;
    m=m%60;
  }
  cout <<h <<":" <<m <<":" <<s <<endl;

    return 0;
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int x[10000000];
int G[20];
int v,w,n,m,cnt=0;

int insertionSort(int x[],int n,int g) {
    for (int i=g;i<n;i++) {
        v=x[i];
        w=i-g;
        while (w>=0 && x[w]>v) {
            x[w+g]=x[w];
            w=w-g;
            cnt++;
        }
        x[w+g]=v;
    }

}

int shellSort(int x[],int n) {
    cnt=0;
    for (int h=0;h<20;h++) {
        if (G[h]>n) {
            m=h;
            break;
        }
    }
    printf("%d\n",m);
    for (int h=m-1;h>=0;h--) {
        printf("%d",G[h]);
        if (h) {
            printf(" ");
        }
        insertionSort(x,n,G[h]);
    }
    printf("\n");
}



int main(){
    double pai=3.141592653589;
    G[0]=1;
    for (int i=1;i<20;i++) {
        G[i]=G[i-1]*3+1;
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    shellSort(x,n);
    printf("%d\n",cnt);
    for(int i=0;i<n;i++){
        printf("%d\n",x[i]);
    }
    return 0;
}

Measured memory_bytes: 7088
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        boolean[] ans = new boolean[N];
        int[] count = new int[N];
        Arrays.fill(count, 1);
        ans[0] = true;
        for (int i = 0; i < M; i++) {
            int x = scan.nextInt()-1;
            int y = scan.nextInt()-1;
            if (!ans[x]) {
                if (1 <= count[x]) {
                    count[x] -= 1;
                    count[y] += 1;
                }
                continue;
            }
            if (count[x] == 1) {
                ans[x] = false;
            }
            count[x] -= 1;
            count[y] += 1;
            ans[y] = true;
        }
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            cnt += ans[i] ? 1 : 0;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 66716
#標準入力(HPと必殺技種類)
s = [int(x) for x in input().split()]

hp = s[0]
atype =s[1]

#標準入力(必殺技で減らすHP)
n = [int(y) for y in input().split()]


if sum(n) >= hp:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 13836
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

	int input;
	int i_test = 1;
	while (1) {
		scanf("%d", &input);
		if (input == 0) break;
		printf("Case %d: %d\n", i_test, input);
		i_test++;
	}

	return 0;
}



Measured memory_bytes: 2024
# -*- coding: utf-8 -*-

from collections import deque

N = int(input())
q = deque()

for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        q.appendleft(lst[1])
    elif command == 'delete':
        try:
            q.remove(lst[1])
        except Exception:
            pass
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop()

print(*q)

Measured memory_bytes: 71848
#include<stdio.h>
#define MAX 100000

int partition(int A[], int n, int q, int r);

int main(){
  int A[MAX], n, i, p;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  p = partition(A, n, 0, n-1);

  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    if ( i == p ) printf("[");
    printf("%d", A[i]);
    if ( i == p ) printf("]");
  }
  printf("\n");

  return 0;
}

int partition(int A[], int n, int q, int r){
  int x, i, j, t;
  x = A[r];
  i = q - 1;
  
  for ( j = q; j < r; j++ ){
    if ( A[j] <= x ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}



Measured memory_bytes: 2144
using System;
using System.Collections.Generic;
using System.IO.Pipes;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            string S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
            int K = cin.nextInt();

            S = S.Replace(" ", "");
            string[] s = S.Split(',');

            Console.WriteLine(s[K - 1]);
        }

    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    if(n<b)cout << a*n/b << endl;
    else cout << a*(b-1)/b << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

ll GCD (ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

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

    return b;
}

ll LCM (ll a, ll b) {
    ll g = GCD (a, b);
    return a * b / g;
}

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

    ll N, K;
    cin >> N >> K;

    N %= K;
    cout << min(N, K-N) << "\n";
}

Measured memory_bytes: 256
from fractions import gcd

n = int(input())
a_list = [int(x) for x in input().split()]

l_list = [0] * n
temp = a_list[0]
for i in range(n - 1):
    if temp == 1:
        l_list[i] = 1
        continue
    temp = gcd(temp, a_list[i])
    l_list[i] = temp

r_list = [0] * n
temp = a_list[n - 1]
for i in range(n - 1, 0, -1):
    if temp == 1:
        r_list[i] = 1
        continue
    temp = gcd(temp, a_list[i])
    r_list[i] = temp

ans = 0
for i in range(n):
    if i == 0:
        temp = r_list[1]
    elif i == n - 1:
        temp = l_list[n - 2]
    else:
        temp = gcd(l_list[i - 1], r_list[i + 1])
    if temp > ans:
        ans = temp
print(ans)

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

ll b[1001000];
bool del[1001000] = {};
ll a[1001];
int cnt[100];
int main(){
  ll n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  int c = 0;
  int tp = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      b[c] = a[j] - a[i - 1];
      ll tmp = b[c];
      c++;
      for (int kk = 0; tmp > 0; kk++) {
        if (tmp & 1) {
          cnt[kk]++;
        }
        tmp >>= 1;
        tp = max(tp, kk);
      }
    }
  }

  for (int i = tp; i >= 0; i--) {
    if (cnt[i] >= k) {
      for (int j = 0; j < n * (n + 1) / 2; j++) {
        if (del[j]) continue;
        if (((b[j] >> i) & 1) == 0) {
          del[j] = true;
          int k = 0;
          while (b[j] > 0) {
            cnt[k] -= b[j] & 1;
            k++;
            b[j] >>= 1;
          }
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i <= tp; i++) {
    if (cnt[i] >= k) {
      ans += (1LL << (ll)i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  COUT(pow(n,3));
  return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;
#define MAX 2147483647
#define MIN (-2147483648)

bool contains(int* a, int len, int number)
{
	for(int i=0; i<len; i++)
	{
		if(a[i]==number) return true;
	}
	return false;
}

int main(void)
{
	int x,n;
	cin >> x >> n;
	int arr[n];
	int numbers[102-n];
	int distances[102-n];

	for(int i=0; i<n; i++) cin >> arr[i];
	int j=0;
	for(int i=0; i<=101; i++)
	{
		if(!contains(&arr[0], n, i))
		{
			numbers[j]=i;
			distances[j]=abs(x-i);
			j++;
			//cout << i<<" "<<abs(x-i)<<endl;
		}
	}

	int diff=0;
	while(1)
	{
		if(!contains(&arr[0], n, x-diff))
		{
			cout << x-diff<<endl;
			return 0;
		}
		else if(!contains(&arr[0], n, x+diff))
		{
			cout << x+diff<<endl;
			return 0;
		}
		diff++;
	}

	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int A, B;

    scanf("%d%d", &A, &B);

    if(A == B){
        printf("Draw\n");
    }else if(A == 1){
        printf("Alice\n");
    }else if(B == 1){
        printf("Bob\n");
    }else if(A < B){
        printf("Bob\n");
    }else{
        printf("Alice\n");
    }

    return 0;
}

Measured memory_bytes: 1628
local n = io.read("*n")
local tsum = 0
local t = {}
local vmax = {}
for i = 1, n do
  t[i] = 2 * io.read("*n")
  tsum = tsum + t[i]
end
local mmi, mma = math.min, math.max
for i = 1, tsum do
  vmax[i] = mmi(i / 2, (tsum - i) / 2)
end
local tprev = 0
for i = 1, n do
  local v = io.read("*n")
  for j = 1, tprev - 1 do
    vmax[j] = mmi(vmax[j], v + (tprev - j) / 2)
  end
  for j = mma(1, tprev), tprev + t[i] do
    vmax[j] = mmi(vmax[j], v)
  end
  tprev = tprev + t[i]
  for j = tprev + 1, tsum do
    vmax[j] = mmi(vmax[j], v + (j - tprev) / 2)
  end
end
local dist = vmax[1]
for i = 2, tsum do
  dist = dist + vmax[i] + vmax[i - 1]
end
print(dist / 4)


Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys

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


alphabets = [chr(ord("a")+i) for i in range(26)]

def solve(S, T):
    if S == T[:-1] and T[-1] in alphabets:
        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()
    S = input()
    T = input()
    solve(S, T)

if __name__ == '__main__':
    main()


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

char wcz[1007];
int czy[1007];
int n;
long long wyn;
 
 void check()
 {
  czy[n]=1;
  long long adku=0;
  for(int i=1;i<=n;i++)
  {
   adku*=10;
   adku+=wcz[i]-'0';
   if(czy[i]) 
   {
    wyn+=adku;
    adku=0;
	}
   }
  }
  
 void rek(int v)
 {
  if(v==n)
  {
   check();
   return;
   }
  czy[v]=0;
  rek(v+1);
  czy[v]=1;
  rek(v+1);
  }
  int main()
  {
   scanf("%s",wcz+1);
   while(wcz[n+1])n++;
   rek(1);
   cout<<wyn<<endl;
   return 0;
   }

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    
    int N=s.size();
    ll cnt=0;
    map<char,int> dic;
    rep(i,N){
        char c=s[i];
        cnt+=i-dic[c];
        dic[c]++;
    }
    cout1(cnt+1)
}

Measured memory_bytes: 720
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readLong();
      const K = readLong();
      debug {
        writeln("N = ", N, ", K = ", K);
      }
      
      if (2 * K <= N + 1) {
        long[] as, bs, cs;
        
        foreach (i; 0 .. N) {
          cs ~= K + 3 * N - 1 - i;
        }
        
        const w = (N - 1) / 2;
        debug {
          writeln("  w = ", w);
        }
        foreach (i; 0 .. w) {
          as ~= K + 2 * N - 1 - i;
          bs ~= K + N - 1 - w - i;
          as ~= K + N + w - 1 - i;
          bs ~= K + N - 1 - i;
        }
        foreach (i; w .. N - w) {
          as ~= K + 2 * N - 1 - i;
          bs ~= K + N - 1 - w - i;
        }
        
        assert(as.length == N);
        assert(bs.length == N);
        assert(cs.length == N);
        foreach (i; 0 .. cast(int)(N)) {
          writeln(as[i], " ", bs[i], " ", cs[i]);
        }
        foreach (i; 0 .. cast(int)(N)) {
          assert(as[i] + bs[i] <= cs[i]);
        }
        debug {
          auto xs = as.dup ~ bs.dup ~ cs.dup;
          xs.sort();
          foreach (j; 0 .. cast(int)(3 * N)) {
            assert(xs[j] == K + j);
          }
        }
      } else {
        writeln("-1");
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 6268
s = gets.chomp.chars

ans = s.size - 1

("a".."z").each do |c|
  count = 0
  t = s.dup

  until t.all? { |tc| tc == c }
    (t.size - 1).times do |i|
      t[i] = [t[i], t[i + 1]].include?(c) ? c : t[i]
    end

    count += 1
    t.pop
  end

  ans = count if count <= ans
end

puts ans


Measured memory_bytes: 1788
use input::Input;

fn main() {
    let mut input = Input::default();

    let a: i64 = input.parse();
    let v: i64 = input.parse();
    let b: i64 = input.parse();
    let w: i64 = input.parse();
    let t = input.parse();

    let d = (a - b).abs();
    let u = v - w;

    if u > 0 {
        for i in 1..=t {
            if u * i >= d {
                println!("YES");
                return;
            }
        }
        println!("NO");
    } else {
        println!("NO");
    }
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 2152
N = int(input())
H = list(map(int, input().split()))
count = 1
max = H[0]

for i in range(1, N):
    if H[i-1] <= H[i] and max <= H[i]:
        count += 1
    if max < H[i]:
        max = H[i]
        
print(count)

Measured memory_bytes: 3060
#include<iostream>
#define INF 1000000000
using namespace std;

int main(){
    int i, n;
    int former = 0;

    cin >> n;

    int a[n + 1];

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

    for(i = 0; i < n - 1; i++){
        if(former < a[i]){
            a[i] -= 1;
        }
        former = a[i];
    }
    int flag = 0;

    //for(i = 0; i < n; i++){
    //    cout << a[i] << endl;
    //}

    for(i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]){
            flag = 1;
            break;
        }
    }

    if(flag == 0 || n == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
let arr_of_str s = Array.init (String.length s) (fun i -> s.[i])
let f b c = b lxor (1 lsl (int_of_char c - 97))
let () =
  let st = Scanf.scanf "%s" arr_of_str |> Array.fold_left f 0 in
  print_endline (if st = 0 then "Yes" else "No")


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

using namespace std;

int main() {
    int K, N;
    int x[50];
    int y[50];
    long long ans = 1LL << 62;

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }


    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                for (int l = 0; l < N; l++) {
                    int count = 0;
                    if (x[j] < x[i] || y[l] < y[k]) {
                        continue;
                    }

                    for (int m = 0; m < N; m++) {
                        if (x[i] <= x[m] && x[m] <= x[j] &&
                            y[k] <= y[m] && y[m] <= y[l] ) {
                            count++;
                        }
                    }

                    if (count >= K) {
                        ans = min(ans, (long long)(x[j] - x[i])*(y[l] - y[k]));
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}



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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;
  vi adj[maxn];
  vi vis(maxn);
  map<pair<int,int>,int> mp;
  int mxcol=1;
  void dfs(int src,int par=-1){
  	int col = 1;
  	vis[src]=1;
  	for(int x:adj[src]){		
  	  if(!vis[x]){
  	  	if(col==mp[{par,src}])col++;
		mp[{src,x}]=col;	
  	  	dfs(x,src);
		mxcol = max(mxcol,col);
		col++;
  	  }  	
  	}
  }

  void solve(){
	 int n;
	 cin >> n;
	 vpi v;
	 for(int i=0;i<n-1;i++){
	 	int a,b;
	 	cin >> a >> b;
	 	adj[a].push_back(b);
	 	adj[b].push_back(a);
	 	v.push_back({a,b});
	 }
	 dfs(1);
	 cout << mxcol << '\n';
	 for(int i=0;i<n-1;i++){
	 	cout << mp[{v[i].ff,v[i].ss}] << '\n';
	 }
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 41900
#include<bits/stdc++.h>
using namespace std;
int N,C[9999],D[5010][2],i,j;
main(){
    cin>>N;for(;i<N-1;)cin>>C[i++];
    fill_n(*D+3,1e4,1e9);D[0][0]=1e9;
    for(i=0;i<N-1;i++)for(j=N/2;~j;j--)D[j+1][0]=min(D[j][0],D[j][1]+C[i]),D[j][1]=min(D[j][0]+C[i],D[j][1]);
    cout<<min(D[N/2][0],D[N/2][1])<<endl;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <queue>
using namespace std;
int main()
{
    int n,m,j,t=0;
   int a[205];
   scanf("%d",&n);
   for(int i=0;i<2*n;i++)scanf("%d",&a[i]);
   sort(a,a+2*n);
   for(int i=0;i<2*n-1;i+=2)
   {
       t+=a[i];

   }
   printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val len = readLine()!!.toInt()
    val n = readLine()!!

    var r = 0
    n.take(len - 2).forEachIndexed { i, c ->
        if (c == 'A' && n[i+1] == 'B' && n[i+2] == 'C') r++
    }

    println(r)
}

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

using namespace std;

int main()
{
  string s;
  cin>>s;
  string t=s;
  set<char>A;
  for(auto x:s)A.insert(x);
  for(int i=s.size();i>=0;i--)
  {
    for(int j=(i==s.size()?0:(s[i]-'a'));j+'a'<='z';j++)
    {
      if(A.count(j+'a')!=0)continue;
      s+=(j+'a');
      if(t>=s)
      {
        s.pop_back();
        continue;
      }
      cout<<s<<endl;
      return 0;
    }
    if(i>0)
    {
      A.erase(s[i-1]);
      s.pop_back();
    }
  }
  cout<<-1<<endl;
  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 pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

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







int main() {
    char s;
    cin >> s;
    cout << char(s+1) << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep2(i,m,n) for(int i=int(m);i<int(n);i++)
#define drep2(i,m,n) for(int i=int(m-1);i>=int(n);i--)
#define rep(i,n) rep2(i,0,n)
#define drep (i,n) drep2(i,n,0)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
ll mod =998244353;

int main()
{
    int n,s;cin >>n>>s;
    int dp[n+1][s+1];
    rep(i,n+1)rep(j,s+1)dp[i][j]=0;
    int a[n];rep(i,n)cin >>a[i];
    rep(i,n){
        rep(j,s+1){
        dp[i+1][j]=dp[i][j];
        dp[i+1][j]%=mod;
        if(j-a[i]>=0)dp[i+1][j]+=dp[i][j-a[i]];
         dp[i+1][j]%=mod;
        if(j==a[i]||j==0)dp[i+1][j]++;
         dp[i+1][j]%=mod;
        }
    }
    ll ans=0;
    rep(i,n){
        ans+=dp[i+1][s];
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35456
//file_name:ABC48_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll n,x;
    scanf("%lld%lld",&n,&x);

    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    ll ans = 0;
    if(a[0]>x){
        ans += a[0]-x;
        a[0] = x;
    }
    srep(i,1,n){
        if(a[i]+a[i-1]>x){
            ans += a[i] + a[i-1] - x;
            a[i] = x - a[i-1];
        }
    }




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



Measured memory_bytes: 1024
def f(x):
  if x % 4 == 0:
    return x
  elif x % 4 == 1:
    return x ^ (x-1)
  elif x % 4 == 2:
    return x ^ (x-1) ^ (x-2)
  else:
    return 0

A, B = map(int, input().split(" "))
string = ""
i = 0
a = f(A-1)
b = f(B)
print(a^b)

Measured memory_bytes: 3064
n,p = map(int,input().split())
a = list(map(int,input().split()))
m = 0
for i in range(n):
    if a[i]%2 == 1:
        m += 1
if m==0 and p==1:
    print(0)
elif m==0 and p==0:
    print(2**(n))
else:
    print(2**(n-1))

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var s = Console.ReadLine().Split();
    var a = int.Parse(s[0]);
    var b = int.Parse(s[1]);
    var c = int.Parse(s[2]);
    var k = int.Parse(s[3]);
    var goukei = 0;
    if(k <= a){
      Console.WriteLine(k);
      return;
    }
    else if(k <= a+b){
       Console.WriteLine(a);
      return;
    }
    else{
      var nokori = k-a-b;
      goukei = nokori *-1 + a;
      Console.WriteLine(goukei);
    }
  }
}

Measured memory_bytes: 17884
a, b = map(str, input().split())
if a == "H" and b == "D":
    print("D")
elif a == "H" and b == "H":
    print("H")
elif a == "H" and b == "D":
    print("D")
elif a == "D" and b == "D":
    print("H")
elif a == "D" and b == "H":
    print("D")

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long a[1000];
long long cum_sum[1001];
int main(){
  int N;
  int K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
      cin >> a[i];
  }
  
  cum_sum[0] = 0;
  for(int i = 0; i < N; i++){
      cum_sum[i + 1] = cum_sum[i] + a[i];
  }
  vector <long long> sums;
  for(int i = 0; i < N; i++){
      for(int j = i + 1; j < N + 1; j++){
          sums.push_back(cum_sum[j] - cum_sum[i]);
      }
  }
  
  /*
  for(int i = 0; i < sums.size(); i++){
      cout << sums[i] << " ";
  }
  cout << endl;
  cout << sums.size() << endl;
  */
  map <int, int> bit_counts;
  for(int i = 0; i < 45; i++){
      bit_counts[i] = 0;
      for(int j = 0; j < sums.size(); j++){
          if(((sums[j] >> i) & (long long) 1) == (long long) 1){
              bit_counts[i] ++;
          }
      }
  }
  
  long long ans = 0;
  for(int i = 44; i >= 0; i--){
      if(bit_counts[i] >= K){
          ans += ((long long) 1 << i);
          bit_counts.clear();
          vector <long long> new_sums;
          for(int j = 0; j < sums.size(); j++){
              if(((sums[j] >> i) & 1) == 1){
                  new_sums.push_back(sums[j]);
              }
          }
          sums = new_sums;
          for(int j = 0; j < 45; j++){
            bit_counts[j] = 0;
            for(int k = 0; k < sums.size(); k++){
                if(((sums[k] >> j) & (long long) 1) == (long long) 1){
                    bit_counts[j] ++;
                }
            }
          }
          
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6256
import sys

n, k, *h = map(int, sys.stdin.read().split())

def main():
    h.sort()
    
    res = float('inf')
    for i in range(n-k+1):
        res = min(res, h[i+k-1] - h[i])
    
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14092
import sys

n = int(input())
task = [list(map(int,input().split())) for i in range(n)]
task.sort(key = lambda x: x[1])
tim = 0
for i in range(n):
	tim += task[i][0]
	if tim > task[i][1]:
		print("No")
		sys.exit()
print("Yes")

Measured memory_bytes: 88024
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { ll K, A, B;
  cin >> K >> A >> B,K++;
  if(A+1<B&&A+1<K){
    K -= A ;
    ll ans = A;
    ll a = K / 2;
    ans += (B-A)*a;
    ans += K % 2;
    cout << ans << endl;
  }else{
    cout << K << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
string str;
cin>>str;
int x=0,temp=0;
for(int i=0;i<n;i++)
{
    if(str[i]=='I')
    {
    	temp++;
    }
    else
    {
    	temp--;
    }
    x=max(x,temp);
}
cout<<x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[111];
	scanf("%d",&n);
	for(int i=0; i<n; i++)scanf("%d",&a[i]);
	sort(a,a+n);
	printf("%d\n",unique(a,a+n)-a);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M;
  cin >> N >> M;
  priority_queue<ll> que;
  rep(i,N){
    ll a;
    cin >> a;
    que.push(a);
  }

  rep(i,M){
    ll x = que.top(); que.pop();
    x >>= 1;
    que.push(x);
  }

  ll sum = 0;
  while(!que.empty()){
    sum += que.top(); que.pop();
  }

  cout << sum << endl;
  
  return 0;
}


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

P s[200000];
signed main() {
	int w, h; scanf("%lld%lld", &w, &h);
	rep(i, w) {
		s[i].second = 0;
		scanf("%lld", &s[i].first);
	}
	rep(i, h) {
		s[i + w].second = 1;
		scanf("%lld", &s[i + w].first);
	}
	sort(s, s + w + h);
	int a = w + 1, b = h + 1;
	int cnt = 0;
	rep(i, w + h) {
		if (s[i].second == 0) {
			a--; cnt += s[i].first*b;
		}
		else {
			b--; cnt += s[i].first*a;
		}
	}
	printf("%lld\n", cnt);
}

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

int main(void)
{
	int n;
	string _event;

	cin >> n;
	for(int i=0; i<n; i++)
	{
		int outN=0;
		int score=0;
		int runnerState=0;

		while(1)
		{
			cin >> _event;
			if(_event == "HIT")
			{
				runnerState <<= 1;
				runnerState |=  1;

				if(runnerState & 0x08)
				{
					runnerState &= ~(0x08);
					score ++;
				}
			}

			if(_event == "HOMERUN")
			{
				score++;
				while(runnerState != 0)
				{
					runnerState >>= 1;
					score++;
				}
			}

			if(_event == "OUT")
			{
				outN++;
				if(outN == 3)break;
			}
		}
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	ll n;
	cin>>n;
	if(n>81)
	{
		cout<<"No";
		return 0;
	}
	for(ll i=1;i<=n;i++)
	{
		if(n%i==0)
		{
			if(max(i,n/i)<10)
			{
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";
}

Measured memory_bytes: 256