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

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

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

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

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

  ll d,g;
  cin>>d>>g;
  vll p(d),c(d);
  REP(i,d)cin>>p[i]>>c[i];

  ll ans=LLINF;
  REP(bit,(1<<d)){
    ll point=0;
    ll cnt=0;
    vll v;
    REP(i,d){
      if((bit>>i)&1){
        point+=(i+1)*100*p[i]+c[i];
        cnt+=p[i];
      }
      else
        v.push_back(i);
    }

    if(g<=point){
      ans=min(ans,cnt);
      continue;
    }

    ll sz=v.size();
    for(ll i=sz-1; i>=0; i--){
      ll base=(v[i]+1)*100;
      if((g-point-1)/base+1<=p[v[i]]-1){
        cnt+=(g-point-1)/base+1;
        point+=((g-point-1)/base+1)*base;
        break;
      }
      else{
        cnt+=p[v[i]]-1;
        point+=base*(p[v[i]]-1);
      }
    }

    if(g<=point)
      ans=min(ans,cnt);
  }

  cout<<ans<<endl;

}



Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;

#define N  1000005

ll minprime[N];

void sieve(){
	for(ll i=2;i<N;i++){
		if(!minprime[i]){
			for(ll j=i*i;j<N;j+=i){
				if(!minprime[j]){
					minprime[j]=i;
				}
			}
			minprime[i]=i;
		}

	}
}

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n){
		ll x;
		cin>>x;
		a[i]=x;
	}	
	ll g=a[0];
	rep(i,1,n)g=__gcd(g,a[i]);
	vi facs[n];
	ll tot=0;
	set<ll> s;
	rep(i,0,n){
		ll temp =a[i];
		ll mp =minprime[a[i]];
		while(temp>1){
			temp=temp/mp;
			if(sz(facs[i])==0 || facs[i][sz(facs[i])-1]!=mp){
				facs[i].pb(mp);
				tot++;
				s.insert(mp);
			}
			mp=minprime[temp];
		}
	}
	if(sz(s)!=tot){
		if(g==1){
			cout<<"setwise coprime"<<endl;
		}
		else{
			cout<<"not coprime"<<endl;
		}
	}
	else{
		// for(auto i:s)cerr<<i<<" ";
		// 	cerr<<endl;
		cout<<"pairwise coprime"<<endl;
	}


}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	sieve();
	// rep(i,1,10)cerr<<minprime[i]<<endl;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

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

