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


template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }
  
  Int P(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[n-k]%MOD;    
  }

  Int H(Int n,Int k){
    return C(n+k-1,n);
  }

  Int S(Int n,Int k){
    Int res=0;
    for(Int i=1;i<=k;i++){
      Int tmp=C(k,i)*pow(i,n)%MOD;
      if((k-i)&1) res+=MOD-tmp;
      else res+=tmp;
      res%=MOD;
    }
    res=res*finv[k]%MOD;
    return res;
  }
  
  Int B(Int n,Int k){
    Int res=0;
    for(Int j=1;j<=k;j++){
      res+=S(n,j);
      res%=MOD;
    }
    return res;
  }
  
  vector<vector<Int> > D(Int n,Int m){
    vector<vector<Int> > dp(n+1,vector<Int>(m+1,0));
    dp[0][0]=1;
    for(Int i=0;i<=n;i++){
      for(Int j=1;j<=m;j++){
	if(i-j>=0) dp[i][j]=(dp[i][j-1]+dp[i-j][j])%MOD;
	else dp[i][j]=dp[i][j-1];
      }
    }
    return dp;
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      rinv=rinv*inverse(k)%MOD;
      if(k%2) res+=MOD-rinv;
      else res+=rinv;
      res%=MOD;
    }
    for(Int i=1;i<=n;i++) res=res*i%MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};


//INSERT ABOVE HERE
Int dp[2020][2020];
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(5e6);
  Int n,k;
  cin>>n>>k;
  if(k==1) return cout<<1<<endl,0;

  auto add=[&](Int &a,Int b){a+=b;a%=MOD;};
  
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(Int i=0;i<=n;i++){
    for(Int j=0;j<=n;j++){
      //cout<<i<<" "<<j<<":"<<dp[i][j]<<endl;
      Int s=i+j*(k-1);
      if(i<j) add(dp[i+1][j],dp[i][j]);
      if(j<n) add(dp[i][j+1],dp[i][j]*mod.C(s+k-2,s)%MOD);
    }
  }
  Int ans=dp[n][n]*mod.fact[n]%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 149376
#include<cstdio>
using namespace std;

struct Card{char suit, value;};

void bubble(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N-1; j > i; j--){
            if(A[j].value < A[j-1].value){
                Card tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[minj].value > A[j].value){
                minj = j;
            }
        }
        Card tmp = A[minj];
        A[minj] = A[i];
        A[i] = tmp;
    }
}

void print(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        if(i)   printf(" ");
        printf("%c%c", A[i].suit, A[i].value);
    }
    printf("\n");
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char buf[3];

    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%s", buf);
        C1[i].suit = buf[0];
        C1[i].value = buf[1];
    }

    for(int i = 0; i < N; i++){
        C2[i] = C1[i];
    }

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    printf("Stable\n");

    print(C2, N);
    if(isStable(C1, C2, N)){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }

    return 0;
}


Measured memory_bytes: 2740
n,m = (int(x) for x in input().split())

sec = []

for i in range(m):
    list = [int(i) for i in input().split()]
    list.reverse()
    sec.append(list)

sec.sort()
left = sec[0][0]
right = sec[0][1]
x = right - 1
ans = 0

for i in range(m):
    if sec[i][1]<x:
        continue
    else:
        x = sec[i][0]
        ans += 1

print(ans)


Measured memory_bytes: 21652
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int n,a,b,k;
	scanf("%d%d%d",&n,&a,&b);
	if(n == 2) printf("Borys\n");
	else{
		if(a < b){
			k = b - a - 1;
			if(k % 2 == 0) printf("Borys\n");
			else printf("Alice\n");
		}
		if(b < a){
			k = a - b - 1;
			if(k % 2 == 0) printf("Alice\n");
			else printf("Borys\n");
		}
	}
	return 0;
}


Measured memory_bytes: 128
/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define PB push_back
#define E end()
#define PB push_back
typedef vector<ll> vctr;
#define REP(i,a,b) for (long long i = a; i < b; i++)
#define RREP(i,a,b) for (long long i = a; i > b; i--)
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');


/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
void solve() {
	ll n;
	cin >> n;
	ll count=0;
	REP(i,1,n){
		
		REP(j,1,n/i+1){
			if(i*j==n){
				continue;
			}
			count++;
			
		}
		
	}

	cout<<count;
		
}




