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

int main(){
    int a, b, ab;
    cin >> a >> b;
    string buf_a = to_string(a);
    string buf_b = to_string(b);
    ab = stoi(buf_a + buf_b);
    for(int i = 0; i < ab; ++i){
        if(ab == i*i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3684
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    let mut counts: HashMap<char, usize> = HashMap::new();
    for i in 0..n {
        *counts.entry(s[i]).or_insert(0) += 1;
    }

    const MOD: usize = 1_000_000_007;
    let mut ans = 1;
    for (_, count) in counts {
        ans = ans * (count + 1) % MOD;
    }
    if ans == 0 {
        ans = MOD - 1;
    } else {
        ans = ans - 1;
    }
    return ans.to_string();
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
struct h{
	int a,pos;
}x[N];
bool operator <(h w,h u){
	return w.a<u.a;
}
int ans[N];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&x[i].a);
		x[i].pos=i;
	}
	sort(x+1,x+n+1);
	for(int i=1;i<=n/2;i++){
		ans[x[i].pos]=x[n/2+1].a;
	}
	for(int i=n/2+1;i<=n;i++){
		ans[x[i].pos]=x[n/2].a;
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4480
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		String msg = "";
		
		if((a * b) % 2 == 0) {
			msg = "Even";
		}else {
			msg = "Odd";
		}
		System.out.println(msg);
	}
}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;



int p,q,a,n;

int rec(int ip,int iq,int ik,int in){
    if(ip*q==iq*p) return 1;
    if(in==0) return 0;
    int ret=0;
    if(iq*ik<=a) ret+=rec(ip*ik+iq,iq*ik,ik,in-1);
    if(iq*(ik+1)<=a) ret+=rec(ip,iq,ik+1,in);
    return ret;
}



int main(){
    while(cin >> p >> q >> a >> n){
        if(!p&&!q&&!a&&!n) break;
        cout << rec(0,1,1,n) << endl;
    }
    return 0;
}




