akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_126_A___Changing_a_Character
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, K;
            string S;
            var M = Console.ReadLine().Split(' ');
            N = int.Parse(M[0]);
            K = int.Parse(M[1]);
            Console.WriteLine();
            S = Console.ReadLine();
           

            char[] cs = S.ToCharArray();
            if (cs[K - 1] == 'A')   cs[K-1] = 'a';
            else if (cs[K - 1] == 'B') cs[K - 1] = 'b';
            else cs[K - 1] = 'c';
            Console.WriteLine(cs);
            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 11092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC098_C solver = new ABC098_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC098_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            String str = in.next();

            int cntE = 0;
            int cntW = 0;

            int ans = Integer.MAX_VALUE;
            for (char c : str.toCharArray()) {
                if (c == 'E') cntE++;
                if (c == 'W') cntW++;
            }

            //リーダーの左で、Wを向いている人
            int leftChange = 0;
            //リーダーの右で、Eを向いている人
            int rightChange = cntE;

            for (char c : str.toCharArray()) {
                if (c == 'E') {
                    rightChange--;
                }
                ans = Math.min(ans, leftChange + rightChange);
                //cをリーダーに任命する
                if (c == 'W') {
                    leftChange++;
                }
            }

            out.print(ans);

        }

    }
}



Measured memory_bytes: 29524
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m,f[10005][4][2];
char ch[10005];
int dfs(int x,int y,int c){
    if(y>m)return 0;
    if(x>n)return y==m;
    if(f[x][y][c]!=-1)return f[x][y][c];
    int ok=c==1?ch[x]-'0':9;
    int sum=0;
    for(int i=0;i<=ok;i++)sum+=dfs(x+1,y+(i!=0),c&&i==ok);
    return f[x][y][c]=sum;
}
int main(){
    memset(f,-1,sizeof(f));
	scanf("%s",ch+1);
    in(m);
    n=strlen(ch+1);
    cout<<dfs(1,0,1)<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll k; cin >> k;
    ll a[n];
    rep(i,n)cin >> a[i];
    ll b[n];
    rep(i,n)cin >> b[i];
    sort(b,b+n);
    sort(a,a+n,greater<ll>());

    ll l = 0;
    ll r = 1001001001001001;

    while(l < r){
        ll m = (l + r) / 2;
        ll cnt = 0;
        rep(i,n){
            ll x = m / b[i];
            if(x < a[i]){
                cnt += a[i] - x;
            }
        }
        if(cnt <= k){
            r = m;
        }else{
            l = m + 1;
        }
    }
    cout << l << endl;
    return 0;
}
 
 


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        String s = obj.next(),t = obj.next();
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)!=t.charAt(i) || s.length()+1!=t.length())
            {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 32816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int M = 1e6 + 7;
const int INF = 1e9 + 7;
int a[1001];
int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        if((a[i] * 4 * m) >= sum)
            ans ++;
    }
    if(ans >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long n, a, mae, add=0;
    scanf("%lld", &n);
    scanf("%lld", &mae);
    for(int i=0; i<n-1; i++){
        scanf("%lld", &a);
        if(mae>a) add += mae-a;
        else mae = a;
    }
    printf("%lld", add);
    return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#define loop(i,n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define INF 999999999;
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
#define ll long long int 

using namespace std;

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])ans("YES");
	else ans("NO");
}

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