int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	long long test;
	test = 1;
	// cin >> test;
	while (test--) {
		solve();
		// cout << "\n";
	}


}

Measured memory_bytes: 3644
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mulmod(ll a, ll b, ll m) {
    ll r = a * b - (ll)((long double)a * b / m + .5) * m;
    return r < 0 ? r + m : r;
}
ll expmod(ll b, ll e, ll m) {
    if (e == 0) return 1;
    if (e & 1) return mulmod(b, expmod(b, e - 1, m), m);
    b = expmod(b, e >> 1, m);
    return mulmod(b, b, m);
}
bool test(ll n, int a) {
    if (n == a) return true;
    ll s = 0, d = n - 1;
    while (d % 2 == 0) s++, d /= 2;
    ll x = expmod(a, d, n);
    if (x == 1 || x + 1 == n) return true;
    for (int i = 0; i < s - 1; i++) {
        x = mulmod(x, x, n);
        if (x == 1) return false;
        if (x + 1 == n) return true;
    }
    return false;
}

bool isPrime(ll n) {
    if (n == 1) return false;
    vector<int> ar = {2, 3, 5, 7, 11, 13, 17, 19, 23};
    for (auto& a : ar)
        if (!test(n, a)) return false;
    return true;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    ll a, b;
    cin >> a >> b;
    ll d = __gcd(a, b);
    vector<ll> div;
    for (ll i = 1; i * i <= d; i++) {
        if (d % i == 0) {
            if (i * i == d)
                div.pb(i);
            else
                div.pb(i), div.pb(d / i);
        }
    }
    int ans = 0;
    for (auto x : div) {
        if (isPrime(x)) ans++;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 384
n,m=list(map(int,input().split()))
road_input=[]
for i in range(m):
    road_input.append(list(map(int,input().split())))

#隣接リスト
road=[[] for i in range(n+1)]
for i in range(m):
    road[road_input[i][0]].append(road_input[i][1])
    road[road_input[i][1]].append(road_input[i][0])

from collections import deque
q=deque([1])
ans=[-1 for i in range(n)]
while len(q)>0:
  p=q.popleft()
  for i in road[p]:
    if ans[i-1]== -1:
      ans[i-1]=p
      q.append(i)

print("Yes")
for j in range(1,n):
    print(ans[j])


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

int main(void)
{
  long int n;
  scanf("%ld", &n);
  --n;
  int i;
  long int sum = 0, p = 1, offset;
  for (i = 0;; ++i)
  {
    if (sum > n)
    {
      offset = n - (sum - p);
      break;
    }
    p *= 26;
    sum += p;
  }
  
  int j;
  char* ans = malloc(i * sizeof(char));
  for (j = i - 1; j >= 0; --j)
  {
    int a = offset % 26;
    ans[j] = 'a' + a;
    offset /= 26;
  }
  
  printf("%s\n", ans);
  
  free(ans);
  
  return 0;
}


Measured memory_bytes: 2000
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int main(){
  cin>>n;
  vector<int> res;
  int sum=0;
  for(int i=1;sum<n;++i){
    sum+=i;
    res.pb(i);
  }
  if(sum>n){
    res.erase(find(ALL(res),sum-n));
  }
  for(auto e:res) printf("%d\n",e);


  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n = s.size();
    int ans = 9*(n-1); int sum = 0;
    for(int i=n-1;i>=0;i--) sum += (s[i]-'0');
    ans = max(ans,sum);
    for(int i=n-1;i>=0;i--){
        int cur = s[i]-'0';
        if(cur) ans = max(ans,sum-1+9*(n-1-i));
        sum -= cur;
    }
    cout << ans <<'\n';
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, ll> cnt;
    ll ans = 0;
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans += cnt[s]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> v(N);
  rep(i,N){
    cin>>v.at(i);
  }
  int s=0;
  int a=10000000;
  rep(i,100){
    s=0;
    rep(j,N){
      s+=(v.at(j)-i-1)*(v.at(j)-i-1);
    }
    if(a>s){
      a=s;
    }
  }
  
  cout<<a<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7


		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] l = Console.ReadLine().Split().Select(int.Parse).OrderBy(p => p).ToArray();
			int sum = 0;
			for (int i = 0; i < n - 1; i++) {
				sum += l[i];
			}
			if (l[n - 1] < sum) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int G[101][101];

int main() {

    int n;
    cin >> n;

    fill(G[0], G[101], 0);

    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u][v] = 1;
        }
    }


    for (int i = 1; i <= n; i++) {
        int k = 0;
        for (int j = 1; j <= n; j++) {
            if (k++) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3124
n=int(input())
a=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]))
    if i==1:
        continue
    dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int MX=1e5+9;
