akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[][]dp;
	static int n;
	static long mod=1000000007;
	static int[][] mat;
	static long solve(int ind,int mask)
	{
		if(ind==n)
			return 1;
		if(dp[ind][mask]!=-1)
		{
			return dp[ind][mask];
		}
		long res=0;
		for(int i=0;i<n;i++)
		{
			if(mat[ind][i]==1 && ((mask&(1<<i))==0))
				res=(res+solve(ind+1,mask|(1<<i)))%mod;
		}
		dp[ind][mask]=res;
		return res;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		n=cin();
		mat=new int[n][n];
		for(int i=0;i<n;i++)
		{
			mat[i]=split();
		}
		dp=new long[n+1][(int)Math.pow(2, n)];
		for(int i=0;i<=n;i++)
		{
			Arrays.fill(dp[i], -1);
		}
		System.out.println(solve(0,0));
	}
}


Measured memory_bytes: 413120
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, d; cin >> n >> d;

    cout << ceil(n / (2.0 * d + 1)) << endl;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    vector<double> A(N);
    rep(i, N){
        double d;
        cin >> d;
        d = (d+1) / 2;
        A[i] = d;
    }
    double sum = 0;
    rep(i, K) sum += A[i];
    double ans = sum;
    for(int i = 1; i <= N-K; i++){
        sum -= A[i-1];
        sum += A[i+K-1];
        ans = max(ans, sum);
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  ll powe(ll a,ll b,ll c){
    if(b==0)
    return 1;
    if(b%2==0)
    {
        ll z=powe(a,b/2,c);
        return (z*z)%c;
    }
    else return ((a%c)*powe(a,b-1,c))%c;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,p;cin>>n>>p;
	ll i,j;
	ll sum=0;
	map<ll,ll> ma;
	string s;cin>>s;
	if(p==2 or p==5){
		ll m=p;
		ll dp[m]={};
	dp[0]=1;
	ll prev=0,sum=0;
	for(i=0;i<n;i++){
		ll p=(prev*10+(s[i]-'0'))%m;
		sum+=dp[p];
		dp[p]++;
		ll dp1[m]={};
		//dp1[0]=1;
		for(j=0;j<m;j++){
			dp1[(j*10)%m]+=dp[j];
		}
		for(j=0;j<m;j++)
			dp[j]=dp1[j];
		prev=p;
		//dp[prev]++;
	}
	cout<<sum<<endl;
	return 0;
} 
	
	ll prev=0;
	ma[0]=1;
	for(j=n-1;j>=0;j--){
		prev=(prev+(s[j]-'0')*powe(10,n-j-1,p))%p;
		sum+=ma[prev];
		ma[prev]++;

	}
	cout<<sum;

	return 0;
} 

Measured memory_bytes: 1044
#include<iostream>

using namespace std;

int main(){
  int n, i;
  while(cin >> n, n != 0){
    //    cout << '!' << endl;
    int ice[10] = {};
    while(n--) {
      cin >> i;
      ice[i]++;
    }
    for(i = 0; i < 10; i++) {
      if(ice[i])
	while(ice[i]--) cout << '*';
      else cout << '-';
      cout << endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#define INFTY 1000000000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);
int num = 0;
int main()
  {
    int n,s[500000],i;

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

    mergeSort(s,0,n);
    for(i = 0;i < n; i++){
      printf("%d",s[i]);
      if(i<n-1) printf(" ");
    }
    printf("\n%d\n",num);
    
    return 0;
  }

void merge(int *a,int left,int mid,int right)
{
  int n1,n2,i,j,k;
  // int *l,*r;

  n1 = mid - left;
  n2 = right - mid;
  // l = (int *)malloc(sizeof(int)*n1);
  // r = (int *)malloc(sizeof(int)*n2);
  int l[n1], r[n2];
  for(i = 0; i < n1; i++){
    l[i] = a[left+i];
  }
  for(i = 0;i < n2; i++){
    r[i] = a[mid+i];
  }
  l[n1] = INFTY;
  r[n2] = INFTY;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    num++;
    if(l[i] <= r[j]){
      a[k] = l[i];
      i = i + 1;
    }
    else{
      a[k] = r[j];
      j = j + 1;
    }
  }
}

void mergeSort(int *a,int left,int right)
{
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
}

Measured memory_bytes: 4508
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  int x=0;
  int y=0;
  int z=0;
  for(int i=0;i<t;i++){
    if(a<b){
      a+=v;
      b+=w;
      x++;
    }
    if(a>b){
      a-=v;
      b-=w;
      z++;
    }
    if(a==b){
      y++;
      break;
    }
  }
  if(y==1){
    cout<<"YES"<<endl;
  }
  else if(x>0&&z>0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    VS w = {"Sunny", "Cloudy", "Rainy"};
    REP(i,0,3) if (s == w[i]) cout << w[(i+1)%3] << endl;
}

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

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int K = sc.nextInt();

		int count = 0;

		int a = 1;


		while(count<N) {

			a = Math.min(a*2, a+K);

			count++;
		}

		System.out.println(a);
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
int main(){
    int a,b,c,n;
    scanf("%d",&n);
    if(n==3){
        scanf("%d %d %d",&a,&b,&c);
        for(int i=1; ;i++){
            if(a+b+c==i*3) break;
            if(((a%i==0)&&(b%i==0))&&(c%i==0)){
                printf("%d\n",i);
            }
        }
    } else {
        scanf("%d %d",&a,&b);
        for(unsigned int i=1; ;i++){
            if(a+b==i*2) break;
            if((a%i==0)&&(b%i==0)){
                printf("%d\n",i);
            }
        }
    }
}


Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    vector<string> s(3);
    REP(i,3) cin >> s[i];

    cout << "A" << s[1][0] << "C"<< endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
res = "UNRESTORABLE"

for i in range(len(S)-1, len(T)-2, -1):

  s = list(S[::])
  j = i
  flag = True
  for k in range(len(T)-1, -1, -1):
    if s[j] == "?":
      s[j] = T[k]
      j -= 1
    elif s[j] == T[k]:
      j -= 1
      continue
    elif s[j] != T[k]:
      flag = False
      break

  if flag:
    for j in range(len(s)):
      if s[j] == "?": s[j] = "a"
    res = "".join(s)
    break

print(res)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; ++i){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int sum = 0;
      	for(int i=0; i<a.length-1; ++i){
			sum = sum + a[i];
		}
      	if(sum<=a[a.length-1]){
          System.out.println("No");
        }else{
          System.out.println("Yes");
        }
      	
	}
}


Measured memory_bytes: 35948
#include<stdio.h>
int main(void)
{
    int c1,c5,c10,c50,c100,c500;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	c5=c5*5;
	c10=c10*10;
	c50=c50*50;
	c100=c100*100;
	c500=c500*500;
	if(1000<=c1+c5+c10+c50+c100+c500){
	    printf("1\n");
	}
	else{
	    printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 2608
import java.util.*;

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


Measured memory_bytes: 62036
import Control.Monad
import Data.Array
main = readLn >>= main'
    where
        main' n = getLine >>= main'' n . map read . words
        main'' n ts = getLine >> getContents >>= mapM_ print . solve (sum ts) (listArray (1, n) ts) . map (map read . words) . lines

solve :: Int -> Array Int Int -> [[Int]] -> [Int]
solve s ts = map (\[p, x] -> s - ts ! p + x)


Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	vector<int> hist(26);
	for(int i = 0; i < n; i += 2){ ++hist[s[i] - 'a']; }
	vector<vector<int>> table(500);
	for(int i = 0; i < 26; ++i){
		table[hist[i]].push_back(i);
	}
	bool is_first = true;
	int answer = 0;
	for(int i = 1; i < 500; ++i){
		if(table[i].empty()){ continue; }
		if(i == 1){
			for(const auto c : table[i]){
				if(!is_first){ ++answer; }
				is_first = false;
				++answer;
			}
		}else{
			if(!is_first){ ++answer; }
			is_first = false;
			if(table[i].size() == 1){
				answer += 3;
			}else{
				answer += 4;
				bool local_first = true;
				for(const auto c : table[i]){
					if(!local_first){ ++answer; }
					local_first = false;
					++answer;
				}
			}
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3224
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

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

  for (int i = 0; i < S.length(); i++){
    if (S[i] != T[i]){
      No(); return 0;
    }
  }
  Yes();

  return 0;
}


Measured memory_bytes: 3612
s1=input()
s2=input()
l1=[s1[i] for i in range(len(s1))]
l2=[s2[j] for j in range(len(s2))]
l1.sort()
l2.sort(reverse=True)
if l1==l2:
    print("No")
    exit()
l3=[l1,l2]
l4=sorted(l3)
if l3==l4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>


using namespace std;

int main(){
 long long int n;
 cin >> n;
  
 vector<long long int> Q;
  
  for(int i=1;i<=9;i++){
    Q.push_back(i);
  }
  
  while(true){
    if(n <= Q.size()){
      cout << Q[n-1] << endl;
      return 0;
    }
    n -= Q.size();
    
    vector<long long int>P;
    swap(P,Q);
    for(long long int a : P){
      for(int i=-1;i<=1;i++){
        if(a%10+i < 0 || a%10+i > 9) continue;
        Q.push_back(a*10+a%10+i);
      }
    }
  } 
}
    
  
  
  

Measured memory_bytes: 1712
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<queue>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int W, H;			
const int MAX = 51;
bool is_visit[MAX][MAX][MAX][MAX];			
int dx[4] = {0, 1, -1, 0};
int dy[4] = {1, 0, 0, -1};

struct Point { 
	int x, y; 
	Point(int x_ = 0, int y_ = 0): x(x_), y(y_) {}
	Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
	bool operator==(const Point &p) const { return (x == p.x && y == p.y); }
};

struct state {
	Point len, rin;
	state(Point len_, Point rin_): len(len_), rin(rin_) {}
};

bool can_move(Point p, vector<vector<char>> &room) {
	if(p.x < 0 || p.x >= W || p.y < 0 || p.y >= H) return false; 
	if(room[p.y][p.x] == '#') return false;	
	return true;
}

int main() {
	while(cin >> W >> H && W) {
		vector<vector<char>> l_room(H, vector<char>(W, '.'));	
		vector<vector<char>> r_room(H, vector<char>(W, '.'));	
		fill_n((bool *)is_visit, MAX*MAX*MAX*MAX, false);

		Point s_len, g_len, s_rin, g_rin;
		rep(y, H) {
			rep(x, W){
				cin >> l_room[y][x];
				if(l_room[y][x] == 'L')	s_len = {x, y};
				else if(l_room[y][x] == '%') g_len = {x, y};
			}
			rep(x, W) {
				cin >> r_room[y][x];
				if(r_room[y][x] == 'R')	s_rin = {x, y};
				else if(r_room[y][x] == '%') g_rin = {x, y};
			}	
		}

		// ????????????????¨??????????	
		queue<state> que;
		que.push(state(s_len, s_rin));
		is_visit[s_len.x][s_len.y][s_rin.x][s_rin.y] = true;

		bool is_clear = false;
		while(!que.empty()) {
			state st = que.front(); que.pop();
			Point len = st.len;		
			Point rin = st.rin;		
			rep(i, 4) {
				// ?¬??????????????±??????????	
				Point l = len + Point(dx[i], dy[i]);	
				Point r = rin + Point(dx[i]*-1, dy[i]);	
				if(!can_move(l, l_room)) l = len;	
				if(!can_move(r, r_room)) r = rin;	
			
				// ?¬???????????????¢????¨??????????????¢??????????
				if(is_visit[l.x][l.y][r.x][r.y]) continue;
				if(l == g_len && r == g_rin) { is_clear = true; goto end; }
				
				// ?????¨?????¶???????¨??????????????????? 	
				is_visit[l.x][l.y][r.x][r.y] = true;
				if(l == g_len || r == g_rin) continue; // ????????????????????????
				que.push(state(l, r));
			}
		}
end:	
		cout << (is_clear ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 8732
n, m = map(int, input().split())


def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


if n >= 2 and m >= 2:
    print(nCr(n, 2) + nCr(m, 2))
elif n >= 2 and m <= 1:
    print(nCr(n, 2))
elif n <= 1 and m >= 2:
    print(nCr(m, 2))
else:
    print(0)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(int argc, char **argv){
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
n, m = gets.chomp.split.map(&:to_i)
a = [-1] + Array.new(m){gets.to_i} + [n + 1]
r = [0, 1]
rl = 1
cnt = 1
100000.times do |i|
  r[i + 2] = (r[-2] + r[-1]) % 1000000007
end
(m + 1).times do |i|
  range = a[i + 1] - a[i] - 1
  cnt = cnt * r[range] % 1000000007
end
puts cnt % 1000000007


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    char a;
    cin >> a;
    if ((a - 'a') <= 27 && a - 'a' >= 0)
    {
        cout << "a" << endl;
    }
    else
    {
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

template <unsigned T>
bool prevSubset(bitset<T>& bs, const bitset<T>& mask)
{
    if(bs.none())
        return false;
    bs = bs.to_ulong() - 1ull;
    bs &= mask;
    return true;
}

int main()
{
    int n, m, p;
    cin >> n >> m >> p;

    vector<vector<int> > edge(n, vector<int>(n, 0));
    for(int i=0; i<m; ++i){
        int u, v;
        cin >> u >> v;
        -- u;
        -- v;
        ++ edge[u][v];
        ++ edge[v][u];
    }

    // 頂点0と連結な頂点をビットで保持
    vector<double> dp(1<<n, 1.0);

    for(int i=0; i<(1<<n); ++i){
        bitset<14> bs(i);
        if(!bs[0])
            continue;

        bitset<14> bs1 = bs;
        while(prevSubset(bs1, bs)){
            if(!bs1[0])
                continue;

            bitset<14> bs2 = bs ^ bs1;
            int e = 0;
            for(int j=0; j<n; ++j){
                for(int k=0; k<n; ++k){
                    if(bs1[j] && bs2[k])
                        e += edge[j][k];
                }
            }

            dp[i] -= dp[bs1.to_ulong()] * pow(p / 100.0, e);
        }
    }

    printf("%.10f\n", dp[(1<<n)-1]);
}

Measured memory_bytes: 1004
class Node
  attr_accessor :key, :left, :right
  def initialize key
    @key = key
  end
 
  def inorder
    left.inorder if left
    print " ", key
    right.inorder if right
  end
 
  def preorder
    print " ", key
    left.preorder if left
    right.preorder if right
  end
end
 
def insert
  z = Node.new $key.to_i
  x = $root
  while x
    y = x  # // x??????
    x = z.key < x.key ? x.left : x.right  #??????????????§????/??????????????§????
  end
 
  unless y  #y???nil??????´???
    $root  = z
  else
    z.key < y.key ? y.left = z : y.right = z  #z???y?????????????????????/z???y?????????????????????
  end
end
 
n = gets.to_i
n.times do
  command, $key = gets.split
  if command == "insert"
    insert
  else
    $root.inorder
    puts
    $root.preorder
    puts
  end
end

Measured memory_bytes: 47900
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    int p[n];
    REP (i, n) {
        scanf("%d", &p[i]);
    }

    int cnt = 0;

    FOR (i, 1, n - 1) {
        cnt += (p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]);
    }

    OUT(cnt);
    return 0;
}



Measured memory_bytes: 256
function main()
  
  N = map(x -> parse(Int,x), split(chomp(readline()),""))
  
  if N[1] < N[2]
    println(N[1]+1,N[1]+1,N[1]+1)
  elseif N[1] > N[2]
    println(N[1],N[1],N[1])
  else
    if N[2] < N[3]
      println(N[2]+1,N[2]+1,N[2]+1)
    else
      println(N[2],N[2],N[2])
    end
  end
  
end

main()

Measured memory_bytes: 110536
#template
def inputlist(): return [int(k) for k in input().split()]
#template
ans = 0
from math import gcd
K = int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        s = gcd(i,j)
        for k in range(1,K+1):
            t = gcd(s,k)
            ans +=t

print(ans)


Measured memory_bytes: 9192
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			Point2D.Double[] p = new Point2D.Double[n];
			for(int i=0;i<n;i++) p[i] = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			
			Arrays.sort(p, new Comparator<Point2D.Double>(){
				public int compare(Point2D.Double o1, Point2D.Double o2) {
					if(o1.y-o2.y>0) return 1;
					else return -1;
				}
			});
			
			int max = 1;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					if(p[j].y-p[i].y>2.0001) break;
					if(p[j].distance(p[i])>2.0001) continue;
					
					double a, b, c, A, B, C;
					double xa = p[i].x;
					double ya = p[i].y;
					double xb = p[j].x;
					double yb = p[j].y;
					double[] x = new double[2];
					double[] y = new double[2];
					
					A = xa-xb;
					B = ya-yb;
					C = (A*xa+A*xb+B*ya+B*yb)/2;
					if(A==0){
						c = (C/B-ya)*(C/B-ya)+xa*xa-1;
						x[0] = xa+Math.sqrt(xa*xa-c);
						x[1] = xa-Math.sqrt(xa*xa-c);
						y[0] = C/B;
						y[1] = C/B;
					}else if(B==0){
						c = (C/A-xa)*(C/A-xa)+ya*ya-1;
						y[0] = ya+Math.sqrt(ya*ya-c);
						y[1] = ya-Math.sqrt(ya*ya-c);
						x[0] = C/A;
						x[1] = C/A;
					}else{
						a = 1+(A*A)/(B*B);
						b = (2*A*ya*B-2*A*C-2*xa*B*B)/(B*B);
						c = (C/B-ya)*(C/B-ya)+xa*xa-1;
						x[0] = (-b+Math.sqrt(b*b-4*a*c))/(2*a);
						x[1] = (-b-Math.sqrt(b*b-4*a*c))/(2*a);
						y[0] = (C-A*x[0])/B;
						y[1] = (C-A*x[1])/B;
					}
					
					for(int d=0;d<2;d++){
						int cnt = 0;
						for(int e=0;e<n;e++){
							if(p[e].y-y[d]>1.0001) break;
							if(p[e].distance(x[d], y[d])<1.0001) cnt++;
						}
						max = Math.max(max, cnt);
					}
				}
			}
			
			System.out.println(max);
		}	
	}	
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m,d; cin>>n>>m>>d;
  
  double ans;
  if(d==0) ans=(double)(m-1)/n;
  else ans=(double)(m-1)*2*(n-d)/n/n;
  coutd(ans);
  
}

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

typedef long long ll;
 
int main(){
  string s, t, ans;
  cin >> s >> t;
  vector<int> a, b;
  for(int i=0; i<int(s.length()); i++){
    a.push_back(s[i]-'a');
  }
  for(int i=0; i<int(t.length()); i++){
    b.push_back(t[i]-'a');
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(), greater<int>());
  int i=0;
  while(true){
    if(i>=int(b.size())){
      ans = "No";
      break;
    }else if(i>=int(a.size())){
      ans = "Yes";
      break;
    }else if(a[i]==b[i]){
      i++;
      continue;
    }else if(a[i]>b[i]){
      ans = "No";
      break;
    }else if(a[i]<b[i]){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<ll>> A(N, vector<ll>(N));
    for (int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        A[l][r] += 1;
    }

    vector<vector<ll>> acc(N + 1, vector<ll>(N + 1));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            acc[i + 1][j + 1] = acc[i + 1][j] + acc[i][j + 1] - acc[i][j] + A[i][j];
        }
    }

    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        p--, q--;
        cout << acc[N][q + 1] - acc[p][q + 1] << endl;
    }

}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 4864
import sys

N = int(input())
L = sys.stdin.readline().strip().split()
L = [int(l) for l in L]
L.sort(reverse=True)
max_L = int(L.pop(0))
sum_L = sum(int(i) for i in L)
if(max_L<sum_L):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String cls[] = new String[9];
		int a[] = new int [9];
		int b[] = new int [9];
 		for(int i = 0;i < 9;i++){
 			cls[i] = in.next();
			a[i] = in.nextInt();
			b[i] = in.nextInt();
		}
 		for(int i = 0; i < 9;i++){
 			System.out.println(cls[i]+" "+(a[i]+b[i])+" "+(200*a[i]+300*b[i]));
 		}
	}
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N + 1);
    rep(i, N) cin >> A[i + 1];

    map<int, int> m;

    for(int j=1;j<=N;j++){
        int x = j - A[j];
        if(x >= 0) m[j - A[j]]++;
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        int x = i + A[i];
        ans += m[x];
    }
    cout << ans << endl;
}


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