int main(){
  int M, K, n;
  int t = 0;
  int N = 0;
  string s;
  cin >> s;

  t = 15 - s.size();
  for(int i = 0; i< s.size(); i++){
    if(s.at(i) == 'o') N++;
  }
  
  if( N + t >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    int offset = n;
    REP(i,n){
        bool flag = true;
        REP(j,n-i){
            //cout << s[j+i] << " " << t[j] << endl;;
            if(s[j+i]!=t[j]) {
                flag = false;
            }
        }
        if(flag){
            offset = i;
            break;
        }
    }
    cout << (s+t.substr(t.length()-offset,offset)).length() << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import numpy as np
import sys

n = int(input())
xy = np.array([list(map(int, input().split())) for _ in range(n)])

if n == 1:
    print(1)
    sys.exit()

memo = defaultdict(int)

for i in xy:
    for j in xy:
        if np.all(i == j):
            continue
        else:
            tmp = j - i
            if tmp[0] < 0:
                tmp *= -1
            elif tmp[0] == 0 and tmp[1] < 0:
                tmp *= -1
            memo[str(tmp)] += 1

print(n - max(memo.values()) // 2)

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  rep(i, 3) {
    if (s.at(i) == '1') {
      count++;
    }
  }
  cout << count << endl;
  
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long MOD = (long)Math.pow(10, 9) + 7;
    long ans = 1;
    for(long i = n; i >= 1; i--) {
      ans = (ans * i) % MOD;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=1e5+5;
int n,cnt;
ll S,X[N],P[N],tmp[N];

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

int main() {
	IN(n),IN(S);
	int ID=0,l=1,r=n;
	for(int i=1;i<=n;++i) IN(X[i]),IN(P[i]);
	for(int i=1;i<=n;++i) if(X[i]<S) ID=i;
	while((l<=ID)^(r<=ID)) {
		if(P[l]>=P[r]) P[l]+=P[r],tmp[++cnt]=X[r--];
		else P[r]+=P[l],tmp[++cnt]=X[l++];
	}
	if(r<=ID) for(int i=l;i<=r;++i) tmp[++cnt]=X[i];
	else for(int i=r;i>=l;--i) tmp[++cnt]=X[i];
	tmp[++cnt]=S;
	ll ans=0;
	for(int i=1;i<cnt;++i) ans+=abs(tmp[i]-tmp[i+1]);
	return printf("%lld\n",ans),0;
}

Measured memory_bytes: 2560
import numpy as np

n, k = map(int, input().split())
sunukes = list(np.zeros(n))
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(n):
        if j+1 in a:
            sunukes[j] = 1
            
print(sunukes.count(0))

Measured memory_bytes: 27128
n,m=map(int,input().split())
count=[0]*m
ans=0
arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))
  for j in range(1,arr[i][0]+1):
    count[arr[i][j]-1]+=1
for i in range(m):
  if count[i]==n:
    ans+=1
print(ans)

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;







int main() {

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    ll n;
    cin >> n;
    map<ll, ll> m;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        m[a[i]]++;
    }
    ll ans = 0;
    for (auto it = m.begin(); it!=m.end(); it++) {
        ans += it->second * (it->second - 1) / 2;
    }
    rep(i, n) {
        ll def;
        def = m[a[i]] - 1;
        cout << ans - def << endl;
    }
}

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

int N, a[112345];
int min = 112345, max = -1;

int main()
{
	in >> N;
	rep(i, N) { in >> a[i]; }

	rep(i,N)
	{
		min = std::min(min, a[i]);
		max = std::max(max, a[i]);
	}
	if (max - min > 1)
	{
		out << "No" << std::endl;
		return 0;
	}
	if (max - min == 0)
	{
		rep(i, N)
		{
			if (a[i] != N - 1 && a[i] * 2 > N)
			{
				out << "No" << std::endl;
				return 0;
			}
		}
	}
	else
	{
		int cou = 0;
		rep(i, N)
		{
			if (a[i] == min) { ++cou; }
		}
		if (cou >= max || (max - cou) * 2 > (N - cou))
		{
			out << "No" << std::endl;
			return 0;
		}
	}
	out << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
using namespace std;
int n,d1,d2,tot; int a[700][700];
void vv(int d){
	int b=0;
	while(d%4==0){
		d/=4;
		b++;
	}
	if (d%2==1){
		for (int i=0; i<2*n; i++){
			for (int j=0; j<2*n; j++)
			if(((i>>b)+(j>>b))%2==1) a[i][j]=1;
		}
	}
	else{
		for (int i=0; i<=2*n; i++){
			for (int j=0; j<=2*n; j++)
			if((i>>b)%2==1) a[i][j]=1;
		}
	}
}
int main(){
 scanf("%d%d%d",&n,&d1,&d2);
  vv(d1);
  vv(d2);
  for (int i=0; i<2*n; i++){
  	for (int j=0; j<2*n; j++)
  	if (!a[i][j] && tot<n*n){
  		printf("%d %d\n",i,j);
  		tot++;
  		
  	}
  } 
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m, a[101010];
i64 dp[101010] = {0};

i64 fib(int c){
	if(c <= 1) return 1;
	if(dp[c] != 0) return dp[c];
	dp[c] = (fib(c-1) + fib(c-2)) % INF;
	return dp[c];
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i];
	}
	a[m] = n+1;
	i64 cnt = 1;
	int now = 0;
	for(int i = 0; i <= m; i++){
		if(a[i] < now) continue;
		if(a[i] == now) {cnt = 0; break;}
		cnt *= fib(a[i]-now-1)%INF;
		now = a[i]+1;
		cnt %= INF;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(10**8)

A, B = map(int, input().split())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

g = gcd(A, B)
count = 0
for i in range(2, 10**6+3):
    if g%i == 0:
        count += 1
    while g%i == 0:
        g //= i
if g != 1:
    count += 1

print(count+1)


Measured memory_bytes: 3064
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;

ll n, k;

ll wyn;

ll tso(ll a, ll b)
{
	return a*7+b+1;
}

ll licz(ll a, ll b)
{
	ll ret=0;
	for (int i=0; i<3; i++)
		for (int j=0; j<3; j++)
			ret+=tso(a+i, b+j);
	
	return ret%11;
}

int main()
{
	scanf("%lld%lld", &n, &k);
	for (int i=0; i<11; i++)
	{
		for (int j=0; j<5; j++)
		{
			if (licz(i, j)==k)
			{
				wyn+=(n-i-2+11-1)/11;
			}
		}
	}
	
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
 
int main(){
  int n,i,j,v,u,k;
  int adj[N+1][N+1]={0};
   
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      adj[i][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",adj[i][j]);
      if(j<n-1){
    printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int PP[] = new int[N];
    for (int i = 0;i < N;i++) {
      PP[i] = scan.nextInt();
      if (PP[i] % 2 == 0) {
        if (PP[i] % 3 == 0 || PP[i] % 5 == 0) {
        }
        else{
          System.out.println("DENIED");
          return;
        }
      }
    }
      System.out.println("APPROVED");
  }
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(){

	int w,h,i,j;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0) break;
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
        return 0;
}

Measured memory_bytes: 1740
// contest.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
using namespace std;

int main()
{
	int  Q;
	string S;
	cin >> S >> Q;
	int parity = 1;
	queue<char> front, end;
	for (int i = 0; i < Q; i++)
	{
		int p;
		cin >> p;
		if (p == 1)
			parity = -parity;
		else if (p == 2)
		{
			int flag;
			cin >> flag;
			flag = flag * 2 - 3;//1(e)or-1(f)
			if (parity * flag > 0)
			{
				char c;
				cin >> c;
				end.push(c);
			}
			else if (parity * flag < 0)
			{
				char c;
				cin >> c;
				front.push(c);
			}

		}

	}
	while (end.size() > 0)
	{
		S += end.front();
		end.pop();
	}
	reverse(S.begin(), S.end());
	while (front.size() > 0)
	{
		S += front.front();
		front.pop();
	}
	if(parity==1)
		reverse(S.begin(), S.end());
	cout << S;
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n, k; cin >> n >> k;
	ll t = n % k;
	ll ans = min(t, abs(t - k));
	cout << ans << '\n';





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vi h(n + 1), dp(n + 1, 1e9);
  rep(i, n) cin >> h[i + 1];
  dp[0] = dp[1] = 0;
  rep2(i, 1, n) rep(j, k) {
    dp[i + j + 1] = min(dp[i + j + 1], dp[i] + abs(h[i] - h[i + j + 1]));
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
n=int(input())
 
num,a,b=0,0,0
 
for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num>=su and num%2 == su%2:
    ans="Yes"
  else:
    ans="No"
    break
      
print(ans)

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
using namespace std;
int n,sum,s;
bool a[100010];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        if(a[s])sum++;
        else a[s]=1;
    }
    if(sum%2==1)sum++;
    cout<<n-sum;
}

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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto A = RD;
	auto B = RD;

	writeln(A*B);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2740
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
  int i,a,b,j;

  Scanner scan =new Scanner(System.in);
  while(true){
    b=scan.nextInt();
    a=scan.nextInt();

    if(a==0&&b==0)

    break;
    for(j=0;j<b;j++){
for(i=0;i<a;i++){
  System.out.print("#");
}System.out.println();
}System.out.println();
}
}
}



Measured memory_bytes: 33328
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        X: usize,
    }
    for i in 1.. {
        if i * (i + 1) / 2 >= X {
            println!("{}", i);
            break;
        }
    }
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = In[0];
            int b = In[1];
            int k = In[2];
            var L = new List<int>();
            for (int i = 1; i <= 100; i++)
            {
                if (a % i == 0 && b % i == 0) L.Add(i);
            }
            var SL = L.OrderByDescending(x => x).ToList();
            Console.WriteLine(SL[k - 1]);
        }
    }
}