const ll inf=(1ll<<60);
const ll mod=1e9+7;
ll n,m,ans;
int main(){
    scanf("%lld%lld",&n,&m);
    ans=min(n,m/2);
    m-=n*2;
    ans+=max(m/4,0ll);
    printf("%lld\n",ans);
}


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

bool solver(queue<int> q, int a, int b){
    bool result = false;
    if(q.empty()) {
        return true;
    }
    int tmp = q.front();
    if(tmp > a){
        a = tmp;
        q.pop();
        result = solver(q, a, b);
        q.push(tmp);
    }
    if(result) return true;
    tmp = q.front();
    if(tmp > b){
        b = tmp;
        q.pop();
        result = solver(q, a, b);
        q.push(tmp);
    }
    if(result) return true;
    return false;
}

int main(){
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        queue<int> q;
        for(int j=0; j<10; j++){
            int tmp;
            cin >> tmp;
            q.push(tmp);
        }
        cout << (solver(q,0,0)?"YES":"NO") << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

string s, t;
int dp[4000 + 1][4000 + 1];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> s >> t) {
        int n = s.size();
        int m = t.size();
        rep(i, n + 1)rep(j, m + 1) dp[i][j] = 0;
        rep(i, n)rep(j, m) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
        }
        int ans = 0;
        rep(i, n + 1)rep(j, m + 1) ans = max(ans, dp[i][j]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 128088
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    cnt=[0 for i in 1:n]
    for i in 1:k
        d=parseInt(readline())
        a=parseMap(split(readline()))
        for j in a
            cnt[j]+=1
        end
    end
    println(count(x->x==0,cnt))
end
main()

Measured memory_bytes: 171292
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in); 
		int n = as.nextInt();
		String[] a;
		a = new String[n];
		for(int i=0;i<n;i++){
			a[i] = as.next();
		}
		int[][] b;
		b = new int[n][26];
		for(int i=0;i<n;i++){
			for(int s=0;s<a[i].length();s++){
				b[i][(int)a[i].charAt(s)-97]++;
			}
		}
		for(int i=0;i<n-1;i++){
			for(int s=0;s<26;s++){
				b[i+1][s]=Math.min(b[i][s], b[i+1][s]);
			}
		}
		String l="";
		for(int i=0;i<26;i++){
			for(int s=0;s<b[n-1][i];s++){
				l+=String.valueOf((char)(i+97));
			}
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 21972
# Pair
K = gets.chomp.to_i
g_count = 0
k_count = 0
for i in 0..K-1 do
    if (K - i) % 2 == 0
        g_count = g_count + 1
    end
end
for j in 0..K-1 do
    if (K - j) % 2 == 1
        k_count = k_count + 1
    end
end
puts (k_count * g_count)

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
int dp[300][300];
int w[300];
int rec(int s,int t){
  if(dp[s][t]!=-1)return dp[s][t];
  if(s==t)return 0;
  //if((t-s+1)%2)return max(rec(s,t-1),rec(s+1,t));
  int ans=rec(s+1,t-1);
  if(ans==t-s-1&&abs(w[s]-w[t])<=1)return dp[s][t]=ans+2;
  for(int i=s;i<t;i++){
    ans=max(ans,rec(s,i)+rec(i+1,t));
  }
  return dp[s][t]=ans;
}

int main(){
  int n;
  while(cin>>n,n){
    memset(w,0,sizeof(w));
    for(int i=0;i<n;i++)cin>>w[i];
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<n;i++)
      dp[i-1][i]=(abs(w[i-1]-w[i])<=1?2:0);
    cout<<rec(0,n-1)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3452
import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=[]
dp=[-1]*(1<<n)
dp[(1<<n)-1]=1
mod=10**9+7
for i in range(n):
  a.append(list(map(int,input().split())))

def dfs(s, cnt):
    if dp[s] != -1:
        return dp[s]
    res = 0
    for i in range(n):
        if (s >> i) & 1 == 0 and a[cnt][i] == 1:
            res += dfs(s + (1 << i), cnt+1)
    dp[s] = res % mod
    return dp[s]
  
print(dfs(0,0))

Measured memory_bytes: 64092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;cin>>A>>B;
  string S;cin>>S;
  string ans="Yes";
  for(int i=0; i<S.size(); i++){
    if(i==A){
      if(S[i]!='-')ans="No";
    }else{
      if(S[i]<'0'||S[i]>'9')ans="No";
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    N--;
    ll x=26;
    ll num=1;
    while (N>=x)
    {
        N-=x;
        x*=26;
        num++;
    }
    for (int i=0; i<num; ++i)
    {
        ll c=N/(x/26);
        N%=(x/26);
        x/=26;
        cout << ((char)('a'+c));
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;

int main()
{
	in >> S;
	if (S.length() == 3) std::reverse(S.begin(), S.end());
	out << S << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1e3+5;
const int MAXM=6e5+6;
int edge,head[MAXN],tail[MAXM],nex[MAXM];
int n,m;
double ans=1e15,dp[MAXN];
void add(int u,int v){
	edge++,nex[edge]=head[u],head[u]=edge,tail[edge]=v;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int u,v; scanf("%d%d",&u,&v);
		add(u,v);
	}
	for (int i=0;i<n;i++){
		dp[n]=0;
		for (int j=n-1;j>=1;j--){
			double num=0,sum=0,mx=0;
			for (int e=head[j];e;e=nex[e]){
				int v=tail[e];
				sum+=dp[v];
				mx=max(mx,dp[v]);
				num++;
			}
			if (j==i&&num>1){
				num--; sum-=mx;
			}
			dp[j]=sum/num+1;
		}
		ans=min(ans,dp[1]);
	}
	printf("%.6lf\n",ans);
	return 0;
}


Measured memory_bytes: 2944
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a=sc.nextInt();
		double b=sc.nextInt();
		int d=(int) (a/b);
		int r=(int) (a%b);
		double f=a/b;
		String s=new BigDecimal(f).toPlainString();
		System.out.println(d+" "+r+" "+s);
	}
}




Measured memory_bytes: 26428
# ABC 141: B – Tap Dance
s = input()

easily_odd_position = 'RUD'
easily_even_position = 'LUD'
is_easily = 'Yes'

for idx in range(len(s)):
    if s[idx] == 'R' and idx %2 == 1:
        is_easily = 'No'
    elif s[idx] == 'L' and idx % 2 == 0:
        is_easily = 'No'

print(is_easily)

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

int main() {
  
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) { cin >> d.at(i); }
  
  sort(d.begin(), d.end());
  int ans = 0;
  int t = (n / 2) - 1;
  for(int i = 1; i < 10e10; i++){
    if(d.at(t) + i <= d.at(t+1)) {
      ans++;
    } else {
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())
s = list(input())

cnt_a = 0
cnt_b = 0

for p in s:
    if p == 'a':
        if (cnt_a+cnt_b) < (a+b):
            print('Yes')
            cnt_a += 1
        else:
            print('No')
    elif p == 'b':
        if (cnt_a+cnt_b) < (a+b) and cnt_b < b:
            print('Yes')
            cnt_b += 1
        else:
            print('No')
    else:
        print('No')


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

int isprime(int x){
	int i=3,t;
	
	if(x==2){return 1;}
	
	if(x<2 || x%2==0){return 0;}
	
	t=sqrt(x);
	
	while(i<=t){
		if(x%i==0){return 0;}
		i=i+2;
	}
	
	return 1;
}

int main(void){
    int x,c=0;
	
	while((scanf("%d",&x)!=EOF)){
		if(isprime(x)==1){c++;}
	}
	
    printf("%d\n",c);
    
    return 0;
}



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

int main() {
  int a[3], cnt = 1;
  cin >> a[0] >> a[1] >> a[2];
  if (a[1] != a[0]) cnt++;
  if (a[2] != a[1] && a[2] != a[0]) cnt++;

  cout << cnt << endl;
  return 0;
}

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

int input(int *n, int *x){

	cin >> *n >> *x;
	if(*n==0 && *x==0)
		return 0;
	else
		return 1;
}

int ways(int n, int x){

	int i,j,k;
	int l=0;

	for(i=1;i<=n-2;i++){
		for(j=i+1;j<=n-1;j++){
			for(k=j+1;k<=n;k++){
				if(i+j+k == x)
					l++;
			}
		}
	}
	return l;
}

int main() {
	int n[500],x[500];
	int i=0,l;

	while(input(&n[i],&x[i]))
		i++;

	l=i;
	for(i=0;i<l;i++)
		cout << ways(n[i],x[i]) << endl;

	return 0;
}



Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A'&&s[i+1]=='C') flag=1;
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i, n;
  scanf("%d", &n);
  int h[n];
  for(i = 0; i < n; i++) {
  	scanf("%d", &h[i]);
  }
  int ans = 0;
  int val = 0;
  for(i = 1; i < n; i++) {
    if( h[i-1] >= h[i] ) val++;
    else val = 0;
    if( val > ans ) ans = val;
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ratio>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T, class U> using p = pair<T, U>;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REP1(i, n) for(int i = 1; i <= n; ++i)

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const ull MOD = 1000'000'007;

const ll NMAX = 1000;
const ll HMAX = 10000;
ll dp[NMAX + 10][HMAX + 10] = {};

ll N = 0;
ll H = 0;
ll A[NMAX] = {};
ll B[NMAX] = {};
ll COST[HMAX + 10] = {};

ll solve(ll h){
    if(h <= 0){ return 0; }
    if(COST[h] > 0){ return COST[h]; }
    ll cost = 1e15;
    for(ll i = 0; i < N; ++i){
        cost = min(cost, B[i] + solve(h-A[i]));
    }
    COST[h] = cost;
    return cost;
}

int main(){
    cin >> H >> N;
    REP(i, N){
        cin >> A[i] >> B[i];
    }
    write(solve(H));
    
}



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

int main() {
  int n, m;
  cin >> n >> m;
  if (n >= m) return cout << 0 << endl, 0;
  vector<int> x(m), d(m - 1);
  for (int i = 0; i < m; i++) cin >> x[i];
  sort(begin(x), end(x));
  for (int i = 1; i < m; i++) d[i - 1] = x[i] - x[i - 1];
  sort(begin(d), end(d));
  int ans = 0;
  for (int i = 0; i < m - n; i++) ans += d[i];
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='?') s[i]='D';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3780
import java.util.*;

public class Main {
	public static void main(String args[] ) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int n = Integer.parseInt(sc.nextLine().trim());
			if (n == 0) {
				break;
			}
			
			Map<String, String> replaceMap = new HashMap<String, String>();
			for (int i = 0; i < n; i++) {
				String[] input = sc.nextLine().split(" ");
				replaceMap.put(input[0].trim(), input[1].trim());
			}
			
			n = Integer.parseInt(sc.nextLine().trim());
			String[][] inputStrArray = new String[n][2];
			for (int j = 0; j < n; j++) {
				inputStrArray[j][0] = sc.nextLine().trim();
				inputStrArray[j][1] = "false";
			}
			
			for (int j = 0; j < n; j++) {
				if (!Boolean.valueOf(inputStrArray[j][1]) && replaceMap.containsKey(inputStrArray[j][0])) {
					inputStrArray[j][0] = replaceMap.get(inputStrArray[j][0]);
					inputStrArray[j][1] = "true";
				}
			}
			
			for (int k = 0; k < n; k++) {
				System.out.print(inputStrArray[k][0]);
			}
			System.out.println("");
		}
	}
}

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

int main(){

int n;
cin >>n;
vector<int> l(110);
rep(i,n) cin >> l[i];
int cnt=0;

for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
        for(int k=0; k<n; k++){
            //cout << 333 << endl;
            //return 0;
            bool flag=true;
            if(!(i<j && j<k)) continue;
            if(!(l[i]+l[j]>l[k])) flag=false;
            if(!(l[i]+l[k]>l[j])) flag=false;
            if(!(l[k]+l[j]>l[i])) flag=false;
            if(!(l[i]!=l[j]&& l[k]!=l[j]&& l[k]!=l[i])) flag=false;
            if(flag) cnt++;
        }
    }
}

cout << cnt << endl;

}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
	
	int n,now=0,r=0;
	string s;
	cin>>n>>s;
	
	for(int i=0;i<n;i++){
		if(s[i]=='D') now--;
		else now++;
		r=max(r,now);
	}
	
	cout<<r<<endl;
	
	return 0;
	
}

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

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here
ll rec(ll a,ll b,ll i)
{
    return (a*i)/b - a*(i/b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll a,n,b;
    cin>>a>>b>>n;
    cout<<rec(a,b,min(n,b-1))<<"\n";
    // for(int i=1;i<=n;i++)
    // {
    //     ll ans=rec(a,b,i);
    //     cout<<i<<":  "<<ans<<"\n";
    // }
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>

using namespace std;

int main(void){
  int c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  int a[2], b[2];
  for(int i = 1; i < 3; i++){
    a[i-1] = c[i][0]-c[0][0];
    b[i-1] = c[0][i]-c[0][0];
  }
  for(int i = 1; i < 3; i++){
    for(int j = 1; j < 3; j++){
      if(c[i][j]!=c[0][0]+a[i-1]+b[j-1]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_bacn
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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

int main()
{
	fast;
	int h, n;
	cin >> h >> n;
	vll dp(h + 1, 1e8 + 1);
	dp[0] = 0;
	FOR(n)
	{
		int health, point;
		cin >> health >> point;
		for (int j = 1; j <= h; j++)
		{
			chmin(dp[j], dp[max(0, j - health)] + point);
		}
	}
	cout << dp[h];
}

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

typedef pair<int,int> Node; // v,com
typedef pair<int,Node> P;  // dp[Node],Node
typedef P Edge;           // int,Node

struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return (h1<<10)^h2;
    }
};

priority_queue<P,vector<P>,greater<P>> qu;
unordered_map<Node,vector<Edge>,pair_hash> g;
unordered_map<Node,int,pair_hash> dp;

int N,M;

void dijkstra(Node start){
    qu.push({dp[start]=0,start});
    while(qu.size()){
        P pr=qu.top(); qu.pop();
        Node v = pr.second;
        if(v==make_pair(N-1,-1))return;
        if(dp[v] < pr.first)continue;

        for(Edge e:g[v]){
            Node to = e.second;
            int cost = e.first;
            if(dp.count(to)==0 || dp[to] > dp[v]+cost){
                dp[to] = dp[v]+cost;
                qu.push({dp[to],to});
            }
        }
    }
}


int main(void){
    cin>>N>>M;
    rep(i,M){
        int p,q,c;
        scanf("%d %d %d",&p,&q,&c);
        p--,q--;
        if(g.count({p,c})==0){
            g[{p,c}].push_back({0,{p,-1}});
            g[{p,-1}].push_back({1,{p,c}});
        }
        if(g.count({q,c})==0){
            g[{q,c}].push_back({0,{q,-1}});
            g[{q,-1}].push_back({1,{q,c}});
        }
        g[{p,c}].push_back({0,{q,c}});
        g[{q,c}].push_back({0,{p,c}});
    }
    dijkstra({0,-1});
    cout<<(dp.count({N-1,-1}) ? dp[{N-1,-1}] : -1)<<endl;
    return 0;
}


Measured memory_bytes: 82420
#include<stdio.h>
int main(void)
{
	int N;
	long long int s[10000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &s[i]);
	}
	int count = 0;
	while (true) {
		for (int i = 0; i < N; i++) {
			if (s[i] % 2 == 1) {
				printf("%d", count);
				return 0;
			}
			else {
				s[i] = s[i] / 2;
			}
		}
		count++;
	}
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            long ans = 0;
            for (long i = 0; i < N; i++)
            {
                ans += n2(long.Parse(s[i]));
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }

        public static long n2(long a)
        {
            long aa = a;
            long i;
            for (i = 0; i < 9999; i++)
            {
                if (aa % 2 == 1 )
                {
                    return i;
                }
                aa = aa / 2;
            }
            return i; 
        }
    }
}


Measured memory_bytes: 13792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a,b;
    cin >> a >> b;
    cout << a * b << endl;
}

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    
    if((b-a)<=0) cout << "delicious" << endl;
    else if((b-a)<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main() {
    fastIO;
    int n, m, c;
    ll rta = 0, aux;
    cin >> n >> m >> c;
    ll b[m], a[n][m];
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        aux = 0;
        for(int j = 0; j < m; j++){
            aux += b[j]*a[i][j];
        }
        aux += c;
        if(aux > 0) rta++;
    }
    cout << rta << endl;
    return 0;
}



Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

using i32 = int;
using i64 = long long;

#define REP(i, stop) for (int i = 0; i < stop; ++i)

template<typename T>
T read() {
  T a = 0;
  for(;;) {
    char c = getchar();
    if (c & 16) {
      a = a * 10 + c - 48;
    } else {
      return a;
    }
  }
}

i64 A[1000], B[1000], C[1000];
i64 AB[3000];
signed main() {
//  i32 x, y, z, k;
//  scanf("%d%d%d%d", &x, &y, &z, &k);
  i32 X = read<i32>(),
      Y = read<i32>(),
      Z = read<i32>(),
      K = read<i32>();
//  REP(i, x) scanf("%lld", &A[i]);
//  REP(i, y) scanf("%lld", &B[i]);
//  REP(i, z) scanf("%lld", &C[i]);
  REP(i, X) A[i] = -read<i64>();
  REP(i, Y) B[i] = -read<i64>();
  REP(i, Z) C[i] = -read<i64>();
  sort(A, A + X);
  sort(B, B + Y);
  sort(C, C + Z);
  using P = pair<i64, i64>;
  set<P> Q;
  Q.insert({A[0] + B[0], 0});
  i32 L = min(K, X * Y);
  i32 AB_i = 0;
  REP(_, L) {
    i64 p = (*Q.begin()).first;
    i64 q = (*Q.begin()).second;
    AB[AB_i] = p;
    ++AB_i;
    Q.erase(Q.begin());
    i32 u = q & 1023;
    i32 v = q >> 10 & 1023;
    i64 u1 = q + 1;
    i64 v1 = q + (1 << 10);
    if (u + 1 < X && (u + 1) * v < L) Q.insert({A[u + 1] + B[v], u1});
    if (v + 1 < Y && u * (v + 1) < L) Q.insert({A[u] + B[v + 1], v1});
  }
  Q.clear();
  Q.insert({AB[0] + C[0], 0});
  REP(_, K) {
    i64 p = -(*Q.begin()).first;
    i64 q = (*Q.begin()).second;
    printf("%lld\n", p);
    Q.erase(Q.begin());
    i32 u = q & 4095;
    i32 v = q >> 12 & 1023;
    i64 u1 = q + 1;
    i64 v1 = q + (1 << 12);
    if (u + 1 < L && (u + 1) * v < K) Q.insert({AB[u + 1] + C[v], u1});
    if (v + 1 < Z && u * (v + 1) < K) Q.insert({AB[u] + C[v + 1], v1});
  }
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int i, j, n, key, array[100];

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

  for(j=0; j<n; j++){
    if(j==n-1) printf("%d", array[j]);
    else printf("%d ", array[j]);
  }
  printf("\n");
  
  for(i=1; i<n; i++){
    key = array[i];
    for(j=i-1; j>=0 && array[j]>key; j--)
      array[j+1]=array[j];
    array[j+1] = key;
    for(j=0; j<n; j++){
      if(j==n-1) printf("%d", array[j]);
      else printf("%d ", array[j]);
    }
    printf("\n");
  }

  return 0;
}

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

using namespace std;

int func(int);
int count(void);

int a[10][10000],r,c;

int main(void){
  
  while(cin >> r >> c,r|c){
    for(int i=0;i<r;i++)
      for(int j=0;j<c;j++)
	cin >> a[i][j];
    
    cout << func(0) << endl;
  }
  
  return 0;
}

int func(int x){
  int res=0;

  if(x+1<r)res=func(x+1);
  res=max(res,count());

  for(int i=0;i<c;i++)
    a[x][i]= a[x][i]?0:1;
  if(x+1<r)res=max(res,func(x+1));

  return res;
}

int count(void){
  int cnt,res=0;
  
  for(int i=0;i<c;i++){
    cnt=0;
    for(int j=0;j<r;j++){
      cnt+=a[j][i];
    }
    res+=max(r-cnt,cnt);
  }
  return res;
}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  ll res=0;
  ll su=0;
  int i=0;
  while(i<n){
    int j=i;
    while(j<n && a[j]>0){
      su+=a[j];
      j++;
    }
    res+=su/2;
    su=0;
    i=j+1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct State
    {
        internal int x, y, cnt;

        public State(int x, int y, int cnt)
        {
            this.x = x;
            this.y = y;
            this.cnt = cnt;
        }
    }

    class Problem
    {
        readonly int[] moveX = new int[] { -1, 0, 1, 0 };
        readonly int[] moveY = new int[] { 0, -1, 0, 1 };
        readonly int INF = 1 << 20;
        readonly int w, h;

        int[,] map, counts;
        int sx, sy, minCnt;

        public Problem(int w, int h)
        {
            this.w = w;
            this.h = h;
            map = new int[h, w];
            counts = new int[h, w];
        }

        public int Solve()
        {
            MakeMap();
            minCnt = INF;

            Stack<State> stk = new Stack<State>();
            stk.Push(new State(sx, sy, 0));

            while (stk.Count > 0)
            {
                State cur = stk.Pop();
                counts[cur.y, cur.x] = cur.cnt;

                for (int i = 0; i < 4; i++)
                {
                    int nextX = cur.x + moveX[i];
                    int nextY = cur.y + moveY[i];

                    if (IsValid(nextX, nextY))
                    {
                        int tempCnt = cur.cnt + (map[cur.y, cur.x] == 1 ? 0 : map[nextY, nextX]);

                        if (counts[nextY, nextX] > tempCnt && tempCnt < minCnt)
                        {
                            stk.Push(new State(nextX, nextY, tempCnt));
                        }
                    }
                    else minCnt = Math.Min(minCnt, cur.cnt);
                }
            }
            return minCnt;
        }

        private bool IsValid(int x, int y)
        {
            if (x < 0 || x >= w) return false;
            if (y < 0 || y >= h) return false;
            return true;
        }

        private void MakeMap()
        {
            for (int i = 0; i < h; i++)
            {
                string input = Console.ReadLine();

                for (int j = 0; j < w; j++)
                {
                    switch (input[j])
                    {
                        case '#':
                            map[i, j] = 1;
                            break;
                        case '&':
                            sx = j;
                            sy = i;
                            break;
                    }
                    counts[i, j] = INF;
                }
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int w = int.Parse(input[0]);
                int h = int.Parse(input[1]);

                if (w == 0 && h == 0) break;

                Problem pb = new Problem(w, h);
                sb.AppendLine(pb.Solve().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10500
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,n,r,ans;
    cin >> n >> r;
    if(n<10)
    {
        r+=100*(10-n);
    }
    cout << r ;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	sort.Sort(sort.Float64Slice(list))
	value := list[0]
	for i := 1; i < n; i++ {
		value = (value + list[i]) / 2
	}
	fmt.Println(value)

}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, A, B := nextInt(), nextInt(), []string{}, []string{}

	for i := 0; i < N; i++ {
		A = append(A, nextLine())
	}
	for i := 0; i < M; i++ {
		B = append(B, nextLine())
	}

	fmt.Printf("%s\n", ABC054B(A, B))
}

// ABC054B ...
func ABC054B(A, B []string) string {
	if len(A) == len(B) {
		if checkUnderRect(A, B, 0, 0) {
			return "Yes"
		}
	} else {
		for i := 0; i < len(A)-len(B); i++ {
			for j := 0; j < len(A[i])-len(B); j++ {
				if A[i][j:j+len(B)] == B[0] {
					if checkUnderRect(A, B, i, j) {
						return "Yes"
					}
				}
			}
		}
	}
	return "No"
}

func checkUnderRect(A, B []string, i, j int) bool {
	for k := 1; k < len(B); k++ {
		ak := k + i
		if A[ak][j:j+len(B)] != B[k] {
			return false
		}
	}

	return true
}


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

int main() {
  int N; cin >> N;
  vector<int>a(N);
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    a[i]--;
  }
  
  int p = 0;
  int res = 0;
  bool undone = true;
  while(res < 10 * N) {
    res++;
    p = a[p];
    if(p == 1){
      undone = false;
      break;
    }
  }
  
  if(undone) cout << -1 << endl;
  else cout << res << endl;
}


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


int main(){
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> m.at(i);
    sum += m.at(i);
  }
  sort(ALL(m));
  int result = N + (X - sum) / m.at(0);
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M1 ((ll)1e9)
#define M 998244353
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;

void solve(){
    int n,m;string s;
    cin>>n>>m>>s;int t;vector<int> v;reverse(s.begin(),s.end());
    for(int i=0;i<n;)
    {
        t=i;
        for(int j=i+1;j<=i+m&&j<n+1;j++)
        {
            if(s[j]=='0')
            t=j;
        }
        if(t==i)
        {
            cout<<-1<<endl;return;
        }
        else
        {
            v.pb(t-i);
            i=t;
        }
    }
    for(int i=v.size()-1;i>-1;i--)
    cout<<v[i]<<" ";
    cout<<endl;
}

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

Measured memory_bytes: 1144