const int maxN = 100;

double N, M, A[maxN];
int total_votes = 0;
int popular_count = 0;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    total_votes += A[i];
  }

  for(int i = 0; i < N; i++) {
    if(A[i] / total_votes >= 1 / (4.0 * M)) popular_count++;
  }

  if(popular_count >= M) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char  a,b,c;
    cin >> a >> b >> c;
    if((a=='a' && b=='b' && c=='c') || (a=='a' && b=='c' && c=='b') || (b=='a' && a=='b' && c=='c') || (b=='a' && a=='c' && c=='b') || (c=='a' && b=='b' && a=='c') || (c=='a' && b=='c' && a=='b'))
        cout << "Yes";
    else

        cout << "No";



    return 0;
}


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

public class ABC0140_A2v1 {
    private static void Main(string[] args) {
        var inputs = new List<string>() {
            Console.ReadLine().Trim(),
            Console.ReadLine().Trim(),
            Console.ReadLine().Trim(),
            Console.ReadLine().Trim(),
        };

        Prepare(inputs);
    }

    private static void Prepare(List<string> inputs) {
        var orders = ConvertStrToIntArray(inputs[1]);
        var satisfactionBases = ConvertStrToIntArray(inputs[2]);
        var satisfactionCombos = ConvertStrToIntArray(inputs[3]);

        Compute(orders, satisfactionBases, satisfactionCombos);
    }