Measured memory_bytes: 2984
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    string s;
    cin >> s;
    int ans = 0;
    REP(i, s.size()){
        if(s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll dp[100005];




int main()
{
    run;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    fr(i,0,n)
    {
        cin>>a[i];


    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    fr(i,2,n)
    {
        dp[i]=10000000000000ll;
    }

    fr(i,2,k)
    {
        fr(j,0,i)
        dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));//,dp[i-2]+abs(a[i]-a[i-2]));
    }

    fr(i,k,n)
    {
        bk(j,i-1,i-k)
        {
            dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
        }
    }

    cout<<dp[n-1];





}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
using namespace std;
char c[1000006];
int main() {
    scanf("%s", c + 1);
    int len = strlen(c + 1);
    if(c[1] == c[len]) {
        if(len % 2 == 0) puts("First");
        else puts("Second");
    }
    else {
        if(len % 2 == 1) puts("First");
        else puts("Second");
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))
a = 0
b = sum(w)
kai = b-a
ichizi = 0
for i in range(n):
  a +=w[i]
  b -=w[i]
  ichizi = abs(a-b)
  kai = min(kai,ichizi)
print(kai)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
string s;
int f;
int main(){
	cin >> s;
	for(int i = 0; i < 3; i++){
		if(s[i] == '7'){
			f = 1;
		}
	}
	if(f == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>

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

void quickSort(int A[], int p, int r){
    if(p<r){
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

int main(){
    int l[3];
    int cnt[4] ={0};

    while(1){
        for(int i=0; i<3; i++) scanf("%d", &l[i]);
        quickSort(l, 0, 2);
        double a = (double)l[0], b=(double)l[1], c=(double)l[2];

        if(!(a+b>c && b+c>a && c+a>b)) break;
        
        cnt[0]++;
        double cosine = (b*b+a*a-c*c)/(2*b*c);
        if(cosine == 0) cnt[1]++;
        else if(cosine >0) cnt[2]++;
        else cnt[3]++;
    }

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

    return 0;
}


Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt[200005],a[200005],cover[200005],ans;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i) a[i]=read(),cnt[a[i]]++,cover[a[i]-cnt[a[i]]+1]++;
	for(int i=1;i<=n;++i) if(cover[i]==0) ans++;
	for(int i=1;i<=m;++i){
		int x,y;
		x=read(),y=read();
		cnt[a[x]]--; if(a[x]-cnt[a[x]]>0){cover[a[x]-cnt[a[x]]]--; if(cover[a[x]-cnt[a[x]]]==0) ans++;}
		cnt[y]++; if(y-cnt[y]+1>0){cover[y-cnt[y]+1]++; if(cover[y-cnt[y]+1]==1) ans--;}
		a[x]=y;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
using namespace std;
int main()
{ int n,m;
cin>>n>>m;
ll a[n];
ll u=0;
FOR(n) cin>>a[i];
FOR(n){u+=a[i];}

 double e=(double)u/(4*m);

int w=0;
FOR(n)
{if((double)a[i]>=e)
{
    w++;

}

    else
    continue;
}
if(w>=m)
{
    cout<<"Yes";
}
else
cout<<"No";




return 0;
}


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

int main()
{
    int n, i, j, sum=0;
    scanf("%d", &n);
    int a[n+1];
    for(i=0; i<n; i++){
		scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			sum+=a[i]*a[j];
		}
    }
    printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128
let n, m, ds = Scanf.scanf "%d %d" @@ fun n m -> Array.(n, m, make_matrix n n (1 lsl 40))
let es = Array.init m @@ fun _ -> Scanf.scanf " %d %d %d" @@ fun a b t -> ds.(a - 1).(b - 1) <- t; ds.(b - 1).(a - 1) <- t; a - 1, b - 1, t
let _ = Array.(iteri (fun i d -> iteri (fun j _ -> if i = j then d.(j) <- 0) d)) ds; for k = 0 to n - 1 do for i = 0 to n - 1 do for j = 0 to n - 1 do ds.(i).(j) <- min ds.(i).(j) @@ ds.(i).(k) + ds.(k).(j) done done done;
  Array.(fold_left (fun r (i, j, t) -> if ds |> to_list |> List.exists (fun s -> s.(i) + t = s.(j) || s.(j) + t = s.(i)) then r - 1 else r) m es) |> Printf.printf "%d\n"

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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 main(){
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;

}






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

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

  sort(a, a+n);

  int t=0;
  long long sum = 0;
  for (int i=0; i<n-1; i++) {
    if (sum*2LL < a[i]) {
      t=i;
    }
    sum+= a[i];
  }

  cout << n-t << endl;
  return 0;
}


Measured memory_bytes: 1024
def task(probs):
    n = len(probs)
    dp = [0] * (n + 1)
    dp[0] = 1

    for i, p in enumerate(probs, start=1):
        state = 0
        for j in range(i + 1):
          #print(state, p, 1-p, dp[j])
          curr = dp[j]
          dp[j] = (curr * (1 - p)) + state
          state =  curr * p

    return sum(dp[(n + 1) // 2:])


n = input()  # n
probs = [float(x) for x in input().split()]
print(task(probs))

Measured memory_bytes: 41452
N = int(input())
B = input().split()

ans = 0

for i in range(N):
    if i == 0:
        ans += int(B[i])
    elif i == N-1:
        ans += int(B[i-1])
    else:
        ans += min(int(B[i]),int(B[i-1]))

print(ans)

Measured memory_bytes: 9212
def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')

        else:
            print(nums[i])
            

n=int(input())
nums=list(map(int,input().split()))
show(nums)

for i in range(1,n):
    v=nums[i]
    j=i-1

    while (j>=0 and nums[j]>v):
        nums[j+1]=nums[j]
        j-=1

    nums[j+1]=v
    show(nums)


Measured memory_bytes: 5976
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    char c; 
    cin>>c;
    if(c<'a') cout << 'A' << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;

const int mod = 1e9+7;
const int N = 306;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n, m, L;
ll d[N][N], e[N][N];
vi can[N];
int vis[N];
void floyed() {
    rep(k, 1, n + 1)
        rep(i, 1, n + 1)
            rep(j, 1, n + 1) {
                d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
            }
}
void initans() {
    rep(i, 1, n + 1) rep(j, i + 1, n + 1) e[i][j] = e[j][i] = 2e18;
    rep(i, 1, n + 1) {
        rep(j, 1, n + 1) {
            if(d[i][j] <= L) e[i][j] = 1;
        }
    }
    rep(k, 1, n + 1)
        rep(i, 1, n + 1)
            rep(j, 1, n + 1) {
                e[i][j] = min(e[i][k] + e[k][j], e[i][j]);
            }
}
int bfs(int s, int t) {
    mt(vis, 0);
    queue<pii> q; q.push(mp(-1,s)); vis[s] = 1;
    while(sz(q)) {
        pii tmp = q.front(); q.pop();
        int u = tmp.se, cnt = tmp.fi;
        if(u == t) return cnt;
        for(auto v: can[u]) {
            if(vis[v]) continue;
            vis[v] = 1;
            q.push(mp(cnt+1,v));
        }
    }
    return -1;
}
int main() {
    scanf("%d%d%d",&n,&m,&L);
    rep(i, 1, n + 1) rep(j, i + 1, n + 1) d[i][j] = d[j][i] = 2e18;
    rep(i, 0, m) {
        int u, v, c; scanf("%d%d%d",&u,&v,&c);
        d[u][v] = d[v][u] = c;
    }
    floyed();
    initans();
    int q; scanf("%d", &q);
    rep(ite, 0, q) {
        int s, t; scanf("%d%d",&s,&t);
        if(e[s][t] != 2e18) printf("%d\n", e[s][t] - 1);
        else printf("-1\n");
    }
    return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n;
    cin>>n;
   for(int i=1;i<=9;i++)
   {
       for(int j=1;j<=9;j++)
       {
           if(i*j==n)
           {
               cout<<"Yes";
               return 0;
           }
       }
   }
   cout<<"No";

}


Measured memory_bytes: 3624
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream> 
    #include <cstdlib>
using namespace std;
typedef long long LL;
const int MAXN=2e5+10;
const int INF=1e9+7;
LL fac[MAXN],inve[MAXN];
int h,w,a,b;
LL qmod(LL a,LL b)
{  
    LL ans=1;
    a=a%INF;  
    while(b)  
    {  
        if(b&1==1) ans=ans*a%INF;  
        a=a*a%INF;  
        b>>=1;  
    }  
    return ans;  
}
LL inv(LL a)
{  
    return qmod(a,INF-2);  
}
void cal_table(int n)
{
	fac[0]=inve[0]=1;  
    for(int i=1;i<=n;i++)  
    {  
        fac[i]=fac[i-1]*i%INF;  
        inve[i]=inv(fac[i]);  
    }  
}

LL C(LL m,LL n)  
{  
	//cout<<n<<" "<<m<<endl;
    if(m>n||m<0||n<0)
		return 0;
	if(m==n)
		return 1;
    return fac[n]*inve[m]%INF*inve[n-m]%INF;  
} 
LL Get(int m,int n)
{
	//cout<<m<<" "<<n<<endl;
	return C(n,m)%INF;  
}
int main()
{
	scanf("%d%d%d%d",&h,&w,&a,&b);
	cal_table(h+w+10);
	LL res=Get(h-1+w-1,w-1);
	//cout<<res<<endl;
	int i=h-a+1,j=b;
	for(i;i<=h;i++)
		res=((res+INF)-Get(i-1+j-1,j-1)*Get(h-i+w-j-1,w-j-1)%INF)%INF;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3328
k, n = map(int, input().split())
a = list(map(int, input().split()))

a.append(a[0] + k)
m = 0
s = 0
for i in range(n):
    m = max(m, a[i+1] - a[i])
    s += a[i+1] - a[i]
print(s - m)

Measured memory_bytes: 26444
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int n;
        int card[4][13];
        for(int i=0;i<4;i++){
                for(int j=0;j<13;j++){
                        card[i][j]=0;
                }
        }
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            char c;
                int m;
                scanf("%s %d",&c,&m);
                if(c=='S'){
                        card[0][m-1]=1;
                }else if(c=='H'){
                        card[1][m-1]=1;
                }else if(c=='C'){
                        card[2][m-1]=1;
                }else{
                        card[3][m-1]=1;
                }
        }
        for(int i=0;i<4;i++){
                for(int j=0;j<13;j++){
                        if(card[i][j]==0){
                                if(i==0){
                                        printf("S %d\n",j+1);
                                }else if(i==1){
                                        printf("H %d\n",j+1);
                                }else if(i==2){
                                        printf("C %d\n",j+1);
                                }else{
                                        printf("D %d\n",j+1);
                                }
                        }
                }
        }
        return 0;
}

Measured memory_bytes: 1176
N = int(input())
A = tuple(map(int, input().split()))
MOD = 10**9+7

arr = [0] * 60
for a in A:
    for i in range(60):
        if a>>i & 1:
            arr[59-i] += 1

ans = 0
for i, a in enumerate(arr):
    b = N - a
    ans += (a*b) * (2**(59-i))
    ans %= MOD
print(ans)

Measured memory_bytes: 122936
N,*A=map(int,input().split());a=[[0]*4];r=[0,1,2]
for i in range(N):l=int(input());a+=[[p[j]+l*(i==j)for j in r]+[p[3]+10]for i in r for p in a]
print(min(sum(abs(p[i]-A[i])for i in r)-30+p[3]for p in a if min(p[:3])>0))

Measured memory_bytes: 16756
s=str(input())
q=int(input())
now = 0
mae,usiro="",""
for _ in range(q):
  lis = list(map(str,input().split()))
  if int(lis[0]) == 1:
    now = (now+1)%2
  else:
    if (int(lis[1])+now)%2 == 1:
      mae = lis[2]+mae
    else:
      usiro= usiro +lis[2]
s = mae+s+usiro
if now ==0:
  print(s)
else:
  print(s[::-1])
    
  


Measured memory_bytes: 4608
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <vector>

// please copy-paste.
// mondai_c
int main()
{
    int32_t n, k;

    std::cin >> n >> k;

    if ( n <= k ) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::vector<int32_t> h(n);

    for ( int _i = 0; _i < n ; _i++ ) {
        std::cin >> h[_i];
    }
    std::sort(h.begin(), h.end());
    int64_t sum = 0;
    for ( int _i = 0; _i < (n-k) ; _i++ ) {
        sum += h[_i];
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 1656
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] a = new String[n];
		int countAns = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		String[] b = a.clone();

		//bubble sort
		for(int i = 0; i < n; i++) {
			for(int j = n - 2; j >= i; j--) {
				int ai = Integer.parseInt(a[j + 1].substring(1, 2));
				int aj = Integer.parseInt(a[j].substring(1, 2));
				if(aj > ai) {
					String tempStr = a[j + 1];
					a[j + 1] = a[j];
					a[j] = tempStr;
				}
			}
		}

		//Selection sort
		for(int i = 0; i < n; i++) {
			int minj = i;
			for(int j = i; j < n; j++) {
				int aminj = Integer.parseInt(b[minj].substring(1, 2));
				int aj = Integer.parseInt(b[j].substring(1, 2));
				if(aj < aminj) {
					minj = j;
				}
			}
			if(minj != i) {
				String temp = b[i];
				b[i] = b[minj];
				b[minj] = temp;
			}
		}

		
		for(int i = 0; i < n; i++) {
			System.out.print(a[i]);
			if(i != n - 1)
				System.out.print(" ");
		}
		System.out.println();
		System.out.println("Stable");
		for(int i = 0; i < n; i++) {
			System.out.print(b[i]);
			if(i != n - 1)
				System.out.print(" ");
		}
		System.out.println();
		if(Arrays.equals(a, b)) {
			System.out.println("Stable");
		}else {
			System.out.println("Not stable");
		}
	}
}


Measured memory_bytes: 26776
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int ALP = 26;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	int c4 = 0;
	int c2 = 0;
	int c1 = 0;
	if (n % 2 && m % 2) {
		c4 = (n / 2) * (m / 2);
		c2 = (n + m - 2) / 2;
		c1 = 1;
	} else if (!(n % 2) && !(m % 2)) {
		c4 = (n / 2) * (m / 2);
	} else if (n % 2) {
		c4 = (n / 2) * (m / 2);
		c2 = m / 2;
	} else {
		c4 = (n / 2) * (m / 2);
		c2 = n / 2;
	}
	vector<int> cnt(ALP);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			cnt[c - 'a']++;
		}
	}
	for (int i = 0; i < ALP; i++) {
		int t = min(cnt[i] / 4, c4);
		cnt[i] -= 4 * t;
		c4 -= t;
	}
	for (int i = 0; i < ALP; i++) {
		int t = min(cnt[i] / 2, c2);
		cnt[i] -= 2 * t;
		c2 -= t;
	}
	for (int i = 0; i < ALP; i++) {
		int t = min(cnt[i], c1);
		cnt[i] -= t;
		c1 -= t;
	}
	if (c1 || c2 || c4) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}

}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <math.h>
#include <chrono>
using namespace std;
#pragma GCC optimize("-O3")
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10), cin.tie(0), cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define sz(X) (int)((X).size())
#define what(x) cerr << #x << " is " << x << endl;
//#define int long long