int main(){
    while(1){
        string n;
        cin >> n;
        if(n=="0") break;

        int ans=0;
        for(int i=0; i<(int)n.length(); i++){
            ans += n[i]-'0';
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3172
#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;

LL N,cou;

bool check(LL n)
{
	for (LL i = 2; i <= sqrt(n); ++i)
	{
		if (n%i == 0) return false;
	}
	return true;
}

int main()
{
	in >> N;
	for (LL i = 2; i <= 55555; ++i)
	{
		if (check(i) && i % 5 == 1)
		{
			++cou;
			out << i << (cou < N ? " " : "\n");
			if (cou == N) return 0;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int n,x,y,z;
int dp[50][(1<<18)];
int main(){
	scanf("%d%d%d%d",&n,&x,&y,&z);
	int xx=1;
	for(register int i=1;i<=n;i++)xx=1ll*xx*10%mod;
	int final=(1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
	int ma=(1<<(x+y+z))-1;
	dp[0][0]=1;
	//cout<<final<<endl;
	for(register int i=1;i<=n;i++){
		for(register int j=0;j<=ma;j++){
			for(register int k=1;k<=10;k++){
				int sta=(j<<k)|(1<<(k-1));
				sta&=ma;
				if((sta&final)!=final)dp[i][sta]=(dp[i][sta]+dp[i-1][j])%mod;
			}
		}
	}
	int ans=xx;
	for(register int i=0;i<=ma;i++){
		if((i&final)!=final)ans=(ans-dp[n][i])%mod;
	}
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 41728
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  x -= ((x/b) * b);
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////
int n;
int k;
int d[11];
vector<int>ans;
vector<int>key;
void dfs(int x,int cnt) {
	if (cnt >= 10)return;
	if (x >= n) {
		key.push_back(x);
		return;
	}
	for (int i = 0; i < ans.size(); ++i) {
		dfs(x * 10 + ans[i],cnt+1);
	}
}
int main() {
	cin >> n >> k;
	for (int i = 0; i < k; ++i)cin >> d[i];
	for (int i = 0; i <= 9; ++i) {
		bool ok = true;
		for (int j = 0; j < k; ++j) {
			if (i == d[j]) {
				ok = false;
				break;
			}
		}
		if (ok)ans.push_back(i);
	}
	dfs(0,0);
	sort(key.begin(), key.end());
	for (int i = 0; i < key.size(); ++i) {
		if (key[i] >= n) {
			cout << key[i] << endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
  int a, b, c, d, e, k; 
  cin >> a >> b >> c >> d >> e >> k;

  bool flg = true;
  if(b - a > k || c - a > k || d - a > k || e - a > k){
    flg = false;
  }
  if(c - b > k || d - b > k || e - b > k){
    flg = false;
  }
  if(d - c > k || e - c > k){
    flg = false;
  }
  if(d - e > k){
    flg = false;
  }

  string result = "";
  if(flg){
    result = "Yay!";
  }
  else
  {
    result = ":(";
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		String s = S.substring(K-1, K);
		if (s.equals("A")) {
			s = "a";
		}else if (s.equals("B")) {
			s="b";
		}else {
			s="c";
		}

		System.out.println(S.substring(0,K-1)+s+S.substring(K,N));
	}
}


Measured memory_bytes: 20692
INF=10**15
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[INF for i in range(N)]
dp[0]=0
for i in range(1,N):
    k=1
    while i-k>-1 and k<=K:
        dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
        k+=1
print(dp[N-1])

Measured memory_bytes: 56544
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  map<ll,ll> p;
  vector<ll> q(n);
  
  rep(i,n){
  cin>>q[i];
    if(p.count(q[i])) p.at(q[i])++;
    else p[q[i]]=1;
  }
  
  ll ans=0;
  for(auto x: p){
    ans+=x.se*(x.se-1)/2;
  }
  
  rep(i,n){
  ll x=p.at(q[i]);
  cout << ans-(x-1) << endl;
  }
  
}


Measured memory_bytes: 12288
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		boolean p[] = new boolean[(1 << 15)+1];

		Arrays.fill(p, true);
		p[0] = false;
		p[1] = false;

		for (int i = 0; i < 1 << 8; i++) {
			if (p[i]) {
				for (int j = i + i; j < (1 << 15)+1; j += i) {
					p[j] = false;
				}
			}
		}

		int c = 0;
		for (int i = 0; i < (1 << 15)+1; i++) {
			c++;
		}
		int pr[] = new int[c];

		int c2 = 0;
		for (int i = 0; i <(1 << 15)+1; i++) {
			if (p[i]) {
				pr[c2] = i;
				c2++;
			}
		}

		int dp[] = new int[(1 << 15)+1];
//		System.out.println(Arrays.toString(pr));
		
		for (int i = 0; i < c; i++) {
			for (int j = i ; j<c&&pr[i] + pr[j] <= 1<<15; j++) {
				
				dp[pr[i] + pr[j]]++;
			}
		}

		
		for(;;){
			int n  =sc.nextInt();
			
			if(n==0){
				break;
			}
			System.out.println(dp[n]);
		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

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

void sort(int &a, int &b){
	int buff;
	buff = a;
	a = b;
	b = buff;
}

int main()
{
	int a, b, c;
	int num[3];
	cin >> a >> b >> c;
	num[0] = a;
	num[1] = b;
	num[2] = c;
	while(true){
		if(num[0] <= num[1] && num[1] <= num[2])
			break;
		if(num[0] >= num[1]){
			sort(num[0], num[1]);
		}
		if(num[0] >= num[2]){
			sort(num[0], num[2]);
		}
		if(num[1] >= num[2]){
			sort(num[1], num[2]);
		}
	}

	cout << num[0] << " " << num[1] << " " << num[2] << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll x,k;cin>>x>>k;
  vector<ll> r(k+1);r[0]=0;for(ll i=1;i<=k;i++)cin>>r[i];
  ll d[k],u[k],da[k],ua[k];
  d[0]=0;
  da[0]=0;
  u[0]=x;
  ua[0]=x;
  for(ll i=1;i<=k;i++){
    ll t=r[i]-r[i-1];
    //cout<<t<<endl;
    if(i%2==0){
      if(da[i-1]+t>=x){
        d[i]=x;
        da[i]=x;
        u[i]=x;
        ua[i]=x;
      }
      else{
        da[i]=da[i-1]+t;
        d[i]=d[i-1];
        ua[i]=ua[i-1]+t;
        u[i]=u[i-1];
        if(ua[i]>=x){
          u[i]=u[i-1]-(ua[i]-x);
          ua[i]=x;
        }
      }
    }
    else{
      if(ua[i-1]-t<=0){
        d[i]=0;
        da[i]=0;
        u[i]=0;
        ua[i]=0;
      }
      else{
        da[i]=da[i-1]-t;
        d[i]=d[i-1];
        ua[i]=ua[i-1]-t;
        u[i]=u[i-1];
        if(da[i]<=0){
          d[i]=d[i]-da[i];
          da[i]=0;
        }
      }
    }
  }
  for(ll i=0;i<=k;i++){
    //cout<<d[i]<<" "<<da[i]<<" "<<u[i]<<" "<<ua[i]<<endl;
  }//return 0;
  ll q;cin>>q;
  for(ll i=0;i<q;i++){
    ll t,a;cin>>t>>a;
    ll e=upper_bound(r.begin(),r.end(),t)-r.begin();
    ll now;
    if(a<=d[e-1])now=da[e-1];
    else if(a>=u[e-1])now=ua[e-1];
    else now=a-d[e-1]+da[e-1];
    if(e%2==1){
      now-=t-r[e-1];
      now=max((ll)0,now);
    }
    else{
      now+=t-r[e-1];
      now=min(x,now);
    }
    cout<<now<<endl;
  }
}

Measured memory_bytes: 6400
struct Spell {
    t: char,
    d: char,
}

#[derive(PartialEq, Debug)]
enum GolemStat {
    Alive,
    DeadLeft,
    DeadRight,
}

// Pマス目のゴーレムが生き残るかチェックする。
fn check_golem_stat(
    mut p: usize,
    n: usize,
    s: &Vec<char>,
    spells: &Vec<Spell>
) -> GolemStat {
    for &Spell{t, d} in spells.iter() {
        if t != s[p] {
            continue;
        }

        if p == 0 && d == 'L' {
            return GolemStat::DeadLeft;
        }
        if p == n-1 && d == 'R' {
            return GolemStat::DeadRight;
        }

        p = if d == 'L' {p-1} else {p+1};
    }

    GolemStat::Alive
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let s = buf.trim().chars().collect::<Vec<char>>();

    let mut spells = Vec::new();
    for _ in 0..q {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.chars();
        let t: char = iter.next().unwrap();
        let _: char = iter.next().unwrap();
        let d: char = iter.next().unwrap();

        spells.push(Spell{t: t, d: d});
    }

    /*
    for i in 0..n {
        println!("{}:{:?}", i, check_golem_stat(i, n, &s, &spells));
    }
    // */

    let mut lb = -1;
    let mut ub = n as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        // println!("lb:{}, ub:{}, mid:{}", lb, ub, mid);
        let stat = check_golem_stat(mid as usize, n, &s, &spells);
        if stat == GolemStat::DeadLeft {
            lb = mid as isize;
        }
        else {
            ub = mid as isize;
        }
    }
    let dead_left = (lb + 1) as usize;

    let mut lb = -1;
    let mut ub = n as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        // println!("lb:{}, ub:{}, mid:{}", lb, ub, mid);
        let stat = check_golem_stat(mid as usize, n, &s, &spells);
        if stat == GolemStat::DeadRight {
            ub = mid as isize;
        }
        else {
            lb = mid as isize;
        }
    }
    let dead_right = n - (ub as usize);

    println!("{}", n - dead_left - dead_right);
}


Measured memory_bytes: 8444
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable long inf = 3L * 10L^^18;

void main() {
    int n, k;
    scan(n, k);
    auto w = new long[](n);
    auto d = new long[](n);

    foreach (i ; 0 .. n) {
        scan(w[i], d[i]);
    }

    bool check(long x) {
        long hana;

        foreach (i ; 0 .. n) {
            if (x - w[i] >= 0) {
                hana += (x - w[i]) / d[i] + 1;
            }
        }

        return hana >= k;
    }

    long btm = 0, top = inf;

    while (top - btm > 1) {
        long mid = btm + (top - btm) / 2;

        if (check(mid)) {
            top = mid;
        }
        else {
            btm = mid;
        }
    }

    writeln(top);
}

void solve(int n, int v, int w) {
    if (n == 1) {
        writeln(min(v, w));
        return;
    }

    auto va = new int[](0);
    va ~= v;

    while (v > 1) {
        if (v % n <= 1) {
            v /= n;
        }
        else {
            v = (v / n) + 1;
        }

        va ~= v;
    }

    va.reverse();

    auto wa = new int[](0);
    wa ~= w;

    while (w > 1) {
        if (w % n <= 1) {
            w /= n;
        }
        else {
            w = (w / n) + 1;
        }

        wa ~= w;
    }

    wa.reverse();

    debug {
        writeln(va);
        writeln(wa);
    }

    int ans = 0;

    while (!va.empty) {
        while (!wa.empty) {
            if (va.front == wa.front) {
                ans = max(ans, va.front);
                va.popFront;
                wa.popFront;
                break;
            }
            else if (va.front < wa.front) {
                va.popFront;
                break;
            }
            else {
                wa.popFront;
            }
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main(){
  int n;
  while(cin>>n,n){
    int a[1001];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    
    int ans=1e9;
    for(int i=1;i<n;i++)ans=min(ans,a[i]-a[i-1]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
 
  if (S == "a" ){
	cout << "vowel" << endl;
  }
  else if (S == "i"){
	cout << "vowel" << endl;
  }
  else if (S == "u"){
	cout << "vowel" << endl;
  }
  else if (S == "e"){
	cout << "vowel" << endl;
  }
  else if (S == "o"){
	cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3616
fn main() {
    let s = read_line();
    let s = read_num_vec(s, 2);
    let n = s.get(0).unwrap().to_owned();
    let k = s.get(1).unwrap().to_owned();
    let mut snack_info_vec = vec![];
    for _ in 0..k {
        let s = read_line();
        let d = read_num_vec(s, 1).get(0).unwrap().to_owned();
        let s = read_line();
        let a_vec = read_num_vec(s, d as usize);
        snack_info_vec.push(a_vec);
    }
    let mut num_snack = vec![];
    for _ in 0..n {
        num_snack.push(0);
    }
    for snack_info in snack_info_vec {
        for snack_index in snack_info {
            let num = num_snack.get_mut((snack_index - 1) as usize).unwrap();
            *num += 1;
        }
    }

    let mut sunuke = 0;
    for num in num_snack {
        if num == 0 {
            sunuke += 1;
        }
    }

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

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().to_owned()
}

fn read_num_vec(s: String, length: usize) -> Vec<i64> {
    let mut ws = s.split_whitespace();
    let mut result = vec![];
    for _ in 0..length {
        result.push(ws.next().unwrap().parse().unwrap());
    }
    result
}


Measured memory_bytes: 2196
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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 my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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



const long long INF = 1LL << 60;

int main() {
    
    string S, T;
    cin >> S >> T;
    int N, M;
    cin >> N >> M;
    string U;
    cin >> U;
    if (U == S) {
        cout << N - 1 << " " << M << endl;
    }
    else {
        cout << N << " " << M - 1 << endl;
    }
}



Measured memory_bytes: 256
#include<stdio.h>

void leap_year(int start_year, int end_year);

int main(void)
{
 int start_year;
 int end_year;
   int i = 0;
   while(1){
   scanf("%d %d", &start_year, &end_year);
   if (start_year == 0 && end_year == 0) {
     break;
  } else {
    if ( i == 1) {
      printf("\n");
  }
    leap_year(start_year, end_year);
    i = 1;
   }
   }
   return 0;
}

void leap_year(int start_year, int end_year)
{
 int n = 0;
 int year = start_year;
   while (year <= end_year){
     if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)){
     printf("%d\n", year);
     n++;
   }
     year++;
 }
 if (n == 0){
   printf("NA\n");
  }
}

 

Measured memory_bytes: 1048
# 2020/01/26
# AtCoder Beginner Contest 153 - C

# Input
n, k = map(int,input().split())
h = list(map(int,input().split()))

# Sort Desc.
h.sort()
h.reverse()

if k >= n:
    ans = 0
else:
    sum = 0
    for i in range(k, n):
        sum = sum + h[i]
    
    ans = sum

# Output
print(ans)


Measured memory_bytes: 26024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int h,a;
  cin >> h >> a;
  cout << ceil(h,a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int N;
    cin >> N;
    
    double v[N];
    rep(i,N) cin >> v[i];
    
    sort(v,v + N);
    
    double ans = 0;
    rep(i,N - 1){
        ans += (v[i] + v[i + 1]) / 2.0;
        v[i + 1] = (v[i] + v[i + 1]) / 2.0;
    }
    
    cout << v[N - 1] << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)
 

int main()
{
    
    ll n;
    string s;
    cin>>n>>s;

    forn(i,s.length())
    {
        ll ascii = int(s[i]);
        ascii += n;
        if(ascii>90)
        {
            ascii-=91;
            ascii+=65;
        }
        char c = ascii;
        cout<<c;
    }
    
    return 0;
}

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

int main(){
	int n;
	while(cin>>n,n){
		int ans=0;
		int head=1,tail=2,sum=1;
		while(2*head<n){
			while(sum<n)sum += tail++;
			if(sum==n)ans++;
			sum -= head++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;

typedef vector<int> vec;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)

int N,M,C;


int main() {
  cin >> N>>M>>C; 
  vec B(M);
  rep(i,M) cin >> B.at(i);
  vector<vec> A(N,vec(M));
  rep(i,N) {
    rep(j,M) cin >> A.at(i).at(j);
  }
  
  int ans = 0, left = 0;
  rep(i,N){
    left = 0;
    rep(j,M) left += A.at(i).at(j)*B.at(j);
	if(left + C > 0) ans++;
  }
  
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  std::string s;
  int q;
  std::cin >> s >> q;

  std::string a[2];
  bool isReverse = false;
  for (int i = 0; i < q; ++i) {
    int t,f;
    char c;
    std::cin >> t;
    if (t == 2) {
      std::cin >> f >> c;
      if (f == 2) {
        if (isReverse) {
          a[0].append(1, c);
        } else {
          a[1].append(1, c);
        }
      } else {
        if (isReverse) {
          a[1].append(1, c);
        } else {
          a[0].append(1, c);
        }
      }
    } else {
      isReverse = !isReverse;
    }
  }

  std::reverse(a[0].begin(), a[0].end());
  auto ret = a[0] + s + a[1];
  if (isReverse) {
    std::reverse(ret.begin(), ret.end());
  }

  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 1348
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

ll b[101] = {};
int main() {
	ll n; cin >> n;
	repe(i, 1, n)cin >> b[i];

	vector<ll> v;
	ll k = n;

	while (1) {
		bool update = false;
		rep_re(i, 1, k) {
			if (i == b[i]) {
				v.push_back(i);
				rep(j, i, n) {
					b[j] = b[j + 1];
				}
				update = true;
				break;
			}
		}
		if (!update) {
			cout << -1 << endl;
			return 0;
		}
		k--;
		if (v.size() == n)break;
	}

	reverse(v.begin(), v.end());
	rep(i, 0, n) {
		cout << v[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<ll> B(A);
  REP(i, N) B[i] = abs(B[i]);
  REP(i, N - 1) {
    if (A[i] < 0) {
      A[i] *= -1;
      A[i + 1] *= -1;
    }
  }

  ll ans = 0;
  REP(i, N) ans += B[i];
  if (A.back() < 0) {
    ans -= 2*(*min_element(ALL(B)));
  }
  cout << ans << endl;
  
  return 0;
}

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

int d[2000][2000];
int main() {
  int n, x, y;
  cin>>n>>x>>y;
  --x;
  --y;
  if (y > x) {
    swap(x, y);
  }
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      d[i][j] = abs(i - j);
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      int tmp;
      int s = i;
      int t = j;
      if (t > s) {
        swap(s, t);
      }
      if (s == x && t == y) {
        d[i][j] = 1;
      } else if (s != x && t != y) {
        tmp = d[s][x] + 1 + d[t][y];
      } else if (s == x) {
        tmp = 1 + d[t][y];
      } else {
        tmp = d[s][x] + 1;
      }
      if (tmp < d[i][j]) {
        d[i][j] = tmp;
      }
    }
  }
  // for (int i=0; i<n; i++) {
  //   for(int j=0; j<n; j++) {
  //     printf("%2d ", d[i][j]);
  //   }
  //   cout<<endl;
  // }
  map<int, int> m;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      ++m[d[i][j]];
    }
  }
  for (int i=1; i<n; i++) {
    cout<<m[i]/2<<endl;
  }
}

Measured memory_bytes: 16000
#include <stdio.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std ;

struct Node
{
	int P ;
	int C ;
	Node ( ) { }
	Node ( int a , int b )
	{
		P = a ;
		C = b ;
	}
	bool operator < ( const Node &a ) const
	{
		return C > a.C ;
	}
} ;

vector < int > ListofRoad [110] ;
vector < int > ListofTime [110] ;
vector < int > ListofCost [110] ;

int CostAns [110][110] ;
int TimeAns [110][110] ;
bool vis[110] ;

void init ( ) ;
void Dijkstra ( int , int , int ) ;

int main ( )
{
	int n ;
	int m ;
	while ( scanf ( "%d %d" , &n , &m ) == 2 && ( n || m ) )
	{
		init ( ) ;
		for ( int i = 0 ; i < n ; i++ )
		{
			int a ;
			int b ;
			int c ;
			int d ;
			scanf ( "%d %d %d %d" , &a , &b , &c , &d ) ;
			ListofRoad[a].push_back ( b ) ;
			ListofCost[a].push_back ( c ) ;
			ListofTime[a].push_back ( d ) ;
			ListofRoad[b].push_back ( a ) ;
			ListofCost[b].push_back ( c ) ;
			ListofTime[b].push_back ( d ) ;
		}
		int Q ;
		scanf ( "%d" , &Q ) ;
		while ( Q-- )
		{
			int p ;
			int q ;
			int r ;
			scanf ( "%d %d %d" , &p , &q , &r ) ;
			if ( r == 0 )
			{
				if ( CostAns[p][q] == -1 )
				{
					Dijkstra ( p , m , 1 ) ;
				}
				printf ( "%d\n" , CostAns[p][q] ) ;
			}
			else
			{
				if ( TimeAns[p][q] == -1 )
				{
					Dijkstra ( p , m , 0 ) ;
				}
				printf ( "%d\n" , TimeAns[p][q] ) ;
			}
		}
	}
	return 0 ;
}

void init ( )
{
	for ( int i = 0 ; i < 110 ; i++ )
	{
		ListofRoad[i].clear ( ) ;
		ListofTime[i].clear ( ) ;
		ListofCost[i].clear ( ) ;
	}
	memset ( CostAns , -1 , 110 * 110 * sizeof ( int ) ) ;
	memset ( TimeAns , -1 , 110 * 110 * sizeof ( int ) ) ;
}

void Dijkstra ( int source , int m , int type )
{
	memset ( vis , false , 110 * sizeof ( bool ) ) ;
	priority_queue < struct Node > pQ ;
	if ( type == 0 )
	{
		TimeAns[source][source] = 0 ;
	}
	else
	{
		CostAns[source][source] = 0 ;
	}
	pQ.push ( Node ( source , 0 ) ) ;
	for ( int i = 1 ; i <= m ; i++ )
	{
		struct Node var = ( struct Node ) { -1 , -1 } ;
		while ( pQ.empty ( ) == false && vis[( var = pQ.top ( ) ).P] == true )
		{
			pQ.pop ( ) ;
		}
		if ( var.P == -1 )
		{
			break ;
		}
		vis[var.P] = true ;
		if ( type == 0 )
		{
			vector < int > :: iterator iu = ListofTime[var.P].begin ( ) ;
			for ( vector < int > :: iterator it = ListofRoad[var.P].begin ( ) ;
				it != ListofRoad[var.P].end ( ) ;
				it++ , iu++ )
			{
				if ( vis[*it] == false )
				{
					if ( TimeAns[source][*it] == -1 || ( TimeAns[source][*it] > var.C + *( iu ) ) )
					{
						TimeAns[source][*it] = var.C + *( iu ) ;
						pQ.push ( Node ( *it , TimeAns[source][*it] ) ) ;
					}
				}
			}
		}
		else
		{
			vector < int > :: iterator iu = ListofCost[var.P].begin ( ) ;
			for ( vector < int > :: iterator it = ListofRoad[var.P].begin ( ) ;
				it != ListofRoad[var.P].end ( ) ;
				it++ , iu++ )
			{
				if ( vis[*it] == false )
				{
					if ( CostAns[source][*it] == -1 || ( CostAns[source][*it] > var.C + *( iu ) ) )
					{
						CostAns[source][*it] = var.C + *( iu ) ;
						pQ.push ( Node ( *it , CostAns[source][*it] ) ) ;
					}
				}
			}
		}
	}
}

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

int main() {
      int H, W, A, B;
      cin >> H >> W >> A >> B;

      for (int i = 0; i < B; i++) {
            for (int j = 0; j < W; j++) {
                  if(j < A) {
                        cout << 1;
                  }
                  else {
                        cout << 0;
                  }
            }
            cout << endl;
      }
      for (int i = 0; i < H - B; i++) {
            for (int j = 0; j < W; j++) {
                  if(j >= A) {
                        cout << 1;
                  }
                  else {
                        cout << 0;
                  }
            }
            cout << endl;
      }
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;


int main()
{
	string str,str2[200000],strmemo="";
	long long int n, m=1, a[2000000], b[20] = {}, c, d, e, f, now[200][200] = {}, x[200006], y[200006], X = 0, Y = 0;
	const long long int mod = 1000000007;
	
	cin >> n;
	while (n != 1) {
		n /= 2;
		m *= 2;
	}
	cout <<m<<endl;
	
}


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

int main() {
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s.at(i)=='9'){
      cout<< "Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3524
from decimal import Decimal, getcontext
a,b,c = input().split()
getcontext().prec = 10000
a = Decimal(a).sqrt()
b = Decimal(b).sqrt()
c = Decimal(c).sqrt()
if a+b+Decimal('0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') < c:
	print('Yes')
else:
  	print('No')


Measured memory_bytes: 5076
#include <stdio.h>

void swap( int *x, int *y ){
  int temp = 0;
  temp = *x;
  *x = *y;
  *y = temp;
}


int main(void){
  int a, b, c;
  
  scanf( "%d", &a );
  scanf( "%d", &b );
  scanf( "%d", &c );
  
  swap( &a, &b );
  swap( &a, &c );
  
  printf( "%d %d %d\n", a, b, c );
  return 0;
}

Measured memory_bytes: 128
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 1e9 + 7;

int n;
vector<vector<int>> g;

inline int add(int a, int b) {
    a += b;
    if (a >= mod)a -= mod;
    return a;
}

inline int mul(int a, int b) {
    return a * b % mod;
}

pair<int, int> dfs(int u, int p) {
    // current node coloured black or white
    int white = 1, black = 1;
    for (int v:g[u]) {
        if (v != p) {
            pair<int, int> res = dfs(v, u);
            white = mul(white, res.first + res.second);
            black = mul(black, res.first);
        }
    }
    return {white, black};
}

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

    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    auto ans = dfs(0, -1);
    cout << add(ans.first, ans.second) << endl;
}

Measured memory_bytes: 12672
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
    for j in range(a):
        for i in range(b):
            if j==0 or i==0 or j==a-1 or i==b-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n,h,w;
  cin>>n>>h>>w;
  ll ans=0;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    ans+=(a>=h&&b>=w);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*
* 素因数分解
* @param [in] n   自然数
* @param [in] out 素因数分解した数が入る
*/
template<typename T>
void PrimeFactors(T n, std::map<T,T> &out)
{
	while (n % 2 == 0)
	{
		++out[2];
		n = n / 2;
	}

	for (T i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n%i == 0)
		{
			++out[i];
			n = n / i;
		}
	}

	if (n > 2)
		++out[n];
}



int main(void){ 
    ll n,m;cin>>n>>m;
    priority_queue<ll> q;
    rep(i,n){
        ll k;cin>>k;
        q.push(k);
    }
    rep(i,m){
        ll ma=q.top()/2;
        q.pop();
        q.push(ma);
    }
    ll sum=0;
    while(q.size()!=0){
        sum+=q.top();
        q.pop();
    }
    cout<< sum << endl;
}



Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

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

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

const int MAX_N = 1e5 + 10;
const ll INF = 1LL << 50;

ll A[MAX_N], dp[MAX_N][2][2];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 1; i <= N ; i++) cin >> A[i];
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) dp[i][j][k] = -INF;
        }
    }
    for (int i = 1; i <= N; i++) {
        ll tmp = 0;
        if (dp[i - 1][0][0] > -INF) tmp = dp[i - 1][0][0];
        if (dp[i - 1][1][0] > -INF) tmp = max(tmp, dp[i - 1][1][0]);
        dp[i][0][0] = tmp + A[i];
        if (i > 1) {
            tmp = 0;
            if (dp[i - 1][0][1] > -INF) tmp = dp[i - 1][0][1];
            if (dp[i - 1][1][1] > -INF) tmp = max(tmp, dp[i - 1][1][1]);
            dp[i][1][0] = tmp - A[i];
        }
        if (i == N) break;
        tmp = 0;
        if (dp[i - 1][0][0] > -INF) tmp = dp[i - 1][0][0];
        if (dp[i - 1][1][0] > -INF) tmp = max(tmp, dp[i - 1][1][0]);
        dp[i][0][1] = tmp - A[i];
        if (i > 1) {
            tmp = 0;
            if (dp[i - 1][0][1] > -INF) tmp = dp[i - 1][0][1];
            if (dp[i - 1][1][1] > -INF) tmp = max(tmp, dp[i - 1][1][1]);
            dp[i][1][1] = tmp + A[i];
        }
    }
    cout << max(dp[N][0][0], dp[N][1][0]) << endl;
    return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        for (int i = 1; i <= x; i++) {
            int max = i * (i+1) / 2;
            if (x <= max) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(1);
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n; cin >> n;
    vector<ll> A(n); cin >> A;
    ll M = 0, ans = 0;
    EACH(a, A) {
        ll cnt = (a-1)/(M+1);
        a -= (M+1) * cnt;
        if (cnt > 0) {
            a = 1;
        }
        ans += cnt;
        M = max(M, a);
    }
    cout << ans << endl;
}


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

int h,n;
vector<ll> a(1000);
vector<ll> b(1000);
typedef vector<ll> ve;
vector<ve> dp(1010,ve(10010));
ll INF_H = 9223372036854775807;

void solve();
int main(){
  cin >> h >> n;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    cin >> b.at(i);
  }
  for(int i=0;i<=h;i++){
    dp[0][i]=INF_H;
    ll count = i/a.at(0);
    if(i%a.at(0)==0){
      dp[1][i]=count*b.at(0);
    }
    else{
      dp[1][i]=(count+1)*b.at(0);
    }
  }
  solve();
}

void solve(){
  for(int i=1;i<n;i++){
    for(int j=0;j<=h;j++){
      if(j==0){
        dp[i+1][j]=0;
      }
      else if(j-a.at(i)<0){
        dp[i+1][j]=min(dp[i][j],b.at(i));
      }
      else{
        dp[i+1][j]=min(dp[i][j],dp[i+1][j-a.at(i)]+b.at(i));
      }
    }
  }
  
  cout << dp[n][h] << endl;
}

Measured memory_bytes: 81408
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
using namespace std;


int main(){

    string S;
    cin>>S;

    if(S=="Sunny"){
        //std::cout<<"Cloudy";
        std::cout<<"Cloudy";
    }
    if(S=="Cloudy"){
        std::cout<<"Rainy";
    }
    if(S=="Rainy"){
        std::cout<<"Sunny";
    }
    //cin>>a>>b>>x;
    //scanf("%d%s%d",&i,&x,&j);


       // printf("%d",i+j);
       //cout<<i+j<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s;
    vector<int> num(26, 0);

    while (cin >> s)
    {
        rep(i, s.size())
        {
            if ('a' <= s[i] && s[i] <= 'z')
            {
                num[s[i] - 'a']++;
            }
            else if ('A' <= s[i] && s[i] <= 'Z')
                num[s[i] - 'A']++;
        }
        
    }

    char a = 'a';
    rep(i, 26)
    {
        printf("%c : %d\n", a + i, num[i]);
    }

    return 0;
}



Measured memory_bytes: 3276
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define MAX 1100

int temp[MAX][MAX];
int main(){
	int q;
	string x, y;
	
	cin>>q;
	
	for(int i = 1; i <= q; i++){
		cin>>x>>y;
		int sx = x.size() ,sy = y.size();
		for(int j = 0; j <= sx; j++)for(int k = 0; k <= sy; k++)temp[j][k] = 0;
		for(int j = 0; j < sx; j++){
			for(int k = 0; k < sy; k++){
				if(x[j] == y[k]){
					temp[j+1][k+1] = max(temp[j][k]+1,temp[j+1][k+1]);
				} else temp[j+1][k+1] = max(temp[j+1][k],temp[j][k+1]);
			}
		}
		cout<<temp[sx][sy]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 7412