akhauriyash/Code-Regression huggingface dataset:
n,k = gets.split.map(&:to_i)
s = gets.split.map(&:to_i).sort

if s.inject(:+) == k
  puts n
else
  ans = 0
  n.times do |i|
    if k >= s[i]
      ans += 1
      k -= s[i]
    else
      break
    end
  end
  puts [ans,n-1].min
end


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    string s;
    cin >> s;

    string ans;
    for (auto c: s) {
        if (c == 'B') {
            if (ans.size() > 0) {
                ans.pop_back();
            }
        } else {
            ans += c;
        }
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159


inline int mul(int a,int b){return (a*1ll*b)%MOD;}
inline int add(int a,int b){a+=b;if(a>=MOD)a-=MOD;return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,MOD-2);}


bitset<N>every;
int n,t;
int arr[N];
signed main() 
{
     cin>>n>>t;

     if((n+1)/2>=t)
          cout<<"YES";
     else cout<<"NO";        
 
     


    
     return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 256
a,b=map(int,input().split())

a_kake_b=''
for i in range(b):
  a_kake_b=a_kake_b+str(a)

b_kake_a=''
for i in range(a):
  b_kake_a=b_kake_a+str(b)

#print(a_kake_b[0])
#print(b_kake_a[0])

if a_kake_b[0]>b_kake_a[0]:
  print(b_kake_a)
elif a_kake_b[0]<b_kake_a[0]:
  print(a_kake_b)
else:#文字列の頭が同じ場合
  if len(a_kake_b)>len(b_kake_a):
    print(b_kake_a)
  elif len(a_kake_b)<len(b_kake_a):
    print(a_kake_b)
  else:#文字列の頭が同じ数字で同じ長さの場合
    if int(a_kake_b)>int(b_kake_a):
      print(b_kake_a)
    else:
      print(a_kake_b)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    int sum=max(2*a-1,max(2*b-1,a+b));
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

struct UnionFind {
    vector<int> data;
    UnionFind(int n) { data.assign(n, -1); }

    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return true;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int root(int x) {
        return (data[x]<0 ? x : data[x]=root(data[x]));
    }

    int size(int x) {
        return -data[root(x)];
    }
};

struct SegmentTree {
    using D = long long int;
    using DD = function<D(D, D)>;
private:
    int n;
    vector<D> data;
    D ie;
    DD f;

public:
    SegmentTree(int len, D ie, DD f) : ie(ie), f(f) {
        n = pow(2, ceil(log2(len)));
        data.assign(2*n, ie);
    }

    void update(int idx, D val) {
        idx += n;
        data[idx] = val;
        while(idx) {
            idx>>=1;
            data[idx] = f(data[idx*2], data[idx*2+1]);
        }
    }

    // [l, r)
    D query(int l, int r) {
        l = min(max(l, 0), n);
        r = min(max(r, 0), n);
        D res = ie;
        for(l+=n, r+=n; l<r; l>>=1, r>>=1) {
            if(l&1)  res = f(res, data[l++]);
            if(r&1)  res = f(res, data[--r]);
        }
        return res;
    }

    D operator[](int i) { return data[i+n]; }
};

int main() {
    lint n, k;
    cin >> n >> k;

    vector<lint> p(n);
    for(auto& elem : p)  cin >> elem;

    UnionFind uf(n-k+1);

    // i+k <= j
    static vector<lint> inc(n,1);
    for(lint i=0; i+1<n; i++) {
        if(p[i] < p[i+1]) inc[i+1] = inc[i] + 1;
    }
    static vector<lint> po;
    for(lint i=0; i+k-1<n; i++) {
        if(inc[i+k-1] - inc[i] == k-1) po.push_back(i);
    }
    for(lint i=0; i+1<po.size(); i++) {
        uf.unite(po[i], po[i+1]);
    }

    // i < j < i+k
    // 隣接間だけチェックすればよい
    SegmentTree mn(n, 1e18, [](lint a, lint b){return min(a,b);});
    SegmentTree mx(n, -1e18, [](lint a, lint b){return max(a,b);});
    for(lint i=0; i<n; i++) {
        mn.update(i, p[i]);
        mx.update(i, p[i]);
    }

    for(lint i=0; i+1+k<=n; i++) {
        if(p[i] < mn.query(i+1,i+k) && mx.query(i+1,i+k) < p[i+k]) {
            uf.unite(i,i+1);
        }
    }

    map<lint, lint> mp;
    for(lint i=0; i<n-k+1; i++) mp[uf.root(i)]++;
    cout << mp.size() << endl;
}

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

int main() {
    int a, b, c, p;
    cin >> a >> b >> c;
    string s="NO";
    for(int i=1; i<=b; i++) {
        p = a*i%b;
        if(p==c) {
            s="YES";
            break;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
      int n=s.nextInt();
      int []a=new int[200010];
        int []ar=new int[200010];
      for(int i=2;i<=n;i++)
      {
        a[i]=s.nextInt();
      }
      for(int i=2;i<=n;i++)
      {
        ar[a[i]]++;
      }
       for(int i=1;i<=n;i++)
       {
         System.out.println(ar[i]);
       }
    }
}


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

int main() 
{
	int n,u;
	
	cin>>n;
	
	int flg=1;
	
	for(int i=0;i<n;i++)
	{
		cin>>u;
		
		if(u%2) flg=0;
	}
	
	if(flg) cout<<"second"<<endl;
	else cout<<"first"<<endl;
	
	return 0;
}

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

int ar[100001][4], dp[100001][4];

int main() {
    int n; cin >> n;
    for(int i=1; i<=n; ++i) {
        for(int j=1; j<=3; ++j) {
            cin >> ar[i][j];
        }
    }

    int ans = -1;

    for(int i=1; i<=3; ++i) dp[1][i] = ar[1][i];

    //iterate to day
    for(int day = 2; day <= n; ++day) {
        for(int act = 1; act <= 3; ++act) {
            int prev_max = -1;
            for(int cur_act = 1; cur_act <= 3; ++cur_act) {
                if(cur_act != act) prev_max = max(prev_max, dp[day-1][cur_act]);
            }
            dp[day][act] = ar[day][act] + prev_max;
        }
    }


    for(int i=1; i<=3; ++i) ans = max(ans, dp[n][i]);

    cout << ans;
    return 0;
}

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

int N,a;

int main(){
	cin >> N;
	set<int> s,t;
	int count = 100,ok1 = 0,ok2 = 0;
	if(N==1){
		cout << 1 << " " << 1 << endl;
		return 0;
	}
	for(int i=0;i<N;i++){
		cin >> a;
		if(a/400>=8){
			s.insert(count);
			count++;
			ok1 = 1;
		}else{
			ok2 = 1;
			s.insert(a/400);
			t.insert(a/400);
		}
	}
	cout << t.size() + ((ok1 && !ok2)) << " " << s.size() << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX


int l,r,ans=INF;

signed main() {
    cin >> l >> r;
    repo(i,l,min(l+2100,r+1)) {
        repo(j,i+1,min(l+2100,r+1)) {
            ans = min(ans,((i%2019) * (j%2019)) % 2019);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	ll X;
  	cin>>X;
  	int flag=0;
  	int a,b;
  	rep(i,1000){
     	for(int j=-1000;j<1000;j++){
         	 if(pow(i,5)-pow(j,5)==X) {
              	 flag=1;
               	 a=i,b=j;
               	 break;
             }
        }
      	if(flag) break;
    }
  	
  	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3916
/* Filename: AGC003A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			String S = input.next();
			
			boolean north = false, south = false;
			boolean east = false, west = false;
			
			for(int i = 0; i < S.length(); ++i){
				switch(S.charAt(i)){
				case'N': north = true;
				break;
				case'S': south = true;
				break;
				case'E': east = true;
				break;
				case'W': west = true;
				break;
				}
			}
			
			if((north ^ south) || (east ^ west)){
				System.out.println("No");
			} else{
				System.out.println("Yes");
			}
		}
	}
}


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

using namespace std;

// 素数判定
bool is_prime(int N) {
    int tmp;

    tmp = N;
    
    if(tmp == 1) {
        return false;
    }

    for (int a = 2; a * a <= N; a++) {
        if(tmp % a == 0) {
            return false;
        }
    }
    
    return true;
}

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

    int l, r;
    vector<bool> like_number(100001, false);
    vector<int> count_like_number(100001, 0);
    vector<int> count(Q, 0);

    count_like_number[0] = 0;

    for(int i = 1; i <= 100000; i++) {
        if(is_prime(i) == true && is_prime((i+1)/2) == true) {
            like_number[i] = true;
            count_like_number[i] = count_like_number[i-1] + 1;
        } else {
            count_like_number[i] = count_like_number[i-1];
        }
    }

    for(int k = 0; k < Q; k++) {
        cin >> l >> r;
        count[k] = count_like_number[r] - count_like_number[l-1];
    }

    for(auto c : count) {
        cout << c << endl;
    }

	return 0;
}

Measured memory_bytes: 3968
a, b, x = gets.split.map(&:to_f)
if x <= a * a * b / 2.0
  theta = Math.atan(a * b * b / x / 2.0)
else
  theta = Math.atan(((b / a) - (x / (a ** 3))) * 2.0)
end
puts theta * 180 / Math::PI


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define int long long 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std ;

int n , m , temp , ans = 0 ;
pair<int,int>a[100001];

int32_t main(){IOS;

        cin >> n >> m ; 
        for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second ;

        sort(a,a+n);

        for(int i=0;i<n;i++){
                temp = min(m,a[i].second);
                if(m>0){
                        m -= temp;
                        ans += a[i].first*temp;
                }
        }
        cout << ans << endl; 
        return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int tot;
char s[20];
char c;
int b;

int main()
{
    while (scanf("%c",&c)!=EOF)
    {
        if (c=='\n') break;
        if (c=='o') b++;
        tot++;
    }
    if (b+(15-tot)>=8)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int x,y,k,n,a[1001];
    scanf("%d %d",&n,&k);
    for(x = 0;x < n;x++){
        scanf("%d",&a[x]);
    }
    int tmp,sum = 0;
    for(x = 0;x < n;x++){
        for(y = x + 1;y < n;y++){
            if(a[x] > a[y]){
                tmp = a[x];
                a[x] = a[y];
                a[y] = tmp;
            }
        }
    }
    for(x = 0;x < k;x++){
        sum += a[x];
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 1736
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a==2) 
	{
		if(b==2) cout<<"Yes"<<endl;
	    else cout<<"No"<<endl;
    }
	if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
	{
		if(b==1||b==3||b==5||b==7||b==8||b==10||b==12) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	if(a==4||a==6||a==9||a==11)
	{
		if(b==4||b==6||b==9||b==11) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#include<set>
#include<map>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const double Pi = acos(-1.0);
inline int read(){
	int v = 0,c = 1;char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') c = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		v = v * 10 + ch - 48;
		ch = getchar();
	}
	return v * c;
}
int main(){
 	double a ,b ,x;
 	cin >> a >> b >> x;
	if(x >= a * a * b / 2.0){
		double d1 = (x / a * 2.0 / a - b);
		double c = b - d1;
		printf("%.10lf\n",90.0 - atan(a / c) / Pi * 180.0);	
	}
	else{
		double d1 = x / a * 2.0 / b;
		printf("%.10lf\n",90.0 - atan(d1 / b) / Pi * 180.0);	
	}
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 14:36:15 2020

@author: shinba
"""

import sys

N,M = map(int,input().split())
result = {}

for i in range(M):
    s,c = map(int,input().split())
    if s in result:
        if c != result[s]:
            print(-1)
            sys.exit()
    else:
        result[s] = c
        
W = [0]*N
W[0] = 1

for i,j in result.items():
    W[i-1] = j
    
ans = "".join(map(str,W))

if ans == "0" or (M == 0 and N == 1):
    print(0)
elif ans[0] == "0":
    print(-1)
else:
    print(ans)





Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    int N; cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    rep(i,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i = 0; i < N-1; i++){
        int current_time = 0;
        for (int j = i; j < N-1; j++){
            if (current_time <= S[j]){
                current_time = S[j];
            }
            else{
                if ((current_time - S[j]) % F[j] != 0){
                    current_time += F[j] - (current_time % F[j]);
                } 
            }
            current_time += C[j];
        }
        cout << current_time << endl;
    }
    cout <<  0 << endl;

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

template<class T> struct BIT{
    int n;
    vector<T> node;
    
    BIT(int n_){
        n = n_;
        node.resize(n+1, 0);
    }
    
    T sum(int i){
        T s = 0;
        while(i){
            s += node[i];
            i -= i & -i;
        }
        return s;
    }
    
    void add(int i, T x){
        while(i <= n){
            node[i] += x;
            i += i & -i;
        }
    }
};

int main(){
    int n;
    lint k;
    scanf("%d%lld", &n, &k);
    lint a[n], asum[n+1];
    vector<lint> v(n+1);
    asum[0] = v[0] = 0;
    rep(i, n){
        scanf("%lld", &a[i]);
        a[i] -= k;
        asum[i+1] = asum[i] + a[i];
        v[i+1] = asum[i+1];
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    lint ans = 0;
    BIT<int> bit(n+1);
    rep(i, n+1){
        int id = lower_bound(v.begin(), v.end(), asum[i]) - v.begin() + 1;
        ans += (lint)bit.sum(id);
        bit.add(id, 1);
    }
    printf("%lld\n", ans);
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define sort_unique(x) sort(ALL(x)); x.resize(distance(x.begin(), unique(ALL(x))))
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#ifdef LOCAL
#define pause system("pause")
#else
#define pause 42
#endif

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;


int main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    cout.precision(15);
    cout << fixed;

    int n, a, b;
    cin >> n >> a >> b;

    auto get = [](int num) {
        int ret = 0;
        while (num) {
            ret += num % 10;
            num /= 10;
        }  
        return ret;
    };

    lld ans = 0;
    for (int i = 0; i <= n; i++) {
        int g = get(i);
        if (g >= a && g <= b) {
            ans += i;
        }    
    }
    cout << ans << '\n';


    
    pause;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

const nb = 4
const nf = 3
const nr = 10

func main() {
	var arr [nb][nf][nr]int

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var b, f, r, v int
		fmt.Scan(&b, &f, &r, &v)
		arr[b-1][f-1][r-1] += v
	}
	for b := range make([]int, nb) {
		if b != 0 {
			fmt.Println(strings.Repeat("#", 20))
		}
		for f := range make([]int, nf) {
			for r := range make([]int, nr) {
				fmt.Printf(" %d", arr[b][f][r])
			}
			fmt.Println()
		}
	}
}



Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)cout<<0<<endl;
	else cout<<min(min(a*b,a*c),b*c)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n >> x;
    rep(i, n) cin >> a[i];
    rep(i, n - 1)
    {
        sum = a[i] + a[i + 1];
        if (sum <= x)
            continue;
        ll her;
        her = sum - x;
        ans += her;
        a[i + 1] -= her;
        if (a[i + 1] < 0)
        {
            a[i + 1] = 0;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
nums = {}
temp = 0
for i in range(n):
  a, b = map(int, input().split())

  if a in nums:
    nums[a] += b
  else:
    nums[a] = b



for key, val in sorted(nums.items()):
  temp += val
  if k <= temp:
    print(key)
    break

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

int main() {
    int h, w, a, b, ans;
    cin >> h >> w >> a >> b;
    ans = (h - a) * (w - b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;

int main() {
	scanf("%d", &n);
	if(n==1) printf("1.0");
	else if(n%2 == 0) printf("0.5");
	else printf("%.8Lf\n", ((n+1)/2)/(long double)n);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 1000001
#define MAX_M 100000
#define MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define ent cout<<endl
using P = pair<int, int>;
#define YES "Yes"
#define NO "No"
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// テレンス「もしかしてACですかーッ!?」　ジョセフ「Yse! Yse! Yse! Oh~MyGod」

int main(){
  double n;
  cin>>n;
  int m=n/1.08;
  if(m==n/1.08){
    cout<<n/1.08<<endl;
  }
  else{
    int w=(m+1)*1.08;
    if(w==n){
      cout<<m+1<<endl;
    }
    else{
      cout<<":("<<endl;
    }
  }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int h[MAXN];

void solve(){
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	REP(i, 0, n) {
		scanf("%d", &h[i]);
	}
	int l = 0, r = INF;
	for(; l + 1 < r; ) {
		int mid = (l + r) / 2;
		ll cnt = 0;
		REP(i, 0, n) {
			cnt += max(0ll, (h[i] - (ll)mid * (ll)b + a - b - 1) / (a - b));
		}
		if (cnt > mid) {
			l = mid;
		} else {
			r = mid;
		}
	}
	printf("%d\n", r);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++) 2
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define le <=
#define ge >=

inline void SUM(ll &x,ll y)
{
    x=x+y;
}
inline void DIFF(ll &x,ll y)
{
    x=x-y;
}
inline void yes(int counter){
    if(counter EE 0)
    cout<<"yes\n";
    else if(counter EE 1)
    cout<<"Yes\n";
    else cout<<"YES\n";
    return;
}
inline void no(int counter){
    if(counter EE 0)
    cout<<"no\n";
    else if(counter EE 1)
    cout<<"No\n";
    else cout<<"NO\n";
    return;
}
ll c E 0;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int count;
    cin>>count;
    string str;
    std::map<string, int > mp;
    for (int i = 0; i < count; ++i)
    {
        cin>>str;
       sort(str.begin(), str.end());
       mp[str]++;
    }
    ll sum E 0;
    for(auto e : mp)
    {
        ll c E e.second;
        DIFF(c,1);
        c E ((c pls 1)*c)/2;
        SUM(sum,c);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 11452
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using i64 = int_fast64_t;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

void solve() {
    int n, q;
    cin >> n >> q;

    atcoder::dsu uf(n);
    while (q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            uf.merge(u, v);
        } else {
            if (uf.same(u, v))
                cout << "1\n";
            else
                cout << "0\n";
        }
    }
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3960
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){

	char a[3][3];
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}
	cout << a[0][0] << a[1][1] << a[2][2] << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<"0"<<endl;
		return 0;
	}
	ll total=1,total2=1;
	rep(i,n){
		total*=i+1;
		total%=1000000007;
	}
	rep(i,m){
		total2*=i+1;
		total2%=1000000007;
	}
	total*=total2;
	total%1000000007;
	if(n==m)total*=2;
	cout<<total%1000000007<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll MOD = 1000000007;
int main() {
	ll N;
	cin >> N;
	vector<ll>a(N);
	ll sum[10];
	for (ll i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (ll i = 0; i<8; ++i) {
		sum[i] = 0;
	}
	for (ll i = 0; i < N; ++i) {
		for (ll j = 0; j <8; j++) {
			if (a[i] >= j * 400 && a[i] < (j + 1) * 400)
				sum[j]++;
		}
	}
 	ll cnt=0; 
  	for(ll j=0; j<8; ++j){
    	if(sum[j]>0)
          cnt++;
    }
  	ll ans=cnt;
  	for(ll j=0; j<N; ++j){
      if(a[j]>=3200)
        ans++;}
  if(cnt>0)
  cout<<cnt<<' '<<ans<<endl;
  else
  cout<<1<<' '<<ans<<endl;
  
        
}
      


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
i64 k;
int main() {
  cin >> s >> k;
  i64 n = s.size();
  
  set<char> st;
  for (char c : s) st.insert(c);
  if (st.size() == 1) {
    cout << n * k / 2 << endl;
    return 0;
  }


  string a = s + s + s;
  i64 x[3] = {};
  for (int i = 1; i < min(k * n, 3 * n); ++i) {
    if (a[i - 1] == a[i]) {
      ++x[i / n];
      a[i] = '*';
    }
  }
  for (int i = 0; i < 3; ++i) cerr << x[i] << endl;
  i64 ans = 0;
  if (k == 1) ans = x[0];
  else if (k == 2) ans = x[0] + x[1];
  else ans = x[0] + (k - 2) * x[1] + x[2];
  cout << ans << endl;
  return 0;
}


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

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ab = 1e6;
  int ans;
  for (int i = -300; i <= 300; i++) {
    bool t = false;
    rep(j, n) {
      if (i == p[j]) t = true;
    }
    if (t) continue;
    if (abs(x - i) < ab) {
      ab = abs(x - i);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
struct light{
    int s[11];
    int length;
    int state;
}f[15];
int swi[15],n,m,cnt=0;

void dfs(int deep)
{
    if(deep==n){
       // for(int i=0;i<n;i++)
      //      cout << swi[i];
      //  cout << endl;
        for(int i=0;i<m;i++){
            int t=0;
            for(int j=0;j<f[i].length;j++){
            //    cout << "swi" << swi[f[i].s[j]];
                if(swi[f[i].s[j]-1]==1)
                    t=!t;
            }
   //         cout <<  "t="<<t << endl;
            if(f[i].state!=t){
      //          cout << i+1 << " " << f[i].state << endl;
                return ;
            }
        }
        cnt++;
        return ;
    }
    swi[deep]=0;
    dfs(deep+1);
    swi[deep]=1;
    dfs(deep+1);

}
int main()
{
   // int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> f[i].length;
        for(int j=0;j<f[i].length;j++){
            cin >> f[i].s[j];
        }
    }
    for(int i=0;i<m;i++)
        cin >> f[i].state;
    dfs(0);
    cout << cnt;

    return 0;
}



Measured memory_bytes: 256
import copy
import math
from typing import List


def compute_prime_factor(n: int) -> None:
    global prime_factors
    sqrt_n = int(math.sqrt(n)) + 1
    for i in range(2, sqrt_n + 1):
        if 0 == (n % i):
            prime_factors.append(i)
            compute_prime_factor(n // i)
            return
    if 1 != n:
        prime_factors.append(n)
        return


if __name__ == "__main__":
    n = int(input())
    A = list(map(lambda x: int(x), input().split()))

    prime_factor_dict: dict = {}
    for i in range(n):
        prime_factors = []  # type: ignore
        compute_prime_factor(A[i])
        prime_factor_dict[A[i]] = prime_factors

    max_num = max(A)
    all_factors: List[int] = prime_factor_dict[max_num]
    for key, factors in prime_factor_dict.items():
        if key == max_num or key == 1:
            continue
        tmp = copy.deepcopy(prime_factor_dict[max_num])
        for elem in factors:
            if elem in tmp:
                tmp.pop(tmp.index(elem))
            else:
                all_factors.append(elem)

    ans = 1
    for elem in all_factors:
        ans *= elem
    print(ans)



Measured memory_bytes: 7272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    vector<int> r(n);
    for (int i = 0; i < n - 1; i++) {
        int c, s, f;
        cin >> c >> s >> f;

        for (int j = 0; j <= i; j++) {
            r[j] = max(r[j], s);
            r[j] = (r[j] + f - 1) / f * f;
            r[j] += c;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << r[i] << '\n';
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define N 10005
using namespace std;

typedef long long ll;
ll n, ans, b[N], v[N], s[N], ans2[N];
vector<ll> a[N];
struct st {
	ll c, z, num;
};

bool operator < (st p, st q) {
	return p.c > q.c;
}
priority_queue<st> qu;
int main()
{
	ll i, j, t1, t2, e;
	st t;
	cin >> n;
	for (i = 0; i < n - 1; i++) {
		scanf ("%lld %lld", &t1, &t2);
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	for (i = 0; i < n; i++) scanf ("%lld", &b[i]);
	sort(b, b + n);
	for (i = 1; i <= n; i++) {
		s[i] = a[i].size();
		qu.push({s[i], i, 0});
	}
	j = 0;
	while (!qu.empty()) {
		t = qu.top(); qu.pop();
		if (v[t.z] != t.num) continue;
		v[t.z] = -1;
		ans += t.c * b[j];
		ans2[t.z] = b[j];
		for (i = 0; i < a[t.z].size(); i++) {
			e = a[t.z][i];
			if (v[e] != -1) {
				s[e]--;
				v[e] = j;
				qu.push({s[e], e, j});
			}
		}
		j++;
	}
    cout << ans << endl;
    for (i = 1; i <= n; i++) printf("%lld ", ans2[i]);
    puts("");
    return 0;
}


Measured memory_bytes: 1664
n = int(input())
s = [int(i) for i in input().split()]
used = [0] * (2 ** n)
used[0] = 1
s.sort(reverse=True)
a = 1
b = [s[0]]
for _ in range(n):
    c = b[:]
    j = 0
    for i in b:
        while j < 2 ** n:
            if used[j] == 0 and s[j] < i:
                c.append(s[j])
                used[j] = 1
                break
            j += 1
        if j >= 2 ** n:
            print("No")
            exit()
    b = sorted(c, reverse=True)

print("Yes")


Measured memory_bytes: 120140
N = int(input())
A = list(map(int,input().split()))
B = [abs(i) for i in A]
k = 0
for i in range(N):
    if A[i] < 0:
        k += 1
if k % 2 == 0:
    ans = sum(B)
else:
    ans = sum(B) - 2*min(B)
print(ans)


Measured memory_bytes: 14252
from collections import deque

def main():
    n, m = map(int, input().split())
    to = [[] for _ in range(n+1)]
    ans = [None]*(n+1)
    for _ in range(m):
        a, b = map(int, input().split())
        to[a].append(b)
        to[b].append(a)
    queue = deque([1])
    while queue:
        parent = queue.pop()
        children = to[parent]
        for child in children:
            if ans[child] is None:
                ans[child] = parent
                queue.appendleft(child)
    print("Yes")
    print("\n".join(list(map(str, ans[2:]))))

if __name__ == "__main__":
    main()

Measured memory_bytes: 41560
from collections import defaultdict
import sys

input = lambda: sys.stdin.readline().rstrip()

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

class mod_int(int):
  def __new__(cls, i=0, *args, **kwargs):
    return int.__new__(cls, i%M, *args, **kwargs)
  
  def __add__(self, x):
    return self.__class__(int.__add__(self, x))
    
  def __sub__(self, x):
    return self.__class__(int.__sub__(self, x))
    
  def __neg__(self):
    return self.__class__(int.__neg__(self, x))
  
  def __mul__(self, x):
    return self.__class__(int.__mul__(self, x))
  
  def __floordiv__(self, x):
    a, b = ext_euc(x, M)
    return self * a
  
  def __invert__(self):
    a, b = ext_euc(self, M)
    return self.__class__(a)
  
  def __pow__(self, x):
    return self.__class__(int.__pow__(self, x, M))

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(mod_int)
  sum_g[0] = (B**(N+1) - B) // (B-1)
  prev = N
  W = B**N
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
      W *= B_inv**(prev-i)
      sum_g[g[i]] +=  W
      sum_g[0]  -= W
      prev, W = i, W
  
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = mod_int(0)
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret += sx*sy*sz
  return ret


M = 998244353
B = mod_int(10) ** 18
B_inv = ~B
N = int(input())

edge = [read_edge() for i in range(3)]

print(solve(N, edge))


Measured memory_bytes: 61312
class Dice: 
    def __init__( self, nums ):
        self.face = nums
     
    def rolltoTop( self, dicenum ): 
        num = 0
        for i,val in enumerate( self.face ):
            if dicenum == val:
                num = i
                break
        if num == 1:
            self.roll( "N" )
        elif num == 2:
            self.roll( "W" )
        elif num == 3:
            self.roll( "E" )
        elif num == 4:
            self.roll( "S" )
        elif num == 5:
            self.roll( "NN" )
     
    def roll( self, actions ):
        for act in actions:
            t = 0
            if act == "E":
                t =   self.face[0]
                self.face[0] =   self.face[3]
                self.face[3] =   self.face[5]
                self.face[5] =   self.face[2]
                self.face[2] = t
            elif  act == "N":
                t =   self.face[0]
                self.face[0] =   self.face[1]
                self.face[1] =   self.face[5]
                self.face[5] =   self.face[4]
                self.face[4] = t
            elif  act == "S":
                t =  self.face[ 0]
                self.face[0] =  self.face[4]
                self.face[4] =  self.face[5]
                self.face[5] =  self.face[1]
                self.face[1] = t    
            elif  act == "W":
                t =  self.face[0]
                self.face[0] =  self.face[2]
                self.face[2] =  self.face[5]
                self.face[5] =  self.face[3]
                self.face[3] = t    
            elif  act == "M":
                t =  self.face[1]
                self.face[1] =  self.face[2]
                self.face[2] =  self.face[4]
                self.face[4] =  self.face[3]
                self.face[3] = t
 
diceface = [ int( val ) for val in input( ).split( " " ) ]
dice = Dice( diceface )
q = int( input( ) )
for i in range( q ):
    topnum, frontnum = [ int( val ) for val in input( ).split( " " ) ]
    dice.rolltoTop( topnum )
    while dice.face[1] != frontnum:
        dice.roll( "M" )
         
    print( dice.face[2] )

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

int main()
{
	while (true)
	{
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0)
		{
			break;
		}
		for (int i = 0; i < h; i++)
		{
			for (int i = 0; i < w; i++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288

using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

bigint fact[100005] ;
bigint inv[100005] ;
bigint inv_fact[100005] ;
void init(){
    fact[0] = fact[1] = 1 ;
    for( int i = 2 ; i <= 100000 ; i++ ){
        fact[i] = fact[i-1] * i ;
        fact[i] %= mod ;
    }
    inv[1] = 1 ;
    for( int i = 2 ; i <= 100000 ; i++ ){
        inv[i] = ( mod - ( mod / i * inv[mod%i] ) % mod) % mod ;
    }
    inv_fact[0] = inv_fact[1] = 1 ;
    for( int i = 2 ; i <= 100000 ; i++ ){
        inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod ;
    }
}

bigint nCr( int N , int R ){
    if( N < R || N < 0 || R < 0 ){
        return 0 ;
    }
    bigint ans = (( inv_fact[R] * inv_fact[N-R] ) % mod * fact[N] ) % mod ;
    return ans ;
}

int main(){
    FAST_IO ;
    init() ;
    
    int N , K ; cin >> N >> K ;
    int arr[N+1] ;
    for( int i = 0 ; i < N ; i++ ){
        cin >> arr[i] ;
    }
    sort( arr , arr + N ) ;
    bigint ans1 = 0 , ans2 = 0 ;
    for( int i = 0 ; i < N ; i++ ){
        bigint a = (nCr(i, K-1) * arr[i]) % mod ;
        bigint b = (nCr(N-i-1, K-1) * arr[i])% mod ;
        ans1 = (ans1 + a) % mod ;
        ans2 = (ans2 + b) % mod ;
    }
    cout << ((ans1 - ans2 ) % mod + mod ) % mod << endl ;
    return 0 ;
  }

Measured memory_bytes: 6328
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long geko[300] = {};
int main() {
	int l, k;
	cin >> l >> k;
	long long ans = 0;
	geko[1] = 1;
	geko[k] = 1;
	for (int i = 1;i <= l;++i) {
		ans += geko[i];
		geko[i + 2] += geko[i];
		geko[i + 1 + k] += geko[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll inf = 1e15;

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

    ll x, y;
    cin >> x >> y;

    ll d1 = (y - x >= 0) ? y - x : inf;
    ll d2 = (y + x >= 0) ? y + x + 1 : inf;
    ll d3 = (- y + x >= 0) ? - y + x + 2 : inf;
    ll d4 = (- y - x >= 0) ? - y - x + 1 : inf;
    ll res = min(min(d1, d2), min(d3, d4));

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdbool.h>
using namespace std;

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b > c*d)cout << a*b << endl;
	else {
		if (a*b == c*d)cout << a*b << endl;
		else cout << c*d << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a,i,j;
	i = 1l;
	while (1)
	{
		scanf("%d", &a);
		if (a == 0) {
			break;
		}
		printf("Case %d: %d\n", i, a);

		i++;
	}
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

const int MOD = 998244353;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int dfs(int i, vector<int>& p, vector<int>& a, vector<bool>& vis) {
    if (vis[i]) return INT_MAX;
    vis[i] = true;
    return min(a[i], dfs(p[i], p, a, vis));
}

int main() {
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    ll ans = 1;
    rep(i, N) ans = ans * gcd(i, a[i]) % MOD;
    cout << ans << endl;
    return 0;
    for (;;) {
        int N; cin >> N;
        vector<int> a(N);
        rep(i, N) cin >> a[i];
        vector<int> p(N);
        iota(all(p), 0);
        vector<ll> ans(N + 1);
        do {
            vector<bool> vis(N);
            int k = 0;
            ll x = 1;
            rep(i, N) if (!vis[i]) {
                k++;
                x *= dfs(i, p, a, vis);
            }
            ans[k] += x;
        } while (next_permutation(all(p)));
        rep(k, N + 1) cout << ans[k] << ' ';
        cout << endl;
        ll d = 0;
        rep(k, N + 1) d = gcd(d, ans[k]);
        cout << d << endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n;

void solve(){
    cin >> n;
    vector<ll> arr(n + 1, 0);
    for(ll i = 1; i <= n-1; i++){
        ll x;
        cin >> x;
        arr[x]++;
    }
    for(ll i = 1; i <= n; i++)
        cout << arr[i] << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4764