const int MAXN = 505;

int ocupied[MAXN * MAXN];
int odleglosc[MAXN * MAXN];
vector<int> N[MAXN * MAXN];
int n;

vector<int> getN(int x)
{
    vector<int> tmp = {x - 1, x + 1, x - n, x + n};
    vector<int> res;
    for (int a : tmp)
        if (a < n * n && a >= 0)
            res.push_back(a);
    return res;
}

int compute(int x)
{
    int res = 1e9;
    for (int a : N[x])
        res = min(res, odleglosc[a] + ocupied[a]);
    return res;
}

void bfs(int x)
{
    queue<int> Q;
    Q.push(x);
    while (!Q.empty())
    {
        x = Q.front();
        Q.pop();
        for (int y : N[x])
        {
            int s = compute(y);
            if (s < odleglosc[y])
            {
                odleglosc[y] = s;
                Q.push(y);
            }
        }
    }
}

int32_t main()
{
    _upgrade;

    cin >> n;
    rep(i, n * n)
    {
        int a = i / n;
        int b = i % n;
        int dist = min(min(a, n - a - 1), min(b, n - b - 1));

        odleglosc[i] = dist;
        ocupied[i] = 1;
        N[i] = getN(i);
    }
    int ile = 0;

    rep(i, n * n)
    {
        int a;
        cin >> a;
        --a;
        ocupied[a] = false;
        ile += odleglosc[a];
        bfs(a);
    }
    cout << ile << endl;

    // int Z;
    // cin >> Z;
    // while (Z--)
    // {
    // }
}

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

