akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int a[55];
int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,K,n;
    //double start=clock();
    scanf("%d%d",&n,&K);
    rep(i,0,n)scanf("%d",&a[i]);
    int x=0;
    rep(i,1,n)if(a[i]<a[x])x=i;
    vi ans;
    rep(i,0,n)if(i!=x)ans.pb(i),a[i]--;
    ans.pb(x);a[x]--;
    rep(i,0,K){
        int y=-1;
        rep(j,0,n)if(j!=x){
            if(a[j]==0){puts("-1");return 0;}
            if(y==-1||a[j]<a[y])y=j;
        }
        rep(j,0,n)if(j!=x&&j!=y){
            ans.pb(j);a[j]--;
        }
        ans.pb(y);a[y]--;
        x=y;
    }
    printf("%d\n",SZ(ans));
    for(auto &x:ans)printf("%d ",x+1);puts("");
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

def gcd(x, y):
    while(y):
        x, y = y, x%y
    return x

def lcm(x, y):
    lcm = (x*y)//gcd(x,y)
    return lcm

ans = 1
for i in a:
    ans = lcm(ans, i)
    
print(ans)

Measured memory_bytes: 7684
#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 N, L;
    cin >> N >> L;

    vector<string> s(N);
    rep (i,N) {
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());

    for (int i = 0; i < N; ++i) {
        cout << s.at(i);
    }
    cout << endl;


}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  int a = 0;
  int b = 0;
  for (int i = 0; i < 3; i++)
  {
    cin >> x;
    if (x == 5)a++;
    if (x == 7)b++;
  }
  if (a == 2 && b == 1){
    cout << "YES" << endl;
    }
  else {cout << "NO" << endl;}
  return 0;
}


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

string maxNum(string A,string B){
  if(A.size()>B.size()) return A;
  if(A.size()<B.size()) return B;
  for(int i=0;i<A.size();i++){
    if(A[i]>B[i]) return A;
    if(A[i]<B[i]) return B;
  }
  return A;
}

int main(){
  string s;
  cin>>s;
  int slen=s.size();
  string dp[N][N];
  for(int i=0;i<slen;i++){
    string num;
    for(int j=i;j<slen;j++){
      if(('0'<=s[j]&&s[j]<='9')||s[j]=='?'){
	if(s[j]!='?') num+=s[j];
	else num+='9';
	if(num.size()>=2&&num[0]=='0') break;
	dp[i][j]=num;
      }else break;
    }
  }
  for(int w=6;w<=slen;w++){
    for(int i=0;i<=slen-w;i++){
      int r=i+w-1;
      if(s[i]!='?'&&(s[i]!='L'&&s[i]!='R')) continue;
      if(s[i+1]!='?'&&s[i+1]!='(') continue;
      if(s[r]!='?'&&s[r]!=')') continue;
      for(int j=i+3;j<=i+w-3;j++){
	if(s[j]!='?'&&s[j]!=',') continue;
	if(dp[i+2][j-1]==""||dp[j+1][i+w-2]=="") continue;
	if(s[i]=='?'||s[i]=='L')
	  dp[i][r]=maxNum(dp[i][r],dp[i+2][j-1]);
	if(s[i]=='?'||s[i]=='R')
	  dp[i][r]=maxNum(dp[i][r],dp[j+1][r-1]);
      }
    }
  }
  if(dp[0][slen-1]!="") cout<<dp[0][slen-1]<<endl;
  else cout<<"invalid"<<endl;
  return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)

int main() {
    long N;
    cin >> N;
    long ans = 0;
    ans += N*(N-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main() {
	lli n, k, a, ans = 0, b = 0;
	lli i, j;
	vector<lli> vec;
	cin >> n >> k;
	rep(i, 0, n) {
		cin >> a;
		vec.push_back(a);
	}
	rep(i, 0, n - 1) {
		rep(j, i + 1, n) {
			if (vec[i] > vec[j]) {
				ans++;
				ans %= N;
			}
		}
	}
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (vec[i] > vec[j]) {
				b++;
			}
		}
	}
	//    cout<<ans<<" "<<b<<endl;
	ans *= k;
	ans %= N;
	k = ((k - 1) * k) / 2 % N;
	//    cout<<b*(k/2)<<endl;
	ans += b * k % N;
	ans %= N;
	cout << ans << endl;
}


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