    private static void Compute(int[] orders, int[] satisfactionBases, int[] satisfactionCombos) {
        var total = satisfactionBases.Sum();
      
        for (var index = 0; index < orders.Length - 1; index++) {
            if (orders[index + 1] == (orders[index] + 1)) total += satisfactionCombos[orders[index] - 1];
        }

        OutputAnswer(total.ToString());
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);
    private static int[] ConvertStrToIntArray(string text) => text.Split().Select(x => int.Parse(x)).ToArray();
}

Measured memory_bytes: 13268
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    """
    （考察を述べてなかったので再提出）
    道を全部張った後に最小全域木を求めれば良いー＞プリム
    ただしそのまま実装すると辺の数が|E|=N^2になり、かつ
    プリムの計算量はO(|E|log|E|)なのでTLEする。

    そこで必要になりそうな辺のみに間引くことを考える。
    可能性のある辺はx座標またはy座標が隣り合うものなので、
    そのような辺のみを格納する。
    """
    N = int(input())
    city_x = defaultdict(list)
    city_y = defaultdict(list)
    indexes_x = set()
    indexes_y = set()
    for v in range(N):
        x, y = map(int, input().split())
        city_x[x].append(v)
        city_y[y].append(v)
        indexes_x.add(x)
        indexes_y.add(y)
    indexes_x = list(indexes_x)
    indexes_y = list(indexes_y)
    indexes_x.sort()
    indexes_y.sort()

    # 必要な道のみに間引く
    repn = [[] for _ in range(N)]
    pre_x = -1
    for x in indexes_x:
        pre_v = city_x[x][0]
        for i, v in enumerate(city_x[x]):
            if i == 0: continue
            repn[v].append((0, pre_v))
            repn[pre_v].append((0, v))
            pre_v = v
        if pre_x != -1:
            repn[city_x[pre_x][0]].append((x - pre_x, pre_v))
            repn[pre_v].append((x - pre_x, city_x[pre_x][0]))
        pre_x = x
    pre_y = -1
    for y in indexes_y:
        pre_v = city_y[y][0]
        for i, v in enumerate(city_y[y]):
            if i == 0: continue
            repn[v].append((0, pre_v))
            repn[pre_v].append((0, v))
            pre_v = v
        if pre_y != -1:
            repn[city_y[pre_y][0]].append((y - pre_y, pre_v))
            repn[pre_v].append((y - pre_y, city_y[pre_y][0]))
        pre_y = y
    # for i in range(N): print(repn[i])

    # プリム
    unvisited = set([i for i in range(1, N)])
    ans = 0
    q = []
    for cost, v in repn[0]: heappush(q, (cost, v))
    while q:
        cost, v = heappop(q)
        if v not in unvisited: continue
        ans += cost
        unvisited.remove(v)
        if not unvisited: break
        for next_cost, u in repn[v]:
            if u not in unvisited: continue
            heappush(q, (next_cost, u))
    print(ans)