Measured memory_bytes: 28368
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var K = input[0];
            var X = input[1];

            for (int i = X - K + 1; i < X + K; i++)
            {
                if (i < -1000000 || 1000000 < i)
                {
                    continue;
                }
                Console.Write(i);
                if (i != X + K - 1)
                {
                    Console.Write(" ");
                }
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k){
        cout << k << endl;
    }else if (a+b >= k){
        cout << a << endl;
    }else{
        cout << a-(k-a-b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import sys
import math
from collections import defaultdict
k,n=map(int,sys.stdin.readline().split())
arr=list(map(int,sys.stdin.readline().split()))
dis=-1
for i in range(n-1):
    d=arr[i+1]-arr[i]
    dis=max(dis,d)
d=(k-arr[-1]+arr[0])
dis=max(dis,d)
print(k-dis)
    


Measured memory_bytes: 72652
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int x;
cin>>x;
if(x>=400&&x<600)cout<<8<<endl;
if(x>=600&&x<800)cout<<7<<endl;
if(x>=800&&x<1000)cout<<6<<endl;
if(x>=1000&&x<1200)cout<<5<<endl;
if(x>=1200&&x<1400)cout<<4<<endl;
if(x>=1400&&x<1600)cout<<3<<endl;
if(x>=1600&&x<1800)cout<<2<<endl;
if(x>=1800&&x<2000)cout<<1<<endl;

return 0;
}

Measured memory_bytes: 3632
/**
 * 2 ????????°?????????

???????????´??° x, y
?????????????????????????????????????°?????????????????????????????????°?????????????????????????????????

?????????????????????????????\?????????????????????????????????????????????????????????????????????????????¨?????¨?????????????????????

Input
??\???????????°????????????????????????????§?????????????????????????????????????????????????????????§??????????????????????????´??°
x, y ??????????????????????§?????????????????????????

x ??¨ y ?????¨?????? 0
?????¨?????\?????????????????????????????????????????????????????????????????????????????£????????????????????????

Output
??????????????????????????¨??????x ??¨ y ????°????????????????????????????????????????????????????????????????x ??¨
y ????????????????????????????????\??????????????????

Constraints
0 ??? x, y ??? 10,000
???????????????????????°??? 3,000 ????¶?????????????
Sample Input
3 2
2 2
5 3
0 0
Sample Output
2 3
2 2
3 5
 */

#include <algorithm>
#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int x, y, i;
  x = y = i = 0;

  while (true) {
    std::string param;

    getline(std::cin, param);
    std::istringstream iss(param);
    iss >> x >> y;

    if (x > 10000 || y > 10000) {
      std::cout << "Error: 1 <= x, y <= 10000" << std::endl;
    } else if (x == 0 && y == 0) {
      break;
    } else {
      std::cout << std::min(x, y) << " " << std::max(x, y) << std::endl;
      i++;
      if (i >= 3000) {
        break;
      }
    }
  }

  return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

struct UnionFind {
    vector<int> par,rank,large;

    void init(int N){
        rank.assign(N,0);
        large.assign(N,1);
        par.resize(N);
        for(int i= 0; i < N; i++){
            par[i]=i;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(rank[rx]<rank[ry]) {
            par[rx]=ry;
            large[ry]+=large[rx];
            large[rx]=0;
        }
        else {
            par[ry]=rx;
            large[rx]+=large[ry];
            large[ry]=0;
            if(rank[rx]==rank[ry])rank[x]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> v(N);
  for(int i = 0; i < N; i++) {
    int x;
    cin>>x;
    v[i]=x-1;
  }
  UnionFind tree;
  tree.init(N);
  for(int i = 0; i < M; i++){
    int x,y;
    cin>>x>>y;
    tree.unite(x-1,y-1);
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(tree.same(i,v[i])) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
using namespace std; 
#define X real()
#define Y imag()

const double EPS = 1e-10;

bool EQ(double a,double b){
  return fabs(a-b) < EPS;
}

typedef complex<double> Point;

namespace std {
  bool operator == (const Point &a, const Point &b) {
    return EQ(a.X, b.X) && EQ(a.Y, b.Y);
  }
  bool operator < (const Point &a, const Point &b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}
struct Segment {
  Point p1, p2;
  Segment(){};
Segment(Point p1, Point p2) : p1(p1), p2(p2) {};
};

typedef Segment Line;
double dot(Point a, Point b){
  return a.X * b.X + a.Y * b.Y;
}
double cross(Point a, Point b){
  return a.real() * b.imag() - a.imag() * b.real();
}

Point project(Segment s, Point p) {
  double r = dot(p - s.p1, s.p2 - s.p1) / norm(s.p2 - s.p1);
  return s.p1 + (s.p2 - s.p1) * r;
}

Point reflect(Segment s, Point p) {
return p + (project(s, p) - p) * 2.0;
}

int main()
{
  Segment s;
  cin >> s.p1.real() >> s.p1.imag() >> s.p2.real() >> s.p2.imag();
  
  int q;
  
  cin >> q;
  Point p;
  for(int i=0;i<q;i++){
    cin >> p.X >> p.Y;
    Point p2 = reflect(s,p);
    //cout << p2.X << p2.Y << endl;
    
    printf("%.15f %.15f\n",p2.X,p2.Y);

  }

  return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;
    cin >> N;
    vector<string> S(N);
    
    for(int i=0;i<N;i++) cin >> S[i];
    
    sort(S.begin(),S.end());
    
    int count = 1;
    for(int i=0;i<N-1;i++){
        if(S[i]!=S[i+1]) count++;
        
    }
    cout << count;
    return 0;
    
}


Measured memory_bytes: 9568
#include <iostream>

int main() {
  int A, B;
  std::cin >> A >> B;
  float tax_8 = 0.08;
  float tax_10 = 0.10;
  int xa = (int)(A / tax_8);
  int xb = (int)(B / tax_10);
  int min = (xa < xb ? xa : xb);
  int max = (xa > xb ? xa : xb);
  for (int i = 1; i <= 1250; i++)
    if (A == (int)(i*tax_8) &&  B==(int)(i*tax_10)) {
      std::cout << i << std::endl;
      return 0;
    }
  std::cout << -1 << std::endl;
}
      

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int n,a,b;
  int ans;
  
  scanf("%d %d %d", &n,&a,&b);
  
  if(a*n<b) ans=a*n;
  else ans=b;
  
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k,q;
	cin>>n>>k>>q;
	vl cnt(n,0);
	rep(i,q){
	    ll t; cin>>t;
	    cnt[t-1]++;
	}
	rep(i,n){
	    if(q-cnt[i]>=k)puta("No");
	    else puta("Yes");
	}
	return 0;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
long long n,m;
long long solve(long long num){
	if (num%4==0) return num;
	if (num%4==1) return 1;
	if (num%4==2) return num+1;
	if (num%4==3) return 0;
}
int main(){
	cin>>n>>m;
	cout<<(solve(n-1)^solve(m))<<endl;
	return 0;
}

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

int n,c,k;
int t[int(1e5+7)];
int ans;
int main()
{
	scanf("%d%d%d",&n,&c,&k);
	for(int i=1;i<=n;++i)scanf("%d",t+i);
	sort(t+1,t+n+1);
	int nt=t[1],re=c-1;
	ans++;
	for(int i=2;i<=n;++i)
	{
		if(nt+k>=t[i]&&re>0){re--;continue;}
		ans++,nt=t[i],re=c-1;
	}
	printf("%d",ans);
}

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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()

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

  ll N;
  ll ans = 0;

  cin >> N;
  
  multiset<ll> ml;
  vector<ll> A(N);
  ll tmp;
  rep(i,N){
    cin >> tmp;
    A[i] = tmp;
    ml.insert(tmp);
  }

  rep(i,N){
    tmp = *ml.find(A[i]);
    ml.erase(ml.find(A[i]));
    cout << *(ml.rbegin()) << "\n";
    ml.insert(tmp);
  }
  return 0;
}


Measured memory_bytes: 12544
#include <stdio.h>

int main(){
	int a,b,c,d;
	int sum;
	int n;
	
	while(sum=0,scanf("%d",&n)!=EOF){
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if(a+b+c+d==n)
							sum++;
					}
				}
			}
		}
		printf("%d\n",sum);
	}
	
	return 0;
}

Measured memory_bytes: 0
n=int(input())

A=[]
B=[]

for i in range(n):
    ai,bi=map(int,input().split())
    A.append(ai)
    B.append(bi)

A.sort()
B.sort()

amid=0
bmid=0
if n%2==0:
    amid=(A[round(n/2-1)]+A[round(n/2)])/2
    bmid=(B[round(n/2-1)]+B[round(n/2)])/2
else:
    amid=A[round((n-1)/2)]
    bmid=B[round((n-1)/2)]

d=bmid-amid

if n%2==0:
    print(round(2*d)+1)
else:
    print(d+1)

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

using namespace std;

const int MaxN = 501;

long long a[MaxN][MaxN];

vector <int> p1;
vector <int> p2;

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

bool isPrime(int x)
{
    if(x == 1)
        return false;
    for(int i = 2; i * i <= x; ++i)
        if(x % i == 0)
            return false;
    return true;
}

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

void build(int x, int y)
{
    for(int i = 0; i < 4; ++i)
    {
        int xx = x + dx[i];
        int yy = y + dy[i];

        if(xx >= 0 && xx < MaxN && yy >= 0 && yy < MaxN)
            a[x][y] = lcm(a[x][y], a[xx][yy]);
    }

    ++a[x][y];

    assert(a[x][y] <= 1e15 && a[x][y] > 0);
}

void check()
{
    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
        {
            for(int d = 0; d < 4; ++d)
            {
                int x = i + dx[d];
                int y = j + dy[d];

                if(x >= 0 && x < MaxN && y >= 0 && y < MaxN)
                {
                    long long k1 = min(a[i][j], a[x][y]);
                    long long k2 = max(a[i][j], a[x][y]);

                    assert(k2 % k1 == 1);
                }
            }
        }
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    mt19937 rnd(clock());

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            a[i][j] = 1;

    for(int i = 2; i <= 20000; ++i)
        if(isPrime(i))
        {
            if(p1.size() <= MaxN)
                p1.push_back(i);
            else
                p2.push_back(i);
        }

//    shuffle(p1.begin(), p1.end(), rnd);
//    shuffle(p2.begin(), p2.end(), rnd);

    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j + i < MaxN; ++j)
            a[i + j][j] *= p1[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; i + j < MaxN; ++i)
            a[i][j + i] *= p1[j - 1];


    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j < MaxN && i - j >= 0; ++j)
            a[i - j][j] *= p2[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; j + i < MaxN; ++i)
            a[MaxN - 1 - i][j + i] *= p2[j - 1];

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            if((i + j) & 1)
                build(i, j);

    check();

    int n;
    cin >> n;

    assert(n <= MaxN);

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

    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
	int H,R;
	scanf("%d %d",&H,&R);
	if(H+R==0){
		printf("0\n");
	}
	else if(H+R>0){
		printf("1\n");
	}
	else if(H+R<0){
		printf("-1\n");
	}
	return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int gcd(int x, int y){
	if(y==0) return x;
	else return gcd(y, x%y);
}

int lcm(int x,int y){
	return x*y / gcd(x,y);
}

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

	int n,k;
	cin >> n >> k;
	vi p(n);
	rep(i,n){
		cin >> p[i];
	}
	sort(all(p));
	int sum = 0;
	rep(i,k){
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

const int inf = 1000000;

int main()
{
    vector <int> A(5);
    vector <int> P = {0, 1, 2, 3, 4};

    for (int i = 0; i < 5; i++){
          cin >> A.at(i);
    }
    int final_answer = inf;
    do{
        int ans = 0;
        for (int i = 0; i < 5; i++){
            while (ans%10 != 0) ans++;
            ans += A.at(P.at(i));
        }
        final_answer = min(final_answer, ans);
    }while(next_permutation(P.begin(),P.end()));

    cout << final_answer << endl;
}

Measured memory_bytes: 256
/**
 * Title: D - Bouquet
 * Url: https://atcoder.jp/contests/abc156/tasks/abc156_d
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

#define MOD 1000000007

// modpow 
// 繰り返し二乗法を利用し, 高速に a^n% mod p を計算する
// 計算量：O(log(n)) 底は2
long long modpow(long long  a, long long n, long long p) {
    int res = 1;
    if (n==1) return a % p;
    if (n % 2 == 1) return (a * modpow(a, n-1, p)) %p;
    long long t = modpow(a, n/2, p);
    return (t * t) % p;
}

// 返り値：a, b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) を格納する.
// 計算量：O(log(max(a, b))) 底は2
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if(b==0) {
        x = 1;
        y = 0;
        return a;
    }
    long long r = a%b;
    long long d = extGCD(b, r, y, x);
    y -= a/b * x;
    return d;
}

// 逆元計算
// フェルマーの小定理を利用版
// 利用条件：p が素数
// 計算量 O(log(p))
long long modinv_fermat(long long a, long long p) {
    return modpow(a, p-2, p)%p;
}

// 逆元計算
// 拡張ユークリッド控除法 利用版
// 利用条件：特になし
// 計算量：O(log(p)) 底は2
long long modinv_extGCD(long long a, long long p) {
    long long x, y;
    long long d = extGCD(a, p, x, y);
    if (x < 0) x += p;
    return x;
}

// 組み合わせ計算
// 計算量：O(2*k)
long long mod_comb(long long n, long long k, long long p) {
    long long count = 0;
    long long res = 1;
    for(long long i=n; i>=n-k+1; i--) {
        res *= i;
        res %= p;
        count++;
    }
    for(long long i=1; i<=k; i++) {
        res *= modinv_fermat(i, p);
        res %= p;
        count++;
    }
    return res;
}

int main() {

    ll n, a, b;

    cin >> n >> a >> b;

    ll ans = modpow(2, n, MOD) - 1 - mod_comb(n, a, MOD) - mod_comb(n, b, MOD);
    while(ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
W, H, x, y = list(map(int, input().split()))

if W == 0 or H == 0:
  print(0, 1)
  exit()

if W / 2 == x and H / 2 == y:
  print(W * H / 2, 1)
else:
  print(W * H / 2, 0)

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

const int bB = 9;
const int B = 1 << bB;

int up(int x) {
	return (x + (1 << bB) - 1) >> bB;
}

int down(int x) {
	return x >> bB;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	int H = up(n);
	vector<int> bv(H), v(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y; x--;
		if (com == 0) {
			v[x] += y;
			bv[down(x)] += y;
		}
		else {
			int res = 0;
			for (int i = x; i < y && i < (up(x) << bB); i++) {
				res += v[i];
			}
			if (up(x) <= down(y)) {
				for (int i = up(x); i < down(y); i++) {
					res += bv[i];
				}
				for (int i = down(y) << bB; i < y; i++) {
					res += v[i];
				}
			}
			printf("%d\n", res);
		}
	}
	return 0;
}



Measured memory_bytes: 3276
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,A,B,C,D,ans;
    string S;
    bool F=true;
int main(){
    cin>>A>>B>>C>>D;

    if(A+B==C+D){cout<<"Balanced";}
    else {cout<<(A+B>C+D?"Left":"Right");}
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;
#define INF (1000)

class Point {
public:
    double x, y;
    Point(double _x = 0.f, double _y = 0.f) : x(_x), y(_y) {}
};

inline bool operator < (const Point& P, const Point& Q)
{
    return (P.x < Q.x) || (P.x == Q.x && P.y < Q.y);
}

inline bool CompY(const Point& P, const Point& Q)
{
    return P.y < Q.y || (P.y == Q.y && P.x < Q.x);
}

istream& operator >> (istream& in, Point& P)
{
    in >> P.x >> P.y;
    return in;
}

double Dist(const Point& P, const Point& Q)
{
    double dx = P.x - Q.x;
    double dy = P.y - Q.y;
    return sqrt(dx * dx + dy * dy);
}

double ClosestDist(const vector<Point>& vP)
{
    int n = (int) vP.size();

    if (n == 1) {
        return INF;
    } else if (n == 2) {
        return Dist(vP[0], vP[1]);
    }

    double dL, dR, dLR;
    vector<Point> vPL, vPR, vPLR;
    auto itM = vP.begin() + n / 2;

    copy(vP.begin(), itM, back_inserter(vPL));
    copy(itM, vP.end(), back_inserter(vPR));
    
    dL = ClosestDist(vPL);
    dR = ClosestDist(vPR);
    double dRet = min(dL, dR);

    Point Left((*itM).x - dRet, -INF);
    Point Right((*itM).x + dRet, INF);
    auto LeftIt = lower_bound(vP.begin(), vP.end(), Left);
    auto RightIt = lower_bound(LeftIt, vP.end(), Right);
    copy(LeftIt, RightIt, back_inserter(vPLR));
    sort(vPLR.begin(), vPLR.end(), CompY);

    int k = (int) vPLR.size();
    dLR = INF;
    for (int l = 0; l < k; ++l) {
        for (int r = l + 1; r < k; ++r) {
            dLR = min(dLR, Dist(vPLR[l], vPLR[r]));
            if (vPLR[r].y - vPLR[l].y > dLR) {
                break;
            }
        }
    }

    dRet = min(dRet, dLR);
    return dRet;
}

int main()
{
    int n;
    cin >> n;
    vector<Point> vP(n);
    for (int i = 0; i < n; ++i) {
        cin >> vP[i];
    }

    sort(vP.begin(), vP.end());
    cout << fixed << setprecision(10);
    cout << ClosestDist(vP) << endl;

    return 0;
}


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

int main() {
  int N, A, B, a, b, c;
  cin >> N >> A >> B;
  a=0;
  b=0;
  c=0;
  vector<int> P(N);
  for (int i=0; i<N; i++) {
    cin >> P[i];
  }
  for (int j=0; j<N; j++) {
    if (P[j]<=A) {
      a=a+1;
    }
    else {
      if (P[j]<=B) {
        b=b+1;
      }
      else {
        c=c+1;
      }
    }
  }
  cout << min(min(a,b),c) << endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  cin>>a;

  priority_queue<ll,deque<ll>,less<>> que;
  rep(i,n)que.push(a[i]);
  rep(i,m){
    ll mx=que.top();
    que.pop();
    mx/=2;
    que.push(mx);
  }

  ll ans=0;
  while(!que.empty()){
    ans+=que.top();
    que.pop();
  }
  cout<<(ans)<<endl;


}


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

using namespace std;

int main (void) {
    long long N, M;
    cin >> N >> M;

    long long ans;
    if ( N >= M / 2 ) {
        ans = M / 2;
    }
    else {
        ans = N + (M - 2 * N) / 4;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>

using namespace std;
unordered_set<string> hit;
int main() {
	int n;
	cin>>n; n--;
	string last; cin>>last;
	hit.insert(last);
	while (n--) {
		string ss;
		cin>>ss;
		if (hit.find(ss) != hit.end()) {
			cout<<"No"<<endl;
			return 0;
		}
		if (ss[0] != last.back()) {
			cout<<"No"<<endl;
			return 0;
		}
		hit.insert(ss);
		last = ss;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256