akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);

const ll MAX = 300010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

signed main(){
  ll h,w,a,b,ans=0;cin>>h>>w>>a>>b;
  COMinit();

  ll x=h-a-1,y=b;

  while(0<=x && y<w){
    (ans+=(COM(x+y,y)%mod)*(COM(h-1-x+w-1-y,w-1-y)%mod))%=mod;
    //ans%=mod;
    x--;y++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7296
import java.util.*;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();

        double PI = 3.1415926535897932;
        double v = 2*R* PI ;

        System.out.println(v);

    }
}

Measured memory_bytes: 35788
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
using namespace std;

ll n,ar[N],sum;


int main()
{
	fast;
	int a,b,k;
	cin>>a>>b>>k;
	int q=0;
	for(int i=max(a,b);i>=1;i--)
	{
		if(a%i==0 && b%i==0)
		{
			q++;
			if(q==k)
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] d = ReadIntArray();

	int[] h = new int[n];
	for (int i = 0; i < n; i++)
	{
	    int x = d[i];
	    if ((i == 0 && x != 0) || (i > 0 && x == 0))
	    {
		WriteLine(0);
		return;
	    }
	    h[x]++;
	}

	long ans = 1;
	for (int i = 1; i < n; i++)
	{
	    if (h[i] > 0)
	    {
		for (int j = 1; j <= h[i]; j++)
		{
		    ans = ans * h[i-1] % 998244353;
		}
	    }
	}

	WriteLine(ans);
    }
}

Measured memory_bytes: 18400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class AtCoderBeginnerContest139
    {
       static void Main(String[] args)
       {
         //A - Tenki
         string S = Console.ReadLine();
         string T = Console.ReadLine();

         int accurateTimes = 0;

         for (int i = 0; i < S.Length; i++)
         {
             if (S[i] == T[i])
             {
               accurateTimes++;
             }
         }
         Console.WriteLine(accurateTimes);
        }
    }
}


Measured memory_bytes: 13140
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7