if __name__ == "__main__":
    main()


Measured memory_bytes: 164956
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> v(n),c(n);
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    for(int i = 0; i < n; i++){
        if(v[i] > c[i]) ans += v[i]-c[i];
    }
    cout << ans << endl;
    return 0;
}

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

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

	vector<int> a(N);
	for(int i = 0; i < N; i++){
		int a_i;
		cin >> a_i;
		a.push_back(a_i);
	}

	int Alice_point = 0;
	int Bob_point = 0;

	sort(a.begin(), a.end(), greater<int>());
	for(int i = 0; i < N; i++){
		if(i % 2 == 0){
			Alice_point += a[i];
		} else{
			Bob_point += a[i];
		}
	}

	cout << Alice_point - Bob_point << endl;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	int n;
	cin>>n;
	
	string x;
	cin>>x;
	
	vector<int>red(n+1,0),white(n+1,0);
	
	for(int i=0;i<n;i++)
	{
		red[i+1]=red[i]+(int)(x[i]=='R');
		white[i+1]=white[i]+(int)(x[i]=='W');
	}
	
	int ans=n;
	
	for(int i=0;i<=n;i++)
	{
		int age_lal=i-red[i];
		int pore_shada=n-i-(white[n]-white[i]);
		int common=min(white[i],red[n]-red[i]);
		
		int temp=age_lal+pore_shada-common;
		
		debug(temp);
		ans=min(ans,temp);
	}
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int t=1;
	//cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t anum,bnum,m;
    cin >> anum >> bnum >> m;
    vi a(anum),b(bnum);
    rep(i,anum) cin >> a.at(i);
    rep(i,bnum) cin >> b.at(i);
    vi x(m),y(m),c(m);
    rep(i,m) cin >> x.at(i) >> y.at(i) >> c.at(i);
    int64_t res = INF;
    // 割引券を使う場合
    int64_t sum = 0;
    rep(i,m){
        sum = a.at(x.at(i)-1) + b.at(y.at(i)-1) - c.at(i);
        res = min(res,sum);
    }
    // 割引券を使わない場合
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sum = a.at(0) + b.at(0);
    res = min(res,sum);
    cout << res << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	int i,x;
	string a;
	cin >> a;
	for(i=0;i<3;i++){
		if(a[i]=='o'){
			x++;
		}
	}
	cout << 700+100*x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int K,Q;
	cin>>K>>Q;
	rep(qt,Q){
		int x,y;
		cin>>x>>y;
		x--,y--;
		if(K==1){
			cout<<x+1<<endl;
			continue;
		}
		while(x!=y){
			if(x>y) swap(x,y);
			y = (y-1)/K;
		}
		cout<<x+1<<endl;
	}
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,c,sum = 0;
    cin >> n >> c;
    rep(i,c){
        int temp; cin >> temp;
        sum += temp;
    }
    ++n;
    cout << sum/n + (sum%n?1:0) << endl;
}





