akhauriyash/Code-Regression huggingface dataset:
/**
 *   created: 26 December 2019  10:45:06
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n,w;
		cin>>n>>w;
		vector<long long> val(n), wgt(n), dp(1e5+1, INFLL);
		for(int i=0; i<n; i++)
			cin>>wgt[i]>>val[i];
		dp[0] = 0;
		for(int i=0;i<n; i++){
			for(int j=1e5; j>=val[i]; j--){
				if(dp[j-val[i]]!=INFLL){
					dp[j] = min(dp[j], dp[j-val[i]] + wgt[i]);
				}
			}
		}
		for(int j=1e5; j>=0; j--){
			if(dp[j]<=w){
				cout<<j;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;

#define fir first
#define sec second

typedef long long LL;
typedef pair<LL,LL> PP;

namespace INPUT{
	const int L=1<<15;
	char _buf[L],*S,*T,c;
	char _gc(){
		if(S==T){
			T=(S=_buf)+fread(_buf,1,L,stdin);
			if(S==T) return EOF;
		}
		return *S++;
	}
	void readi(int &X){
		for(c=_gc();c<'0'||c>'9';c=_gc());X=c&15;
		for(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());
	}
	void readl(LL &X){
		for(c=_gc();c<'0'||c>'9';c=_gc());X=c&15;
		for(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());
	}
}
using INPUT::readi;
using INPUT::readl;

const int Maxn=100;
const LL Maxx=(LL)1E18;
const int Mod=1E9+7;

int Q;
LL X,Y;
LL fib[Maxn];
PP s[Maxn][Maxn];

LL GCD(LL X,LL Y){
	if(X<Y) swap(X,Y);
	if(Y==0) return 0;
	return GCD(Y,X%Y)+1;
}

int main(){
	fib[1]=1,fib[2]=2;
	for(int i=3;;++i){
		fib[i]=fib[i-1]+fib[i-2];
		if(fib[i]>Maxx) break;
	}
	s[2][1]=PP(2,3),s[2][2]=PP(3,4);
	for(int i=3;;++i){
		if(fib[i]>Maxx) break;
		for(int j=1;j<i;++j)
			s[i][j]=PP(s[i-1][j].sec,s[i-1][j].fir+s[i-1][j].sec);
		s[i][i]=PP(fib[i+1],fib[i-1]+fib[i+1]);
	}
	//for(int i=2;i<=5;++i,cerr<<endl)
	//	for(int j=1;j<=i;++j) cerr<<s[i][j].fir<<' '<<s[i][j].sec<<endl;
	readi(Q);
	while(Q--){
		LL Ans=0;
		readl(X),readl(Y);
		if(X==1&&Y==1){puts("1 1");continue;}
		if(X>Y) swap(X,Y);
		int t=1;
		for(t=1;;++t)
			if(fib[t]>X||fib[t+1]>Y) break;
		--t;
		if(t==1){
			printf("%d %lld\n",t,X*Y%Mod);
			continue ;
		}
		for(int i=1;i<=t;++i)
			if(s[t][i].fir<=X&&s[t][i].sec<=Y)
				(Ans+=(Y-s[t][i].sec)/s[t][i].fir+1)%=Mod;
		for(int i=1;i<=t;++i)
			if(s[t][i].fir<=Y&&s[t][i].sec<=X)
				(Ans+=(X-s[t][i].sec)/s[t][i].fir+1)%=Mod;
		printf("%d %lld\n",t,Ans);
	}
	return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int a, b;
    cin >> a >> b;

    cout << max(a - 2 * b, 0);
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
vector<ll>q;

ll getAns(ll m){
	ll x=0;
	auto it=upper_bound(all(q),m)-q.begin()-1;
	return it;
}

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<=1e4;i++){
		q.pb(((i+1)*i)/2);
	}
	for(ll i=2;i*i<=n;i++){
		ll cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		ans+=getAns(cnt);
	}
	if(n>1)ans++;
	cout<<ans;
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  int X, i;
  cin >> X;
  int sum = 0;
  for(i=1; i<10000000000; i++){
    sum += i;
    if(sum>=X){
      cout << i << endl;
      break;
    } 
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int x=sc.nextInt();
        int asa[] = new int[x];
        long sum = 0;
        for(int i=0;i<x;i++){
            asa[i]=sc.nextInt();
            sum +=asa[i];
        }
        Arrays.sort(asa);
        
        System.out.println(asa[0]+" "+asa[x-1]+" "+sum);
    }
}


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

int digit_sum(int n) {
  int digit;
  int ans = 0;
  while(n) {
    digit = n % 10;
    ans += digit;
    n /= 10;
  }
  return ans;
}

int main () {
  int n, a, b;
  cin >> n >> a >> b;
  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = digit_sum(i);
    if(a <= x && x <= b) ans += i;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
H,W = map(int,input().split())
if H%3 ==0:
    print(0)
    sys.exit()
if W%3 ==0:
    print(0)
    sys.exit()
A=[H,W]
for i in range(H%3+1):
    M = H//3
    if W%2==0:
        N = W//2
        A.append(abs((M+i)*W-(2*M+2-i)*N))
    else:
        N = W//2
        A.append(max((M+i)*W,(2*M+2-i)*N,(2*M+2-i)*(N+1))
                    -min((M+i)*W,(2*M+2-i)*N,(2*M+2-i)*(N+1)) )
for i in range(W%3+1):
    M = W//3
    if H%2==0:
        N = H//2
        A.append(abs((M+i)*H-(2*M+2-i)*N))
    else:
        N = H//2
        A.append(max((M+i)*H,(2*M+2-i)*N,(2*M+2-i)*(N+1))
                    -min((M+i)*H,(2*M+2-i)*N,(2*M+2-i)*(N+1)) )
print(min(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    float temp1,temp2;
    cin>>x;
    for(int i=0;i<x;i++)
    {
        temp1=pow((x+pow(i,5)),0.2);
        temp2=pow((x+-1*pow(i,5)),0.2);
        if((int)temp1==temp1)
        {
            cout<<(int)temp1<<" "<<i;
            break;
        }
        if((int)temp2==temp2)
        {
            cout<<(int)temp2<<" "<<-1*i;
            break;
        }
    }
return 0;
}

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


unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  long long A, B;
  cin >> A;
  cin >> B;

  long long r = 0;
  r = euclidean_gcd(A,B);

  //cout << A << endl;
  //cout << B << endl;
  //cout << A*B << endl;
  //cout << r << endl;
  cout << (A*B)/r << endl;
}


Measured memory_bytes: 256
<?php


fscanf(STDIN, "%d", $n);

$array = explode(" ",trim(fgets(STDIN)));
$last = 0;
$jump = 0;
$ans = 0;

foreach($array as $value){
    if($last >= $value){
        $jump++;
        $last = $value;
    }else{
        $ans = max($ans, $jump);
        $jump = 0;
        $last = $value;
    }

}
$ans = max($ans, $jump);
echo $ans;

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

int main()
{
    long long int n;
    long long int a;
    long long int k[20] = {0};
    long long int t = 0;
    long long int ans = 0;
    cin >> n;
    for(int i = 1;i<=n;i++){
        cin >> a;
        
        for(int j = 0 ; j<20;j++){
            if(a%2 == 1){
                if(t < k[j]) t = k[j];
                k[j] = i;
            }
            a = a/2;
            if(a ==0) break;
        }
        ans += i -t;
        
    }
    cout << ans;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int A, B, C, X;
	int count = 0;
	int i, j;
	if (scanf("%d", &A) != 1) return 1;
	if (scanf("%d", &B) != 1) return 1;
	if (scanf("%d", &C) != 1) return 1;
	if (scanf("%d", &X) != 1) return 1;
	for (i = 0; i <= A; i++) {
		for (j = 0; j <= B; j++) {
			int nokori = X - 500 * i - 100 * j;
			if (nokori >= 0 && nokori % 50 == 0 && nokori / 50 <= C) count++;
		}
	}
	printf("%d\n", count);
	return 0;
}


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

using namespace std;

int a, b;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&a,&b);
	if (a <= 0 && 0 <= b){
		printf("Zero");
	}
	else if (a > 0) printf("Positive");
	else{
		b = min(b, -1);
		b -= a - 1;
		if (b % 2) printf("Negative");
		else printf("Positive");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  
  vector<int> P(M);
  vector<int> Y(M);  
  map<int, vector<int>> PY;
  
  for (auto i = 0; i < M; i++) {
    cin >> P[i] >> Y[i];
    if (PY.find(P[i]) == PY.end()) {
      vector<int> tmp;
      PY[P[i]] = tmp;
    }
    PY[P[i]].push_back(Y[i]);
  }
  
  for (auto iter = PY.begin(); iter != PY.end(); iter++)
    sort(iter->second.begin(), iter->second.end());
           
  for (auto i = 0; i < M; i++) {
    cout << setw(6) << setfill('0') << P[i];
    cout << setw(6) << setfill('0') << lower_bound(PY[P[i]].begin(), PY[P[i]].end(), Y[i]) - PY[P[i]].begin() + 1 << endl;
  }
    
  return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll n, sum = 10,ans =0;cin >> n;
	if (n % 2 != 0) cout << 0 << endl;
	else {
		while (sum <= n) {
			ans += (n / sum);
			sum *= 5;
		}
        cout << ans << endl;
	}
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c=0
    for j in range(m):
        c+=a[i][j]*b[j]
    print(c)


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

int main(){
  int n;
  long long d;
  cin >> n >> d;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    long long x, y;
    cin >> x >> y;
    if(x * x + y * y <= d * d){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>

int main()
{
	char s[20];
	char a[6],b[8],c[6];
	scanf("%s",s);
	strncpy(a,s,5);
	strncpy(b,s+6,7);
    strncpy(c,s+14,5);
	a[5]='\0';
	b[7]='\0';
	c[5]='\0';
	printf("%s %s %s",a,b,c);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll N;
    cin >> N;
    ll max = 0;
    ll out = 0;
    rep(i,N){
        ll p;
        cin >> p;
        out += p;
        if(p>max) max = p;
    }
    cout << out-max/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,ans;
    cin>>x;
    for(int i=1;i<=9;i++)
    {
        if(x%i==0 && (x/i<=9))
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc089/tasks/abc089_b

int main() {
    int N; cin >> N;
    set<string> st;
    string S;
    REP(i, N) {
        cin >> S;
        st.insert(S);
    }

    if (st.size() == 4) {
        cout << "Four" << "\n";
    } else {
        cout << "Three" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n,W;cin>>n>>W;
  int w,v;cin>>w>>v;
  int dp[110000];rep(i,110000)dp[i] = INF;// dp[i] = valueがi以上の時のweightの最小値、 dp[i] = min(dp[i], dp[i - 1)
  dp[0] = 0;
  repd(i,1,v+1)dp[i] = w;
  rep(i,n-1){
    cin>>w>>v;
    for(int j = 109999;j >= v;j--)dp[j] = min(dp[j], dp[j - v] + w);
  }
  for(int i = 109999;i >= 0;i--){
    if(dp[i] <= W){
      cout << i << endl;
      return 0;
    }
  }
}



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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0;
    rep(i,n) {
        ll sum = 0;
        rep(j,i+1) {
            sum+=a[j];
        }
        for(int k = i; k<n; ++k){
            sum+=b[k];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a;cin>>a;
    if(a%10==9||a/10==9)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var str = Console.ReadLine();
        var res = 0;
        for (int i = 0; i < 4; i++)
        {
            if (str[i] == '+') res++;
            else res--;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		final int MAX = 2000;
		
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		
		int[][] dp = new int[MAX*2+1][MAX*2+1];
		for(int i=0; i<N; i++)
			dp[MAX-A[i]][MAX-B[i]]++;
		for(int i=0; i<=MAX*2; i++) {
			for(int j=0; j<=MAX*2; j++) {
				if(i<MAX*2)
					dp[i+1][j] = (int)((dp[i+1][j] + dp[i][j])%MOD);
				if(j<MAX*2)
					dp[i][j+1] = (int)((dp[i][j+1] + dp[i][j])%MOD);
			}
		}
		long sum = 0;
		for(int i=0; i<N; i++)
			sum = (sum + dp[MAX+A[i]][MAX+B[i]])%MOD;
		
		init(MAX*4);
		for(int i=0; i<N; i++)
			sum = (sum - comb(A[i]*2+B[i]*2, A[i]*2) + MOD)%MOD;
		
		System.out.println(sum*rev[2]%MOD);
		
		sc.close();
	}
	
	static long fac[],rev[],revfac[];
	
	static void init(int N) {
		fac = new long[N+1];
		rev = new long[N+1];
		revfac = new long[N+1];
		fac[0] = 1;
		rev[0] = 0;
		revfac[0] = 1;
		for(int i=1; i<=N; i++) {
			fac[i] = fac[i-1]*i%MOD;
			rev[i] = pow(i, MOD-2);
			revfac[i] = pow(fac[i], MOD-2);
		}
	}
	static int pow(long a, long b) {
		long ans = 1;
		while(b>0) {
			if((b&1)!=0)
				ans = (ans * a)%MOD;
			a = (a * a)%MOD;
			b>>=1;
		}
		return (int)ans;
	}
	static long comb(int a, int b) {
		if(a<0 || b<0 || a<b)
			return 0;
		return (((fac[a]*revfac[a-b])%MOD)*revfac[b])%MOD;
	}
	
}

Measured memory_bytes: 95952
#include<iostream>

using namespace std;

int main()
{
	int n, x;
	int a;
	int ans;


	while (1)
	{
		a = 0;
		ans = 0;
		cin >> n >> x;
		//
		if (n == 0 && x == 0)
		{
			break;
		}
		else
		{
			for (int i = 1; i <= n; i++)
			{
				for (int j = 1; j <= n; j++)
				{
					for (int k = 1; k <= n; k++)
					{
						if (i != j && j != k && k != i)
						{
							a = i + j + k;
							if (a == x)
							{
								ans++;
							}
							a = 0;
						}
					}
				}
			}
		}
		ans = ans / 6;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            int iN = int.Parse(Console.ReadLine().Trim());
            int iK = int.Parse(Console.ReadLine().Trim());
            int iX = int.Parse(Console.ReadLine().Trim());
            int iY = int.Parse(Console.ReadLine().Trim());

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            if (iN > iK) { iOut = iK * iX + (iN - iK) * iY; }
            else { iOut = iN * iX; }

            // 出力
            Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
from collections import deque

def resolve():
    N, M = map(int, input().split())
    to = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)

    INF = 1001001001
    dist = [INF] * N
    prev = [-1] * N
    dist[0] = 0
    q = deque([0])
    while len(q) > 0:
        i = q.popleft()
        for j in to[i]:
            if dist[j] != INF:
                continue
            dist[j] = dist[i] + 1
            prev[j] = i
            q.append(j)

    print("Yes")
    for i in range(1, N):
        ans = prev[i]
        ans += 1
        print(ans)

if __name__ == "__main__":
    resolve()

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

#define int long long
signed main(){
  int n;
  cin >> n;
  
  string s;
  int ans = 0;
  map<string, int> mp;
  for(int i = 0;i < n;i++){
    cin >> s;
    sort(s.begin(), s.end());
    ans += mp[s];
    mp[s]++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 11136
n=int(input())
a,b=[],[]
for _ in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
ans,temp=0,0
for i in range(n-1,0,-1):
    if a[i]%b[i]!=0: temp2=b[i]+b[i]*(a[i]//b[i])-a[i]
    else: temp2=0
    temp+=temp2
    ans+=temp2
    a[i-1]+=temp
if a[0]%b[0]!=0: ans+=b[0]+b[0]*(a[0]//b[0])-a[0]
print(ans)

Measured memory_bytes: 21600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n,h;
  cin >> n >> h;
  vi a(n), b(n);
  ll maxNum = 0;
  ll ans = 0;
  ll hit = 0;
  rep(i, n){
    cin >> a[i] >> b[i];
    maxNum = (maxNum < a[i]) ? a[i] : maxNum;
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  rep(i, n){
    if(maxNum > b[i]) continue;
    ans++;
    hit += b[i];
    if(hit >= h){
      cout << ans << endl;
      return 0;
    }
  }
  ll nokori = h - hit;
  ans += int(nokori / maxNum);
  if((double)nokori / maxNum - int(nokori / maxNum) != 0) ans++;
  cout << ans << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<long>> C(N+M,vector<long>(2));
  for(int i=0; i<N; i++){
    cin >> C.at(i).at(0);
    C.at(i).at(1)=1;
  }
  for(int i=0; i<M; i++){
    cin >> C.at(N+i).at(1) >> C.at(N+i).at(0);
  }
  sort(C.begin(),C.end());
  reverse(C.begin(),C.end());
  int i=0,j=0;
  long S=0;
  while(i<N){
    for(int k=0; k<C.at(j).at(1); k++){
      S+=C.at(j).at(0);
      i++;
      if(i==N){
        break;
      }
    }
    j++;
  }
  cout << S << endl;
}

Measured memory_bytes: 11264
n,q=map(int,input().split())
s=input()
ac=[0]*n
for i in range(n-1):
  if s[i:i+2]=="AC":
    ac[i]=ac[i-1]+1
  else:
    ac[i]=ac[i-1]
for i in range(q):
  l,r=map(int,input().split())
  if l==1:
    print(ac[r-2])
  else:
    print(ac[r-2]-ac[l-2])


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

using namespace std;
int main(void){
    long long N,M;
    cin >> N >> M;
    vector<vector<unsigned long long>>shop(N,vector<unsigned long long>(2));
    for(long long  i=0;i<N;i++){
        cin>>shop[i][0]>>shop[i][1];
    }
    
    sort(shop.begin(),shop.end());
    unsigned long long sum=0;
    for(long long  i=0;i<N;i++){
        if(shop[i][1]<M){
            sum+=shop[i][0]*shop[i][1];
            M-=shop[i][1];
        }
        else{
            sum+=shop[i][0]*M;
            M=0;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
#include<unordered_set>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100 * 1000 + 47;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(false); cin.tie(0);
	int n, a, b;
	cin >>n >> a >> b;
	if ((b - a) % 2 == 0)
	{
		cout << "Alice" << endl;
		return 0;
	}

	cout << "Borys" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
using namespace std;
int main() {
	int N, X;
	cin >> N >> X;
	vector<int> v(N);

	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	int sum = accumulate(v.begin(), v.end(), 0);
	//cout << sum << endl;
	sort(v.begin(), v.end());
	int mn = v.front();


	cout << (X - sum) / mn + N << endl;
	//cin >> X;

	return 0;
}

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

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			List<Integer> list = new ArrayList<>();
			list.add(n);
			sc.close();
			while(true) {
			if(n%2==1) {
				n = n*3+1;
				if(list.contains(n)) {
					break;
				}
				else {
					list.add(n);
				}
			}
			else {
				n= n/2;
				if(list.contains(n)) {
					break;
				}
				else {
				list.add(n);
				}
			}
			}	
			int res = list.size()+1;
			System.out.println(res);
	}
		
	
	public static void main(String[] args) {
		solve();

	}

}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li cost[333][333];
li n;
li m;

vector<PI> edge[111];

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

    rin{
        rep(j, n) {
            cost[i][j] = INF;
        }
        cost[i][i] = 0;
    }
    rep(i, m) {
        li a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edge[a].pb({b, c});
        edge[b].pb({a, c});
        cost[a][b] = c;
        cost[b][a] = c;
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    li res = 0;

    rin{
        for (auto e : edge[i]) {
            if (cost[i][e.F] < e.S) {
                res++;
            }
        }
    }

    cout << res / 2 << endl;


    return 0;
}

Measured memory_bytes: 512
import heapq
n, m = map(int, input().split())
ab_list = [list(map(int, input().split())) for i in range(n)]
ab_list.sort()
idx = 0
q = []
ans = 0
for j in range(1, m+1):
    while idx < n:
        a, b = ab_list[idx]
        if a <= j:
            heapq.heappush(q, -b)
            idx += 1
        else:
            break
    if len(q) > 0:
        b = heapq.heappop(q)
        ans -= b
print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<int>s(N);
    for (int i = 0; i < N; ++i) {
      cin >> s[i];
    }

    ll ans = 0; // A = N-1 のとき, 下限
    // A - B = C の値で全探索
    // C < A, A + C <= N-1 より, C <= N/2 - 1
    for (int i = 1; i <= N/2 -1; ++i) {
        ll dp[(N-1)/i]; // DP[j]はCをj回やってからAでゴール
        dp[0] = 0;
        for (int j = 1; j < (N-1)/i; ++j) {
            if((N-1-i*j == i*j) || (N-1-i*j == i*(j-1))) break;
            dp[j] = dp[j-1] + s[N-1-i*j] + s[i*j];
            ans = max(ans, dp[j]);
        }
    }
    cout << ans;
    return 0;
}

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

int main(){

    int x;
    cin >> x;
    int hap = (x/500)*1000;
    x %= 500;
    hap += (x/5)*5;

    cout << hap << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int m, n, L, i, j, k;
	int a[100][100], b[100][100];

	scanf("%d%d%d", &n, &m, &L);
	for (i = 0; n > i; i++) {
		for (j = 0; m > j; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0; m > i; i++) {
		for (j = 0; L > j; j++) {
			scanf("%d", &b[i][j]);
		}
	}


	for (i = 0; n > i; i++) {
		for (j = 0; L > j; j++) {
			long long int c = 0;
			for (k = 0; m > k; k++) {
				c += a[i][k] * b[k][j];
			}
			printf("%lld", c);
			if (j != L - 1) {
				printf(" ");
			}
			else {

			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
long long int min_cost = INT_MAX;

void help(vector<long long int>& prices, vector<long long int> &currset, vector<vector<long long int>>& nums, int index, int n, int m, int x, long long int cost) {

    if(index >= prices.size()) {
        int i;
        if(currset.size() == 0)
            return;
        for(i = 0; i < currset.size(); i++){
            if(currset[i] < x)
                break;
        }
        if(i < currset.size())
            return;
        else {
            if(cost != 0)
             min_cost = min(cost,min_cost);
        }
        return;
    }
    //dont take this index
    help(prices,currset, nums,index+1,n,m,x, cost);

    //take this num
    cost+= prices[index];
    for(int i = 0; i < m; i++) {
        currset[i]+=nums[index][i];
    }
    help(prices,currset,nums,index+1,n,m,x,cost);
    for(int i = 0; i < m; i++) {
        currset[i]-=nums[index][i];
    }

}



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

    int n,m,x;
    cin>>n>>m>>x;

    vector<vector<long long int>> nums(n,vector<long long int>(m,0));
    vector<long long int> prices(n,0);
    for(int i = 0; i < n; i++){
        cin>>prices[i];
        for(int j = 0; j < m; j++) {
            cin>>nums[i][j];
        }
    }
    long long int cost = 0;
    vector<long long int> currset(m,0);
    help(prices,currset,nums,0,n,m,x,cost);
    if(min_cost == INT_MAX)
        cout<<"-1";
    else cout<<min_cost;


}

Measured memory_bytes: 3664
from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]
S = Counter(A[0::2]).most_common()
T = Counter(A[1::2]).most_common()

if S[0][0] != T[0][0]:
    ans = n - S[0][1] - T[0][1]
elif S[0][0] == T[0][0]:
    if len(S) == 1 and len(T) > 1:
        ans = n // 2 - T[0][1]
    elif len(S) > 1 and len(T) == 1:
        ans = n // 2 - S[0][1]
    elif len(S) > 1 and len(T) > 1:
        ans = min(n - S[0][1] - T[1][1], n - S[1][1] - T[0][1])
    else:
        ans = n // 2
        
print(ans)

Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(2 * n);
	for (auto &it : a) {
		cin >> it;
	}
	sort(all(a));
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2) {
		ans += a[i];
	}
	cout << ans << '\n';
}

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

int main() {
	int W,H,x,y,r;
	cin >>W>>H>>x>>y>>r;
	if(x-r<0 || x+r>W || y-r<0 || y+r>H){
		cout<<"No"<<endl;
	}else {
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 3096
# -*- coding: utf-8 -*-
n = int(raw_input())

def lucas(n):
	if n == 0:
		return 2
	elif n == 1:
		return 1

	pre_num = 2
	cur_num = 1
	for i in range(1, n):
		rtn_num = cur_num + pre_num
		pre_num = cur_num
		cur_num = rtn_num
	return rtn_num

print(lucas(n))

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

template<typename T>
class UnionFind {
public:
  vector<int> par, siz;
  vector<T> diff_weight;
    
  UnionFind(int sz_, T x) {
    init(sz_, x);
  }
  void init(int sz_, T x) {
    par.resize(sz_);
    siz.resize(sz_, 1);
    diff_weight.resize(sz_);
    rep(i, sz_) par[i] = i, diff_weight[i] = x;
  }

  int root(int x) { 
    if (par[x] == x) return x;
    else {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }

  T weight(int x) {
    root(x);
    return diff_weight[x];
  }

  bool merge(int x, int y, T w) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y), w = -w;
    siz[x] += siz[y];
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return siz[root(x)];
  }

  T diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, q;
  cin >> n >> q;
  UnionFind<int> uf(n, 0);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;

    if (c) {
      if (uf.issame(x, y)) cout << uf.diff(x, y) << '\n';
      else cout << "?\n";
    }
    else {
      int z;
      cin >> z;
      uf.merge(x, y, z);
    }
  }

  
  return 0;
}



Measured memory_bytes: 4140
from collections import deque
x, y, A, B, C = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = sorted(a)[::-1]
b = sorted(b)[::-1]
c = sorted(c)

s = 0

a = a[:x]
b = b[:y]
s += sum(a)
s += sum(b)

a = deque(a)
b = deque(b)
c = deque(c)

a_nex = a.pop()
b_nex = b.pop()
c_nex = c.pop()

while True:
#     print(s)
    if a_nex > b_nex:
        if c_nex > b_nex:
            s = s - b_nex + c_nex
            if len(b) == 0:
                b_nex = int(2e9)
            else:
                b_nex = b.pop()
            if len(c) == 0:
                break
            c_nex = c.pop()
    else:
        if c_nex > a_nex:
            s = s - a_nex + c_nex
            if len(a) == 0:
                a_nex = int(2e9)
            else:
                a_nex = a.pop()
            if len(c) == 0:
                break
            c_nex = c.pop()

    if c_nex <= a_nex and c_nex <= b_nex:
        break

print(s)

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

int main(){
    int money,cnt = 0;
    cin >> money;
    while(money >= 500){
        money -= 500;
        cnt += 1000;
    }
    while(money >= 5){
    money -= 5;
    cnt += 5;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b){
    return (a < b ? a : b);
}

int max(int a, int b){
    return (a > b ? a : b);
}

int main(){
    int k, x;
    scanf("%d%d", &k, &x);
    int lb = max(x - k + 1, -1000000);
    int rb = min(x + k - 1, 1000000);
    for(int i = lb; i <= rb; i++) printf("%d ", i);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

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

	int n = str.size();
	vec_i v(n, 0);

	int sum = 0;
	rep(i, n){
		if(str[i]=='R'){
			sum++;
		}else{
			v[i-1] += (sum+1)/2;
			v[i] += sum - (sum+1)/2;
			sum=0;
		}
	}

	rrep(i, n){
		if(str[i]=='L'){
			sum++;
		}else{
			v[i+1] += (sum+1)/2;
			v[i] += sum - (sum+1)/2;
			sum=0;
		}
	}

	rep(i,n) cout << v[i] << " ";
	cout << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long int a,b,c,ar[100009],br[10000],sum,cnt;
string s,s1;
int main()
{cin>>a;
  cin>>s>>s1;

       for(int i=0;i<s.size();i++)
       {
           cout<<s[i]<<s1[i];
       }
       return 0;
   }



Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())

    a = [input() for _ in range(n)]
    b = [input() for _ in range(m)]

    for i in range(n - m + 1):
        j = a[i].find(b[0])
        while j != -1:
            if judge(a, b, m, i, j):
                print('Yes')
                return
            j = a[i].find(b[0], j + 1)
    print('No')

def judge(a, b, m, i, j):
    for k in range(m):
        if a[i + k][j:j+m] != b[k]:
            return False
    return True

main()


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
#define N 1000000

bool prime[N+1];

int main()
{
    for(int i = 0; i < N+1; i++){
        prime[i] = true;
    }
    prime[0] = prime[1] = false;
    for (int i = 2; i <= sqrt(N); i++) {
        if (prime[i]) {
            for (int j = 2; j * i <= N; j++) {
                prime[i*j] = false;
            }
        }
    }
    int a, d, n;
    while (true) {
        cin >> a >> d >> n;
        if (a == 0 && d == 0) {
            break;
        }
        int cnt = 0;
        int i = 0;
        while (true) {
            if (prime[a + d * i]) {
                cnt++;
            }
            if (cnt == n) {
                cout << a + d * i << endl;
                break;
            }
            i++;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 2140
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int N[4],sum=0,mul=1,check=1;

int main(){
    rep(i,4){
        cin>>N[i];
        sum+=N[i];
        mul*=N[i];
        if(N[i]==2)check=0; 
    }
    if(sum==21 && mul==252 &&check){
        out("YES");
    }
    else{
        out("NO");
    }
}


Measured memory_bytes: 256
// 2017/12/13 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		char c[100];
		for(int i=0; i<n; i++){
			cin >> c[i];
		}

		int cnt[26] = {0};		// ?\¨??°???A???Z???0???25????????????

		for(int i=0; i<n; i++){
			cnt[(int)(c[i]-'A')]++;

			int max1 = -1;			// 1???????\¨??°
			int max2 = -1;			// 2???????\¨??°

			for(int j=0; j<26; j++){
				if(cnt[j]>max1){
					max2 = max1;
					max1 = cnt[j];
				}
				else if(cnt[j]>max2){
					max2 = cnt[j];
				}
			}

			if(max1-max2>n-(i+1)){		// 1?????¨2???????????????????\¨??°
				for(int j=0; j<26; j++){
					if(cnt[j]==max1){
						cout << (char)(j+'A') << ' ';
						break;
					}
				}
				cout << (i+1) << endl;
				break;
			}

			if(i==n-1){			// ???????????§????\¨??????
				cout << "TIE" << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3080
#! /usr/bin/env python3
import itertools
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def solve(N: int, P: "List[int]", Q: "List[int]"):
    X = list(range(1,N+1))
    R = []
    for r in itertools.permutations(X,N):
        R.append(int("".join(list(map(str,r)))))
        
    R.sort() 
    P = int("".join(P))
    Q = int("".join(Q))
    a,b = 0,0
    for i,r in enumerate(R):
        if r == P:
            a = i
        if r == Q:
            b = i

    print(abs(a-b))
    


    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [str(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [str(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)



if __name__ == "__main__":
    main()


Measured memory_bytes: 74792
#include<iostream>
#include<cmath>
#include<algorithm>
typedef long long ll;
using namespace std;
int main() {
	int h, n;
	cin >> h >> n;
	int sum = 0;
	while (n--) {
		int x;
		cin >> x;
		sum += x;



	}
	if (sum >= h) cout << "Yes";
	else cout << "No";

	return 0;

} 

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

    int N;
    std::cin >> N;
    if(N == 1) {
        std::cout << "Hello World" << std::endl;
    }
    else {
        int A, B;
        std::cin >> A >> B;
        std::cout << A + B << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
aList = {}
bList = {}
result = 0

i = 1
while result == 0:
    aList[a * i] = 0
    bList[b * i] = 0
    if (b * i) in aList:
        result = b * i
    elif (a * i) in bList:
        result = a * i
    i += 1
print(result)

Measured memory_bytes: 59120
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int height = sc.nextInt();
		int width = sc.nextInt();
		
		char[][] board = new char[height][width];
		
		for (int i = 0; i < height; i++) {
			String sCurr = sc.next();
			for (int j = 0; j < width; j++) {
				board[i][j] = sCurr.charAt(j);
			}
		}
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (!(board[i][j] == '#')) {
					boolean iLess = false;
					boolean iMore = false;
					boolean jLess = false;
					boolean jMore = false;
					int tempVal = 0;
					if (i - 1 >= 0) {
						iLess = true;
					} 
					if (i + 1 < board.length) {
						iMore = true;
					}
					if (j - 1 >= 0) {
						jLess = true;
					}
					if (j + 1 < board[0].length) {
						jMore = true;
					}
					if (iLess) {
						if (board[i - 1][j] == '#') {
							tempVal++;
						}
					}
					if (iMore) {
						if (board[i + 1][j] == '#') {
							tempVal++;
						}
					}
					if (jLess) {
						if (board[i][j - 1] == '#') {
							tempVal++;
						}
					}
					if (jMore) {
						if (board[i][j + 1] == '#') {
							tempVal++;
						}
					}
					if (iLess && jLess) {
						if (board[i - 1][j - 1] == '#') {
							tempVal++;
						}
					}
					if (iLess && jMore) {
						if (board[i - 1][j + 1] == '#') {
							tempVal++;
						}
					}
					if (iMore && jLess) {
						if (board[i + 1][j - 1] == '#') {
							tempVal++;
						}
					}
					if (iMore && jMore) {
						if (board[i + 1][j + 1] == '#') {
							tempVal++;
						}
					}
					board[i][j] = Integer.toString(tempVal).charAt(0);
				}
			}
		}
		for (int i = 0; i < height; i++) {
			String printString = "";
			for (int j = 0; j < width; j++) {
				printString += board[i][j];
			}
			System.out.println(printString);
		}
	}
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;
int abs(int s, int t){
    if(s-t < 0) return -(s - t);
    else return s - t;
}

int main(){
    int A,B;
    cin >> A >> B;
    bool res = false;
    for(int i = min(A,B); i <= max(A,B); i++){
        if(abs(A,i) == abs(B,i)){
            cout << i << endl;
            res = true;
        }
    }
    if(res == false){
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    vector<int> a(n);
    int c2 = 0;
    int c4 = 0;
    rep(i, 0, n) {
        cin >> a[i];
        if (a[i] % 4 == 0) {
            c4++;
        } else if (a[i] % 2 == 0) {
            c2++;
        }
    }
    if (c2 > 1) {
        n -= c2 - 1;
    }
    if (c4 + 1 >= n - c4) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 640