int main() {
	int n;
	map <int, int> mp;
	rep (i, 52 * 2) {
		if (i < 26) {
			mp[i] = 'a' + i;
		} else if (i < 52) {
			mp[i] = 'A' + 26 - (52 - i);
		} else if (i < 26 * 3) {
			mp[i] = 'a' + 26 - (26*3 - i);
		} else {
			mp[i] = 'A' + 26 - (26*4 - i);
		}
	}

	while (cin >> n, n) {
		vector <int> k(n);
		rep (i, n) cin >> k[i];
		string s;
		cin >> s;
		string out = "";

		rep (i, s.size()) {
			int tmp;
			if ('a' <= s[i] && s[i] <= 'z') tmp = 52 + s[i] - 'a';
			else tmp = s[i] - 'A' + 78;
			out.push_back((char)mp[tmp - k[i%n]]);
		}
		cout << out << endl;
	}
	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    string L;
    cin >> L;

    enum{lower = 0, unkown = 1};
    const i64 MOD = 1e9 + 7;
    const int N = L.size();
    vector<vector<i64>> dp(N+1,vector<i64>(2, 0));
    dp[0][lower] = 1; // (0, 0)
    dp[0][unkown] = 2; // (1..., 0...), (0..., 1...)
    
    //digit :  0-indexed
    for(int digit = 1; digit < N; digit++){
        // lower
        dp[digit][lower] = (dp[digit][lower] + 3*dp[digit-1][lower]) % MOD;
        // unknown
        if(L[digit] == '1'){
            dp[digit][unkown] = (dp[digit][unkown] + 2*dp[digit-1][unkown]) % MOD; // choose 1
            dp[digit][lower] = (dp[digit][lower] + dp[digit-1][unkown]) % MOD; // choose 0
        } else {
            dp[digit][unkown] = (dp[digit][unkown] + dp[digit-1][unkown]) % MOD;
        }
    }
    // L == A+B -> dp[N-1][unkown]
    i64 ans = (dp[N-1][lower] + dp[N-1][unkown]) % MOD;
    cout <<  ans << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN 2999
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9

long double dp[MAXN][MAXN];
vector<long double> arr(MAXN);

long double sol(int ind,int nh,int n){

	if(ind < 0 && 2*nh > n) return (long double)1.0;
	else if(ind < 0) return (long double)0.0;

	if(dp[ind][nh] != -1.0) return (long double)dp[ind][nh];

	long double prob = 0.0;

	prob = prob + (long double)arr[ind]*sol(ind-1,nh+1,n);
	prob = prob + (long double)(1.0-arr[ind])*sol(ind-1,nh,n);

	dp[ind][nh] = prob;
	return dp[ind][nh];
}


int main(){

	fastio;
	int n;
	cin >> n;

	fo(n) cin >> arr[i];

	fo(MAXN){
		for(int j = 0;j < MAXN;j++){
			dp[i][j] = -1.0;
		}
	}
	long double prob = sol(n-1,0,n);

	cout << std::setprecision(10) << std::fixed;
	cout << prob << endl;

	return 0;
 }	

Measured memory_bytes: 141056
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int res = N;
    rep(i,N-1){
        if(S[i]!=S[i+1]){
            res = min(res,max(i+1,N-i-1));
        }
    }
    cout << res << endl;
    return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  set<int>S;
  int a,b,c;
  cin >> a >> b >> c;
  S.insert(a);
  S.insert(b);
  S.insert(c);
  
  cout << S.size() << endl;
}
      
       

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll ans[100010];
int num[100010];
ll sum;
#define INF 1000100