Measured memory_bytes: 3088
#include <iostream>

using namespace std;

const int money[] = {100, 500, 1000};

int main()
{
    int a, b;

    while (cin >> a >> b, a || b) {
        int num[3] = {0};

        a = b - a;
        for (int i = 2; i >= 0; i--) {
            num[i] = a / money[i];
            a -= num[i] * money[i];
        }
        for (int i = 0; i < 2; i++)
            cout << num[i] << " ";
        cout << num[2] << endl;;
    }

    return 0;
}

Measured memory_bytes: 1164
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000, M = 100000, MD = 1000000007;

int xx[N], yy[M];

long long solve(int *aa, int n) {
	long long sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ans = (ans + (long long) aa[i] * i - sum) % MD;
		sum += aa[i];
	}
	return ans;
}

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> xx[i];
	for (int j = 0; j < m; j++)
		cin >> yy[j];
	cout << solve(xx, n) * solve(yy, m) % MD << '\n';
	return 0;
}


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

int main() {
  std::string s;
  cin >> s;
  int a, z;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'A'){
      a = i + 1;
      break;
    }
  }
  for(int i = s.size() - 1; i != 0; i--){
    if(s.at(i) == 'Z'){
      z = i + 1;
      break;
    }
  }
  cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
N = int(input())
A, B, C = list(map(int, input().split()))