n = int(input())
A = list(map(int,input().split()))
ass = set()
def div(x):
    for i in range(1,int(x**0.5)+1):
        if x%i == 0:
            ass.add(i)
            ass.add(x//i)
    return ass
a0 = A[0]
a1 = A[1]
div(a0)
div(a1)
ans = []
for i in ass:
    cnt = 0
    for a in A:
        if a%i == 0:
            cnt += 1
    if cnt >= n-1:
        ans.append(i)
print(max(ans))

Measured memory_bytes: 14196
#include <stdio.h>
#include <math.h>

int     main(void)
{
    double r, area, shu;
    
    r = 0;
    scanf("%lf",&r);
    area = r * r * M_PI;
    shu = 2 * r * M_PI;
    printf("%f %f\n",area,shu);
    return(0);
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for (;n--;){
        string order,S; cin >> order >> S;
        int s=S.size();
        reverse(order.begin(),order.end());
        for (int i=0;i<order.size();++i){
            if (order[i]=='J'){
                S+=S;
                S=S.substr(s-1,s);
            }
            if (order[i]=='C'){
                S+=S;
                S=S.substr(1,s);
            }
            if (order[i]=='E'){
                for (int j=0;j<s/2;++j) swap(S[j],S[j+(s+1)/2]);
            }
            if (order[i]=='A'){
                reverse(S.begin(),S.end());
            }
            if (order[i]=='P'){
                for (int j=0;j<s;++j){
                    int x=S[j]-'0';
                    if (x<10) S[j]='0'+(x+9)%10;
                }
            }
            if (order[i]=='M'){
                for (int j=0;j<s;++j){
                    int x=S[j]-'0';
                    if (x<10) S[j]='0'+(x+1)%10;
                }
            }
        }
        cout << S << '\n';
    }
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int X[1010], Y[1010], R[1010];
double d[1010][1010];
double dd[1010];

void dijkstra() {
    rep(i, 1010)dd[i] = INF;
    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> que;
    dd[0] = 0;
    que.push(make_pair(0, 0));
    while (!que.empty()) {
        pair<double, int> p = que.top();
        que.pop();
        int v = p.second;
        if (dd[v] < p.first)continue;
        rep(j, N + 2) {
            if (dd[j] > dd[v] + d[v][j]) {
                dd[j] = dd[v] + d[v][j];
                que.push(make_pair(dd[j], j));
            }
        }
    }
}

signed main() {
    int xt, yt;
    cin >> X[0] >> Y[0] >> xt >> yt;
    cin >> N;
    X[N + 1] = xt;
    Y[N + 1] = yt;
    rep(i, N) {
        cin >> X[i + 1] >> Y[i + 1] >> R[i + 1];
    }
    rep(i, N + 2) {
        for (int j = i + 1; j < N + 2; ++j) {
            d[i][j] = (X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]);
            d[i][j] = sqrt(d[i][j]) - R[i] - R[j];
            if (d[i][j] < 0)d[i][j] = 0;
            d[j][i] = d[i][j];
        }
    }
    dijkstra();
    printf("%.20lf", dd[N + 1]);
    return 0;
}


Measured memory_bytes: 13680
n = int(input())
al = list(map(int, input().split()))    
# al.sort()
al_cnts = [0]*(10**5+1)
for a in al:
    al_cnts[a] += 1

ans = 0
for a1,a2,a3 in zip(al_cnts[0:-2],al_cnts[1:-1],al_cnts[2:]):
    v = a1+a2+a3
    ans = max(ans,v)

print(ans)

Measured memory_bytes: 87144
import collections
s=input()
q=int(input())
qv=[list(input().split()) for _ in range(q)]
cnt=0
ans=collections.deque()
for i in range(len(s)):
  ans.append(s[i])
for i in range(q):
  if qv[i][0]=="1":
    cnt+=1
  else:
    t,f,c = qv[i]
    if f=="1":
      if cnt%2==0:
        ans.appendleft(c)
      else:
        ans.append(c)
    elif f=="2":
      if cnt%2==0:
        ans.append(c)
      else:
        ans.appendleft(c)
if cnt%2!=0:
  ans.reverse()
print("".join(ans))

Measured memory_bytes: 35308
def main():
    N, M = map(int, input().split(' '))
    wc_cnt = [0 for _ in range(N + 1)]
    ac, wc = 0, 0
    for i in range(M):
        num, result = input().split(' ')
        num = int(num)
        if wc_cnt[num] is None:
            continue
        if result == 'AC':
            wc += wc_cnt[num]
            wc_cnt[num] = None
            ac += 1
        else:
            wc_cnt[num] += 1
    print(ac, wc)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3888
n,m = map(int,input().split())
num = [0]*m
acwa = [0]*m
for i in range(m):
    num[i], acwa[i] = input().split()
account = 0
wacount = 0
sumi = {}
for i in range(m):
    if num[i] in sumi:
        if sumi[num[i]]!='AC':
            if acwa[i] == 'AC':
                account += 1
                wacount += sumi[num[i]]
                sumi[num[i]]= 'AC'
            else:
                sumi[num[i]] += 1
    else:
        if acwa[i] == 'AC':
            account += 1
            sumi[num[i]]= 'AC'
        else:
            sumi[num[i]]= 1

print(account,wacount)


Measured memory_bytes: 25060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/








int N, Q; string S;
int ok[101010], sm[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> Q >> S;
	rep(i, 0, N - 1) if (S[i] == 'A' and S[i + 1] == 'C') ok[i] = 1;
	sm[0] = ok[0];
	rep(i, 1, N) sm[i] = sm[i - 1] + ok[i];

	rep(q, 0, Q) {
		int L, R; cin >> L >> R; L--; R--;

		int ans = sm[R-1];
		if (L) ans -= sm[L - 1];
		
		printf("%d\n", ans);
	}
}


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

using i64 = int64_t;

constexpr i64 INF = 1e12;

int bsearch(int ok, int ng, vector<i64> &v, i64 x){
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(v[mid] <= x)ok = mid;
        else ng = mid;
    }
    return ok;
}

