akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn

object Main extends App {
  
  def loop(x: Int, y: Int): Unit = {
    if(x != 0 || y != 0){
      if(x <= y) println(x + " " + y)
      else println(y + " " + x)

      val a = StdIn.readLine().trim.split(' ').map(_.toInt)
      loop(a(0), a(1))
    } 
  }

  val Array(fx, fy) = StdIn.readLine().trim.split(' ').map(_.toInt)

  loop(fx, fy)

}


Measured memory_bytes: 46392
#pragma GCC optimize("O3")
#include<stdint.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
/*****************************************************************************/
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
//																#define __debug
#ifdef __debug
	#define IOS (void)0
	#define de(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define de(...) (void)0
	#define ar(...) (void)0
#endif
/***********************************default***********************************/
const int maxn=5e5+9,mo=998244353;
int n,m,fac[maxn],res=0;

int qp(int x,int t=mo-2){
	int re=1;
	while(t){
		if(t&1)re=re*x%mo;
		x=x*x%mo,t>>=1;
	}
	return re;
}

int c(int x,int y){
	if(x==y)return 1;
	else if(y>x||y<0)return 0;
	else return fac[x]*qp(fac[y])%mo*qp(fac[x-y])%mo;
}

main(){
	IOS;
	fac[0]=1;REP(i,1,maxn)fac[i]=fac[i-1]*i%mo;
	cin>>n>>m;
	REP(i,0,min(n,m)+1){
		(res+=(i%2?-1:1)*c(n,i)*c(m,i)%mo*fac[i]%mo*qp(m+1,n-i)%mo*qp(n+1,m-i)%mo)%=mo;
	}
	cout<<(mo+res%mo)%mo<<endl;
}

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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<int> d;
  rep(i, x) d.push_back(p[i]);
  rep(i, y) d.push_back(q[i]);
  rep(i, c) d.push_back(r[i]);
  sort(d.rbegin(), d.rend());
  ll ans = 0;
  rep(i, x + y) ans += d[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6476
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int x[n];
  int y[n];
  int i;
  for(i=0;i<n;i++){
    cin>>x[i];
  }
  for(i=0;i<n;i++){
    cin>>y[i];
  }
  int z = 0;
  for(i=0;i<n;i++){
    if(x[i]-y[i]>0)
      z+=x[i]-y[i];
  }
  cout<<z;
  return 0;
}
  


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009

typedef long long ll;