for i in range(N-1):
    a, b, c = list(map(int, input().split()))

    a += max(B, C)
    b += max(A, C)
    c += max(A, B)

    A, B, C = a, b, c

print(max(A, B, C))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string s,t;
int x,y;
int main()
{
    cin>>s>>t;
    if (s==t)
    {
        cout<<"Yes";
        return 0;
    }
    for (int i=0;i<s.size();i++)
    {
        reverse(s.begin(),s.end());
        s+=s[0];
        s.erase(s.begin(),s.begin()+1);
        reverse(s.begin(),s.end());
        if (s==t)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


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

int main() {
    int N, T;
    cin >> N >> T;
    int cost = INT32_MAX;
    rep(i, N) {
        int c, t;
        cin >> c >> t;
        if (t <= T)
            cost = min(c, cost);
    }

    if (cost == INT32_MAX)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << cost << endl;
    }
}


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

using namespace std;
#define int long long

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

    if(S.length()==2)
        cout<<S<<endl;
    else if(S.length()==3){
        for(int i=2;i>=0;i--){
            cout<<S[i];
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i, a, b;
        String N="", M="";
        a = scan.nextInt();
        b=scan.nextInt();
        for(i=0; i<b; i++){
            N = N+a;
        }
        for(i=0; i<a; i++){
            M = M+b;
        }
        if(N.compareTo(M)<=0) {
            System.out.println(N);
        }else{
            System.out.println(M);
        }
    }
}


Measured memory_bytes: 21844
import bisect
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
    ans += (bisect.bisect_left(A,b)*(n-bisect.bisect_right(C,b)))
print(ans)

Measured memory_bytes: 29360
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "\n********************************************\n"
#define fast  ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
    fast;
    ll n, k, ans = 0;
    cin >> n >> k;
    while (n --)
    {
    	ll num;
    	cin >> num;
    	ans += (num >= k);
    }
    cout << ans;
    return 0;
}

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

