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




int main(){

    int n,k;
    cin>>n>>k;

    vi data(n);
    for (int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }


    for (int j=0;j<k;j++){
        bool flag=true;
        for(int i=0;i<n;i++){
            if (data.at(i)!=n){
                flag=false;
                break;
            }
        }

        if (flag){
            break;
        }
             vi tmpvec(n,0);
            for (int i=0;i<n;i++){
                int tmpmin=max(0,i-data.at(i));
                tmpvec.at(tmpmin)++;

                int tmpmax=i+data.at(i)+1;
                if (tmpmax<=(n-1)){
                    tmpvec.at(tmpmax)--;
                }          
            }

			int cnt=0;
            for (int i=0;i<n;i++){ 
                cnt+=tmpvec.at(i);
                data.at(i)=cnt;
            }


    }

    for (int i=0;i<n;i++){
        cout<<data.at(i)<<" ";
    }

    cout<<endl;
    



  

 

}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n,wm,ma=0,ans=-1;
	cin>>n>>wm;
	ll w[n],v[n];
	for(ll i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
		ma+=v[i];
	}
	vector<ll>dp(ma+1,INT_MAX);
	dp[0]=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=ma-v[i];j>=0;j--)
		{
			dp[j+v[i]]=min(dp[j+v[i]],w[i]+dp[j]);
		}
	}
	for(ll i=0;i<dp.size();i++)
	{
		if(dp[i]!=INT_MAX && dp[i]<=wm)ans=max(ans,i);
	}
	cout<<ans<<endl;
	return 0;
}

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

int f(string s, string t){
  int count = 0;
  for(char c = 'a'; c <= 'z'; c++){
    bool founds = false;
    bool foundt = false;
    for(int i = 0; i < s.length(); i++){
      if(s[i] == c) founds = true;
    }
    for(int i = 0; i < t.length(); i++){
      if(t[i] == c) foundt = true;
    }
    if(founds && foundt) count++;
  }
  return count;
}