i64 solve(vector<i64> &s, vector<i64> &t, i64 x){
    int ss[2]={0}, tt[2]={0};
    ss[0] = bsearch(0, s.size(), s, x);
    ss[1] = ss[0] + 1;
    tt[0] = bsearch(0, t.size(), t, x);
    tt[1] = tt[0] + 1;
    i64 ans = INF;
    for(int i=0;i<2;++i){
        for(int j=0;j<2;++j){
            ans = min({ans, abs(x-s[ss[i]])+abs(s[ss[i]]-t[tt[j]]), abs(x-t[tt[j]])+abs(t[tt[j]]-s[ss[i]])});
        }
    }
    return ans;
}

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<i64> s, t;
    s.push_back(-INF);
    for(int i=0;i<a;++i){
        i64 tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    s.push_back(INF);
    t.push_back(-INF);
    for(int i=0;i<b;++i){
        i64 tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    t.push_back(INF);

    for(int i=0;i<q;++i){
        i64 x;
        cin >> x;
        cout << solve(s, t, x) << endl;
    }

    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	string N;
	cin >> N;
	
	string ans;
	if (N[0] == '9' || N[1] == '9') {
		ans = "Yes";
	} else {
		ans = "No";
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
num = 0
ai = 0
while True:
    asum = 500*ai
    if asum > x or ai > a:
        break
    bi = 0
    while True:
        bsum = asum + bi*100
        if bsum > x or bi > b:
            break
        ci = 0
        while True:
            csum = bsum + ci*50
            if csum > x or ci > c:
                break
            if csum == x:
                num += 1
            ci += 1
        bi += 1
    ai += 1
print(num)


Measured memory_bytes: 3064
N, M = gets.chomp.split(" ").map(&:to_i)
cnt = {}
M.times do |i|
  p, s = gets.chomp.split(" ")
  cnt[p] ||= { ac: 0, wa: 0 }
  if s == "AC"
    cnt[p][:ac] = 1
  elsif s == "WA" && cnt[p][:ac].zero?
    cnt[p][:wa] += 1
  end
end

ac_cnt = cnt.select{|_, v| v[:ac] > 0}
ac = ac_cnt.count
wa = 0
ac_cnt.each {|_, v| wa += v[:wa] }
puts "#{ac} #{wa}"


Measured memory_bytes: 49532
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n, m;
    int z = 0;
    cin >> n; m = n;
    for (ll i = 2; i * i <= m; i++) {
        int c = 0;
        if (n % i == 0) {
            while (n % i == 0) n /= i, c++;
            for (int j = 1; j < 28; j++) {
                if (c >= j) c -= j, z++;
                else break;
            }
        }
    }
    if (n > 1) z++;
    cout << z;
}


Measured memory_bytes: 3564
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%lld%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

typedef long long ll;

//------------------------------------------------------------------------------
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
//------------------------------------------------------------------------------

const int N_MAX = 400;
const int C_MAX = 400;
const int X_MAX = 400;
const int MOD = 1e9+7;

int N, C;
int A[N_MAX];
int B[N_MAX];

ll acc[X_MAX + 1][C_MAX + 1];
ll dp[N_MAX + 1][C_MAX + 1];

void solve() {

  FOR(x, 1, X_MAX) FOR(k, 0, C_MAX) {
    acc[x][k] = (acc[x - 1][k] + mod_pow(x, k, MOD)) % MOD;
  }

  // DUMP2D(acc, 8, 8);

  dp[0][0] = 1;
  REP(i, N) FOR(j, 0, C) FOR(k, 0, C - j) {
    ll sum = (acc[B[i]][k] - acc[A[i] - 1][k] + MOD) % MOD;
    ll mul = dp[i][j] * sum % MOD;
    dp[i + 1][j + k] = (dp[i + 1][j + k] + mul) % MOD;
    // printf("i: %d, j:%d, k:%d, sum: %lld, mul: %lld\n", i, j, k, sum, mul);
  }

  // DUMP2D(dp, N + 1, C + 1);

  printf("%lld\n", dp[N][C]);
}

void input() {
  scanf("%d%d", &N, &C);
  REP(i, N) scanf("%d", A + i);
  REP(i, N) scanf("%d", B + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
#define REP(i,n)for(int i = 0;i<(n);i++)
const int INF = 1e9;
 
int H,W;
string s[50];
string order;
int ct;
 
vector<char> COND{'~','N','E','S','W','C','T'};
vector<char> MOVE{'^','v','<','>'};
map<char,int> mp;
int dy[4] = {-1,0,1,0},dx[4] = {0,1,0,-1};
 
int stepped[1000][50][50][4];
bool goaled;
int y,x,dir;
 
bool regionCheck(int y,int x){
  return 0<=x&&x<W&&0<=y&&y<H&&s[y][x]!='#';
}
 
bool goalCheck(int y,int x){
  return s[y][x]=='g';
}

int search(int order_i){
  int start_i = order_i;
  while(order_i < order.size()){//end check
    int condition = 1;
 
    //stepped?
    if(stepped[order_i][y][x][dir]==1){goaled = false;
      return INF;
    }else stepped[order_i][y][x][dir]++;
 
    //is condition?
    for(auto o:COND){
      if(order[order_i]==o){condition=-1;break;}
    }
 
    //condition check
    if(condition ==-1){
      bool reverse = false;
      if(order[order_i]=='~'){reverse=true;order_i++;}
 
      if(order[order_i] == 'C'){
				if(s[y + dy[dir]][x + dx[dir]] == '#')condition = 1;
				else condition = 0;
      }else if(order[order_i] == 'T')condition = 1;
      else if(mp[order[order_i]]==dir)condition = 1;
      else condition = 0;
       
      if(reverse)	{
				if(condition)condition = 0;
				else  condition= 1;//reverse
			}
      order_i++;
    }
     
		//execute move order
    if(condition==1){
      while(true){
				//is move order?
				bool canMove = false;
				for(auto m:MOVE)if(order[order_i]==m){canMove=true;break;}
				if(!canMove)break;
 
				//move
				ct++;
				if(order[order_i] == '^'){
					if(regionCheck(y+dy[dir],x+dx[dir])){
						y += dy[dir];x+=dx[dir];
					}
					if(goalCheck(y,x)){goaled = true;return INF;}
				}else if(order[order_i] == 'v'){
					if(regionCheck(y-dy[dir],x-dx[dir])){
						y -= dy[dir];x-=dx[dir];
					}
					if(goalCheck(y,x)){goaled = true;return INF;}
				}else if(order[order_i] == '<'){
					dir = (dir-1 + 4)%4;
				}else{
					dir = (dir+1 + 4)%4;
				}
 
				order_i++;
      }
    }else{
			//proceed index
			int bracket = 0,brace = 0;
			do{
				if(order[order_i] == '['){bracket++;
				}else	if(order[order_i] == ']'){bracket--;
				}else if(order[order_i] == '}'){brace--;
				}else if(order[order_i] == '{'){brace++;
				}
				if(bracket < 0 || brace < 0)break;
			}while(++order_i);
		}
    if(order[order_i] == '['||order[order_i]=='{'){
      order_i += search(order_i + 1);
		}
    else if(order[order_i] == '}'&&condition==1){
      order_i = start_i;
    }
    else if(order[order_i] == ']' || order[order_i] == '}'){
      return order_i - start_i + 2;
    }
  }
}
int main(){
  cin>>H>>W;
  REP(i,H)cin>>s[i];
  cin>>order;
  mp['N'] = 0;
  mp['E'] = 1;
  mp['S'] = 2;
  mp['W'] = 3;
  REP(i,H){
    REP(j,W){
      if(s[i][j]== 's'){
				y = i;x = j;
				s[i][j] = '.';
				break;
      }
    }
  }
  search(0);
  if(goaled) cout << ct << endl;
  else cout << -1 << endl;
}

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

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

    int sumA = 0, sumB = 0;
    for (int i = 0; i < M; i++) {
        if (A[i] < X) {
            sumA++;
        } else {
            sumB++;
        }
    }
    cout << min(sumA, sumB) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] height = new int[1000];
		
		for (int i = 1; i <= 999; i++) {
			height[i] = ((i + 1) * i) / 2;
		}
		
		for (int i = 1; i <= 998; i++) {
			if (a <= height[i] && b <= height[i+1]) {
				if (height[i] - a == height[i+1] - b) {
					System.out.println(height[i]-a);
					System.exit(0);
				}
			}
		}
	}
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pb push_back
using namespace std;
using P = pair<int,int>;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef tuple<int,int,int> T;
typedef vector<P> vp;
typedef vector<T> vt;

const int INF = 1001001001;

int main(void) {
    string s,t;
    cin >> s >> t;
    t.pop_back();
    if(s==t){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n;
    cin >> n;
    int v[n];
    REP(i, n) cin >> v[i];
    vector<int> vc;
    REP(i, n) {
        int input;
        cin >> input;
        vc.push_back(v[i] - input);
    }
    SORT(vc);
    int ans = 0;
    REP(i, n) {
        if (vc[i] > 0) ans += vc[i];
    }
    P(ans);

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main()
{
    int n,ma,mi,a;
    ma=0,mi=100000;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&a);
        if(a<mi) mi=a;
        if(ma<a) ma=a;
    }
    printf("%d\n",ma-mi);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll power = 1;
    REP(i,n){
        power=power*(i+1)%MOD;
    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];

  ll ans = 0;
  rep(l,min(n,k)+1) rep(r,min(n,k)+1){
    if(l+r>min(n,k)) continue;
    priority_queue<ll,vector<ll>,greater<ll>> q;
    rep(i,l) q.emplace(v[i]);
    rep(i,r) q.emplace(v[n-1-i]);

    int rk = k-l-r;
    while(rk>0 && !q.empty() && q.top()<0) {
      q.pop();
      --rk;
    }

    ll sum = 0;
    while(!q.empty()){
      sum += q.top(); q.pop();
    }
    ans = max(ans,sum);
  }
  cout << ans << endl;
}

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

int main() {
  int N = 0, A = 0;
  cin >> N >> A;
  int a = N / 500;
  a *= 500;
  if( N - a <= A ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a + b == 2 || c == 1){
			System.out.println("Open");
		} else {
			System.out.println("Close");
		}
		
		
		sc.close();
	}

}

Measured memory_bytes: 17352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double n1, e1, n2, e2;
		final double R = 6378.1;

		while (true) {
			n1 = sc.nextDouble();
			e1 = sc.nextDouble();
			n2 = sc.nextDouble();
			e2 = sc.nextDouble();
			if (n1 == -1 && e1 == -1 && n2 == -1 && e2 == -1) {
				break;
			}
			
			double x1, y1, z1;
			double x2, y2, z2;
			x1 = R * Math.cos(Math.toRadians(n1)) * Math.cos(Math.toRadians(e1));
			y1 = R * Math.cos(Math.toRadians(n1)) * Math.sin(Math.toRadians(e1));
			z1 = R * Math.sin(Math.toRadians(n1));
			x2 = R * Math.cos(Math.toRadians(n2)) * Math.cos(Math.toRadians(e2));
			y2 = R * Math.cos(Math.toRadians(n2)) * Math.sin(Math.toRadians(e2));
			z2 = R * Math.sin(Math.toRadians(n2));
			
			double theta = Math.acos((x1 * x2 + y1 * y2 + z1 * z2) / (R * R));
			System.out.printf("%.0f\n", R * theta);
		}
	}
}