int main()
{
	ll n;cin >> n;
	vector<ll> v;
	ll a1;cin >> a1;sum += a1;
	v.PB(a1);
	map<ll,ll> mp;
	mp[a1] = 1;
	ll sa = 0;

	
	REP(i,n-1)
	{
		int a;cin >> a;sum += a;
		decltype(v)::iterator tmp;
		tmp = lower_bound(ALL(v),a+1);
		if(a == v[v.size()-1])tmp--;
		if(tmp == v.end())
		{
			v.PB(a);
			mp[a] = i+2;
			num[i+2]++;
		}
		else if(tmp != v.begin())
		{
			int tt = a - *(tmp-1);
			ans[mp[*tmp]] += tt;
			sa += tt;
			num[mp[*(tmp-1)]]++;
		}
	}
		
	/*
	SHOW1d(num,n+1);
	SHOW1d(ans,n+1);
	*/
	
	ll cou = 0;
	for(int i = v.size()-1;i > 0;i--)
	{
		cou += num[mp[v[i]]];
		ll tmp = cou * (v[i] - v[i-1]);
		ans[mp[v[i]]] += tmp;
		sa += tmp;
	}
	//cout << sum << ' ' << sa << endl;
	ans[1] = sum - sa;
	
	for(int i = 1;i <= n;i++)
	{
		cout << ans[i] << endl;
	}
	
		
	
	
	return 0;
}

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define ms memset
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define lower_bound lb
#define upper_bound ub

int main()
{
    int ac = 0; int wa = 0; int tle = 0; int re = 0;
    int TC; cin >> TC;
    while (TC--){
        string s; cin >> s;
        if (s[0] == 'A') ac++;
        if (s[0] == 'W') wa++;
        if (s[0] == 'T') tle++;
        if (s[0] == 'R') re++;
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  getline(cin,s);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      char c; c = s[i] - 0x20;
      cout << c;
    }
    else if (s[i] >= 'A' && s[i] <= 'Z') {
      char c; c = s[i] + 0x20;
      cout << c;
    }
    else {
      cout << s[i];
    }
  }
  cout << endl;
}



Measured memory_bytes: 3172
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

bool is_integer(double x)
{
    return std::floor(x) == x;
}