int main(void){
  int n;
  string s;
  cin >> n >> s;
  int num = 0;
  for(int i = 0; i <= n; i++){
    int temp = f(s.substr(0, i), s.substr(i));
    num = max(num, temp);
  }
  cout << num << endl;
  return 0;
}


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

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
int vis[120];
int main(){
    int n,k,d,a;
    cin >> n >> k;
    while(k--){
        cin >> d;
        while(d--){
            cin >> a;
            if(++vis[a] == 1) n--;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3592
n, x, y = map(int,input().split())

cnt = [0 for i in range(n)]
for i in range(1,n+1):
    for j in range(i+1,n+1):
        dist = min(j-i,abs(x-i)+abs(y-j)+1)
        cnt[dist] += 1

for i in range(1,n):
    print(cnt[i])


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

int main(){
  int N;
  string s;
  cin>>N>>s;
  int f;
  int ok=0;
  std::vector<int> v(N);
  for(int i=0;i<4;i++){
    if(i<2)v[0]=1;
    else v[0]=-1;
    if(i%2)v[1]=-1;
    else v[1]=1;
    for(int j=1;j<N-1;j++){
      if(s[j]=='o')f=1;
      else f=-1;
      v[j+1]=v[j-1]*v[j]*f;
    }
    if(s[N-1]=='o')f=1;
    else f=-1;
    int wf;
    if(s[0]=='o')wf=1;
    else wf=-1;
    if(v[0]==v[N-2]*v[N-1]*f&&v[1]==v[N-1]*v[0]*wf){ok++;break;}
  }
  if(ok){
    for(int i=0;i<N;i++){
      if(v[i]==1)cout<<"S";
      else cout<<"W";
    }
    cout<<endl;
  }
  else cout<<-1<<endl;
}


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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if(c - a - b < 0){
    cout << "No" << endl;
  }else{
    if(4 * a * b < (c - a - b) * (c - a - b)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define vvll vector <vll>
#define vvii vector <vii>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll mod = 1000000007;
ll power(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
  	ll n;
  	cin >> n;
  	string s = to_string(n);
  	ll sz = s.size();
  	if(sz%2 == 0){
    	ll ans = 0, val = 9, si = 1;
      	for(int i = 1; i < sz; i++){
        	ans+= si*val;
          	si*=-1;
          	val = 10*val + 9;
        }
      	cout << ans << "\n";
    }
  	else{
    	ll ans = 0, val = 9, si = 1;
      	for(int i = 1; i <= sz - 2; i++){
        	ans+= si*val;
          	si*=-1;
          	val = 10*val + 9;
        }
      	ans += n - power(10,sz-1) + 1;
      	cout << ans << "\n";
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int W, a, b;
  cin >> W >> a >> b;
  if (abs(a - b) <= W) {
    cout << 0 << endl;
  } else {
    cout << abs(a - b) - W << endl;
  }
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())

if D * K < abs(X):
  print(abs(X) - D * K)
else:
  k = abs(X) // D
  if (K - k) % 2 == 1:
    print(abs(abs(X) - D * k - D))
  else:
    print(abs(X) - D * k)

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
 
#define EPS (1e-10)
#define equals (fabs((a)-(b)<EPS)
int n;
 
struct Point
{
    double x, y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator +(Point a)
    {//x+a.x,y+a.y
        return Point(x+a.x,y+a.y);
    }
    Point operator -(Point a)
    {//x-a.x,y-a.y
        return Point(x-a.x,y-a.y);
    }
    Point operator *(double a)
    {//x*a,y*a
        return Point(x*a,y*a);
    }
 
    double norm()
    {//x*x+y*y
        return x*x+y*y;
    }
};
Point p1,p2,p3,p4;
double cross(Point a,Point b)
{//a.x*b.y-a.y*b.x
    return a.x*b.y-b.x*a.y;
}
double dot(Point a,Point b)
{//a.x*b.x+a.y*b.y
    return a.x*b.x+a.y*b.y;
}
void solve()
{
   Point a=p2-p1;
   Point b=p4-p3;
   Point c=p3-p1;
   Point d=p4-p1;
   double d1=fabs(cross(a,c));
   double d2=fabs(cross(a,d));
   double t=d1/(d1+d2);
   Point p=p3+b*t;
   printf("%.8lf %.8lf\n",p.x,p.y);
}
 
int main()
{
//    freopen("in.txt","r",stdin);
      scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y,&p4.x,&p4.y);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3224
//ROADTOBLUE
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <cstring>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define ull unsigned ll
// #define endl '\n'
#define mp make_pair
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define DO(x) for(int i = 1; i <= x; i++){ solve(i); }
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
#define M_PI 3.14159265358979323846
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }


const long long MAXN = 1e9;
const long long LMAXN = 5e18;
const int SIZE = 1e5 + 5;  //are u sure ?
const int MOD = 1e9 + 7;
int x, n, d = MAXN, res = MAXN;
bool used[202];

void solve(int CASE) {
	cin >> x >> n;
	form(i, n) {
		int num; cin >> num;
		used[num] = true;
	}
	for(int i = -200; i <= 200; i++) {
		if(!used[i]) {
			int dist = abs(x - i);
			if(dist < d) {
				d = dist;
				res = i;
			} 
		}
	}	cout << res << endl;
}


int main(){
	speedhack()
	// int IT; cin >> IT;
	int IT = 1;
	DO(IT);
	return 0;
}

Measured memory_bytes: 3652
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD 1e9+7

int main(){
	int N;
	cin >> N;
	int A[50], B[50];
	for(int i=0; i<N; i++){
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B, B+N);
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			bool flg = true;
			swap(A[i], A[j]);
			for(int k=0; k<N; k++){
				if(A[k] != B[k]) flg = false;
			}
			swap(A[i], A[j]);
			if(flg){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
}

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

int a[100][100];
int n;
int D[100];
void bfs(int src) {
	queue<int> Q;
	Q.push(src);
	D[src] = 0;
	while (! Q.empty()) {
		int cur = Q.front();
		Q.pop();
		for (int dst=0; dst<n; ++dst) {
			if (a[cur][dst] == 1 && D[dst] == -1) {
				D[dst] = D[cur]+1;
				Q.push(dst);
			}
		}
	}
}

int main() {
	cin >> n;
	int p,q,r;
	for (int i=0; i<n; ++i) {
		cin >> p >> q;
		D[i] = -1;
		for (int i=0; i<q; ++i) {
			cin >> r;
			a[p-1][r-1] = 1;
		}
	}
	bfs(0);
	for (int i=0; i<n; ++i) {
		cout << i+1 << " " << D[i] << endl;
	}
}

Measured memory_bytes: 1240
import sys
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
    sys.exit()
if n == 1 and m == 2:
    print(0)
    sys.exit()
if n == 2 and m == 1:
    print(0)
    sys.exit()
if n == 1:
    print(m - 2)
    sys.exit()
if m == 1:
    print(n - 2)
    sys.exit()
if n == 2 and m == 2:
    print(0)
    sys.exit()
if n == 2 or m == 2:
    print(0)
    sys.exit()

center = (n - 2) * (m - 2)

print(center)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const double eps=(int)1e-9;
const int mod=1e9+7;
const int N=1e5+9;

int32_t main() {
    IOS;
int n;
cin>>n;
vi v(n);
    for (int i = 0; i < n; ++i) {
        cin>>v[i];
    }
    sort(all(v));
    cout<<v[(n+1)/2]-v[(n+1)/2-1]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c;
    int n=0;
    scanf("%d %d %d",&a,&b,&c);
    for (int i=a; i<=b; i++) {
        if(c % i == 0) n++;
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const int grid = 80;
const int maxa = 80;
const int mg = 6400;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    int H,W; cin >>H>>W;
    vector<vector<vector<bool> > > G(H+1,vector<vector<bool> >(W+1,vector<bool>(2 * mg + 1,false))); // 2 は-と+に伸びる感じ
    /*REP(i,H+1){
        G[i][0][mg] = true;
    }
    REP(i,W+1){
        G[0][i][mg] = true;
    }*/
    G[1][0][mg] = true;
    G[0][1][mg] = true;
    vector<vector<int> > A(H,vector<int>(W)), B(H,vector<int>(W)), diff(H,vector<int>(W));
    REP(i,H){
        REP(j,W){
            cin >> A[i][j];
        }
    }
    REP(i,H){
        REP(j,W){
            cin >> B[i][j];
        }
    }
    REP(i,H){
        REP(j,W){
            diff[i][j] = abs(A[i][j] - B[i][j]);
            //cout << diff[i][j] << " ";
        }
        //cout << endl;
    }

    REP(i,H){
        REP(j,W){
            REP(k, 2 * mg+1){
                if((k - diff[i][j] >= 0) && (G[i+1][j][k - diff[i][j]] == true)){
                    G[i+1][j+1][k] = true;
                }
                if((k + diff[i][j] <= 2*mg) && (G[i+1][j][k + diff[i][j]] == true)){
                    G[i+1][j+1][k] = true;
                }                
            }

            REP(k, 2 * mg+1){
                if((k - diff[i][j] >= 0) && (G[i][j+1][k - diff[i][j]] == true)){
                    G[i+1][j+1][k] = true;
                }
                if((k + diff[i][j] <= 2*mg) && (G[i][j+1][k + diff[i][j]] == true)){
                    G[i+1][j+1][k] = true;
                }                
            }
            
        }
    }

    int ans = INF;
    REP(i,2*mg+1){
        if(G[H][W][i]){
            //cout << i << endl;
            ans = min(ans, abs(mg - i));
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  if(s.at(0)==t.at(2) && s.at(1)==t.at(1) && s.at(2)==t.at(0)){
    cout << "YES";
  }else{
    cout << "NO";
  }
}


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

using namespace std;

bool map[20][20];

long long int num[20][20];

int main(){
	int a, b, n;
	while(true){
		cin >> a >> b;
		if(a == 0 && b == 0){
			break;
		}
		cin >> n;
		int x, y;
		for(int i = 0; i < 20; i++){
			for(int j = 0; j < 20; j++){
				map[i][j] = false;
			}
		}
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			map[x][y] = true;
		}
		if(map[1][1]){
			num[1][1] = 0;
		}else{
			num[1][1] = 1;
		}
		for(int i = 2; i <= a; i++){
			if(map[i][1]){
				num[i][1] = 0;
			}else{
				num[i][1] = num[i - 1][1];
			}
		}
		for(int i = 2; i <= b; i++){
			if(map[1][i]){
				num[1][i] = 0;
			}else{
				num[1][i] = num[1][i - 1];
			}
		}
		for(int i = 2; i <= a; i++){
			for(int j = 2; j <= b; j++){
				if(map[i][j]){
					num[i][j] = 0;
				}else{
					num[i][j] = num[i - 1][j] + num[i][j - 1];
				}
			}
		}
		
		printf("%lld\n", num[a][b]);
	}
	return 0;
}

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

int main() {
	// your code goes here
	string str;
	getline(cin, str);
	if(str.find("RRR") != string::npos) printf("3");
	else if(str.find("RR") != string::npos) printf("2");
	else if(str.find("R") != string::npos) printf("1");
	else printf("0");
	return 0;
}


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

int main() {
	string s;
	long long k;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
		if (i + 1 == k) {
			cout << 1 << endl;
			return 0;
		}
	}
}


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

int main(){
    vector<ll> x(5);
    rep(i,5) cin >> x[i];

    for(long long i = 0; i < 5; i++){
        if(x[i] == 0){
            put(i+1);
            return 0;
        }
    }
}

Measured memory_bytes: 3624
#ifndef ___Rank_Union_Find
#define ___Rank_Union_Find

#include <vector>

// ------ Class ------ //
class UnionFind {
private:
	unsigned size_; std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

#endif

#include <iostream>
#include <algorithm>
using namespace std;
struct edge { int s, t, c; };
bool operator<(const edge& e1, const edge& e2) { return e1.c < e2.c; }
int n, m;
int main() {
	while (cin >> n >> m, n | m) {
		vector<edge> v(m);
		for (int i = 0; i < m; i++) cin >> v[i].s >> v[i].t >> v[i].c, v[i].s--, v[i].t--;
		sort(v.begin(), v.end());
		int cnt = 0;
		UnionFind uf(n);
		for (int i = 0; i < n; i++) {
			if (!uf.same(v[i].s, v[i].t)) {
				uf.unite(v[i].s, v[i].t);
				cnt++;
			}
			if (cnt == n / 2) {
				cout << v[i].c << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3104
'''
Pythonのリストはappend, popなどを末尾の要素に対して実行するのは早いが、先頭への挿入や取り出しは遅い。
collections.dequeを使えば両端に対する操作を効率的に実行可能。enqueueはappend, dequeueはpopleftを使う。
'''
from collections import deque
n, q = map(int, input().split())
L = []
for i in range(n):
    a, b = input().split()
    L.append([a, int(b)])
L = deque(L)

t = 0
while L:
    x = L.popleft()
    if x[1] > q:
        t += q
        x[1] -= q
        L.append(x)
    else:
        t += x[1]
        print(x[0], t)



Measured memory_bytes: 13412
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int m = inf;
	int ans = 0;
	rep(i, n)
	{
		// cout << a[i] << " " << m << endl;
		if (a[i] < m)
			ans++;
		m = min(m, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <bitset>
#include <unordered_map>
#include <vector>
using namespace std;

const int N = 2e5 + 5;
const int MOD = 998244353;


long long fac[N] = {0}, fac2[N] = {0};

void init() {
    fac[1] = 1;
    fac2[1] = 1;
    for (int i = 2; i < N; ++i) {
        fac[i] = fac[i - 1] * 10 % MOD + 1;
        fac[i] %= MOD;
        fac2[i] = fac2[i - 1] * 10 % MOD;
    }
}

struct TreeNode {
    int l, r;
    long long sum;
    long long rep;

    long long len() {
        return fac[r - l + 1];
    }
    long long len2() {
        return fac2[r - l + 2];
    }
}tree[N * 4];

void pushup(int p) {
    tree[p].sum = tree[p * 2].sum * (tree[p * 2 + 1].len2()) % MOD;
    tree[p].sum = (tree[p].sum + tree[p * 2 + 1].sum) % MOD;
    // cout << tree[p].sum << " " << tree[p * 2].sum << " " << tree[p * 2 + 1].sum << endl;
}

void pushdown(int p) {
    if (tree[p].rep) {
        tree[p * 2].rep = tree[p].rep;
        tree[p * 2].sum = tree[p].rep * tree[p * 2].len() % MOD;
        tree[p * 2 + 1].rep = tree[p].rep;
        tree[p * 2 + 1].sum = tree[p].rep * tree[p * 2 + 1].len() % MOD;
        tree[p].rep = 0;
    }
}

void build(int p, int l, int r) {
    tree[p].l = l;
    tree[p].r = r;
    if (tree[p].l == tree[p].r) {
        tree[p].sum = 1;
        return ;
    }
    int mid = (tree[p].l + tree[p].r) / 2;
    build(p * 2, l, mid);
    build(p * 2 + 1, mid + 1, r);
    pushup(p);
}

void update(int p, int l, int r, long long v) {
    if (l <= tree[p].l && tree[p].r <= r) {
        tree[p].rep = v;
        tree[p].sum = v * tree[p].len() % MOD;
        return ;
    }
    pushdown(p);
    int mid = (tree[p].l + tree[p].r) / 2;
    if (l <= mid) {
        update(p * 2, l, r, v);
    }
    if (r > mid) {
        update(p * 2 + 1, l, r, v);
    }
    pushup(p);
}

long long query(int p, int l, int r) {
    if (l <= tree[p].l && tree[p].r <= r) {
        return tree[p].sum;
    }
    pushdown(p);
    long long sum = 0;
    int mid = (tree[p].l + tree[p].r) / 2;
    if (l <= mid) {
        sum += query(p * 2, l, r);
        sum %= MOD;
    }
    if (r > mid) {
        sum += query(p * 2 + 1, l, r);
        sum %= MOD;
    }
    return sum;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    init();
    int n, q;
    scanf("%d %d", &n, &q);
    build(1, 1, n);
    for (int i = 1; i <= q; ++i) {
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);
        update(1, l, r, d);
        printf("%lld\n", query(1, 1, n));
    }
    return 0;
}

Measured memory_bytes: 19176
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
  int cnt;
  int i;
  int P,Q,R;
  int A, B;
  int ret;

  cnt = scanf("%d %d %d", &P, &Q, &R);

  if (MIN(P,Q) == P) {
    A = MIN(P,R);
    B = MIN(Q,MAX(P,R));
  } else {
    A = MIN(Q,R);
    B = MIN(P,MAX(Q,R));
  }
  
  printf("%d", (A+B));

  return 0;
}



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int n, m; cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<55)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

int main(){

    lli n;
    cin>>n;
    set<char> s;
    REP(i,0,n){
        char t;
        cin>>t;
        s.insert(t);
    }

    if(s.size()==3)cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,x,ans;
int main()
{
    cin>>a>>b>>c>>x;
    for (int i=0;i<=a;i++)
       for (int j=0;j<=b;j++)
          for (int k=0;k<=c;k++)
          if (i*500+j*100+k*50==x)
             ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

int main()
{
  int n;
  int k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) > abs(y);
      });

  if (a[k - 1] == 0) {
    cout << 0 << endl;
    return 0;
  }

  bool haveZero = (a.back() == 0);
  int neg = 0;
  for (int i = 0; i < k; ++i) if (a[i] < 0) neg++;

  if (neg % 2) {
    vll left, right;
    for (int i = k - 1; i >= 0; --i) if (a[i] > 0) {
      left.push_back(i);
      break;
    }
    for (int i = k - 1; i >= 0; --i) if (a[i] < 0) {
      left.push_back(i);
      break;
    }
    for (int i = k; i < n; ++i) if (a[i] > 0) {
      right.push_back(i);
      break;
    }
    for (int i = k; i < n; ++i) if (a[i] < 0) {
      right.push_back(i);
      break;
    }
    int bestI = -1;
    int bestJ = -1;
    for (int i = 0; i < left.size(); ++i) for (int j = 0; j < right.size(); ++j) {
      if (a[left[i]] * a[right[j]] > 0) continue;
      if (bestI == -1 || abs(a[right[j]] * a[left[bestI]]) > abs(a[right[bestJ]] * a[left[i]])) {
        bestI = i;
        bestJ = j;
      }
    }
    if (bestI != -1) {
      swap(a[left[bestI]], a[right[bestJ]]);
    } else {
      reverse(a.begin(), a.end());
    }
  }


  const ll MODULO = 1e9 + 7;
  ll result = 1;
  for (int i = 0; i < k; ++i) {
    result = (result * a[i] % MODULO + MODULO) % MODULO;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 4772
// abc166_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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,k,d,a;
  set<int> ans;
  cin>>n>>k;
  rep(i,k){
    cin>>d;
    rep(j,d){
      cin>>a;
      ans.insert(a);
    }
  }
  cout<<n-ans.size()<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
string s,t;
int ans;
int main()
{
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==t[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)
#define mod 1000000007LL

int main()
{
    int n;
    cin >> n;
    ll v1 = 1LL, v2 = 1LL, v3 = 1LL;
    rep(i, n){
        v1 = v1 * 10 % mod;
        v2 = v2 * 9 % mod;
        v3 = v3 * 8 % mod;
    }
    v1 = v1 - 2 * v2;
    if(v1 < 0) v1 += 2 * mod;
    v1 %= mod;
    v1 = (v1 + v3) % mod;
    cout << v1 << endl;
}

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

int main(){
  int a, b, c, sum;
  cin >> a >> b >> c >> sum;
  int count=0;
  for (int i=0; i<=a; i++){
    for (int j=0; j<=b; j++){
      for (int k=0; k<=c; k++){
        if (500*i+100*j+50*k==sum){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}



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


int main() {
    int n;
    std::cin >> n;
    std::vector<int> r1(n);
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        r1[i] = a;
    }
    std::vector<int> r2(n);
    long long r2_sum = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        r2[i] = a;
        r2_sum += a;
    }

    long long r1_sum = 0;

    long long max_candies = 0;
    for (int i = 0; i < n; ++i) {
        r1_sum += r1[i];
        if (r1_sum + r2_sum >= max_candies) {
            max_candies = r1_sum + r2_sum;
        }
        r2_sum -= r2[i];
    }
    std::cout << max_candies;

    return 0;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


int main() {
    int H, W; cin >> H >> W;
    int h, w; cin >> h >> w;
    int ans = (H-h) * (W-w);
    cout << ans <<  endl;
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,A,B;
int OH,OW,OA,OB;

string S[1010];

void output() {
	int y;
	cout<<"YES"<<endl;
	FOR(y,OH) cout<<S[y]<<endl;
	exit(0);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>A>>B;
	if(H*W<2*(A+B)) return _P("NO\n");
	OH=H,OW=W,OA=A,OB=B;
	
	FOR(y,H) S[y]=string(W,'.');
	if(H%2==1) {
		for(x=0;x<W-1&&A;x+=2) S[H-1][x]='<', S[H-1][x+1]='>', A--;
		H--;
	}
	if(W%2==1) {
		for(y=0;y<H-1&&B;y+=2) S[y][W-1]='^', S[y+1][W-1]='v', B--;
		W--;
	}
	
	for(y=0;y<H;y+=2) {
		for(x=0;x<W;x+=2) {
			if(A) {
				S[y][x]='<', S[y][x+1]='>', A--;
				if(A) S[y+1][x]='<', S[y+1][x+1]='>', A--;
			}
			else if(B) {
				S[y][x]='^', S[y+1][x]='v', B--;
				if(B) S[y][x+1]='^', S[y+1][x+1]='v', B--;
			}
		}
	}
	if(A==0 && B==0) output();
	
	H=OH,W=OW,A=OA,B=OB;
	if(H%2 && W%2 && H>=3 && W>=3 && A>=2 && B>=2) {
		A-=2;
		B-=2;
		FOR(y,H) S[y]=string(W,'.');
		S[H-3][W-3]=S[H-1][W-2]='<';
		S[H-3][W-2]=S[H-1][W-1]='>';
		S[H-2][W-3]=S[H-3][W-1]='^';
		S[H-1][W-3]=S[H-2][W-1]='v';
		for(y=0;y<H-3&&B;y+=2) S[y][W-1]='^',S[y+1][W-1]='v',B--;
		for(x=0;x<W-3&&A;x+=2) S[H-1][x]='<',S[H-1][x+1]='>',A--;
		for(y=0;y<H-1;y+=2) {
			for(x=0;x<W-1;x+=2) {
				if(S[y][x]!='.') continue;
				if(A) {
					S[y][x]='<', S[y][x+1]='>', A--;
					if(A) S[y+1][x]='<', S[y+1][x+1]='>', A--;
				}
				else if(B) {
					S[y][x]='^', S[y+1][x]='v', B--;
					if(B) S[y][x+1]='^', S[y+1][x+1]='v', B--;
				}
			}
		}
		if(A==0 && B==0) output();
	}
	
	
	cout<<"NO"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
  int n; cin>>n;
  ll res=0;
  rep(i, n) {
    int tmp=i+1;
    if (tmp%15==0) res+=0;
    else if (tmp%5==0) res+=0;
    else if (tmp%3==0) res+=0;
    else res+=tmp;
  }
  cout<<res<<endl;
}


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

int main(){
  
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double s=h*30+0.5*m;
  double g=m*6;
  double x=(max(s,g)-min(s,g))*3.14159265358979/180;
    // Your code here!
  cout<<fixed<<setprecision(18)<<sqrt(a*a+b*b-2*a*b*cos(x)) <<endl;
}


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

namespace ALDS1_3
{
    class Progarm
    {
        static void Main()
        {
            var i = new LinkedList<string>();
            var l = int.Parse(Console.ReadLine());
 
            for (var j = 0; j < l; j++)
            {
                var _t = Console.ReadLine().Split();
                 
                if (_t.Length == 1)
                {
                    if (_t[0] == "deleteFirst")
                        i.Remove(i.First);
                    else
                        i.Remove(i.Last);
                }
                else
                {
                    if (_t[0] == "insert")
                        i.AddFirst(_t[1]);
                    else
                    {
                        var node = i.Find(_t[1]);
                        if (node != null) i.Remove(node);
                    }
                        
                }        
            }

            Console.WriteLine(string.Join(" ", i.ToArray()));
         }
    }
}

Measured memory_bytes: 144052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>d(N);
  int x = N;
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  
  for(int i = 0; i < N - 1; i++) {
    if (d.at(i) == d.at(i+1)) {
      x--;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	double long a,b;
	cin>>a>>b;
	ll ans;
	ans = trunc(a*b);
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	vector<int> ans(n);
	int count = 0;
	rep(i,s.size()-1){
		if(s[i] == 'R' && s[i+1] == 'R') count++;
		if(s[i] == 'R' && s[i+1] == 'L'){
			count++;
			ans[i+1] += count/2;
			ans[i] += (count+1)/2;
			count = 0;
		}
	}
	reverse(s.begin(),s.end());
	reverse(ans.begin(),ans.end());
	rep(i,s.size()-1){
		if(s[i] == 'L' && s[i+1] == 'L') count++;
		if(s[i] == 'L' && s[i+1] == 'R'){
			count++;
			ans[i+1] += count/2;
			ans[i] += (count+1)/2;
			count = 0;
		}
	}
	reverse(ans.begin(),ans.end());
	rep(i,n){
		cout << ans[i] << " ";
	}
	cout << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >>n;
  string s[n];
  rep(i,n){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s,s+n);
  ll c=1;
  ll ans=0;
  rep(i,n-1){
    if(s[i]==s[i+1]) c++;
    else{
      if(c>1){
	ans+=c*(c-1)/2;
      }
      c=1;
    }    
  }
  if(s[n-1]==s[n-2]) ans+=c*(c-1)/2;
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <math.h>
#include <string>
using namespace std;
const int M=998244353;


int main()
{
//	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int k,n;
	cin>>k>>n;
	std::vector<int> a(n);
	int prv=-1;
	int mx=-1;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if(prv<0){
			prv=a[i];
			continue;
		}
		mx=max(mx,a[i]-prv);
		prv=a[i];
	}
	mx=max(a[0]-a[n-1]+k,mx);
	printf("%d\n",k-mx );
 	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
 
using namespace std;
  
const double eps=1e-10;
 
const int dy[]={-1,-1,0,1,1, 1, 0,-1};
const int dx[]={ 0, 1,1,1,0,-1,-1,-1};

class rect{
public:
	int h,w,d2;
	rect(int _h,int _w){h=_h; w=_w; d2=h*h+w*w;}
	bool operator<(const rect& r) const{
		return d2<r.d2 || d2==r.d2 && h<r.h;
	}

};

int main()
{

	vector< rect > vr;
	for(int h=1;h<=150;h++){
		for(int w=h+1;w<=150;w++) vr.push_back(rect(h,w));
	}
	sort(vr.begin(),vr.end());

	int h,w;
	while(cin>>h>>w,h){

		rect r(h,w);
		for(int i=0;i<vr.size();i++){
			if(r<vr[i]){
				cout<<vr[i].h<<" "<<vr[i].w<<endl;
				break;
			}
		}

	}
 
 
	return 0;
}

Measured memory_bytes: 1332
N, A, B, C = list(map(int, raw_input().split()))
length = list()
for n in xrange(N): length.append(int(raw_input()))

INF = 10 ** 16

def cost(idx, a, b, c):
    if idx == N: return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    val1 = cost(idx+1, a, b, c)
    val2 = cost(idx+1, a+length[idx], b, c) + 10
    val3 = cost(idx+1, a, b+length[idx], c) + 10
    val4 = cost(idx+1, a, b, c+length[idx]) + 10
    return min(val1, val2, val3, val4)

print cost(0, 0, 0, 0)
 

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

ans=set()
for i in range(1,3 * int(n ** 0.5)):
    n -= i
    ans.add(i)
    if n < i + 1:
        ans.add(i + 1)
        no = i + 1 - n
        break

for i in ans:
    if i == no:
        continue
    print(i)

Measured memory_bytes: 3656
import itertools

n=int(input())
s=[input() for _ in range(n)]

MARCH=[0]*5
for name in s:
    if name[0]=="M":
        MARCH[0]+=1
    elif name[0]=="A":
        MARCH[1]+=1
    elif name[0]=="R":
        MARCH[2]+=1
    elif name[0]=="C":
        MARCH[3]+=1
    elif name[0]=="H":
        MARCH[4]+=1
    else:
        continue

ans=0
c=list(itertools.product([0,1], repeat=5))

for i in c:
    a=1
    if sum(i)==3:
        for g in range(5):
            if i[g]==1:
                a*=MARCH[g]
        ans+=a
print(ans)

Measured memory_bytes: 9772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int sum=A+B+C;
    if(sum>=22){
        out("bust");
    }else{
        out("win");
    }

    return 0;
}


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

struct proc {
    string name;
    int time;
};

int main() {
    int n, q, curTime = 0;
    cin >> n >> q;
    
    queue<proc> que;
    for(int i = 0; i < n; i++){
        proc p;
        cin >> p.name >> p.time;
        que.push(p);
    }
    
    while(que.size()){
        proc p = que.front(); que.pop();
        p.time -= q;
        curTime += q;
        if(p.time <= 0){
            curTime += p.time;
            cout << p.name << " " << curTime << endl;
            continue;
        }
        que.push(p);
    }
    
    return 0;
}

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

int main(){
  double r;
  cin >> r ;
  double pi = 3.14159265;
  cout << fixed << setprecision(10);
  cout << 2*r*pi << endl;
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll a; cin >> a;
	string s; cin >> s;
	ll b;
	b = 100*(s[0]-'0')+10*(s[2]-'0')+(s[3]-'0');
	cout << a*b/100 << endl;
	return 0;
}

Measured memory_bytes: 3616
package main

import (
  "fmt"
)

func main() {
  var s string 
  fmt.Scan(&s)
  res := make(map[rune]bool)
  for _, c := range s {
    res[c] = true
  }
  ans := "no"
  if len(res) == len(s) {
    ans = "yes"
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	Int n, y; cin >> n >> y;
	int a, b;
	for (int a = 0; a <= n; a++) {
		for (int b = 0; b <= n-a; b++) {
			int c = n - a - b;
			if (a * 10000 + b * 5000 + c * 1000 == y) {
				cout << a << " " << b << " " << c;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define inf 1012345678
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};

int dp[100010][15];

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

	string s;
	cin >> s;
	int n = s.size();
	dp[0][0] = 1;

	rep(i, n) {
		int t;
		if(s[i] == '?') t = -1;
		else t = s[i] - '0';

		rep(j, 10) {
			if(t != -1 && t != j) continue;
			rep(k, 13) {
				dp[i+1][(k*10+j) % 13] += dp[i][k];
			}
		}
		rep(j, 13) dp[i+1][j] %= MOD;
	}
	cout << dp[n][5] << endl;
	return 0;
}


Measured memory_bytes: 12240
#include <iostream>
#include <map>

int main(){

    long long n = 0, k = 0;

    std::cin >> n >> k;

    std::map<int, long long int, std::less<int>> bucket;


    for(long long int i = 0; i < n; ++i){
        long long int tmp = 0, tmp_n = 0;
        std::cin >> tmp >> tmp_n;

        bucket[(int)tmp] += tmp_n;
    }

    long long int count = 0;
    int index = 0;

    for(auto const & it: bucket){

        count += it.second;
        index =  it.first;
        if(count >= k)
            break;
   
    }

    std::cout << index << std::endl;  

    return 0;

}

Measured memory_bytes: 4224