Measured memory_bytes: 20540
#include <stdio.h>

#define N 2000

int func(int, int);

int A[N], n;

int main () {
  int q = 0, M[N], i, j;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(i = 0 ; i < q ; i++) {
    scanf("%d",&M[i]);
  }
  

  for(i = 0 ; i < q ; i++) {
    if(func(M[i], 0) == 1) printf("yes\n");
    else printf("no\n");
  }


  return 0;
}


int func(int x, int i) {
  int a = 0 , b = 0;

  if(x == 0) return 1;
  
  if(i >= n) return 0;

  a = func(x-A[i], i+1);
  b = func(x, i+1);

  
  if(a > b) return a;
  else return b;
}



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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 500005
#define MAXM 1005
#define MAXP 25
#define INF 2000000000
#define A first
#define B second
#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define re(i, n) FOR(i, 1, n)
#define rep(i, n) for(int i = 0;i <(n); ++i)
#define fore(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

const ll MOD = 1e9+7;
int N;
ll fac[MAXN];
ll ans[MAXN];
ll powmod(ll a, ll b) {
    ll x = 1, y = a;
    while(b > 0) {
        if(b%2 == 1) {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}

ll inv(ll a)
{
	return powmod(a, MOD-2);
}

ll NCK(int a, int b)
{
	if(a < b) return 0LL;
	if(a == b) return 1LL;
	if(b == 0) return 1LL;
	ll ans = fac[a];
	ans = ((ans*inv(fac[b]))%MOD);
	ans = ((ans*inv(fac[a-b]))%MOD);
   	return ans;
}
int pos[MAXN];
int ar[MAXN];
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	fac[0] = fac[1] = 1;
	for(ll i=2; i<=N+1; i++) fac[i] = (fac[i-1]*i)%MOD;

	int curlen = N-1;
	for(int i=0; i<=N+1; i++) ans[i] = NCK(N+1, i);
	memset(pos, 0, sizeof(pos));
	int p1, p2;
	for(int i=1; i<=N+1; i++) {
		cin >> ar[i];
		if(pos[ar[i]] == 0) pos[ar[i]] = i;
		else {
			p1 = pos[ar[i]];
			p2 = i;
		}
	}
	int numend = N+1-p2;
	int numbegin = p1-1;
	int x = numend+numbegin;
	for(int i=1; i<=N+1; i++) ans[i] = (ans[i]-NCK(x, i-1)+MOD)%MOD;
	
	ans[1] = N;
	for(int i=1; i<=N+1; i++) {
		int x;
		cin >> x;
		printf("%lld\n", ans[i]);
		//if(x != ans[i]) printf("lol length %d, %d %d\n", i, x, ans[i]);
	}
	
	
		

	

}

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

int main(void)
{
        int N;
        cin >> N;
        int cost[N][201];
        int now;

        for(int i=1;i<=N;i++)
        {
                cin >> now;
                for(int j=-100;j<=100;j++)
                {
                        cost[i-1][j+101-1]=(now-j)*(now-j);
                }
        }

        int total_cost[201];
        for(int i=1;i<=201;i++)
        {
                total_cost[i-1]=0;
                for(int j=1;j<=N;j++)
                {
                        total_cost[i-1]+=cost[j-1][i-1];
                }
        }
        sort(total_cost,total_cost+201);
        cout << total_cost[0] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;


#define MAX 500000
#define SENTINEL 2000000000
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2


int main(){
  int a, b, c, n;
  int cnt=0;
  cin >> a >> b >> c >> n;
  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 == n) cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N,D;
	cin>>N>>D;
	int x = (2*D+1);
	int ans;
	if(N%x == 0)ans = N/x;
	else ans = N/x + 1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
l=[int(i) for i in input().split()]
l1=[[l[i],i] for i in range(n)]
l1.sort() 
mi=n//2 
cand1=l1[mi][0]
ind1=l1[mi][1]
cand2=l1[mi-1][0]
ind2=l1[mi][1]
if ind1>ind2:
    ind1,ind2=ind2,ind1
    cand1,cand2=cand2,cand1
ans=[0]*n 
#print(cand1,cand2)
#print(l)
for i in range(n): 
    if l[i]<=cand2:
        print(cand1)
    else:
       # print('fshd')
        print(cand2)

Measured memory_bytes: 42304
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
 
 
 
int main(){
	fast;
	int n;
	cin>>n;
	cout<<(n*n*n)<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.14159265;
const ll MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 105;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
char text[MAXN];
char text2[MAXN];
char ans[MAXN * 2];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    scanf("%s%s", text, text2);
    for (int i = 0; i < n; i++) {
        ans[i * 2] = text[i];
        ans[i * 2 + 1] = text2[i];
    }
    printf("%s", ans);
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

# N < 100 , K < 10^5
N,K = inpl()
aa = inpl()

dp = [[0]*(K+1) for _ in range(N)]
# dp[i][k] : i人目までに k個を配る場合の数
# dp[i][k] = sum(a=0,aa[i]) dp[i-1][k-a]
#          = sum(x=k-aa[i],k) dp[i-1][x]


for k in range(aa[0]+1):
    dp[0][k] = 1

for i in range(1,N):
    tmp = 0
    rdp = [0]*(K+2)
    for k in range(K+1):
        tmp += dp[i-1][k]
        tmp %= mod
        rdp[k+1] = tmp

    a = aa[i]
    for k in reversed(range(K+1)):
        dp[i][k] = (rdp[k+1] - rdp[max(k-a,0)])%mod

print(dp[-1][-1])


Measured memory_bytes: 158472
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int a[2][101];
int sum[101];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,ans(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[0][i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> a[1][i];
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            sum[i] += a[0][j];
        }
        for(int j = i; j < n; j++)
        {
            sum[i] += a[1][j];
        }
        ans = max(ans,sum[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

vector<pl> toppo (pl *p, int si) {
    sort(p, p+si);
    vector<pl> ret;
    ret.push_back(p[0]);
    for (int i = 1; i < si; i++) {
        while (ret.size() > 1) {
            int tmp = ret.size()-1;
            if ((p[i].second-ret[tmp-1].second)*(ret[tmp].first-ret[tmp-1].first) >= 
                (ret[tmp].second-ret[tmp-1].second)*(p[i].first-ret[tmp-1].first)) {
                ret.pop_back();
            } else {
                break;
            }
        }
        ret.push_back(p[i]);
    }
    vector<pl> ret2;
    ret2.push_back(p[si-1]);
    for (int i = si-2; i >= 0; i--) {
        while (ret2.size() > 1) {
            int tmp = ret2.size()-1;
            if ((p[i].second-ret2[tmp-1].second)*(ret2[tmp].first-ret2[tmp-1].first) >= 
                (ret2[tmp].second-ret2[tmp-1].second)*(p[i].first-ret2[tmp-1].first)) {
                ret2.pop_back();
            } else {
                break;
            }
        }
        ret2.push_back(p[i]);
    }
    ret2.pop_back();
    for (int i = 1; i < ret2.size(); i++) ret.push_back(ret2[i]);
    return ret;
}

int n;
pl pos[100], tmp[100];
double ans[100];

int main() {
    cin >> n;
    rep(i,n) cin >> pos[i].first >> pos[i].second;
    rep(i,n) tmp[i] = pos[i];
    vector<pl> topp = toppo(tmp, n);
    int si = topp.size();
    for (int i = 0; i < si; i++) {
        pl pre = topp[(i-1+si)%si];
        pl now = topp[i];
        pl nxt = topp[(i+1)%si];
        double dy1 = now.second-pre.second, dx1 = now.first-pre.first;
        double dy2 = nxt.second-now.second, dx2 = nxt.first-now.first;
        double d1 = atan2(dy1, dx1);
        double d2 = atan2(dy2, dx2);
        double d = abs(d1-d2);
        if (d > PI) d = 2*PI-d;
        rep(j,n) {
            if (topp[i] == pos[j]) {
                ans[j] = d/(2*PI);
            }
        }
    }
    rep(i,n) {
        printf("%.9f\n", ans[i]);
    }
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 100*1000+10, inf = 1*1000*1000*1000+10;
int x, y, a, b, c, s, f, mid, aa[maxn], ab[maxn], ac[maxn];
pair<int, int> pbc[2 * maxn];
ll ans, sa[maxn], sbc[2 * maxn], si[2 * maxn], sb[maxn], sc[maxn];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> x >> y >> a >> b >> c;
	for (int i = 0; i < a; i++)
		cin >> aa[i];
	sort(aa, aa + a);
	for (int i = 0; i < a; i++)
		sa[i + 1] = sa[i] + aa[a - 1 - i];
	for (int i = 0; i < b; i++)
	{
		cin >> pbc[i].first;
		ab[i] = pbc[i].first;
		pbc[i].second = 0;
	}
	sort(ab, ab + b);
	for (int i = 0; i < b; i++)
		sb[i + 1] = sb[i] + ab[b - 1 - i];
	for (int i = 0; i < c; i++)
	{
		cin >> pbc[i + b].first;
		ac[i] = pbc[i + b].first;
		pbc[i + b].second = 1;
	}
	sort(ac, ac + c);
	for (int i = 0; i < c; i++)
		sc[i + 1] = sc[i] + ac[c - 1 - i];
	sort(pbc, pbc + (b + c));
	for (int i = 0; i < b + c; i++)
	{
		sbc[i + 1] = sbc[i] + pbc[(b + c) - 1 - i].first;
		si[i + 1] = si[i] + pbc[(b + c) - 1 - i].second;
	}
	for (int i = 0; i <= x; i++)
	{
		if (x - i > c)
			continue;
		s = -1;
		f = b + c;
		while (f - s > 1)
		{
			mid = (s + f) / 2;
			if (si[mid] >= x - i && mid - (x - i) >= y)
				f = mid;
			else
				s = mid;
		}
		//cerr << i << " " << f << endl;
		if (f + i > x + y)
			ans = max(ans, sa[i] + sb[y] + sc[x - i]);
		else
			ans = max(ans, sa[i] + sbc[f]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 8448
while True :
    n = int(input())
    if n == 0 :
        break
    
    max_sum = 0
    min_sum = 500
    for i in range(n) :
        m_sum = 0
        m = list(map(int, input().split()))
        for j in range(5) :
            m_sum += m[j]
        if max_sum < m_sum :
            max_sum = m_sum 
        if min_sum > m_sum :
            min_sum = m_sum
        
    print(max_sum, min_sum)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define SZ(x) ((int)(x).size())
using namespace std;
const int P=998244353;
map<string,int>f;
int sol(const string&s){
	if(s.empty())return 1;
	if(f.count(s))return f[s];
	int&res=f[s];
	res=sol(s.substr(1));
	if(s[0]=='1')(res+=res)%=P;
	for(int len=1;len<=SZ(s);++len){
		string tmp(s.substr(0,len));
		for(int i=len;i+len<=SZ(s);i+=len){
			for(int j=0;j<len;++j)tmp[j]=min(tmp[j],s[i+j]);
			res+=1LL*sol(tmp)*sol(s.substr(i+len))%P;
			if(res>=P)res-=P;
		}
	}
	return res;
}
int main(){
	string s;
	cin>>s;
	cout<<sol(s)<<endl;
	return 0;
}

Measured memory_bytes: 8032
n = int(input())
l = list(map(int, input().split()))
l_div = [x for x in l if x % 2 == 0]
for x in l_div:
    if x % 3 == 0 or x % 5 == 0:
      pass
    else:
        print("DENIED")
        exit(0)
print("APPROVED")


Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
  ll n, k;
  cin >> n >> k;
  int sum = 0; int i = 0;
  while (true) {
    if (pow(k, i) > n) {
      cout << sum;
      exit(0);
    }
    sum++;
    i++;
  }
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

#define N 101

int main(){
  int n,q;
  while(cin>>n>>q,n+q){
    int convenient[N]={0};
    for(int i=0;i<n;i++){
      int m;
      cin >> m;
      for(int j=0;j<m;j++){
	int tmp;
	cin >> tmp;
	convenient[tmp]++;
      }
    }
    int ans=-1;
    int m=q-1;
    for(int i=0;i<N;i++){
      if(m<convenient[i]){
	ans=i;
	m=convenient[i];
      }
    }
    if(ans==-1) cout << 0 << endl;
    else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000

using namespace std;

int main()
{
for (int i=1;i<4000;i+=1){
	int x,y;
	cin>>x>>y;
	if (x==0&&y==0) break;
	else if (x<=y)
		cout<<x<<" "<<y<<endl;
    else cout<<y<<" "<<x<<endl;
   }
    return 0;
}



Measured memory_bytes: 3020
def solve():
    S = input()
    X,Y = map(int, input().split())
    
    S_F = S.split('T')
    move_x = list(map(len, S_F[::2]))
    move_y = list(map(len,S_F[1::2]))
    
    if move_x:
        X -= move_x[0]
        move_x = move_x[1:]
    
    # たどりつけない場合
    if sum(move_x) < abs(X) or sum(move_y) < abs(Y):
        print('No')
        return
    
 
    move_x_process = [mx for mx in move_x if mx > 0]
    move_y_process = [my for my in move_y if my > 0]
    X = abs(X); Y = abs(Y)
    len_move_x = len(move_x_process)
    sum_x = sum(move_x_process)
    len_move_y = len(move_y_process)
    sum_y = sum(move_y_process)
 
    dp_table = [[False for _ in range(sum_x+1)] for _ in range(len_move_x+1)]
    dp_table[0][0] = True
    
    for i in range(0,len_move_x):
        for j in range(0, sum_x+1):
            dp_table[i+1][j] = dp_table[i][abs(j-move_x_process[i])]
            if j+move_x_process[i] <= sum_x: 
                dp_table[i+1][j] = dp_table[i+1][j] or dp_table[i][j+move_x_process[i]]
    
    # print(dp_table)
    ret = dp_table[len_move_x][X]
    dp_table = [[False for _ in range(sum_y+1)] for _ in range(len_move_y+1)]
    dp_table[0][0] = True
    for i in range(0,len_move_y):
        for j in range(0, sum_y+1):
            # if j-move_x_process[i] >= 0:
            dp_table[i+1][j] = dp_table[i][abs(j-move_y_process[i])]
            if j+move_y_process[i] <= sum_y:
                dp_table[i+1][j] = dp_table[i+1][j] or dp_table[i][j+move_y_process[i]]
    
    ret = ret and dp_table[len_move_y][Y]
    print('Yes' if ret else 'No')
    
solve()

Measured memory_bytes: 110428
macro_rules! input {
    ( $( $var:ident : $t:tt ),* ) => {
        use std::io::{stdin, Read};
        let mut bytes = stdin().bytes();
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        $(let $var = read_value!(next, $t);)*
    };

    ( $( $var:ident : $t:tt ),+ ,) => {
        input!{ $($var : $t),* }
    };
}

macro_rules! read_value {
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: u32,
        m: usize
    }
    let inf = 10_u64.pow(9);
    let mut dp = vec![vec![inf; 1 << n]; 2];
    dp[0][0] = 0;
    (0..m).map(|i| {
        input! {
            a: u64,
            b: usize,
            c: [usize; b]
        }

        let c = c.iter().fold(0, |acc, x| acc | (1_usize << (x-1)));
        (0..2_usize.pow(n)).rev().map(|j| {
            let next = j | c;
            dp[(i + 1) % 2][j] = dp[i % 2][j];
            dp[(i + 1) % 2][next] = cmp::min(dp[(i + 1) % 2][next], dp[i % 2][j] + a);
        }).collect::<Vec<_>>();
    }).collect::<Vec<_>>();
    let ans: i64 = if *dp[m % 2].last().unwrap() == inf {
        -1
    } else {
        *dp[m % 2].last().unwrap() as i64
    };
    println!("{}", ans);
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  int sum = 0;
  rep(i,n) sum += m[i];

  x -= sum;

  sort(all(m));

  int ans = n + (x / m.front());

  cout << ans << endl;
  
}


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

n,a,b,c=MI()
mn=inf
lis=[I() for i in range(n)]
for i in list(product([0,1,2,3],repeat=n)):
    x=[]
    y=[]
    z=[]
    for j in range(n):
        if i[j]==0:
            x.append(lis[j])
        elif i[j]==1:
            y.append(lis[j])
        elif i[j]==2:
            z.append(lis[j])
    if len(x)==0 or len(y)==0 or len(z)==0:
        ans=inf
    else:
        ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1)
    #print(ans)
    if ans<mn:
        mn=ans
        X=x
        Y=y
        Z=z
print(mn)
'''print(X)
print(Y)
print(Z)
'''

Measured memory_bytes: 60464
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include <iostream>
#include <string>

struct bigint {
private:
    std::string s;
public:
    bigint(std::string s): s(s) {}
    bigint& operator +(bigint rhs)
    {
        int d = rhs.s.size() < this->s.size() ? this->s.size() - rhs.s.size() : rhs.s.size() - this->s.size();
        if (rhs.s.size() < this->s.size()) for (int i = 0; i < d; ++i) rhs.s = '0' + rhs.s;
        else for (int i = 0; i < d; ++i) this->s = '0' + this->s;

        int c = 0;
        for (int i = this->s.size() - 1; i >= 0; --i) {
            int a = this->s[i] - '0' + rhs.s[i] - '0' + c;
            this->s[i] = a % 10 + '0';
            c = a / 10;
        }
        if (c) this->s = (char)(c + '0') + this->s;
        return *this;
    }
    void print()
    {
        if (s.size() > 80) std::cout << "overflow";
        else std::cout << s;
    }
};

int main()
{
    int n;
    std::cin >> n;
    std::cin.ignore();

    for (int i = 0; i < n; ++i) {
        std::string s1, s2;
        getline(std::cin, s1);
        getline(std::cin, s2);

        bigint bi1(s1), bi2(s2);
        (bi1 + bi2).print();
        std::cout << std::endl;
    }
}

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

const int N = 1e7 + 10, mod = 998244353;
long long fac[N];

long long bpow(long long b, long long e) {
  long long res = 1;
  while (e) {
    if (e & 1) {
      res *= b;
      res %= mod;
    }
    b *= b;
    b %= mod;
    e >>= 1;
  }
  return res;
}

long long inv(long long x) { return bpow(x, mod - 2); }

long long C(int n, int k) {
  // n! / k! / (n - k)!
  return fac[n] * inv(fac[k]) % mod * inv(fac[n - k]) % mod;
}

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  for (int i = n / 2 + 1; i <= n; i++) {
    // nCi * 2 ^ (n - i)
    ans += bpow(2, n - i) * C(n, i) % mod;
    ans %= mod;
  }
  ans <<= 1;
  ans %= mod;
  // cout << ans << endl;
  ans = ((bpow(3, n) - ans) % mod + mod) % mod;
  cout << ans << endl;
  return 0;
}


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

#define F1(n) (n/2)
#define F2(n) (3*n+1)

using namespace std;
int main()
{
	int s,i=1;
	cin >> s;
	map<int, bool> m;
	while (1) {
		if (m[s]) {
			cout << i << endl;
			return 0;
		}
		m[s] = true;
		if (s & 1)
			s = F2(s);
		else
			s = F1(s);
		i++;
		
	}
	return 0;
}

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

int main(){
    ll N,D;
    cin>>N>>D;
    ll X;
    ll Y;
    ll value=D*D;
    ll cnt=0;
    for(int i=0;i<N;i++){
        cin>>X>>Y;
        if(value>=X*X+Y*Y){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3632