int main(){
  string S;
  cin >> S;
  
  int count = 0;
  int ans = 0;
  repeat(i,S.length()){
    if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      count++;
    }else{
      count = 0;
    }
    ans = max(count,ans);
  }
  cout << ans << endl;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;


int main(){
  string s;
  cin >> s;
  // int s_num = 0;
  // int t_num = 0;
  int count = 0;
  int res = 0;
  for(auto a : s){
    if(a == 'S') count++;
    else if(a == 'T' && count >= 1) {
      count--;
      res++;
    }
  }
  cout << int(s.size()) - res * 2 << endl;


}


Measured memory_bytes: 640
program connection_and_disconnection
  implicit none
  character(100) :: s
  integer :: n, i, x(100) = 0, y(100) = 0
  integer(8) :: k, a1 = 0_8, a2 = 0_8
  read(*,*) s
  read(*,*) k
  n = len_trim(s)
  do i = 1, n
    x(i) = ichar(s(i:i))-96
    y(i) = x(i)
  end do
  if (all(x(1:n) == x(1))) then
    write(*,'(i0)') (int(n,8)*k)/2_8
    stop
  end if
  do i = 2, n
    if (x(i) == x(i-1)) then
      x(i) = 100
      a1 = a1+k
    end if
  end do
  if (x(n) == x(1)) a1 = a1+k-1_8
  do i = n-1, 1, -1
    if (y(i) == y(i+1)) then
      y(i) = 100
      a2 = a2+k
    end if
  end do
  if (y(1) == y(n)) a2 = a2+k-1_8
  write(*,'(i0)') min(a1,a2)