void swap(ll *a, ll *b)
{
  ll tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

// a ÷b (mod MOD) →(a % MOD) * modinv(b, MOD) % MDO
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(&a, &b);
        u -= t * v; swap(&u, &v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


ll combi(ll n, ll r) {
	ll ans = 1;
	for ( ll i = 0; i < r; i++ ) {
		ans = (ans * (n - i) % MOD) * modinv(r - i, MOD) % MOD;
	}
	return ans;
}

ll PowMod(ll n, ll pow, ll mod) {
	if (pow == 0) return 1;
	if (pow % 2 == 0) {
		ll tmp = PowMod(n, pow / 2, mod);
		return tmp * tmp % mod;
	}
	return n * PowMod(n, pow - 1, mod);
}



int main(void) {
	ll n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);

	
	ll sum = PowMod(2, n, MOD);
	sum = ((sum - combi(n, a) + MOD) % MOD - combi(n, b) - 1 + MOD) % MOD;
	printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define max(a,b)((a)>(b)?(a):(b))

int ans=0;

void brock(int ice[92][92],int x,int y,int dep){
	ice[x][y]=0;
	if(ice[x][y-1]==1){
		brock(ice,x,y-1,dep+1);
	}
	if(ice[x][y+1]==1){
		brock(ice,x,y+1,dep+1);
	}
	if(ice[x-1][y]==1){
		brock(ice,x-1,y,dep+1);
	}
	if(ice[x+1][y]==1){
		brock(ice,x+1,y,dep+1);
	}
	ice[x][y]=1;
	if((ice[x][y-1]||ice[x][y+1]||ice[x-1][y]||ice[x+1][y])==0){
		if(dep+1>ans)ans=dep+1;
	}
}

int main(void){
	int m,n;
	int i,j;
	int ice[92][92];
	while(1){
		scanf("%d",&m);
		scanf("%d",&n);
		if(m==0 && n==0)break;
		memset(ice,0,sizeof(ice));
		ans=0;
		for(j=1;j<=n;j++){
			for(i=1;i<=m;i++){
				scanf("%d",&ice[i][j]);
			}
		}
		for(j=1;j<=n;j++){
			for(i=1;i<=m;i++){
				if(ice[i][j]==1)brock(ice,i,j,0);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	int n;
	std::cin >> n;
	std::vector<pair<int,int>> a(n);
	rep(i,n){
		std::cin >> a[i].first;
		a[i].second=i+1;
	}
	sort(all(a));
	rep(i,n)std::cout << a[i].second << ' ' ;
	std::cout << ' ' << std::endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
typedef pair<int,int> pii;

int main(){
int n;
  string s;
  cin>>n;
  FOR(i,n,n+112){
  s=to_string(i);
    if(s[0]==s[1]&&s[1]==s[2]){
    cout<<i<<endl;
      break;
    }
  }
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define pb push_back
#define eb emplace_back
const  int MAX=1000000;
int main()

{
    ll a,b;

    cin>>a>>b;

    if(a==b)
    {
        cout<<"Draw"<<endl;
    }
    else if(b==1)
    {
        cout<<"Bob"<<endl;
    }
    else if(a==1)
    {
        cout<<"Alice"<< endl;
    }
    else{
        if(a>b)
        {
            cout<<"Alice"<<endl;
        }
        else{
            cout<<"Bob"<<endl;
        }
    }

}



Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <cmath>
#include <tuple>
#include <unordered_map>
#include <bitset>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define all(n)	n.begin(),n.end()
#define each(i,n) for(auto &i : n)

const int INF = 1e9;

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

signed main() {

	int w, h;
	while (cin >> w >> h && w) {
		typedef pair<int, int> p;

		char d[20][20];
		p s;
		map<p, int> tb;
		rep(y, h)rep(x, w) {
			cin >> d[y][x];
			if (d[y][x] == 'o') {
				s.first = y, s.second = x;
			}
			if (d[y][x] == '*') {
				tb[p(y, x)] = tb.size();
			}
		}

		typedef bitset<10> bit;
		unordered_map<bit ,int> m[20][20];
		m[s.first][s.second][bit()] = 0;
		typedef pair<bit, p> sp;
		queue<sp> q;
		q.push(sp(bit(), s));
		int ans = INF;
		while (q.size()) {
			p n = q.front().second;
			auto se = q.front().first;
			q.pop();
			int y = n.first;
			int x = n.second;
			auto nse = se;
			if (d[y][x] == '*') {
				nse[tb[p(y, x)]] = 1;
			}
			if (nse.count() == tb.size()) {
				ans = min(ans, m[y][x][se]);
			}
			rep(i, 4) {
				int ty = y + dy[i];
				int tx = x + dx[i];
				if (ty >= 0 && tx >= 0 && ty < h && tx < w && d[ty][tx] != 'x') {
					if (!m[ty][tx].count(nse) || m[ty][tx][nse] > m[y][x][se] + 1) {
						m[ty][tx][nse] = m[y][x][se] + 1;
						q.push(sp(nse, p(ty, tx)));
					}
				}
			}

		}
		if (ans == INF)ans = -1;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll A, B, C;
    cin >> A >> B >> C;

    ll mx = max({A, B, C});
    ll mn = min({A, B, C});
    ll md = A + B + C - mx - mn;
    ll ans = mx - md;
    ans += (md - mn + 1) / 2;
    if((md - mn) % 2 == 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<math.h>
using namespace std;

int main(){
    // 整数の
    int N;
    cin >> N;
    int V[100];
    int C[100];
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int j=0;j<N;j++){
        cin >> C[j];
    }
    double rN = pow(2,N);
    int N2 = static_cast<int>(rN);
    int maxVal = 0;
    for(int m=0;m<N2;m++){
        int X=0,Y=0;
        bitset<30> value(m);
        for(int n=0;n<30;n++){
            if(value[n]==1){
                X += V[n];
                Y += C[n];
            }
        }
        if(X-Y > maxVal){
            maxVal = X-Y;
        }
    }
    cout << maxVal << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+205;
void solve(){
	int n; 
	cin>>n; 
	ll a = 1;
	ll b = 1;
	for(int i=1;i<=n;i++){
		ll x,y; 
		cin>>x>>y;
		ll af = max((a+x-1)/x,(b+y-1)/y);
		ll aa = af*x;
		ll ba = af*y;
		a = aa;
		b = ba;
	}
	cout<<a+b<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}
/// 2:3 /// 2,3
/// 1:1 /// 3,3
/// aa/bb =x/y
/// bb*x/y = aa
/// bb = aa*y/x


Measured memory_bytes: 3628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CSnack {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll A, B;
	    in >> A >> B;
	    ll X = A * B;
        ll R = A % B;
        while(R!=0){
            A = B;
            B = R;
            R = A % B;
        }
        out << X / B << "\n";
    }
};


signed main() {
	CSnack solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>

typedef long long ll;

ll wrong(std::vector<ll> arr) {
    std::sort(arr.begin(), arr.end());
    std::deque<ll> items;
    for (auto& it : arr) {
        items.push_back(it);
    }
    std::deque<ll> deque;
    deque.push_back(items.front());
    items.pop_front();
    while (!items.empty()) {
        if (items.size() >= 1u) {
            deque.push_back(items.back());
            items.pop_back();
        }
        if (items.size() >= 1u) {
            deque.push_front(items.back());
            items.pop_back();
        }
        if (items.size() >= 1u) {
            deque.push_back(items.front());
            items.pop_front();
        }
        if (items.size() >= 1u) {
            deque.push_front(items.front());
            items.pop_front();
        }
    }
    ll prev = deque.front();
    ll answ = 0;
    for (auto& it : deque) {
        answ += std::abs(prev-it);
        prev = it;
    }
    return answ;
}

ll solve(std::vector<ll> arr) {
    std::sort(arr.begin(), arr.end());
    std::deque<ll> items;
    for (auto& it : arr) {
        items.push_back(it);
    }
    std::deque<ll> deque;
    deque.push_back(items.front());
    items.pop_front();
    while (!items.empty()) {
        auto back  = items.back();
        auto front = items.front();
        auto back_diff_front  = std::abs(deque.front()-back);
        auto back_diff_back   = std::abs( deque.back()-back);
        auto front_diff_front = std::abs(deque.front()-front);
        auto front_diff_back  = std::abs( deque.back()-front);
        auto max = std::max({
            back_diff_front  ,
            back_diff_back   ,
            front_diff_front ,
            front_diff_back  
        });
        if (max == back_diff_front) {
            items.pop_back();
            deque.push_front(back);
            continue;
        }
        if (max == back_diff_back) {
            items.pop_back();
            deque.push_back(back);
            continue;
        }
        if (max == front_diff_back) {
            items.pop_front();
            deque.push_back(front);
            continue;
        }
        if (max == front_diff_front) {
            items.pop_front();
            deque.push_front(front);
            continue;
        }
    }
    ll prev = deque.front();
    ll answ = 0;
    for (auto& it : deque) {
        answ += std::abs(prev-it);
        prev = it;
    }
    return answ;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0);
    ll n;
    while (std::cin >> n) {
        std::vector<ll> arr(n);
        for (auto& it : arr) {
            std::cin >> it;
        }
        std::cout << solve(arr) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2688
S = input()
T = input()

l1,l2 = len(S),len(T)

ans = float('inf')

for i in range(l1-l2+1):
  swap = 0
  s = i
  for j in range(l2):
    if S[s]!=T[j]:
      swap += 1
    s += 1
  ans = min(ans, swap)

print(ans)

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

public class Program
{

	static void Main(string[] args)
	{
		var array = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => x).ToArray();
		var answer = array[1] - array[0];

		if(answer % 2 == 0)
		{
			Console.WriteLine((answer/2) + array[0]);
		}
		else
		{
			Console.WriteLine("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 13396
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] != t[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  vector<int> dp(n);

  REP(i, n) {
    cin >> h[i];
  }

  dp[0] = 0;
  FOR(i, 1, n) {
    dp[i] = MOD;
    for (int j = i - 1; j >= max(0, i - k); j--) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }

  cout << dp[n - 1] << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int A, B;
	cin >> A >> B;

	const int N = 100;

	int Z[N + 2][N + 2] = {};

	REP(i, (N + 2) / 2) REP(j, N + 2) Z[i][j] = 1;

	int dx[] = { 0,  1,  1,  1,  0, -1, -1, -1};
	int dy[] = { 1,  1,  0, -1, -1, -1,  0,  1};
	A--; B--;
	FOR(i, 1, (N + 2) / 2){
		FOR(j, 1, N + 1){
			if(A == 0) break;
			bool ok = true;
			REP(k, 8){
				if(Z[i + dx[k]][j + dy[k]] == 0) ok = false;
			}
			if(ok){
				Z[i][j] = 0;
				A--;
			}
		}
		if(A == 0) break;
	}
	FOR(i, (N + 2) / 2 + 1, N + 1){
		FOR(j, 1, N + 1){
			if(B == 0) break;
			bool ok = true;
			REP(k, 8){
				if(Z[i + dx[k]][j + dy[k]] == 1) ok = false;
			}
			if(ok){
				Z[i][j] = 1;
				B--;
			}
		}
		if(B == 0) break;
	}
	cout << 100 << " " << 100 << endl;
	FOR(i, 1, N + 1){
		FOR(j, 1, N + 1){
			cout << (Z[i][j] == 0 ? '.' : '#');
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 256
def num():
    from sys import stdin
    h, n = map(int, input().split())
    magic = [list(map(int, stdin.readline().split())) for _ in range(n)]
    INF = float('inf')
    ans = [INF]*(h+1)
    ans[-1] = 0

    for i in range(h, 0, -1):
        if ans[i] != INF:
            for j, k in magic:
                if i-j < 0:
                    num = ans[i]+k
                    if ans[0] > num:
                        ans[0] = num
                else:
                    num = ans[i]+k
                    if ans[i-j] > num:
                        ans[i-j] = num
    return ans[0]
print(num())




Measured memory_bytes: 9572
n, w = [int(i) for i in input().split()]
dp = [10 ** 18] * (10 ** 5 + 1)
dp[0] = 0
for _ in range(n):
    u, v = [int(i) for i in input().split()]
    for i in reversed(range(len(dp))):
        if i + v < len(dp) and dp[i]+u <= w:
            dp[i + v] = min(dp[i + v], dp[i] + u)
ans = 0
for i, j in enumerate(dp):
    if j != 10 ** 18:
        ans = max(ans, i)
print(ans)


Measured memory_bytes: 42588
<?php
	fscanf(STDIN, "%d %d", $N, $Y);

	$res10000 = -1;
	$res5000  = -1;
	$res1000  = -1;
	for ($a=0; $a <= $N; $a++)
	{
		for ($b=0; $b+$a <= $N; $b++)
		{
			$c = $N-($a+$b);
			$total = 10000*$a + 5000*$b + 1000*$c;
			if ($total === $Y)
			{
				$res10000 = $a;
				$res5000  = $b;
				$res1000  = $c;
			}
		}
	}
	echo $res10000.' '.$res5000.' '.$res1000;
?>

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

const int INF = 1001001001;

int a[12][12];

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> c(N);
  rep(i,N) {
    cin >> c[i];
    rep(j, M) cin >> a[i][j];
  }
  
  int ans = INF;
  rep(s, 1 <<N) {
    int cost = 0;
    vector<int> d(N);
    rep(i, N){
      if (s>>i&1){
        cost += c[i];
        rep(j,M) d[j] += a[i][j];
      }
    }

    bool ok = true;
    rep(j, M) if (d[j] < X) ok = false;
    if (ok) ans = min(ans, cost);
   }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int n, count;

  scanf("%d", &n);
  while(n != 0){
    count = 0;
    while(n != 0){
      count += n/5;
      n /= 5;
    }
    printf("%d\n", count);
    scanf("%d", &n);
  }
  return 0;
}

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

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	vi a(3);
	rep(i,3)cin>>a[i];
	sort(all(a),greater<int>());
	cout<<a[0]*10+a[1]+a[2]<<endl;
	return 0;
}


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

vector<int> graph[100001];
map<pair<int, int>, int> mp;
void dfs(int par, int v, int ban){
    int c = 1;
    for (int x: graph[v]) {
        if(x == par) continue;
        if(c == ban) c++;
        mp[{min(v, x), max(v, x)}] = c;
        dfs(v, x, c);
        c++;
    }
}

int main() {
    int N;
    cin >> N;
    vector<int>a(N-1);
    vector<int>b(N-1);
    for (int i = 0; i < N-1; ++i) {
        cin >> a[i] >> b[i];
        graph[a[i]].push_back(b[i]);
        graph[b[i]].push_back(a[i]);
    }
    int K = 0;
    for (int i = 1; i <= N; ++i) {
        if(K < graph[i].size()) K = graph[i].size();
    }
    dfs(0, 1, 0);
    cout << K << "\n";
    for (int i = 0; i < N-1; ++i) {
        int ans = mp[{a[i], b[i]}];
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
 
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;
 
#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int n, m;
string a[50], b[50];

bool check(int x, int y) {
	REP(i, m) {
		REP(j, m) {
			int nx = j + x;
			int ny = i + y;
			
			if (a[ny][nx] != b[i][j]) return false;
		}
	}
	return true;
}

int main() {
	cin >> n >> m;
	REP(i, n) cin >> a[i];
	REP(i, m) cin >> b[i];
	
	int ans = 0;
	REP(i, n - m + 1) {
		REP(j, n - m + 1) {
			if (check(j, i)) ans++;
		}
	}
	
	puts(ans ? "Yes" : "No");
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    int p = a + b;
    int t = a * b;
    if(p == 15){
        cout << "+" << endl;
    }else if(t == 15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
    return 0;
}


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

int main(){
  int N, t, x, h;
  double ans = 0, temp;
  cin>>N>>t;
  for(int i = 0; i < N; i++){
    cin>>x>>h;
    temp = (double)h/x *t;
    if(temp > ans) ans = temp;
  }

  printf("%.4f\n", ans);
  return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int N;
    int a[100];
    int num = 0;

    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &a[i]);
        if((i % 2 == 0) && (a[i] % 2 == 1)) {
            num++;
        }
    }

    printf("%d\n", num);
    
    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define INT long long int
#define N 3
#define PA pair<INT, INT>
#define oo 9876543219876543
#define MOD 1000000007
using namespace std;
INT T, n, m, k, x, y, z, a[500050], b[500040], c[500050], ans, Z, Y, dt[2020];
set<INT> u, d;
string s, t;

INT dp(int x)
{
    if( x > n ) return 0;
    if( x == n ) return 1;
    if( ~dt[x] ) return dt[x];
    INT &ret = dt[x] = 0;
    for(int i = 3 ; i <= n ; i++ )
        ret += dp(x+i), ret %= MOD;
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    T = 1; //cin>>T;
    while( T-- )
    {
        memset(dt, -1, sizeof(dt));
        cin>>n;
        cout<<dp(0)<<endl;
    }
    return 0;
}


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

int main(){
    size_t H, W;
    cin >> H >> W;
    size_t d;
    cin >> d;
    vector<vector<char>> c{{'R', 'G'}, {'B', 'Y'}};
    for(size_t i = 0; i < H; ++i, cout << endl)for(size_t j = 0; j < W; ++j)cout << c[(i + j) / d & 1][(i + W - j) / d & 1];
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int H,R;
  cin>>H>>R;
  if(-R==H){
    cout<<0<<endl;
  }else if(H<0&&abs(H)>R){
    cout<<-1<<endl;
  }else{
    cout<<1<<endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  map <tuple <int, int, int>, int> cont;
  for(int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    long long num = 0;
    int ten = 0;
    int cnt = 0;
    long long base = 1;
    for(int j = s.size() - 1; j >= 0; j--) {
      if(s[j] == '.') {
        ten = cnt;
      } else {
        num += base * (s[j] - '0');
        base = base * 10;
        ++cnt;
      }
    }
    int two = 0, five = 0;
    while(num % 2 == 0) {
      num /= 2;
      ++two;
    }
    while(num % 5 == 0) {
      num /= 5;
      ++five;
    }
    cont[make_tuple(two, five, ten)] += 1;
  }
  long long ans = 0;
  for(auto i : cont) {
    for(auto j : cont) {
      int two = get<0>(i.first) + get<0>(j.first);
      int five = get<1>(i.first) + get<1>(j.first);
      int ten = get<2>(i.first) + get<2>(j.first);
      if(i.first == j.first) {
        if(min(two, five) >= ten) {
          ans += (1LL * i.second * (i.second - 1)) / 2;
        }
      } else if (i.first < j.first) {
        if(min(two, five) >= ten) {
          ans += 1LL * i.second * j.second;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJ2007().doIt();
	}
	
	class AOJ2007{
		int n,money[];
		int[] array;
		int getMoney(int a,int b,int c,int d){
			int result = 0;
			int sum = a*10+b*50+c*100+d*500;
			int siharai = n-sum;
			if(siharai>0)return Integer.MAX_VALUE/2;
			siharai = Math.abs(n-sum);
			while(siharai>=500){
				result++;siharai-=500;
			}
			while(siharai>=100){
				result++;siharai-=100;
			}
			while(siharai>=50){
				result++;siharai-=50;
			}
			while(siharai>=10){
				result++;siharai-=10;
			}
			return result;
		}
		
		void solve(){
			int[] result = new int[4];
			int sum = 0;for(int i=0;i<4;i++)sum+=money[i];
			int rsum = Integer.MAX_VALUE;
			for(int ten=0;ten<=money[0];ten++)
				for(int five=0;five<=money[1];five++)
					for(int hund=0;hund<=money[2];hund++)
						for(int fhund=0;fhund<=money[3];fhund++){
							int a = getMoney(ten, five, hund, fhund);
							int cnt = sum-(ten+five+hund+fhund)+a;
							if(cnt>=rsum)continue;
							rsum = cnt;
							result[0] = ten;result[1] = five;
							result[2] = hund;result[3] = fhund;
						}
			for(int i=0;i<4;i++)if(result[i]>0){
				System.out.println(array[i]+" "+result[i]);
			}
		}
		
		void doIt(){
			array = new int[4];array[0] = 10;array[1] = 50;array[2] = 100;array[3] = 500;
			n = in.nextInt();
			if(n==0)return;
			money = new int[4];
			for(int i=0;i<4;i++)money[i] = in.nextInt();
			solve();
			while(in.hasNext()){
				n = in.nextInt();
				if(n==0)break;
				System.out.println();
				money = new int[4];
				for(int i=0;i<4;i++)money[i] = in.nextInt();
				solve();
			}
		}
	}
	
}

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

static const int INF=(1<<21);

int n,M[101][101];
int d[101];

void bfs(int s){
  queue<int>q;
  q.push(s);

  for(int i=0;i<n;i++){
    d[i]=INF;
  }

  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v]==0) continue;
      if(d[v]!=INF) continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<( (d[i]==INF) ? (-1):d[i] )<<endl;
  }
}

int main(){
  int u,k,v;

  cin>>n;

  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }

  bfs(0);

  return 0;
}





Measured memory_bytes: 3132
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;




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





int main() {
	char c[7];
	REP(i, 6) {
		cin >> c[i];
	}
	if (c[0] == c[5] && c[1] == c[4] && c[2] == c[3]) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}



Measured memory_bytes: 256
import collections

N = int(input())
A = list(map(int, input().split()))

CA = collections.Counter(A)

max1 = 0
max2 = 0
for item in CA.items():
    if item[1] >= 2 and item[0] > max1:
        if item[1] >= 4:
            max1 = item[0]
            max2 = item[0]
        else:
            max2 = max1
            max1 = item[0]
    elif item[1] >= 2 and item[0] > max2:
        max2 = item[0]
print(max1*max2)


Measured memory_bytes: 18600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        bool ok = s.StartsWith("YAKI");

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 26180
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long c[410000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%lld",c+i);
		c[i+b]=c[i]+a;
	}
	long long ret=0;
	ret=max(a-c[0],c[b-1]);
	long long cur=0;
	for(int k=0;k<2;k++){
		cur=0;
		for(int i=1;i*2<=b;i++){
			cur+=(c[b+b-2*i]-c[b-i])*2;
			cur-=(c[b+b-i]-c[b+b-i*2+1])*2;
			ret=max(ret,cur-min(c[b+b-i-1]-a,a-c[b-i]));
			//printf("%d %lld\n",i,cur-min(c[b+b-i-1]-a,a-c[b-i]));
		}
		cur=(c[b+b-1]-a)*2;
		for(int i=1;i*2<=b;i++){
			cur+=(c[b+b-1-2*i]-c[b-i])*2;
			cur-=(c[b+b-i]-c[b+b-i*2])*2;
			ret=max(ret,cur-(c[b+b-i-1]-a));
		//	printf("%d %lld %lld\n",i,cur,cur-(c[b+b-i-1]-a));
		}
		for(int i=0;i<b;i++){
			c[i]=a-c[i];
		}
		reverse(c,c+b);
		for(int i=0;i<b;i++){
			c[i+b]=c[i]+a;
		}
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 3328
// https://atcoder.jp/contests/abc085/tasks/abc085_c
"use strict"
function Main(input) {
  const params = input.split(' ').map(Number);
  const n = params[0];
  const y = params[1];
  let total = 0;
  let existing = false;

  loop:
  for(let i = n; i >= 0; i--) {
    total = 10000 * i;
    if (total > y) {
      continue;
    }

    for(let j = n-i; j >= 0; j--) {
      total = 10000 * i + 5000 * j;
      if (total > y) {
        continue;
      }

      for(let k = n - i - j; k >= 0; k--) {
        if (!(i+j+k === n)) {
          break;
        }
        total = 10000 * i + 5000 * j + 1000 * k;

        if(total === y) {
          console.log(`${i} ${j} ${k}`);
          existing = true
          break loop;
        }
      }
    }
  }

  if(!existing) {
    console.log('-1 -1 -1');
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = map(int,read().split())

s = input()
c = s.count("R")
if c==3: print(3)
if c==2:
    if s[1] == "S":
        print(1)
    else:
        print(2)
if c==1:
    print(1)
if c==0: print(0)







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

int main(){
    int k, i, j, cont=0;
    cin >> k;

    for(i=2; i<=k; i+=2){
        for(j=1; j<=k; j+=2){
            cont++;
        }
    }
    cout << cont << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

#各電球がつながっているスイッチの数
K = []

#各電球がつながっているスイッチの集合のリスト
S = []

for _ in range(M):
  ks = list(map(int, input().split()))
  K.append(ks[0])
  S.append(set(ks[1:]))
  
#各電球が偶数点灯(0)か奇数点灯(1)か
P = list(map(int, input().split()))
  
#条件を満たす組み合わせの数
cnt = 0

#0～2**N-1 最大1023(2**10)
for i in range(2**N):
  #全部onなら1のまま、1つでもoffになったら0にして次のループへ
  nowflag = 1
  #今回にiにおいてonになっているスイッチの集合をつくる
  nowon = set()
  for k in range(1,N+1):
    if i%(2**k)>=2**(k-1): nowon.add(k)
  
  #スイッチと電球につながっているスイッチの積集合をとり、
  #その集合のlen%2==Pならフラグそのまま、違ったらフラグを落としてループ抜け
  for j in range(M):
    if len(nowon&S[j])%2!=P[j]:
      nowflag = 0
      break
      
  if nowflag == 1: cnt += 1
#ループ終わり

print(cnt)

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

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	map<vector<int>,int> mp;
	
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		vector<int> hsh(26,0);
		for(int j=0;j<s.size();j++)
			hsh[s[j]-'a']++;
		mp[hsh]+=1;
	}
	
	ll ans=0;
	for(auto i: mp)
	{
		ll val = i.second;
		ans+= ((val)*(val-1))/2;
	}
	cout<<ans;
	
}

Measured memory_bytes: 19072
#include <iostream>
#include <algorithm>
using namespace std;
 
int b[1000001];
int ans;
int main () {
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++) {
		if(b[a[i]]==0) {
			if (a[i]!=a[i-1]&&a[i]!=a[i+1]) {
				ans++;
			}
			for(int j=a[i];j<1000001;j+=a[i]) {
				b[j]=1;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 8264
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	string s;
	int a,z;
	cin >> s;
	a=s.find("A");
	z=s.rfind("Z");
	cout<<z-a+1;
}
	

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


char a[1000][1000];
int dp[1000][1000];
int H, W, K;
queue<int> qh, qw, qk;
int vh[4] = {1, -1, 0, 0};
int vw[4] = {0, 0, 1, -1};
int sh, sw;

int min_to_go(int h, int w){
  int hh = min(H-h-1, h);
  int ww = min(W-w-1, w);
  return min(hh, ww);
}

int bfs(int m){
  if(qh.empty())  return m;
  int h = qh.front(); qh.pop();
  int w = qw.front(); qw.pop();
  int k = qk.front(); qk.pop();
  int mi = min(m, min_to_go(h, w));
  if(k >= K) return bfs(mi);
  for(int i = 0; i < 4; i++){
    int hh = h + vh[i], ww = w + vw[i];
    if(hh < 0 || hh >= H) continue;
    if(ww < 0 || ww >= W) continue;
    if(a[hh][ww] == '.' && dp[hh][ww] == 1e9){
      dp[hh][ww] = k+1;
      qh.push(hh); qw.push(ww); qk.push(k+1);
    }
  }
  return bfs(mi);
}

int d(int x){
  if(x % K == 0)  return x / K;
  else return x / K + 1;
}

int main(){
  cin >> H >> W >> K;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a[i][j];
      if(a[i][j] == 'S'){
        sh = i; sw = j;
      }
      dp[i][j] = 1e9;
    }
  }

  qh.push(sh);  qw.push(sw); qk.push(0); dp[sh][sw] = 0;
  int mi = bfs(1e9);
  cout << 1 + d(mi) << endl;

  return 0;
}


Measured memory_bytes: 53888
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define fup(i,a,b) for(int i=a;i<=b;i++)
#define fdw(i,a,b) for(int i=a;i>=b;i--)
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define cl(a) memset(a,0,sizeof(a))
using namespace std;
typedef long long ll;
const int N=2e6+10;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n>=m)
        fup(i,1,n)
            cout<<m;
    else if(m>n)
        fup(i,1,m)
            cout<<n;
    cout<<endl;
    return 0;
}


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int target = n / 2 * 2;
  vector<PII> edges;
  FOR(i,1,n+1){
    FOR(j,i+1,n+1){
      if(i+j == target+1) continue;
      edges.push_back(PII(i,j));
    }
  }
  
  int m = (int) edges.size();
  cout << m << endl;

  for (auto &p : edges) {
    cout << p.first << " " << p.second << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int n, bestPos;
string s;

bool compare(int x, bool reversed) {
    for (int i = 0; i < n; i++) {
        if (!reversed && s[i + x] != s[i + bestPos]) {
            return s[i + x] < s[i + bestPos];
        }
        if (reversed && s[n - 1 - i + x] != s[n - 1 - i + bestPos]) {
            return s[n - 1 - i + x] < s[n - 1 - i + bestPos];
        }
    }
    return true;
}

int main() {
    int k;
    cin >> n >> k >> s;
    
    if (k > 100 || n >> k == 0) {
        char mi = 'z';
        for (auto c:s)mi = min(mi, c);
        cout << string(n, mi) << endl;
        return 0;
    }

    for (int i = 0; i < k; i++) {
        string t = s;
        reverse(t.begin(), t.end());
        s += t;

        bestPos = 0;
        for (int j = 0; j <= n; j++) {
            if (compare(j, i != k - 1))bestPos = j;
        }

        string best = s.substr(bestPos, n);
        s = best;
    }

    cout << s << endl;
    return 0;
}

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

const int N=2e5+1, M=1e5+1;
int dp[N];
vector<int>adj[N];
bool visited[N];
int maxm=0, n, m;
void dfs(int x)
{
	if(visited[x])
		return;
	visited[x]=1;
	for(auto y:adj[x])
	{
		dfs(y);
		dp[x]=max(dp[x], dp[y]+1);
	}
	maxm=max(maxm, dp[x]);
}

int32_t main()
{
	cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin>>u>>v;
		adj[u].push_back(v);
	}
	for(int i=1; i<=n; ++i)
	{
		dfs(i);
	}
	cout<<maxm;
}
    

Measured memory_bytes: 11520
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<utility>
#include<stack>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1; i <= n; i++) 
		sum += i;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int MAX_MASK=59049;
int dp[11][10][MAX_MASK][3]={};
int mask_size=0;

int getbit(int b,int p){
	REP(i,p){
		b/=3;
	}
	return b%3;
}

int substMask(int mask,int p){
	int minus=getbit(mask,p);
	REP(i,p){
		minus*=3;
	}
	return mask-minus;
}
int addMask(int mask,int p,int v){
	REP(i,p){
		v*=3;
	}
	return mask+v;
}
int getNewMask(int mask,int p,int v){
	return addMask(substMask(mask,p),p,v);
}

const int MOD=100000007;

int main(){
	int r,c;
	cin>>r>>c;
	vs grid(r);
	REP(i,r){
		cin>>grid[i];
	}
	mask_size=pow(3,c);
	dp[0][0][0][0]=1;
	REP(y,r)REP(x,c){
		if(grid[y][x]!='.'){
			REP(mask,mask_size)REP(lmask,3){
				int remain=grid[y][x]-'0';
				remain-=getbit(mask,x);
				remain-=lmask;
				if(remain>=0&&remain<=4){
					if(x<c-1){
						REP(i,remain+1){
							int right=(remain-i);
							if(i>=0&&i<=2&&right>=0&&right<=2){
								int nm=getNewMask(mask,x,i);
								dp[y][x+1][nm][right]+=dp[y][x][mask][lmask];
								dp[y][x+1][nm][right]%=MOD;
							}
						} 
					}else{
						if(remain>=0&&remain<=2){
							dp[y+1][0][getNewMask(mask,x,remain)][0]+=dp[y][x][mask][lmask];
							dp[y+1][0][getNewMask(mask,x,remain)][0]%=MOD;
						}
					}
				}
			}
		}else{
			REP(mask,mask_size){
				if(x<c-1){
					REP(lmask,3){
						if(getbit(mask,x)&&lmask){
							continue;
						}
						dp[y][x+1][mask][lmask]=dp[y][x][mask][lmask];
					}
				}else{
					dp[y+1][0][mask][0]=dp[y][x][mask][0];
				}
			}
		}
	}

	//REP(k,pow(3,3)){
	//	REP(i,r){
	//		REP(j,c){
	//			cerr<<dp[i][j][k][0]<<dp[i][j][k][1]<<dp[i][j][k][2]<<" ";
	//		}
	//		cerr<<endl;
	//	}
	//	cerr<<endl;
	//}
	cout<<dp[r][0][0][0]<<endl;
}

Measured memory_bytes: 72232
# coding: utf-8
# Your code here!
from collections import deque
s=deque(input())
Q=int(input())
count=0
query=[]
for i in range(Q):
    arr=input().split()
    query.append(arr)

for i in range(Q):
    if query[i][0]=="1":
        count+=1
    else:
        if count%2==0:
            if query[i][1]=="1":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])
        else:
            if query[i][1]=="1":
                s.append(query[i][2])
            else:
                s.appendleft(query[i][2])
if count%2==0:
    for i in range(len(s)):
        print(s[i],end="")
        
else:
    s.reverse()
    for i in range(len(s)):
        print(s[i],end="")

Measured memory_bytes: 45152
#include <iostream>
using namespace std;
int main(void){
    long long A,B,C,X,Y,sum=0;
    cin>>A>>B>>C>>X>>Y;
    if(C*2<A+B){
        if(X>Y){
            sum+=C*2*Y;
            X-=Y;Y=0;
        }else{
            sum+=C*2*X;
            Y-=X;X=0;
        }
    }
    if(X>0){
        sum+=min(A,C*2)*X;
    }
    if(Y>0){
        sum+=min(B,C*2)*Y;
    }
    cout<<sum<<endl;
}


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

int main(){
  int n,T;cin >> n >> T;
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  int count=0;
  for(int i=1;i<n;i++){
    if(t[i]-t[i-1]>T){
      count += T;
    }else{
      count += t[i]-t[i-1];
    }
  }
  cout << count+T << endl;
}

Measured memory_bytes: 1024
import itertools
N = int(input())
e = [0]*(N+1)
for i in range(2,N+1):
  cur = i
  for j in range(2,i+1):
    while cur%j==0:
      e[j] += 1
      cur = cur//j

ans = 0
for x in e :
  if x>=74:
    ans +=1
for (x, y) in itertools.combinations(e, 2):
  for a, b in [(24, 2), (14, 4), (4, 14), (2, 24)]:
    if x >= a and y >= b:
      ans += 1
for (x, y, z) in itertools.combinations(e, 3):
  for a, b, c in [[4, 4, 2], [4, 2, 4], [2, 4, 4]]:
    if x >= a and y >= b and z >= c:
      ans += 1
print(ans)

Measured memory_bytes: 3188
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] s = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++){
			s[i] = in.nextInt();
			sum += s[i];
		}
		Arrays.sort(s);
		
		if(sum % 10 != 0) System.out.println(sum);
		else{
			for(int i = 0; i < N; i++){
				if(s[i] % 10 != 0){
					System.out.println(sum-s[i]);
					return;
				}
			}
			System.out.println(0);
		}
	}
}


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

using namespace std;

int mod = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;i < n;i++)
		cin >> a[i];
		
	vector<long long >pref(n);
	for(int i = 0;i < n;i++){
		if(i == 0)
			pref[i] = a[i];
		else
			pref[i] = pref[i-1] + a[i];
	}
	
	long long ans = 0;
	for(int i = 0;i < n;i++){
		ans += a[i] * ((pref[n-1] - pref[i])% mod) % mod;
		ans %= mod;
	}
	
	cout << ans << "\n";
} 

Measured memory_bytes: 5604