int calc_num_div(int N)
{
    int ans = 0;
    for (int i = 1; i * i < N; i++)
    {
        if (N % i == 0)
            ans += 2;
    }

    if (is_integer(sqrt(N)))
        ans--;

    return ans;
}

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, ans = 0;
    cin >> N;

    for (int i = 1; i <= N; i += 2)
    {
        if (calc_num_div(i) == 8)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int function(int N) {
    int sum = 0;
    while (N > 0) {
        sum += N % 10;
        N /= 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    if (N % function(N)) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
io = STDIN
$h,$w,$n=io.gets.chomp.split.map(&:to_i)
masu=Hash.new{|h,k|h[k]=0}
$n.times do
  i,j = io.gets.chomp.split.map{|s|s.to_i.pred}
  [-1,0,1].product([-1,0,1]) do |x,y|
    xx,yy=i+x,j+y
    next if xx<=0 || yy<=0
    next if xx>=$h-1 || yy>=$w-1
    masu[xx*$w+yy]+=1
  end
end
ans={}
1.upto(9) do |ct|
  ans[ct]=0
end
cnts=masu.values
cnts.each do |ct|
  ans[ct]+=1
end
puts ($w-2)*($h-2)-cnts.size
puts ans.values

Measured memory_bytes: 67068
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
using P = pair<int, int>;
using ll = long long;
vector<int> to[100005];
int cost[100005];

signed main(){
    int n, a, b;
    cin >>n >>a>>b;
    int ans = 0;
    FOR(i, 1, n+1) {
        int tmp = 0;
        int k = i;
        while(k>0){
            tmp += k%10;
            k /= 10;
        }
        if(tmp>=a && tmp <=b) {
            ans+=i;
            //cout << i<<" "<<tmp << endl;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <bitset>

#define mod 1e9+7
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h;
    ll n = 0;
    ll ans = 0;
    cin >> h;
    while(h >= 1){
		h/=2;
        n++;
    }
    rep(j, n) ans+=pow(2, j);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N + 2);
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i <= N; i++) {
		M += abs(v[i] - v[i + 1]);
	}
	for (int i = 1; i <= N; i++) {
		cout << M - abs(v[i] - v[i - 1]) - abs(v[i] - v[i + 1]) + abs(v[i - 1] - v[i + 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

typedef vector<int> Set;
Set sets[5];
Set U;
string input;
int index;

void Print(const Set& s) {
  if (s.empty()) {
    cout << "NULL";
  } else {
    for (int i = 0; i < s.size(); ++i) {
      if (i != 0) cout << " ";
      cout << s[i];
    }
  }
  cout << endl;
}

Set Union(const Set& a, const Set& b) {
  Set r;
  set_union(a.begin(), a.end(), b.begin(), b.end(), back_inserter(r));
  return r;
}

Set Intersection(const Set& a, const Set& b) {
  Set r;
  set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(r));
  return r;
}

Set Diff(const Set& a, const Set& b) {
  Set r;
  set_difference(a.begin(), a.end(), b.begin(), b.end(), back_inserter(r));
  return r;
}

Set SymDiff(const Set& a, const Set& b) {
  Set r;
  set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), back_inserter(r));
  return r;
}

string bin_ops = "uids";
Set Fact();
Set Exp() {
  Set val = Fact();
  while (index < input.size() && bin_ops.find(input[index]) != string::npos) {
    char op = input[index++];
    Set b = Fact();
    switch (op) {
    case 'u': val = Union(val, b); break;
    case 'i': val = Intersection(val, b); break;
    case 'd': val = Diff(val, b); break;
    case 's': val = SymDiff(val, b); break;
    }
  }
  return val;
}

Set Fact() {
  char op = input[index++];
  Set r;
  if (op == 'c') {
    r = Diff(U, Fact());
  } else if (op == '(') {
    r = Exp();
    ++index;
  } else {
    r = sets[op - 'A'];
  }
  return r;
}

int main() {
  char name;
  int num;
  while (cin >> name >> num) {
    for (Set& s : sets) s.clear(); U.clear();
    do {
      for (int i = 0; i < num; ++i) {
	int v;
	cin >> v;
	sets[name - 'A'].push_back(v);
      }
    } while (cin >> name >> num && name != 'R');
    for (Set& s : sets) {
      sort(s.begin(), s.end());
      U = Union(U, s);
    }
    cin >> input;
    index = 0;
    Set res = Exp();
    Print(res);
  }
}

Measured memory_bytes: 1240
n = int(input());
a = input().split(" ");
for i in range(n) :
	a[i] = int(a[i]);

a.insert(0,0);

ans = [0] * n;
for i in range(1,n+1) :
	ans[ a[i]-1 ] = i;

print(' '.join(map(str,ans)));

Measured memory_bytes: 18404
def solve(n:int, l:list):
    cnt = 0
    for i in range(n):
        cnt += 1/l[i]
    return 1/cnt

def main():
    n = int(input())
    l = list(map(int, input().split(" ")))
    print(solve(n, l))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m,a[100]={},b[100]={},g[10][10]={};
	cin>>n>>m;
	FOR(i,0,m){
		cin>>a[i]>>b[i];
		g[a[i]][b[i]]=1;
		g[b[i]][a[i]]=1;
	}
	vector<int> p(n);
	FOR(i,0,n){
		p[i]=i+1;
	}
	int ans=0;
	do{
		if(p[0]!=1)break;
		int f=1;
		FOR(i,1,n){
			if(g[p[i]][p[i-1]]==0)f=0;
		}
		ans+=f;
	}while(next_permutation(p.begin(),p.end()));
	cout<<ans;
    return 0;
}


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

int main(){

    int n; cin>>n;

    vector<int> sta(n);

    for(int i=0; i<n; i++) cin>>sta[i];

    bool judge = true;

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

        if(sta[i] > sta[i-1]) sta[i]--;

        if(sta[i-1] > sta[i]) judge = false; 
    }

    if(judge)cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;

}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

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


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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
	
    ll h; 
    cin >> h;
    ll pow2 = 1, ans = 0;
    while(h != 0){
        ans += pow2;
        pow2 *= 2;
        h /= 2;
    }
    cout << ans;
}








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

using namespace std;

int main(){
  long long n,m;
  cin >> n >> m;
  priority_queue<long long> a;
  for(int i=0;i<n;i++){
    long long p;
    cin >> p;
    a.push(p);
  }
  for(int i=0;i<m;i++){
    long long q=a.top();
    a.pop();
    a.push(q/2);
  }
  long long ans=0;
  for(int i=0;i<n;i++){
    long long r=a.top();
    a.pop();
    ans+=r;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
N,M=map(int,input().split())
A=[0]*N
B=[0]*M
C=[[0]*N for i in range(N)]
D=[[0]*N for i in range(N)]

for i in range(N):
    A[i]=list(input())
for i in range(M):
    B[i]=list(input())

SUM=0
for i in range(M):
    for j in range(M):
        if(B[i][j]=="#"):
            SUM+=1

for k in range(N):
    t=0
    for i in range(M):
        if(A[k][i]=="#"):
            t+=1
    C[k][i-M+1]=t
    for i in range(M,N):
        if(A[k][i]=="#"):
            t+=1
        if(A[k][i-M]=="#"):
            t-=1
        C[k][i-M+1]=t
for i in range(N):
    for j in range(N-M+1):
        for k in range(M):
            D[j][i]+=C[j+k][i]

for i in range(N-M+1):
    for j in range(N-M+1):
        if(D[i][j]==SUM):
            e=1
            for k in range(M):
                for l in range(M):
                    if(A[i+l][j+k]!=B[k][l]):
                        e=0  
            if(e==1):
                print("Yes")
                exit()
print("No")


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

ll n, k;
ll a[212345];

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

    rep(i,n) cin >> a[i];

    for (int i = k; i < n; i++){
        if (a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 5192
#include <cstdio>
 
using namespace std;
 
int main(void){
  int N,K;
  
  scanf("%d%d", &N, &K);
  if(N%2==0){
    if(N/2>=K) printf("YES\n");
    else printf ("NO\n");
  }else{
  if(N/2+1>=K) printf("YES\n");
  else printf ("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    LL N;
    cin >> N;

    string Ns = to_string(N);
    LL Nf = 0;
    REP(Ns.size()) Nf += (LL)(Ns.at(i) - '0');

    if(N % Nf == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1050
#define M 200
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;
vector<string>ar;
int on = 1;
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
  	int h,w,k;
  	cin>>h>>w>>k;
  	ar.resize(h);
  	for(int i=0;i<h;i++)
  	    cin>>ar[i];
  	int ans = 0;
  	//cout<<h<<" "<<w<<"\n";
  	for(int i=0;i<(on<<h);i++){
  	  //  cout<<" r ";
  	    for(int j=0;j<(on<<w);j++){
  	        int co = 0;
  	      //  cout<<" r ";
  	        for(int k=0;k<h;k++){
  	            for(int l=0;l<w;l++){
  	                if(i&(on<<k))continue;
  	                if(j&(on<<l))continue;
  	                if(ar[k][l]=='#')co++;
  	            }
  	        }
  	        //cout<<co<<" "<<i<<" "<<j<<"\n";
  	        if(co==k)ans++;
  	    }
  	}
  	cout<<ans;
  	return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll X[100005];
ll S[100005];

int main()
{
	int N, K;
	cin >> N >> K;
	REP(i, N)
	{
		cin >> X[i];
	}

	ll sum = 0;
	FOR(i, K, 1)
	{
		sum += X[i] - X[i - 1];
	}


	ll min = INF;
	REP(i, N - K + 1)
	{
		ll t = std::min(std::abs(X[i]), std::abs(X[i + K - 1]));
		min = std::min(min, sum + t);
		sum -= X[i + 1] - X[i];
		sum += X[i + K] - X[i + K - 1];
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw26(12,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,11) pw26[i]=26*pw26[i-1];}
    ll N; cin>>N;
    
    ll tmp=26,i=1,sum=0;
    while(sum+tmp<N){
        sum+=tmp;
        tmp*=26;
        i++;
    }
    //i文字のN-sum番目
    //BIT全探索
    vector<ll> BIT(i);
    ll tmps=N-sum-1;
    rrep(i2,i){
        BIT[i2]=tmps/pw26[i2];
        tmps%=pw26[i2];
    }
    rrep(j,i){
        cout<<(char)(BIT[j]+'a');
    }
}



Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    A_enable = []
    B_enable = []
    AB_enable = []
    a = 0
    while a <= F:
        A_enable.append(a)
        a += A*100
    
    b = 0
    while b <= F:
        B_enable.append(b)
        b += B*100

    for aa in A_enable:
        for bb in B_enable:
            if aa+bb<=F:
                AB_enable.append(aa+bb)
    AB_enable = sorted(list(set(AB_enable)))
    AB_enable.pop(0)

    C_enable = []
    D_enable = []
    CD_enable = []
    c = 0
    while c <= F:
        C_enable.append(c)
        c += C
    d = 0
    while d <= F:
        D_enable.append(d)
        d += D

    for cc in C_enable:
        for dd in D_enable:
            if cc+dd <= F:
                CD_enable.append(cc+dd)
    CD_enable = sorted(list(set(CD_enable)))
    CD_enable.pop(0)

    answer = [AB_enable[0],0,0] 

    for aabb in AB_enable:
        for ccdd in CD_enable:
            if (aabb/100)*E >= ccdd and aabb+ccdd<=F and answer[2] < ccdd/(aabb+ccdd): 
                
                answer[0] = aabb
                answer[1] = ccdd
                answer[2] = ccdd/(aabb+ccdd)
    
    print(answer[0]+answer[1], answer[1])
            
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12608
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();

    let m = n * (n - 1) / 2 - (n - 1);
    if k > m {
        println!("-1");
        return;
    }

    let mut v = vec![];
    for i in 2..n + 1 {
        v.push((1, i));
    }

    let mut k = m - k;
    for i in 2..n + 1 {
        for j in i + 1..n + 1 {
            if k > 0 {
                v.push((i, j));
                k -= 1;
            }
        }
    }

    println!("{}", v.len());
    for (u, v) in v {
        println!("{} {}", u, v);
    }
}


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

int main(void){
    int k,s;
    cin >> k >> s;
    
    int count=0;
    for(int x=0;x<k+1;x++){
        for(int y=0;y<k+1;y++){
            int z = s-x-y;
            if(0<=z && z<=k) count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vl vector<long int>
#define vll vector<long long int>
#define pi pair<int, int>
#define  ump unordered_map
#define us  unordered_set
 using namespace std;
  
   int main()
   {
   	  int k;
   	   cin>>k;
   	    int a,b;
   	     cin>>a>>b;
   	     // b=a+(n-1)*k;
   	      int flag=0;
   	 for(int i=a; i<=b; i++)
   	 {
   	 	if(i%k==0)
   	 	{
   	 		flag=1;
   	 		 break;
			}
		}
		 if(flag==1)
		 cout<<"OK";
		 else
   	      cout<<"NG";

   	       
   	      
   }

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

// void attack(long x, long& num_atk){
//     if (x == 1){num_atk+=1;return;}
//     long next_hp = x / 2;
//     num_atk+=1;
//     attack(next_hp, num_atk);
//     attack(next_hp, num_atk);
// }

int main(){
    long h;
    cin >> h;
    long total = 1;
    long prev = 1;
    //attack(h, total);
    while (h>1){
        h /= 2;
        prev *=2;
        total += prev;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    char s[h][w];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          cin>>s[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(s[i][j]=='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'&&s[i-1][j]!='#'&&s[i+1][j]!='#'){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
    cout<<"Yes"<<endl;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;
const int MAX = 1e6;

map<int, int> mp;

bool check(int n){
	string s = to_string(n);
	REP(i,s.length()){
			if(mp[s[i]-'0']) return false;
	}

	return true;
}

int main(void){

	int N, K; cin >> N >> K;

	REP(i,K){
		int d; cin >> d;
		mp[d]++;
	}
	
	FOR(i,N,MAX){
		if(check(i)){
			cout << i << endl;
			return 0;
		}
	}




	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

template<typename Type_k,typename Type_p>
Type_p mod_pow(long long n,Type_k k,Type_p p){//n^k(mod p).
	if(k==0) return 1;
	long long res=mod_pow(n*n%p,k/2,p);
	if(k&1) res=res*n%p;
	return res;
}

int main(){//解説参考.
	string s;
	cin>>s;
	
	llong ans=0;
	int len=s.size();
	int cnt=0;
	REP(i,len){
		if(s[i]=='1'){
			cnt++;
			llong tmp=(llong)mod_pow(2LL,cnt-1,MOD)*mod_pow(3LL,len-i-1,MOD)%MOD;
			ans=(ans+tmp)%MOD;
		}
	}
	ans=(ans+mod_pow(2LL,cnt,MOD))%MOD;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3724
using System;
public class Hello{
    public static void Main(){
        var s = Console.ReadLine();
        var ans = string.Empty;
        for(var i = 0;i < s.Length;i++){
            if(s[i] == '1'){
                ans += "9";
            }else{
                ans += "1";
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int H, W; cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  for (auto& r : A) {
    for (auto& c : r) {
      cin >> c;
    }
  }

  vector<vector<int>> res(H+2, vector<int>(W+2, 0));
  res[1][1] = 1;
  for (int row = 1; row <= H; ++row) {
    for (int column = 1; column <= W; ++column) {
      if (row == 1 && column == 1) {
        continue;
      }
      if (A[row-1][column-1] == '#') {
        continue;
      }
      res[row][column] = res[row-1][column] + res[row][column-1];
      res[row][column] %= MOD;
    }
  }
  auto ans = res[H][W];
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, m,ans=0;
  cin >> n >> m  ;
  vector<pair<ll, ll>> info(n);
  for (auto &[a, b] : info) {
    cin >> a >> b;
  }
  sort(ALL(info));
  REP(i, n) {
    ans += min(info[i].second, m) * info[i].first;
    m -= min(info[i].second, m);
  }
  cout << ans << endl;
  
  return 0;
}


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

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

  int64_t a,b;
  for(a=0; a<100; a++) {
    for(b=a; b<100; b++) {
      if(a*a*a*a*a + b*b*b*b*b == x) {
        cout<<a<<' '<<-b<<endl;
        return 0;
      }
    }
  }

  for(a=1; a<1000; a++) {
    for(b=1; b<=a; b++) {
      if(a*a*a*a*a - b*b*b*b*b == x) {
        cout<<a<<' '<<b<<endl;
        return 0;
      }
    }
  }




  return 0;
}

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

int main() {
	int n,m;
	while(cin>>n>>m,n,m){
		int ans=0;
		queue<int> que;
		for(int i=0,num;i<m;i++){
			cin>>num;
			que.push(num);
			ans+=num;
		}
		for(int i=m,num,sum=ans-que.front();i<n;i++){
			que.pop();
			cin>>num;
			sum+=num;
			ans=max(ans,sum);
			sum-=que.front();
			que.push(num);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1348
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

#define VMAX 100

struct OwnEdge
{
	int f, t, flow, cap;
	OwnEdge(int f, int t, int flow, int cap) :f(f), t(t), flow(flow), cap(cap) {}
};

vector<OwnEdge> G[VMAX];
int src, dest;
int level[VMAX], prog[VMAX], que[VMAX];

bool bfs()
{
	fill(level, level + VMAX, -1);
	int l = 0, r = 0;
	level[src] = 0;
	que[l] = src;
	while (l <= r)
	{
		int t = que[l++];
		if (t == dest)
		{
			break;
		}
		for (int i = 0; i != G[t].size(); i++)
		{
			if (level[G[t][i].t] == -1 && G[t][i].cap > G[t][i].flow)
			{
				level[G[t][i].t] = level[t] + 1;
				que[++r] = G[t][i].t;
			}
		}
	}

	return level[dest] != -1;
}

int dfs(int now, int lim)
{
	int ans = 0;
	if (now == dest)
	{
		return lim;
	}

	for (int& i = prog[now]; i != G[now].size(); i++)
	{
		if (G[now][i].flow >= G[now][i].cap)
		{
			continue;
		}
		if (level[G[now][i].t] == level[now] + 1)
		{
			int t = dfs(G[now][i].t, min(lim, (G[now][i].cap - G[now][i].flow)));
			G[now][i].flow += t;
			G[G[now][i].t][G[now][i].f].flow -= t;
			ans += t;
			lim -= t;
			if (lim == 0)
			{
				break;
			}
		}
	}

	return ans;
}

int dinic(int V)
{
	src = 0, dest = V - 1;
	int ans = 0;

	while (bfs())
	{
		fill(prog, prog + VMAX, 0);
		ans += dfs(src, INF);
	}

	return ans;
}

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

	int V, E;
		cin >> V >> E;

	for (int i = 0; i < E; i++)
	{
		int u, v, c;
		cin >> u >> v >> c;

		int tus = G[u].size(), tvs = G[v].size();

		G[u].push_back(OwnEdge(tvs, v, 0, c));
		G[v].push_back(OwnEdge(tus, u, c, c));
	}

	cout << dinic(V) << endl;

	return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
int main(){
    char  x[101],y[101],xy[202]={NULL};
    cin>>x>>y;
    strcpy(xy,x);
    strcat(xy,y);
    long long a=atoi(xy);
    for(int i=1;i<a/2;i++){
       /* long long b=a;
        if(b%i==0){
            while(b%i!=1){
               b=b/i;
               if(b==0){
                   cout<<"Yes"<<endl;
                   return 0;
               }
            }
        }*/
        //cout<<"i*iは？"<<i*i<<endl;
        //cout<<"aは？　"<<a<<endl;
        if(i*i==a){
            cout<<"Yes"<<endl;
            return 0;
        }
        else{
            if(i*i>a){cout<<"No"<<endl;
            return 0;
            }
        }
    }
    return 0;
}

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

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< int, ll > pil;
typedef pair< ll, int > pli;
typedef pair< ll, ll > pll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector< double > vd;
typedef vector< vd > vvd;
typedef vector< pii > vp;
typedef vector< vp > vvp;
typedef vector< bool > vb;
typedef vector< vb > vvb;

template< class T1, class T2 >
bool upmin( T1 &x, T2 v ){
    if( x > v ){
        x = v;
        return true;
    }
    return false;
}

template< class T1, class T2 >
bool upmax( T1 &x, T2 v ){
    if( x < v ){
        x = v;
        return true;
    }
    return false;
}

void solve(){
    int A, B, C; cin >> A >> B >> C;
    if( A % 2 == 0 or B % 2 == 0 or C % 2 == 0 ){
        cout << 0 << endl;
        return;
    }
    cout << min( 1LL * A * B, min( 1LL * B * C, 1LL * A * C ) ) << endl;
}

int main(){
    ios::sync_with_stdio( false );
    solve();
    return 0;
}


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

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x)
    {
        data=x;
        left=NULL;
        right=NULL;
    }
};
#define Node struct Node

ll modpow(ll a, ll n)
{
    ll m=1e9+7;
    if(n==0)
        return 1;
    ll y=modpow(a,n/2)%m;
    if(n%2==0)
        return (y*y)%m;
    return (((y*y)%m)*a)%m;
}

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        for(ll i=1;i<n;i++)
        {
            ans+=(n-1)/i;
        }
        cout<<ans<<endl;
    }
    return 0;
}
















Measured memory_bytes: 3632