end program connection_and_disconnection

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    cout << b << a << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back
 
using namespace std; 

ll fact(ll n){
    ll answ = 1;
    for( int i = 1; i <= n; i++){
        answ *= i;
    }
    return answ;
}

ll c(ll n, ll m){
    return fact(n) / (fact(m) * fact(n - m));
}


int main() {

    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);

    int t;  t = 1; //cin >> t;
    while(t--){
        ll a; cin >> a;
        cout << a + a * a + a * a * a << endl;
    }
    return 0;
}

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

int max_value(int input[], int n);
int value_add(int input[], int n, int exception);

int main(void) {
	int n;
	scanf("%d", &n);
	int input[n], max_num;

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

	max_num = max_value(input, n);
	//printf("\n%d ", max_num);
	//printf("\n%d\n", value_add(input, n, max_num));

	if(input[max_num] < value_add(input, n, max_num)){
		puts("Yes");
	}else{
		puts("No");
	}

	return EXIT_SUCCESS;
}

int max_value(int input[], int n){
	int i, ans = 0;
	for(i = 1 ; i < n ; i++){
		if(input[ans] < input[i]){
			ans = i;
		}
	}
	return ans;
}

int value_add(int input[], int n, int exception){
	int sum, i;
	for(i = 0 ; i < n ; i++){
		if(i != exception){
			sum += input[i];
		}
	}
	return sum;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P > T;

bool ac[52][12];
int wg[52][12];

bool cmp(const T &a,const T &b) {
    if(a.second.first != b.second.first) return a.second.first>b.second.first;
    else{
        if(a.second.second != b.second.second)return a.second.second < b.second.second;
        else return a.first < b.first;
    }
}


int main(void){
    int t,p,r;
    while(true){
        cin>>t>>p>>r;
        if(t==0 && p==0 && r==0)break;
        vector<T>ans(t);
        for(int i=0;i<t;i++)ans[i]=T(i+1,P(0,0));
        for(int i=0;i<52;i++){
            for(int j=0;j<12;j++){
                ac[i][j]=false;
                wg[i][j]=0;
            }
        }
        for(int i=0;i<r;i++){
            int x,y,time;
            string s;
            cin>>x>>y>>time>>s;
            int index =x-1;
            if(s == "WRONG"){
                if(!ac[x][y]){
                    wg[x][y]++;
                }
            }
            else{
                if(!ac[x][y]){
                    ans[index].second.first++;
                    ans[index].second.second += 1200*wg[x][y]+time;
                    ac[x][y]=true;
                }
            }
        }
        sort(ans.begin(),ans.end(),cmp);
        for(int i=0;i<t;i++){
            cout<<ans[i].first<<" "<<ans[i].second.first<<" "<<ans[i].second.second<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll n,m,x;
    cin>>n>>m>>x;
    V c(n);
    VV a(n,V(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m)cin>>a[i][j];
    }
    ll ans=1e9;
    for(ll bit=0;bit<(1<<n);bit++){
        ll cost=0;
        V v(m,0);
        for(ll k=0;k<n;k++){
            if(bit&(1<<k)){
                cost+=c[k];
                rep(j,m)v[j]+=a[k][j];
            }
        }
        bool ok=true;
        rep(i,m){
            if(v[i]<x)ok=false;
        }
        if(ok)ans=min(ans,cost);
    }
    if(ans==1e9){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3636
import java.util.*
import kotlin.comparisons.compareByDescending

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toLong() }
    val pq = PriorityQueue<Long>(n, compareByDescending { it })
    a.forEach { pq.add(it) }

    repeat(m) {
        val num = pq.poll()
        pq.add(num / 2)
    }
    println(pq.sum())
}

Measured memory_bytes: 72056
class Combination
  MOD = 1_000_000_007
  def initialize
    @fact = (1..2000000).to_a
    @fact.each_with_index do |e, idx|
      @fact[idx] = @fact[idx] * @fact[idx-1] % MOD if idx > 0
    end
  end

  def comb(n, r)
    return 0 if not (0 <= r and r <= n)
    return 1 if r == 0 or r == n
    fact(n) * inverse( fact(r) * fact(n-r) % MOD ) % MOD
  end

  def fact(n)
    @fact[n-1]
  end

  def inverse(x)
    pow(x, MOD-2)
  end

  def pow(x, n)
    ans = 1
    while n > 0
      ans = ans * x % MOD if n.odd?
      x = x * x % MOD
      n >>= 1
    end
    ans
  end
end


X,Y = gets.split.map(&:to_i)

if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0
  a = (2 * Y - X) / 3
  b = (2 * X - Y) / 3
  puts Combination.new.comb(a + b, a)
else
  puts 0
end


Measured memory_bytes: 18940
import java.io.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        long sum = 0;
        int n = Integer.parseInt(br.readLine());
        String[] line = br.readLine().split(" ");
        for (int i=0; i<n; i++) {
            int ai = Integer.parseInt(line[i]);
            if(ai < min) min = ai;
            if(max < ai) max = ai;
            sum += ai;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}

Measured memory_bytes: 25548
#include <stdio.h>
typedef long long ll;

const ll modulus = (ll)(1e9) + 7;

ll n;
ll mul[1005];
ll ans = 1;

int main()
{
	scanf("%lld", &n);
	
	for (ll i = 2; i <= n; i++) {
		ll j = 2;
		ll tmp = i;

		while (tmp > 1) {
			if (tmp % j == 0) {
				tmp /= j;
				mul[j]++;
			}
			else {
				j++;
			}
		}
	}

	for (ll i = 0; i < 1005; i++) {
		if (mul[i]) {
			ans *= mul[i] + 1;
			ans %= modulus;
		}
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using i64 = long long;

int v[21][21];

int main() {
    int n;
    constexpr i64 mod = 1000000007;
    std::cin >> n;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) std::cin >> v[i][j];

    std::vector<i64> dp(1 << 21);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        std::vector<i64> cp(1 << 21);
        for (int mask = 0; mask < (1 << n); mask++) {
            if (__builtin_popcount(mask) != i) continue;
            for (int j = 0; j < n; j++) {
                if (mask & (1 << j)) continue;
                if (!v[i][j]) continue;

                cp[mask | (1 << j)] = (cp[mask | (1 << j)] + dp[mask]) % mod;
            }
        }

        std::swap(cp, dp);
    }

    std::cout << dp[(1 << n) - 1] << std::endl;

    return 0;
}

Measured memory_bytes: 33144
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;

const ll modo=1e9+7;
const ll ms=2e5+5;
const ll inf=1e15;

int ar[ms];


int main()
{
    idfc;
    int ans=0;
    int i,j,k;

    int n;
    cin>>n;
    for(i=1;i<=n;i++)cin>>ar[i];



    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            for(k=j+1;k<=n;k++)
            {
                if(ar[i]!=ar[j]&&ar[j]!=ar[k]&&ar[i]!=ar[k]&&((ar[i]+ar[j])>ar[k])&&((ar[i]+ar[k])>ar[j])&&((ar[j]+ar[k])>ar[i])){ans++;}
            }
        }
    }
    cout<<ans;
    return 0;
}

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

int main(){
long long int a[1000000],n,MIN,MAX,SUM;
MIN=100000000;
MAX=-100000000;
SUM=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
if(MIN>a[i]){
MIN=a[i];
}
if(MAX<a[i]){
MAX=a[i];
}
SUM += a[i];
}
cout<<MIN<<" "<<MAX<<" "<<SUM<<endl;
return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n; ll k;
ll a[maxn], f[maxn];





bool good(ll x) {
  ll t = 0;
  for (int i=0; i<n; i++) {
    ll maxtime = x/f[i];
    t += max(0LL, a[i] - maxtime);
  }
  return t <= k;
}

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

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

  sort(a,a+n);
  sort(f,f+n);
  reverse(a,a+n);

  ll lo = 0;
  ll hi = 1e13;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (good(mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  ll ans = -1;
  if (good(hi)) ans = hi;
  if (good(lo)) ans = lo;
  assert(ans != -1);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5888
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef long long ll;

int DescendingSort(int [101], int);

int main()
{
	int N, Alice = 0, Bob = 0;
	scanf("%d", &N);
	int V[101];
	for (int i = 0; i < N; i++) {
		scanf("%d", &V[i]);
	}
	DescendingSort(V, N);
	for (int j = 0; j < N; j++) {
		if (j % 2 == 0)
			Alice += V[j];
		else
			Bob += V[j];
	}

	printf("%d\n", Alice - Bob);
	return 0;
}

int DescendingSort(int *number, int len) {
	int tmp;
	for (int i = 0; i < len; i++) {
		for (int j = i + 1; j < len; j++) {
			if (number[i] < number[j]) {
				tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
		}
	}
}

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

using namespace std;

bool check(int i,int m,const vector<int> &int_array){
    if(m == 0) return true;
    else if(i>=int_array.size()) return false;
    bool res = check(i+1,m,int_array) || check(i+1,m - int_array[i],int_array);
    return res;
}

int main(){
    int flag = 0;
    int len_array,num_query;
    int temp,m;
    scanf("%d",&len_array);
    
    vector<int> int_array(len_array,0);
    for(int i = 0;i < len_array;i++){
        scanf("%d",&temp);
        int_array[i] = temp;
    } 
    scanf("%d",&num_query);
    for(int i = 0; i < num_query;i++){
        scanf("%d",&m);
        if(check(0,m,int_array)) printf("yes\n");
        else printf("no\n");
    }


    return 0;   
}



Measured memory_bytes: 3156
N = input()
n = int(N[-1])
hon = [2, 4 ,5 ,7 ,9]
pon = [0, 1, 6, 8]
bon = 3
if n in hon:
    print('hon')
elif n in pon:
    print('pon')
elif n == 3:
    print('bon')
    

Measured memory_bytes: 9172
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	int x[32] = { 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 >> K;
	cout << x[K - 1];
}

Measured memory_bytes: 256
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1,M+1):
    while (j<N) and (X[j][0] <=i):
        heappush(hq,-X[j][1])
        j+=1
    if hq:
        ans-=heappop(hq)
print(ans)

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

int main(void) {
  char strings[100],stringp[100],longstring[200];
  scanf("%s",strings);
  scanf("%s",stringp);
  strcpy(longstring,strings);
  strcat(longstring,strings);

  if(strstr(longstring,stringp) == NULL){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

ll func(ll t, ll x){
	if(t < 0) return 0ll;
	else return t / x + 1;
}
int main(void){
	ll a, b; cin >> a >> b;
	ll x; cin >> x;
	ll ans = func(b, x) - func(a - 1, x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
      int n,count=0;
      cin>> n;
      int num[n];
      for(int i= 0;i<n;i++)
            cin>>num[i];
      bool flag=true;
      while(flag){
            flag=false;
            for(int j = n-1 ; j>0;j--){
                  if(num[j]<num[j-1]){
                        swap(num[j],num[j-1]);
                        flag = true;
                        count++;
                  }
            }
      }
      for(int i= 0;i<n-1;i++)
            cout<<num[i]<<" ";
      cout<<num[n-1]<<endl<<count<<endl;
}

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

int main() {
  ll A;
  cin >> A;
  string s;
  cin >> s;
  ll B = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
  cout << A * B / 100 << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N,M,K; cin>>N>>M>>K;
    bool f=false;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= M; j++){
            if(M*i+N*j-2*i*j==K){ f=true; break; }
        }
    }
    cout<<(f?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

c = 0
for i in range(N):
    e = min(A[i],B[i])
    A[i] -= e
    B[i] -= e
    d = min(A[i+1],B[i])
    A[i+1] -= d
    B[i] -= d

    c += e + d

print(c)

Measured memory_bytes: 19116
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
/// joooob zadam
const int N=2e5+100;
ll nxt[N][26];
ll par[N];
ll dp[N];
int32_t main(){
    string s;
    cin >> s;
    ll n=s.size();

    for (int i=0;i<26;i++){
        ll t=n+1;
        for (int j=n;j>0;j--){
            nxt[j][i]=t;
            if (s[j-1]-'a'==i){
                t=j;
            }
        }
        nxt[0][i]=t;
    }
    memset(dp,69,sizeof dp);
    dp[n+1]=0;
    for (int i=n;i>-1;i--){
        for (int j=0;j<26;j++){
            ll z=nxt[i][j];
            dp[i]=min(dp[i],dp[z]+1);

          //  cout << i << " " << z << " " << dp[i] << " " << dp[z] << endl;
        }
        for (int j=0;j<26;j++){
            ll z=nxt[i][j];
            if (dp[z]+1==dp[i]){
                par[i]=j;
                break;
            }
        }
    }
    string a="";
    ll x=0;
    while(x!=n+1){
        ll v=par[x];
        a+='a'+v;
        x=nxt[x][v];
    }
    cout << a << endl;
   // /cout << dp[0];

}


Measured memory_bytes: 44292
N, W = map(int, input().split())
v = [None] * (N + 1)
w = [None] * (N + 1)
for i in range(1, N + 1):
    v[i], w[i] = map(int, input().split())

# dp[i][j] := i番目の品物までで重さjとなるように選んだときの価値の最大値
# dp[i][j] := max(dp[i - 1][j - w] + v, dp[i - 1][j])
dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        if w[i] > j:  # 今選ぼうとしている品物の重さが制限jを超える場合には当然選べない
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j])
print(dp[N][W])


Measured memory_bytes: 42268
#include <stdio.h>
#define error -1
int size=0,list[2000000];
  
int parent(int i){
   return i/2;
}
  
int Left(int i){
  return 2*i;
 }
  
int Right(int i){
  return 2*i+1;  
 }
  
void maxHeapify(int i){
  int left,right,largest,key;
  left=Left(i);
  right=Right(i);
    
  if(left<=size && list[left]>list[i])
    largest=left;
  else largest=i;
    
  if(right<=size && list[right]>list[largest])
    largest=right;
    
  if(largest!=i){
    key=list[i];
    list[i]=list[largest];
    list[largest]=key;
    maxHeapify(largest);
  }  
}
void heapIncrease(int i,int key){
  int ch;
  if(key<list[i]) return;
  list[i]=key;
  while(i>0 && list[parent(i)]<list[i]){
    ch=list[i];
    list[i]=list[parent(i)];
    list[parent(i)]=ch;
    i=parent(i);
  }
  return;
}
  
  
void insert(int key){
  size=size+1;
  list[size]=-1000000;
  heapIncrease(size,key);
}
  
  
int heapExtractMax(){
  int max;
  if(size<0) return error;
  max=list[0];
  list[0]=list[size];
  size=size-1;
  maxHeapify(0);
  return max;
}
   
int main(){
  char Inst[10];
  int count,del,key;
   
 while(1){
     
   scanf("%s %d",Inst,&key);
   if(Inst[0]=='i') insert(key);
   else if(Inst[1]=='x'){
     del=heapExtractMax();
     printf("%d\n",del);
   }
   else if(Inst[2]=='d') break;
     
 }
 return 0;
}

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

class Dice {
    public:
    int f[6];
    Dice() {}
    void roll_z() { roll(1, 2, 4, 3);}
    void roll_W() { roll(0, 2, 5, 3);}
    void roll_N() { roll(0, 1, 5, 4);}
    void roll_S() { roll(0, 4, 5, 1);}
    void roll_E() { roll(0, 3, 5, 2);}
    void roll (int i, int j, int k, int l) {
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
    int top() {
        return f[0];
    }
    int front() {
        return f[1];
    }
    int left() {
        return f[3];
    }
    int right() {
        return f[2];
    }
};


int main() {
    Dice d;
    
    for (int i = 0; i < 6; i++) cin >> d.f[i];
    int q;
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        int a ,b; cin >> a >> b;
        if(d.left() == a) d.roll_E();
        if(d.right() == a) d.roll_W();
        while(d.top() != a) d.roll_N();
        while(d.front() != b) d.roll_z();
        cout << d.right() << endl;
    }
    return 0;
}



Measured memory_bytes: 3104