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

int main() {
  int N;
  cin >> N;
  int m = N%1000;
  int M = N/10;
    
    if ( m % 111 ==0 || M % 111 ==0 ) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No"<< endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	vector<int> v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	cout << (v[1] - v[0]) + (v[2] - v[1]);
}

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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int addm(int a, int b)
{
	return (0L + a + b) % MOD;
}

int main()
{
	int S;
	cin >> S;
	
	vector<int> dp(S + 1);

	dp[0] = 1;

	for (int i = 1; i <= S; ++i) {
		for (int k = 0; k <= i - 3; ++k) {
			dp[i] = addm(dp[i], dp[k]);
		}
	}

	cout << dp[S] << endl;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int m;cin >> m;
    out(48-m);
}


Measured memory_bytes: 256
N, M = map(int, input().split())
like_set = {0}
for i in range(1, M+1):
    like_set.add(i)
for i in range(N):
    like = list(map(int,input().split()))
    like = set(like[1:])
    like_set = like_set & like
print(len(like_set))


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

int main(){
  int x, y, z, i;
  int count = 0;
  cin >> x >> y >> z;
  for(i = x; i <= y; i++){
    if(0 == z % i){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		int[] sortedA = new int[N];
		int idx;
		for (idx = 0; idx < N; idx++) {
			A[idx] = Integer.parseInt(sc.next());
			sortedA[idx] = A[idx];
		}
//		Arrays.parallelSort(sortedA);
		Arrays.sort(sortedA);

		int max = sortedA[N - 1];
		int second = sortedA[N - 2];

		for (idx = 0; idx < N; idx++) {
			if (A[idx] == max) {
				System.out.println(second);
			} else {
				System.out.println(max);
			}
		}

	}

}


Measured memory_bytes: 89940
import fractions

a,b,c,d=map(int,input().split())
e=b-a+1
f=b//c
g=b//d
h=(a-1)//c
i=(a-1)//d
j=c*d//fractions.gcd(c,d)
k=b//j
l=(a-1)//j
m=e-(f-h)-(g-i)+(k-l)
print(m)

Measured memory_bytes: 5432
#include <iostream>

using namespace std;

int main(){

    int x, y;
    int a, b;

    cin >> x >> y;

    if (x*4 < y){
         cout << "No" << endl;
        return 0;
    }
    else if (y < 2*x) {
        cout << "No" << endl;
        return 0;
    }

    if ((y - 2*x)%2 == 0){
        b = (y-2*x)/2;
    } else {
        cout << "No" << endl;
        return 0;
    }

    if ((y-4*b)%2 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  vector<int> e(n, 0), w(n, 0);
  rep(i, n) {
    if (i) {
      e[i] += e[i - 1];
      w[i] += w[i - 1];
    }
    if (s[i] == 'E') e[i]++;
    else if (s[i] == 'W') w[i]++;
  }

  int ans = n;
  rep(i, n) {
    int res = 0;
    if (i) res += w[i - 1];
    res += e[n - 1] - e[i];
    ans = min(ans, res);
  }
  cout << ans << endl;




  
  return 0;
}

Measured memory_bytes: 2948
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

	if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	return 0;
}

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

int main() {
	
	int N, M;
	std::cin >> N >> M;
	std::priority_queue<int> que;
	for(int i=0; i<N; i++) {
		int a; std::cin >> a;
		que.push(a);
	};

	for(int i=0; i<M; i++) {
		int x = que.top();
		que.pop();
		x >>= 1;
		que.push(x);
	}
	long long int ans = 0;
	while(!que.empty()) {
		ans += que.top();
		que.pop();
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

const ll DIVIDE = (1E+9)+7;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H, W, K;
  cin >> H >> W >> K;

  if(W==1){
    cout << "1\n";
    return 0;
  }

  vll random_num(W, 0);
  vll put_num(W-1, 0);
  vll nonput_num(W, 0);

  random_num[0] = 1;
  random_num[1] = 2;
  random_num[2] = 3;
  FOR(i, 3, W-1){
    random_num[i] = (random_num[i-1] + random_num[i-2])%DIVIDE;
  }

  put_num[0] = random_num[W-3];
  FOR(i, 1, W-2){
    put_num[i] = (random_num[i-1]*random_num[W-3-i])%DIVIDE;
  }
  put_num[W-2] = random_num[W-3];

  nonput_num[0] = random_num[W-2];
  FOR(i, 1, W-1){
    nonput_num[i] = (random_num[i-1]*random_num[W-2-i])%DIVIDE;
  }
  nonput_num[W-1] = random_num[W-2];

  vll dp(W, 0);
  vll dp2(W, 0);
  dp[0] = 1;
  FOR(i, 0, H){
    dp2[0] = (dp[0]*nonput_num[0] + dp[1]*put_num[0])%DIVIDE;
    FOR(j, 1, W-1){
      dp2[j] = (dp[j-1]*put_num[j-1] + dp[j]*nonput_num[j] + dp[j+1]*put_num[j])%DIVIDE;
    }
    dp2[W-1] = (dp[W-2]*put_num[W-2] + dp[W-1]*nonput_num[W-1])%DIVIDE;

    dp = dp2;
  }

  cout << dp[K-1] << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 100005
int n,m,A[M];
ll sum,ans,cnt1[M],cnt2[M];
int dis(int a,int b){
	if(a<=b)return b-a;
	return m-a+b;
}
int nxt(int a,int b=1){
	return (a+b-1)%m+1;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<n;i++)sum+=dis(A[i],A[i+1]);
	for(int i=1;i<n;i++){
		if(nxt(A[i])==A[i+1])continue;
		int s=nxt(A[i],2),t=A[i+1];
		cnt1[s]++;
		if(s<=t){
			if(t!=m)cnt1[nxt(t)]--,cnt2[nxt(t)]-=dis(s,t)+1;
		}
		else{
			cnt1[1]++;
			cnt2[1]+=dis(s,1);
			cnt1[nxt(t)]--;
			cnt2[nxt(t)]-=dis(s,t)+1;
		}
	}
	ll t=0,res=0;
	for(int i=1;i<=m;i++){
		t+=cnt1[i];
		res+=t+cnt2[i];
		ans=max(ans,res);
	}
	cout<<sum-ans<<endl;
	return 0;
}

Measured memory_bytes: 2176
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int A, B;
  string S;
  cin >> A >> B;
  cin >> S;
  string ans = "Yes";
  for(int i=0; i<S.size();++i){
    if((i == A && S[i] != '-') || (i != A && S[i] == '-')){
      ans = "No";
      break;
    }
  }
  cout << ans << endl;

}

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

const int N = 1e5 + 10;
typedef long long LL;

int n, x, a[N];
LL ans;

LL cal(){
	LL ret = 0;
	int pre = 0;
    for(int i=0; i<n; i++){
		if(pre + a[i] <= x){
			pre = a[i];
		} else {
            ret = ret + pre + a[i] - x;
            pre = x - pre;
		}
    }
    return ret;
}

int main(){
	while(~scanf("%d %d", &n, &x)){
		for(int i=0; i<n; i++)	scanf("%d", a+i);
		ans = cal();
		reverse(a, a+n);
		ans = min(ans, cal());
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s="CODEFESTIVAL2016",st;
    int i,sum=0;
    cin>>st;
    for (i=0;i<s.length();i++)
    if (s[i]!=st[i]) sum++;
    cout<<sum<<endl;
    return 0;
}


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

int main() 
{
    char b;
    cin >> b;

    switch ( b )
    {
      case 'A':
            cout << 'T' << endl;
            break;
      case 'T':
            cout << 'A' << endl;
            break;
      case 'C':
            cout << 'G' << endl;
            break;
      case 'G':
            cout << 'C' << endl;
            break;
    }
}

Measured memory_bytes: 256
unittest
{
	assert( [ "3", "0 1 1 2" ].parse.expand.solve == 7 );
	assert( [ "4", "0 0 1 0 2" ].parse.expand.solve == 10 );
	assert( [ "2", "0 3 1" ].parse.expand.solve == -1 );
	assert( [ "1", "1 1" ].parse.expand.solve == -1 );
	assert( [ "10", "0 0 1 1 2 3 5 8 13 21 34" ].parse.expand.solve == 264 );
	
	assert( [ "1", "2" ].parse.expand.solve == -1 );		// 追加ケース
	assert( [ "30", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100000000 100000000" ].parse.expand.solve == 568435455 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	// 深さ0からnに向かって最大頂点数を計算
	auto ans = 0L;
	auto at = as.sum;
	auto n = 1L;
	foreach( i, a; as )
	{
		ans += n;
		if( n < a ) return -1L;		// どうやっても葉が足りない
		at -= a;
		n = min( ( n - a ) * 2, at );		// 頂点数が残りの葉の数を超えないようにする
	}
	return ans;
}


Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<" "<<#x<<"="<<x

#define bit(k) (1LL<<(k))

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/
struct mint {
    ll x; // typedef long long ll;
    mint(ll _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(ll t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint Comb(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n,k;
    cin>>n>>k;
    combination c(n);
    k = min(k, n-1);
    mint ans = 0;
    rep(i,k+1){
        ans += c.Comb(n,i) * c.Comb(n-1-i+i, i);
    }
    cout<<ans.x<<endl;
}

Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Moats around the Castle
public class Main{

	static int N, M;
	static boolean safe(int i, int j){
		return 0<=i&&i<M&&0<=j&&j<N;
	}
	static int[][] d;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] move = {{0,1},{0,-1},{1,0},{-1,0}};
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			N = n+2;
			M = m+2;
			char[][] map = new char[M][N];
			for(int i=0;i<M;i++)map[i][0]=map[i][N-1]='.';
			for(int j=0;j<N;j++)map[0][j]=map[M-1][j]='.';
			for(int i=1;i<=m;i++){
				char[] s = sc.next().toCharArray();
				for(int j=0;j<n;j++)map[i][j+1]=s[j];
			}
			d = new int[M][N];
			for(int i=0;i<M;i++)Arrays.fill(d[i], Integer.MAX_VALUE);
			d[0][0] = 0;
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(M, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return d[o1[0]][o1[1]]-d[o2[0]][o2[1]];
				}
			});
			q.add(new int[]{0,0});
			int ans = Integer.MAX_VALUE;
			while(!q.isEmpty()){
				int[] a = q.poll();
				int i = a[0];
				int j = a[1];
				if(map[i][j]=='&'){
					ans = Math.min(ans, d[i][j]);
				}
				for(int k=0;k<4;k++){
					int ni = i+move[k][0];
					int nj = j+move[k][1];
					if(safe(ni,nj)){
						int cost = d[i][j] + (map[i][j]=='#'&&map[ni][nj]!='#'?1:0);
						if(cost < d[ni][nj]){
							d[ni][nj] = cost;
							q.add(new int[]{ni,nj});
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 0
/***************************************************************************
                                AUTHOR: SPARSH SINHA
            **************************************************************************/


#include <bits/stdc++.h>
using namespace std;
#define si(N) scanf("%d",&N);
#define sll(N) scanf("%lld",&N);
#define ss(s) scanf("%s",s);
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a; i<=b;i++)
#define fori(i,n) for(int i = 0 ; i < n; i++)
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define debug(x)       cerr<< #x <<" : "<<x<<endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
const int INF = 1e9 + 7;
const int NAX = 1e5 + 5;
int main()
{
        int N , M;
        cin >> N >> M;
        vector<vector<int>> v(NAX);
        for(int i = 0 ; i < N; i++){ int a , b;  cin >> a >> b; v[a].pb(b); } 
        multiset <int> rew;
        int ans = 0;
        for(int i = 0; i <= M; i++){
             for(auto x : v[i]) rew.insert(x);  
             if(rew.empty()) continue;
             auto mx = rew.end();--mx;
             ans = ans + *mx; 
             rew.erase(mx); 
        }
        //time complexity M + N*LOGN  = O(NLOGN)
        cout << ans << endl;
}


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

char line[301];

class rectangle {
	int h; // heigt of rectangle
	int w; // width of rectangle
public:
	int setheight(int height);
	int setwidth(int width);
	int getheight(void);
	int getwidth(void);
	char* linepaint(int hei);
};

int rectangle::setheight(int height) {
	if(height >= 0 && height <= 300){
		h = height;
		return 0;
	} else {
		h = -1;
		return -1;
	}
}
int rectangle::setwidth(int width) {
	if(width >= 0 && width <= 300){
		w = width;
		return 0;
	} else {
		w = -1;
		return -1;
	}
}
int rectangle::getheight(void) {
	if(h >= 0 && h <= 300)
		return h;
	else
		return -1;
}
int rectangle::getwidth(void) {
	if(w >=0 && w <= 300)
		return w;
	else
		return -1;
}

char* rectangle::linepaint(int height) {
	//char line[301];
	if(h >= 0 && h <= 300 && w >=0 && w <= 300) {
		if(height >= 0 && height <= h){
			for(int i=0;i<w;i++)
				line[i] = '#';
			line[w]='\0';
			return line;
		} else {
			line[0]='\0';
			return  line;
		}
	} else {
		line[0]='\0';
		return line;
	}
}

int main() {
	int h,w,i=0,n;
	class rectangle x[1000];

	while((cin >> h >> w) && !(h ==0 && w == 0)){
		x[i].setheight(h);
		x[i].setwidth(w);
		i++;
	}
	n=i;
	for(i=0;i<n;i++){
		h=x[i].getheight();
		for(int j=0;j<h;j++){
			cout << x[i].linepaint(j) << endl;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
	
	int x,a,b;
	cin >>x >>a >>b;
	
	int da=abs(x-a),db=abs(x-b);
	if (da<=db) {
		cout <<"A" <<endl;
	} else {
		cout <<"B" <<endl;
	}
	
	return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n,m;
	cin >> n>>m;
	print((1900 * m + 100 * (n - m))*(pow(2, m)));
}

Measured memory_bytes: 4280
//g++ D.cpp -I /usr/local/include/ac-library
#include<cmath>
#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define mod 1000000007
//#define mint=modint1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int op(int a,int b){
    return max(a,b);
}

int e(){
    return 0;
}

int main(){
    int n,k;
    cin >> n>> k;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
    }
    segtree<int,op,e> seg(300005);
    rep(i,300004){
        seg.set(i,0);
    }
    rep(i,n){
        int p=seg.prod(max(0,A[i]-k),min(300001,A[i]+k+1));
        seg.set(A[i],p+1); 
    }
    int ans=seg.all_prod();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9628
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Edge{
	Edge(int arg_to,ll arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to;
	ll cost;
};

struct Info{
	Info(int arg_node_id,ll arg_sum_cost){
		node_id = arg_node_id;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Info &arg) const{

		return sum_cost > arg.sum_cost; //総コストの昇順(PQ)
	}

	int node_id;
	ll sum_cost;
};

int N,R;
ll min_dist[SIZE],value[SIZE];
vector<Edge> G[SIZE];


int main(){

	scanf("%d %d",&N,&R);

	int root = 0;

	ll cost;

	for(int i = 1; i <= N; i++){

		scanf("%lld %lld",&cost,&value[i]);
		G[root].push_back(Edge(i,cost));
	}

	int from,to;

	for(int loop = 0; loop < R; loop++){

		scanf("%d %d %lld",&to,&from,&cost);
		G[from].push_back(Edge(to,cost-1));
	}

	for(int i = 1; i <= N; i++){

		min_dist[i] = HUGE_NUM;
	}
	min_dist[root] = 0;

	priority_queue<Info> Q;
	Q.push(Info(root,0));

	while(!Q.empty()){

		if(Q.top().sum_cost > min_dist[Q.top().node_id]){

			Q.pop();

		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next_node = G[Q.top().node_id][i].to;
				ll next_cost = Q.top().sum_cost+G[Q.top().node_id][i].cost;

				if(min_dist[next_node] > next_cost){
					min_dist[next_node] = next_cost;
					Q.push(Info(next_node,next_cost));
				}
			}
			Q.pop();
		}
	}

	ll ans = 0;

	for(int i = 1; i <= N; i++){

		ans += value[i]*min_dist[i];
	}

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

	return 0;
}



Measured memory_bytes: 14592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main() {
	int N;
	cin >> N;
	vi A(N);
	int tmp;
	rep(i,N){
		scanf("%d",&tmp);
		A[i]=tmp-(i+1);
	}
	sort(all(A));
	tmp = A[N/2];
	rep(i,N)A[i]=abs(A[i]-tmp);
	ll sum=0;
	rep(i,N)sum+=A[i];
	cout << sum;

	return 0;
}


Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
#https://note.nkmk.me/python-union-find/

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n
    
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]
    
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
    
            if x == y:
                return
    
            if self.parents[x] > self.parents[y]:
                x, y = y, x
    
            self.parents[x] += self.parents[y]
            self.parents[y] = x
    
        def size(self, x):
            return -self.parents[self.find(x)]
    
        def same(self, x, y):
            return self.find(x) == self.find(y)
    
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
    
        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]
    
        def group_count(self):
            return len(self.roots())
    
        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}
    
        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    n,q=MI()
    uf=UnionFind(n)
    for i in range(q):
        t,u,v=MI()
        if t==0:
            uf.union(u,v)
        else:
            if uf.find(u)==uf.find(v):
                print(1)
            else:
                print(0)
        
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 12248
#include <bits/stdc++.h>
using namespace std;
string s[100001];
int n;
long long ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s+1,s+1+n);
	long long rest=1;
	for(int i=2;i<=n;i++)
	{
		if(s[i]==s[i-1])
		{
			rest++;
		}
		else 
		{
			ans+=rest*(rest-1)/2;
			rest=1;
		}
	}
	cout<<ans+rest*(rest-1)/2;
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
   ll n;
   cin>>n;
   ll a[n],i,sum=0;
   for(i=0;i<n;i++)
   cin>>a[i];
   for(i=1;i<n;i++)
   {
       if(a[i-1]>a[i])
       {
           sum+=a[i-1]-a[i];
           a[i]=a[i-1];
       }
   }
   cout<<sum<<endl;
}

Measured memory_bytes: 5132
#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};
const int INF = 1<<30;

int main() {
  string s;
  cin>>s;
  int ans = 0;
  for(int i = 0; i < (int)s.size(); i++){
    if(i%2==0&&s[i]=='p')ans--;
    if(i%2==1&&s[i]=='g')ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int s = n * 3;
		System.out.println((s+m)/2);
		
		
	}
}


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

#define rep(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int64_t A, B, N;
  cin >> A >> B >> N;
  int ans=0;
  rep(k,1,A-1) {
    int64_t y=B*(A-k)/A;
    if(A*y==B*(A-k)&&y<=N||A*(y+1)<B*(A-k+1)&&y+1<=N) {
      ans=A-k;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 1000001;
const int mod = 1000000007;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
vector<int> isPrime(MAX, 1);
vector<int> prime, a;
map<int, int> gcd;
int N;
/* function */
void eratos() {
    isPrime[0] = isPrime[1] = 0;
    for (int i = 2; i*i < MAX; i++) {
        if (isPrime[i]) {
            for (int j = i * 2; j < MAX; j += i) isPrime[j] = 0;
        }
    }
    for (int i = 0; i < MAX; i++) if (isPrime[i]) prime.push_back(i);
}

void primeFactorization() {
    for (int i = 0; i < N; i++) {
        map<int, int> factor;
        int x = a[i];
        if (x < 2) {
            factor[x]++;
            return ;
        }
        for (int j = 0; prime[j] * prime[j] <= a[i]; j++) {
            while (x%prime[j] == 0) {
                factor[prime[j]]++;
                x /= prime[j];
            }
        }
        if (x != 1) factor[x]++;

        for (auto f : factor) {
            gcd[f.first] = max(gcd[f.first], f.second);
        }
    }

}
/* main */
int main(){
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", &a[i]);

    eratos();
    primeFactorization();

    mint L = 1;
    for (auto g : gcd) {
        mint b = g.first;
        L *= b.pow(g.second);
    }
    mint ans = 0;
    for (int i = 0; i < N; i++) {
        mint x = a[i];
        ans += L / x;
    }

    cout << ans << '\n';
}


Measured memory_bytes: 4988
#include<stdio.h>

int main(void)
{
  int N,K;
  char S[50];
  
  scanf("%d%d",&N,&K);
  scanf("%s",S);
  
  if(S[K-1]=='A'){
      S[K-1]='a';
  }else if(S[K-1]=='B'){
    S[K-1]='b';
  }else if(S[K-1]=='C'){
      S[K-1]='c';
  }
  
  printf("%s\n",S);
  
  return 0;
}

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

int main(){
  string x;
  int sum=0;


  while(1){
    cin >> x;
    sum = 0;
    if ( x[0] == '0' )break;
    
    for (int  i = 0 ; i < x.size() ; i++){
      sum = sum + (x[i]-'0');
    }
    cout << sum << endl;
  }

  return 0  ;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n, k;
  std::cin >> n >> k;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int h;
    std::cin >> h;
    if (h >= k)
      ++cnt;
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 3164
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

string s,t;
int main() {
    int n;
    R(n,s,t);
    for ( int i=n; i>=0; i-- ) {
        string z=s+t.substr(i);
        if ( z.substr(SZ(z)-n)==t ) {
            dump(z);
            W(SZ(z));
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct stu{
	int q,k;
}a[100005];
int n;
bool cmp(stu x,stu y) {
	return x.k<y.k;
}
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i].k);
		a[i].q=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++) printf("%d ",a[i].q);
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll n,m,s[2222],t[2222],dp[2222][2222],i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>s[i];
	for(i=1;i<=m;i++)
		cin>>t[i];
	for(i=0;i<=n;i++)
		dp[i][0]=1;
	for(j=0;j<=m;j++)
		dp[0][j]=1;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			if(s[i]!=t[j])
				dp[i][j]+=(M-dp[i-1][j-1]);
			dp[i][j]%=M;
		}
	}
	cout<<dp[n][m]<<endl;
}

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

using namespace std;

int solve(int N) {
	int ans = 0;
	for (int w = 2; w < N; ++w) {
		for (int i = 1; i < N; ++i) {
			int j = i + w - 1;
			int a0 = i - 1;
			if (a0 * w + w * (w+1) / 2 == N) {
//				cout << i << " " << w << endl;
				++ans;
			}
		}
	}
	return ans;
}
int main() {
	int N;
	while ( cin >> N, N ) {
		cout << solve(N) << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define MOD 1000000007
#define MAX 505
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int p[MAX], c[MAX], score[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int n, g;
    cin>>n>>g;
    for(int i = 0; i < n; i++){
        cin>>p[i]>>c[i];
    }
    for(int i = 0; i < n; i++)
        score[i] = 100 * (i + 1);

    int Min = 1e8;
    for(int i = 0; i < (1 << n); i++){
        bitset<10> bit(i);
        int cnt = 0;
        int temp = g;
        for(int j = 0; j < n; j++){
            if(bit[j]){
                temp -= (p[j] * score[j]) + c[j];
                cnt += p[j];
            }
        }
        for(int j = n - 1; j >= 0; j--){
            if(!bit[j]){
                int t = min(p[j], (max(0, temp) + score[j] - 1) / score[j]);
                cnt += t;
                temp -= (t * score[j]);
            }
        }
        Min = min(Min, cnt);
    }

    cout<<Min<<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 a,b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int N, K;
  scanf("%d%d", &N, &K);
  double p = 0.0;
  rep(i, 1, N + 1) {
    int H = 0;
    while ((i * (1 << H)) < K)
      H++;
    p += (1.0 / (1.0 * (1 << H)));
  }
  p /= (1.0 * N);
  printf("%.9f\n", p);
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  solve();
	return 0;
}



Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

N, M = map(int,input().split())
p = list(map(int,input().split()))

i = []
for k in range(N):
    i.append([p[k],k])
i = sorted(i)

uf = UnionFind(N)
for k in range(M):
    x, y = map(int,input().split())
    uf.union(x-1,y-1)
ans = 0
for k in range(N):
    if uf.same(k,i[k][1]):
        ans += 1
print(ans)


Measured memory_bytes: 23236
#include<stdio.h>
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main(){ ; 
    int a,b,c;
    cin >> a >> b >> c;
    if (c-(a-b) >= 0){
         printf("%d",c-(a-b));
    }
    else{
        printf("%d",0);
    }

}   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define maxn 5003
#define mod 1000000007
using namespace std;
vector <int> G[maxn];
int g[maxn], f[maxn][maxn], tmp[maxn], sze[maxn];
void upd(int& x, int y){
	x += y;
	if (x >= mod)
		x -= mod;
}
void dp(int u, int fa){
	sze[u] = 1;
	f[u][1] = 1;
	for (int i = 0; i < G[u].size(); ++ i){
		int v = G[u][i];
		if (v != fa){
			dp(v, u);
			for (int i = 1; i <= sze[u] + sze[v]; ++ i)
				tmp[i] = f[u][i], f[u][i] = 0;
			for (int i = 1; i <= sze[u]; ++ i)
				for (int j = 1; j <= sze[v]; ++ j){
					upd(f[u][i + j], 1LL * tmp[i] * f[v][j] % mod);
					upd(f[u][i], mod - 1LL * tmp[i] * f[v][j] % mod * g[j] % mod);
				}
			sze[u] += sze[v];
		}
	}
}
int main(){
	int n;
	cin >> n;
	for (int i = 1; i < n; ++ i){
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	g[0] = 1;
	for (int i = 2; i <= n; i += 2)
		g[i] = 1LL * g[i - 2] * (i - 1) % mod;
	dp(1, 0);
	int ans = 0;
	for (int i = 2; i <= n; i += 2)
		upd(ans, 1LL * f[1][i] * g[i] % mod);
	cout << ans << endl;
}


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


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (auto i = 0; i < M; ++i) {
    cin >> A[i];
  }

  int days = accumulate(A.begin(), A.end(), 0);
  int answer = N - days;
  if (answer < 0) answer = -1;

  cout << answer << endl;

}

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

using namespace std;

#define int long long

const int MOD = 1e9 + 7;
const int N = 1e6 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

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

int dp[N];
int ps[N];

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

	int n;
	cin >> n;
	dp[0] = 1;
	ps[0] = 1;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (i - 3 >= 0) dp[i] = add(dp[i], ps[i - 3]);
		ps[i] = add(ps[i - 1], dp[i]);
	}
	for (int i = 0; i < n; i++) {
		int l = (n - i);
		int r = n;
		l = max(l, (int)2);
		if (l <= r) {
			ans = add(ans, mul(dp[i], r - l + 1));
		}
	}
	for (int i = 0; i <= n; i++) {
		if (i + 2 <= n) {
			int v = mul(n - 1, n - 1);
			v = mul(v, dp[i]);
			ans = add(ans, v);
		} else if (i == n) {
			ans = add(ans, dp[i]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vec P(n+1),C(n+1);
    rep1(i,n) cin>>P[i];
    rep1(i,n) cin>>C[i];
    ll ans=-1e18;
    rep1(i,n){
        vec num(n+1,0);
        ll a=i,b=0;
        ll s=0;
        while(num[P[a]]==0){
            num[P[a]]=1;
            s+=C[P[a]];
            a=P[a];
            b++;
        }
        if(b<k){
            if(s>0){
                ll x=-1e18,y=0,a=i;
                rep(j,b+k%b){
                    y+=C[P[a]];
                    a=P[a];
                    x=max(x,y);
                }
                ans=max(ans,(k/b-1)*s+x);
            }
            else{
                ll x=-1e18,y=0,a=i;
                rep(j,b){
                    y+=C[P[a]];
                    a=P[a];
                    x=max(x,y);
                }
                ans=max(ans,x);
            }
        }
        else{
            ll x=-1e18,y=0,a=i;
            rep(j,k){
                y+=C[P[a]];
                a=P[a];
                x=max(x,y);
            }
            ans=max(ans,x);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3788
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int a[] = new int[n];
	int sum = 0;
	for(int i = 0; i < n;i++){
	   a[i] = sc.nextInt();
           a[i]--;
	   sum += a[i];
	}
	System.out.println(sum);
    }
}


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

int main(void){
  int X, Y;
  cin >> X >> Y;

  for(int i = 0; i <= X; ++i) {
    if((i * 2) + ((X - i) * 4) == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
string a,b;
int cmp(char a,char b)
{
	return a>b;
}
int main() {
    getline(cin,a);
    getline(cin,b);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    if(a>=b) 
    {
    	cout<<"No";
	}
	else 
	{
		cout<<"Yes";
	}
	cout<<endl;
	
}

Measured memory_bytes: 256