using namespace std;
int  dig(int x)
{
    int sum=0;
    while(x%2==0)
    {
        sum++;
        x=x/2;
    }
    return sum;
}
int main()
{
    int n;
    cin>>n;
    int maxn=-1;
    int res=0;
    for(int i=1;i<=n;i++)
    {
        int temp=dig(i);
       //1 cout<<temp<<"   ";
        if(temp>maxn)
        {
            res=i;
            maxn=temp;
        }
    }
    cout<<res<<endl;
   // cout << "Hello world!" << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    int a[100], b[100];
    rep(i, n-1) cin >> b[i+1];
    b[0] = b[1];
    int ans = 0;
    rep(i, n-1) ans += min(b[i], b[i+1]);
    ans += b[n-1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  string s; cin >> s;
  vector<vector<int>> is(26);
  FOR(i,0,s.length()-1){
    is[s[i] - 'a'].PB(i);
  }
  FOR(i,0,s.length()-1){
    is[s[i] - 'a'].PB(i+s.length());
  }
  ll now = 0;
  ll ans = 0;
  string t; cin >> t;
  FOR(i,0,t.length()-1){
    char a = t[i];
    if(SZ(is[a-'a'])==0){
      cout << -1 << endl;
      return 0;
    }
    now = *lower_bound(is[a-'a'].begin(),is[a-'a'].end(),now) + 1;
    if(now>=s.length()){
      now -= s.length();
      ans += s.length();
    }
  }
  ans += now;
  cout << ans << "\n";
    

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  ll n,l; cin >> n >> l;
  ll a[n];
  FOR(i,0,n-1) cin >> a[i];
  int hold = -1;

  FOR(i,0,n-2){
    if(a[i]+a[i+1]>=l){
      hold = i+1;
      break;
    }
  }

  if(hold!=-1){
    cout << "Possible" << endl;
    FOR(i,1,hold-1){
      cout << i << endl;
    }
    FORD(i,n-1,hold+1){
      cout << i << endl;
    }
    cout << hold << endl;
  } else {
    cout << "Impossible" << endl;
  }



}

Measured memory_bytes: 1664
/* B - Multiplication 2 */

#include <bits/stdc++.h>
using namespace std;

#define MAX 1000000000000000000

int main(){
  int N;
  vector<long long> A(100000);
  long long ans = 1;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    // 答えが0になる場合
    if(A.at(i) == 0){
      ans = 0;
    }
  }
  // 答えが0になる場合とそうでない場合で場合分け
  if(ans == 0){
    cout << "0" << endl;
  }else{
    for(int i = 0; i < N; i++){
      if(A.at(i) <= MAX / ans){ // 10^18を超えるかどうかの判定は乗算ではなく除算で行う必要がある
        ans *= A.at(i);
      }else{
        cout << "-1" << endl;
        break;
      }
      if(i == N - 1){
        cout << ans << endl;
      }
    }
  }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = (int) s.size();
    int best = 100000;
    for (int i = 0; i + 2 < n; ++i) {
        best = min(best, abs(753 - stoi(s.substr(i, 3))));
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 256