akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

int N; cin >> N;
vi a(N); rep(i,N) cin >> a[i];

vi x(N+1);
set<int> st;
for(int i = N; i >= 1; --i) {
    int cur = a[i-1];
    for(int j = i * 2; j <= N; j = j + i) {
        cur += x[j];
    }
    x[i] = cur % 2;
    if(x[i] == 1) st.insert(i);
}

cout << SZ(st) << endl;
for(auto x : st) cout << x << endl;

return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define cin_fit() cin.tie(nullptr);ios::sync_with_stdio(false)
#define rep(i, N) for(int i=0; i<(N); i++)
#define reps(i, N) for(int i=1; i<=(N); i++)
#define rrep(i, N) for(int i=(int)(N)-1; i>=0; i--)
#define rreps(i, N) for(int i=(int)(N); i>=1; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using V = vector<ll>;
using P = pair<ll, ll>;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
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;}

ll n, m;
ll a[100010];
ll ans[100010];

int main() {
    cin_fit();
    cin >> n >> m;
    rep(i, m) {
        ll t; cin >> t;
        a[t] = 1;
    } 
    ans[0] = 1;
    rep(i, n-1) {
        if(a[i] == 0) {
            ans[i+1] = (ans[i] + ans[i+1]) % mod;
            ans[i+2] = (ans[i] + ans[i+2]) % mod;
        }
    }
    if(a[n-1] == 0) ans[n] = (ans[n] + ans[n-1]) % mod;
    cout << ans[n] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    ll a,b;
    cin >> a >> b;
    COUT(lcm(a, b));
}


Measured memory_bytes: 3608
d,g = map(int,input().split())

p = []

for i in range(d):
    p.append(list(map(int,input().split())))

from itertools import product
from math import ceil

ans = 1e09

for c in product([0,1],repeat=d):
    score = 0
    num = 0
    ind = 0
    for i in range(d):
        if c[i] == 1:
            score += p[i][0]*100*(i+1) + p[i][1]
            num += p[i][0]
        else:
            ind = max(i,ind)
    
    if g - score <= 0:
        ans = min(ans,num)
    elif g - score <= (p[ind][0]-1)*100*(ind+1):
        num += ceil((g-score)/(100*(ind+1)))
        ans = min(ans,num)
print(ans)

Measured memory_bytes: 40560
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

upper_list = [0] * (N + 1)
upper_list[0] = N
lower_list = [0] * (N + 1)
lower_list[0] = 0
ans_list = [0] * (N + 1)


for i in range(1, N + 1):
    lower_list[i] = lower_list[i - 1] + i
    upper_list[i] = upper_list[i - 1] + (N - i)

for i in range(N + 1):
    ans_list[i] = (upper_list[i] - lower_list[i] + 1) % MOD

ans = print(sum(ans_list[K - 1:]) % MOD)


Measured memory_bytes: 39636
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	x_str := stdin.Text()

	x, _ := strconv.Atoi(x_str)
	var ans int = x * x * x

	fmt.Println(ans)
}



Measured memory_bytes: 1080
N, W = map(int, input().split())

W1,V1 = map(int, input().split())

P = {W1:[V1], W1+1:[], W1+2:[], W1+3:[]}

for i in range(1,N):
  w,v = map(int, input().split())
  P[w].append(v)

PS={}
for k,v in P.items():
  v.sort(reverse=True)
  S = [0] * (len(v)+1)
  for i in range(len(v)):
    S[i+1] = S[i] + v[i]
  PS[k] = S
  
#print(P)
#print(PS)
A,B,C,D = len(PS[W1]), len(PS[W1+1]), len(PS[W1+2]), len(PS[W1+3])
ans = 0
for a in range(A):
  for b in range(B):
    for c in range(C):
      for d in range(D):
        if a*W1 + b*(W1+1) + c*(W1+2) + d*(W1+3) > W:
          continue
        ans = max(ans, PS[W1][a] + PS[W1+1][b] + PS[W1+2][c] + PS[W1+3][d])
        
print(ans)

Measured memory_bytes: 9136
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, n, m, can;
	cin >> n >> m;
	vector<vector<int>> adj(n);
	for (i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}
	{
		queue<int> bfs;
		vector<bool> flag(n, false);
		vector<int> dist(n);
		bfs.push(0);
		flag[0] = true;
		dist[0] = 0;
		while (!bfs.empty()){
			int current = bfs.front();
			bfs.pop();
			for (int next : adj[current]){
				if (flag[next] == false){
					bfs.push(next);
					flag[next] = true;
					dist[next] = dist[current] + 1;
				}
			}
		}
		if (flag[n - 1] == true && dist[n - 1] <= 2) can = true;
		else can = false;
	}
	if (can == false) cout << "IMPOSSIBLE" << endl;
	else cout << "POSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 13168
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(N):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1
print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		if((a|b|c|d|e|f)==0) break;
			int sum = 100;
		
			//-3*a : ゲーム開始用のコイン
			//15*a : 777そろって手に入るコイン
			//a*5*13 : ボーナスゲーム中のブドウで, 2枚入れて15枚返ってくるやつ
			sum += -3 * a + 15 * a + a * 5 * 13;
			f -= a + 5 * a;

			//-3*b : ゲーム開始用のコイン
			//15*b : BARBARBARそろって手に入るコイン
			//b*3*13 : ボーナスゲーム中のブドウで, 2枚入れて15枚返ってくるやつ
			sum += -3 * b + 15 * b + b * 3 * 13;
			f -= b + 3 * b;

			//-3*c : ゲーム開始用のコイン
			//7*c : ブドウがそろって手に入るコイン
			sum += -3 * c + 7 * c;
			f -= c;

			//-d : ゲーム開始に3枚入れて, チェリーの場合2枚返ってくる
			sum -= d;
			f -= d;

			//e*3 : ゲーム開始時のコイン
			sum -= e * 3;
			f -= e * 2;

			//3*f : 残りゲーム回数で3枚ずつ投入してそろわなかった
			sum -= 3 * f;
			
			System.out.println(sum);
		}
		}

}

Measured memory_bytes: 20816
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll r[64];
char s[205];
ll a[205];
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> a[i];
		scanf("%s", s + 1);
		int fl = 0;
		memset(r, 0, sizeof(r));
		for (int i = n; i >= 1; i--) {
			ll x = a[i];
			for (int j = 62; j >= 0; j--) {
				ll tr = (1ll << j);
				if (x & tr) {
					if (r[j]) x ^= r[j];
					else {
						if (s[i] == '1') fl = 1;
						else r[j] = x;
						
						break;
					}
				}
			}
		}
		if (fl) cout << 1 << endl;
		else cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 200005
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, m, ans = 2e9, s, t;
vector<int> vec[SIZE];
bool vis[SIZE][3];
int dis[SIZE][3];
void bfs(int s, int t) {
	queue<pair<int, int> > q;
	q.push(mp(s, 0));
	rep(i, 0, 200000) rep(j, 0, 2) dis[i][j] = 2e9;
	vis[s][0] = true;
	while (!q.empty()) {
		pair<int, int> top = q.front();
		q.pop();
		for (auto it : vec[top.first]) {
			int dep = top.second + 1;
			if (vis[it][dep % 3]) continue;
			else {
				q.push(mp(it, dep));
				dis[it][dep % 3] = min(dis[it][dep % 3], dep);
				vis[it][dep % 3] = true;
			}
		}
	}
	ans = min(ans, dis[t][0]);
}

int main() {
	io(); cin >> n >> m;
	rep(i, 1, m) {
		int x, y;
		cin >> x >> y;
		vec[x].emplace_back(y);
	}
	cin >> s >> t;
	bfs(s, t);
	cout << (ans >= 2e9 ? -1 : ans / 3);
}

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

using namespace std;

int ans;
int main(){
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < s.length(); i++){
		if((s[i] + n) > 90){
			int temp = (90 - s[i]) + 1;
			int sum = n - temp;
			s[i] = 'A';
			s[i] = s[i] + sum;	
		} else s[i] = s[i] + n;
	}
	cout << s ;	
}

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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define E "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const int MAX = 1e18;

#define N 5010

int sum(int x){
    int s=0;
    while(x>0){
        s+=x%10;
        x/=10;
    }
    return s;
}

void solve()
{
    int n,m=0;
    cin>>n;
    int c=0,b,d=0;
    while(n>0){
        c++;
        b=n%10;
        if (b==9) d++;
        n/=10;
    }
    if (d>=c-1){
        if (b!=9||(b==9&&d==c)){
            cout<<b+9*(c-1);
        }
        else {
        cout<<b-1+9*(c-1);
    }
    }
    else {
        cout<<b-1+9*(c-1);
    }

}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 3564
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if((a==b)&&(b==c)){
            System.out.println("1");
        }else if((a!=b)&&(a!=c)&&(b!=c)){
            System.out.println("3");
        }else{System.out.println("2");}

}
        
        
    }


Measured memory_bytes: 21204
N = int(input())
A = list(map(int, input().split()))

#例外処理
if A[0] == 1:
  if N == 0:
    print("1")
  else:
    print("-1")
  quit()
elif A[0] > 1:
  print("-1")
  quit()
  
answer = 0
ans = [0] * (N + 1)
ans2 = [0] * (N + 1)
now = 1
ans[0] = 1
ans2[N] = A[-1]

for i in range(N):
  if now >= A[i]:
    now = 2 * (now - A[i])
    ans[i + 1] += now
  else:
    print("-1")
    quit()

if now < A[-1]:
  print("-1")
  quit()
  
for i in range(1, N + 1):
  ans2[N - i] = ans2[N - i + 1] + A[N - i]

for i in range(N + 1):
  answer += min(ans[i], ans2[i])
  
#print(ans)
#print(ans2)
print(answer)

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

const int _ = 2e5 + 7;
int fa[_] , N , S[_] , T[_];
set < int > node[_]; map < pair < int , int > , int > ext;
queue < pair < int , int > > q;
void del(int x){node[S[x]].erase(x); node[T[x]].erase(x);}
void add(int x){
	if(S[x] > T[x]) swap(S[x] , T[x]);
	pair < int , int > t(S[x] , T[x]);
	if(ext.find(t) == ext.end()) ext[t] = x;
	else{del(x); auto p = ext.find(t); del(p->second); q.push(t); ext.erase(p);}
}

int find(int x){return fa[x] == x ? x : (fa[x] = find(fa[x]));}
void merge(int p , int q){
	p = find(p); q = find(q); if(node[p].size() < node[q].size()) swap(p , q);
	fa[q] = p;
	for(auto t : node[q]){
		ext.erase(make_pair(S[t] , T[t]));
		node[p].insert(t); (S[t] == q ? S[t] : T[t]) = p; add(t);
	}
}

int main(){
	cin >> N; for(int i = 1 ; i <= N ; ++i) fa[i] = i;
	for(int i = 1 ; i <= 2 * N - 2 ; ++i){int A , B; cin >> A >> B; node[A].insert(i); node[B].insert(i); S[i] = A; T[i] = B;}
	for(int i = 1 ; i <= 2 * N - 2 ; ++i) add(i);
	
	while(!q.empty()){int x = q.front().first , y = q.front().second; q.pop(); merge(x , y);}
	cout << (ext.empty() ? "YES" : "NO");
	return 0;
}


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

int main() {
  int N, M;
  cin >> N;
  map<string, int> score;
  for (int i = 0; i < N; i++) {
    string key;
    cin >> key;
    if (score.count(key)) score[key]++;
    else score[key] = 1;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    string key;
    cin >> key;
    if (score.count(key)) score[key]--;
    else score[key] = -1;
  }
  int ans = 0;
  for (pair<string, int> p : score) {
    int v = p.second;
    ans = max(ans, v);
  }
  cout << ans << endl;
}

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


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


ans = 0
for _, j in p(n):
    i = 1
    while j >= i:
        j -= i
        i += 1
        ans += 1
print(ans)


Measured memory_bytes: 9200
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int lis(int N,vint a){
	vint L;
	rep(i,N){
		if(i!=0){
			if(L.back()<a[i]){
				L.push_back(a[i]);
			}
			else{
				L.at(lower_bound(L.begin(),L.end(),a[i])-L.begin())=a[i];
			}
		}
		else{
			L.push_back(a[i]);
		}
	}
	return L.size();
}
int lds(int N,vint a){
	rep(i,N){
		a[i]=-a[i];
	}
	vint L;
	rep(i,N){
		if(i!=0){
			if(L.back()<a[i]){
				L.push_back(a[i]);
			}
			else{
				L.at(lower_bound(L.begin(),L.end(),a[i])-L.begin())=a[i];
			}
		}
		else{
			L.push_back(a[i]);
		}
	}
	return L.size();
}
int main(){
	int N;
	vint retu;
	int A,B;
	scan(N);scan(A);scan(B);
	if(N/A+(N%A!=0)<=B&&B<=N-A+1){
		if(min(A,B)==1){
			if(A+B==N) retu.push_back(-1);
			else{
				if(A==1){
					rep(i,N) retu.push_back(N-i);
				}
				else{
					rep1(i,N) retu.push_back(i);
				}
			}
		}
		else{
			for(int i=N-A+1;i<=N;i++){
				retu.push_back(i);
			}
			int husayouso=(N-A)/(B-1);
			int amarihusa=(N-A)%(B-1);
			int initialnum=N-A+1;
			for(int husa=1;husa<=B-1;husa++){
				int husanum;
				if(husa<=amarihusa) husanum=husayouso+1;
				else husanum=husayouso;
				initialnum-=husanum;
				for(int tama=initialnum;tama<initialnum+husanum;tama++){
					retu.push_back(tama);
				}
			}
		}
	}
	else{
		retu.push_back(-1);
	}
	rep(i,retu.size()){
		printf("%d ",retu[i]);
	}
	kaigyo;
	//if(retu.size()==N) printf("lis:%d lds:%d\n",lis(N,retu),lds(N,retu));
	return 0;
}


Measured memory_bytes: 3440
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String str = sc.next();
        int count = 0;
        for (char c : str.toCharArray()) {
            count = count + Character.getNumericValue(c);
        }
        if (Integer.valueOf(str) % count == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

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

    for(int bit = 0; bit < (1<<3); bit++){
        int res = s[0]-'0';
        for(int i = 0; i < 3; i++){
            res += ((bit>>i) & 1 ? +1: -1) * (s[i+1] -'0');
        }

        if(res == 7){
            cout << s[0];
            for(int i = 0; i < 3; i++){
                cout << (bit & (1<<i)?"+":"-") << s[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }
        
    }

}

Measured memory_bytes: 256
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint
import itertools
import fractions

N = int(input())
AB = []
for _i in range(N):
    AB.append([ int(x) for x in input().split() ])
AB = sorted(AB, key=lambda x:x[1])

fail = False
now = 0
for ab in AB:
    a = ab[0]
    b = ab[1]
    now += a
    if now > b:
        fail = True
        break

if fail:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 53108
#include<stdio.h>

int main(){
  long i,j,h,w,smax,smin,s[3],hh,hw,min=20000000000;
  scanf("%ld %ld",&h,&w);
  hh=h/2;
  for(i=1;i<=hh;i++){
    smin=smax=i*w;
    if(smin>(h-i)*(w/2))
      smin=(h-i)*(w/2);
    if(smax<(h-i)*(w-w/2))
      smax=(h-i)*(w-w/2);
    if(smax-smin<min)
      min=smax-smin;
    smin=smax=i*w;
    if(smin>(h-i)/2*w)
      smin=(h-i)/2*w;
    if(smax<((h-i)-((h-i)/2))*w)
      smax=((h-i)-((h-i)/2))*w;
    if(smax-smin<min)
      min=smax-smin;
  }
  hw=w/2;
  for(i=1;i<=hw;i++){
    smin=smax=i*h;
    if(smin>(w-i)*(h/2))
      smin=(w-i)*(h/2);
    if(smax<(w-i)*(h-h/2))
      smax=(w-i)*(h-h/2);
    if(smax-smin<min)
      min=smax-smin;
    smin=smax=i*h;
    if(smin>(w-i)/2*h)
      smin=(w-i)/2*h;
    if(smax<((w-i)-((w-i)/2))*h)
      smax=((w-i)-((w-i)/2))*h;
    if(smax-smin<min)
      min=smax-smin;
  }
  printf("%ld\n",min);
}

Measured memory_bytes: 128
N=int(input())
d_pre=input().split()
d=[int(s) for s in d_pre]
ans=0
for i in range(N-2):
    for j in range(i,N-1):
        for k in range(j,N):
            if (d[i]+d[j]>d[k]) and (d[i]+d[k]>d[j]) and (d[k]+d[j]>d[i]) and d[i]!=d[k] and d[i]!=d[j] and d[k]!=d[j]:
                ans+=1
print(ans)

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

int main() {
	int S,h,m,s;
	
	cin >> S;
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1164
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [s] <- readStrings
  print . showAnswer $ solve s

type Input  = (String)
type Output = Int

solve :: Input -> Output
solve = foldl f 0
  where
    f acc '+' = succ acc
    f acc '-' = pred acc

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readStrings :: IO [String]
readStrings = map C8.unpack . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        // int result = b * 2
        if (b * 2 < a) {
            System.out.println(a - b * 2);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 23764
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    l, r = map(int, input().split())
    if r - l >= 2019:
        print(0)
    else:
        mods = []
        for i in range(l, r + 1):
            mods.append(i % 2019)
        ans = float('inf')
        for i in range(len(mods) - 1):
            for j in range(i + 1, len(mods)):
                tmp = (mods[i] * mods[j]) % 2019
                if tmp < ans:
                    ans = tmp
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

using namespace std;

int main(void){

    string s;
    cin >> s;

    int start_index = 0;
    int end_index = 0;
    
    for(int i=0; i<s.size(); i++) {
        if(s.substr(i,1) == "A") {
            start_index = i;
            break;
        }
    }
    
    for(int i=s.size()-1; i>=0; i--) {
        if(s.substr(i,1) == "Z") {
            end_index = i;
            break;
        }
    }

    cout << end_index - start_index + 1 << endl;

    return 0;
    
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    map <int,int> m;
    vector <int> dp(n);
    for(int i=0;i<n;i++)
    {
        if(v[i]==1)
            dp[i]=1;
        else
        {
            if(m.find(v[i]-1)!=m.end()&&dp[m[v[i]-1]]!=0)
                dp[i]=dp[m[v[i]-1]]+1;
            else
                dp[i]=0;
        }
        m[v[i]]=i;
    }
    int max=0;
    for(int i=0;i<n;i++)
        if(dp[i]>max)
            max=dp[i];
    if(max==0)
        cout<<"-1\n";
    else
        cout<<n-max<<endl;
    

    return 0;   
}


 
 


Measured memory_bytes: 11264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <inttypes.h>

int main(void){
	char s[20]={'\0'},t[21]={'\0'};
	int slen;

	scanf("%s\n",s);
	scanf("%s",t);
	slen=strlen(s);
	if(strncmp(s,t,slen)==0){
		printf("Yes");
	}else{
		printf("No");
	}

	return 0;
}


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

int main(){
	int n,x;
	while(1){
		int N=0;
		cin >> n >> x;
		if(n==0 && x==0)break;
		for(int j=1;n-2>=j;j++){
			for(int k=j+1;n-1>=k;k++){
				for(int l=k+1;n>=l;l++){
					if(j+k+l==x)++N;

				}
			}
		}
		cout << N << endl;
	}
}

Measured memory_bytes: 3092
#include <stdio.h>
int main(void) {
    int house[4][3][10]={{{0}}},num,i,j,k,b,f,r,v;
    scanf("%d",&num);
    for (i=0; i<num; i++) {
        scanf("%d %d %d %d",&b,&f,&r,&v);
        house[b-1][f-1][r-1]+=v;
    }
    for (i=0; i<4; i++) {
        for (j=0; j<3; j++) {
            for (k=0; k<10; k++) printf(" %d",house[i][j][k]);
            printf("\n");
        }
        if (i!=3) {
            for (j=0; j<20; j++) printf("#");
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 600
n, m, x = gets.split(" ").map(&:to_i)
arr = gets.split(" ").map(&:to_i)
cost = 0
arr.each_with_index do |a, i|
  if arr[i] < x && x < arr[i+1]
    cost += [i+1, arr.size-(i+1)].min
    break
  end
end
puts cost


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

int Walk(int, int, int, int, int);

int map[20][20];

int main()
{
	char input[21];
	int i, j, ans, w, h, sH, sW;
	
	while(1)
	{
		sH = sW = 0;
		
		scanf("%d %d", &w, &h);
		
		if(w == 0 && h == 0) break;
		
		for(i = 0; i < h; i++)
		{
			scanf(" %s", input);
			
			for(j = 0; j < w; j++)
			{
				if(input[j] == '.')
				{
					map[i][j] = 1;
				} else if(input[j] == '#') {
					map[i][j] = 0;
				} else {
					map[i][j] = 1;
					sH = i;
					sW = j;
				}
			}
		}
		
		ans = Walk(0, sH, sW, h, w);
		
		printf("%d\n", ans);
	}
	
	return 0;
}

int Walk(int count, int h, int w, int maxH, int maxW)
{
	int i, j, ans, dh, dw, ch, cw;
	
	map[h][w] |= 2;
	ans = count + 1;
	
	for(i = 0; i < 4; i++)
	{
		dw = cos(90 * i * M_PI / 180);
		dh = sin(90 * i * M_PI / 180);
		
		ch = h + dh;
		cw = w + dw;
		
		if(ch > -1 && ch < maxH && cw > -1 && cw < maxW && (map[ch][cw] & 3) == 1)
		{
			ans = Walk(ans ,ch, cw, maxH, maxW);
		}
	}
	
	return ans;
}

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

constexpr int MAX_LENGTH = 401;
constexpr char INF = '~';
class edge{
public:
	string cost;
	size_t from, to;
	edge(string c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
using edges = vector<edge>;
using graph = vector<edges>;
bool operator<(const edge &e, const edge &f){
	return e.cost != f.cost ? e.cost > f.cost : e.from != f.from ? e.from < f.from : e.to < f.to;
}

string solve(int n, int a, int s, int g){
	graph gr(n * MAX_LENGTH);
	for(int i=0; i<a; ++i){
		int x, y;
		string st;
		cin >> x >> y >> st;
		for(size_t j=0; j+st.size()<MAX_LENGTH; ++j)
			gr[x * MAX_LENGTH + j].push_back(edge(st, x * MAX_LENGTH + j, y * MAX_LENGTH + j + st.size()));
	}
	vector<string> dist(n * MAX_LENGTH);
	for(int i=0; i<n; ++i)
		for(int j=0; j<MAX_LENGTH; ++j)
			dist[i * MAX_LENGTH + j] = string(j, INF);
	priority_queue<edge> pq;
	pq.push(edge("", s * MAX_LENGTH, s * MAX_LENGTH));
	while(!pq.empty()){
		edge e = pq.top(); pq.pop();
//		cout << e.cost << " " << e.to << "\n";
		for(edge f:gr[e.to]){
			if(e.cost + f.cost < dist[f.to]){
				dist[f.to] = e.cost + f.cost;
				pq.push(edge(dist[f.to], s * MAX_LENGTH, f.to));
			}
		}
	}
	string ans(MAX_LENGTH, INF);
	for(int i=1; i<MAX_LENGTH; ++i)
		ans = min(ans, dist[g * MAX_LENGTH + i]);
//	for(int i=1; i<10; ++i)
//		cout << dist[g * MAX_LENGTH + i] << "\n";
	if(ans.size() > 240 || ans == "~") return "NO";
	return ans;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		int n, a, s, g; cin >> n >> a >> s >> g;
		if(n == 0) break;
		cout << solve(n, a, s, g) << "\n";
	}
}


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

const int MAX = 200005;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  int n,k;
  cin>>n>>k;
  ll ans=0;
  for(int i=0; i<=min(k,n-1); i++){
    ans=(ans+(COM(n,i)*COM(i+(n-i-1),i))%MOD)%MOD;
  }
  cout<<ans<<endl;
  return 0;
}



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

long long l[100];
string s;

int main() {
    cin >> s;
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    for (int i = -1; i <= 1; i += 2) {
        for (int j = -1; j <= 1; j += 2) for (int k = -1; k <= 1; k += 2) {
            int s = a + i * b + j * c + k * d;
            if (s == 7) {
                char aa = (i == -1 ? '-' : '+');
                char bb = (j == -1 ? '-' : '+');
                char cc = (k == -1 ? '-' : '+');
                cout << a << aa << b << bb << c << cc << d << "=7" << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    t1: i64,
    t2: i64,
    a: [i64; 2],
    b: [i64; 2],
  }
  if t1 * a[0] + t2 * a[1] == t1 * b[0] + t2 * b[1] {
    puts!("infinity\n");
    return;
  }
  let mut d1 = t1 * (b[0] - a[0]);
  let mut d2 = t2 * (b[1] - a[1]);
  if d1 < 0 {
    d1 = -d1;
    d2 = -d2;
  }
  if d1 + d2 > 0 {
    puts!("0\n");
    return;
  }
  let p = - (d1 + d2);
  let mut ans = (d1 / p) * 2;
  if d1 % p != 0 {
    ans += 1;
  }
  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <iostream>
 
using namespace std;
#define ll long long
 
int main(){
  ll a, b;
  cin >> a >> b;
  ll ans(0); 
  ll k, cnt(0);
  while(a--){
  	cin >> k; if(ans <= b) cnt++;
    ans+=k;
  }
  if(ans <= b) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
bool cmp(int val1,int val2){
	return val1>val2;
}
int main(){
	int n; cin>>n; getchar();
	set<string>Color;
	string s;
	for(int i=0;i<n;i++){
		 cin>>s;
		 Color.insert(s);
	}

	printf("%s\n", Color.size()==3 ? "Three" : "Four");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
struct UnionFind {
    vector<int> u;
    UnionFind(int n): u(n+5, -1) {}
    int  size(int i)        { return (-u[root(i)]); }
    int  root(int x)        { return (u[x] < 0)? x : u[x] = root(u[x]); }
    bool same(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
};

// }}}

struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

int N, M;
vector<int> G[100010];

signed main()
{
    cin >> N >> M;

    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    deque<int> path;
    UnionFind uf(N);
    path.push_back(1);
    path.push_back(G[1][0]);
    uf.unite(path.front(), path.back());


    while(true) {
        int s = path.front();
        bool ok = true;
        for (int u : G[s]) {
            if (!uf.same(u, s)) {
                path.push_front(u);
                uf.unite(u, s);
                ok = false;
                break;
            }
        }
        if (ok) break;
    }
    while(true) {
        int s = path.back();
        bool ok = true;
        for (int u : G[s]) {
            if (!uf.same(u, s)) {
                path.push_back(u);
                uf.unite(u, s);
                ok = false;
                break;
            }
        }
        if (ok) break;
    }

    int L = path.size();
    cout << L << endl;
    for (int i = 0; i < L; ++i) {
        cout << path[i] << (i+1 < L ? ' ' : '\n');
    }

    return 0;
}


Measured memory_bytes: 7168
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            var result = new DateTime();
            IFormatProvider formatProvider = null;

            var isYymm = DateTime.TryParseExact(S, "yyMM", formatProvider, System.Globalization.DateTimeStyles.None, out result);
            var isMmyy = DateTime.TryParseExact(S, "MMyy", formatProvider, System.Globalization.DateTimeStyles.None, out result);

            if (isYymm && isMmyy)
            {
                WriteAMBIGUOUS();
                return;
            }

            if (isYymm && !isMmyy)
            {
                WriteYYMM();
                return;
            }

            if (!isYymm && isMmyy)
            {
                WriteMMYY();
                return;
            }
            WriteNA();
            return;
        }


        private static void WriteAMBIGUOUS()
        {
            Console.WriteLine("AMBIGUOUS");
        }

        private static void WriteYYMM()
        {
            Console.WriteLine("YYMM");
        }

        private static void WriteMMYY()
        {
            Console.WriteLine("MMYY");
        }

        private static void WriteNA()
        {
            Console.WriteLine("NA");
        }
    }
}


Measured memory_bytes: 13664
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans = "Left";
    if(a+b < c+d){
        ans = "Right";
    }else if(a+b == c+d){
        ans = "Balanced";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    ll w,h;cin>>w>>h;
    ll a[w];rep(i,0,w-1)cin>>a[i];
    ll b[h];rep(i,0,h-1)cin>>b[i];
    
    int aa=h,bb=w;
    priority_queue<l_l,vector<l_l>,greater<l_l>>q;
    rep(i,0,w-1)q.push(l_l(a[i],1));
    rep(i,0,h-1)q.push(l_l(b[i],2));
    ll res=w*h;
    ll ans=0;rep(i,0,w-1)ans+=a[i];rep(i,0,h-1)ans+=b[i];
    while(res>0){
        l_l t=q.top();q.pop();
        if(t.second==1){
            if(res-aa>=0){
                res-=aa;
                ans+=t.first*aa;
                bb--;
            }else{
                ans+=t.first*res;
                res=0;
            }
        }else{
            if(res-bb>=0){
                res-=bb;
                ans+=t.first*bb;
                aa--;
            }else{
                ans+=t.first*res;
                res=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  vector<int> X,Y;
  rep(i,n){
    long long x;
    cin>>x;
    X.push_back(x);
    Y.push_back(x);
  }
  sort(X.begin(),X.end());
  long long ml=X[n/2-1],mr=X[n/2];
  //cout<<ml<<" "<<mr<<endl;
  rep(i,n){
    if(Y[i]<=ml) cout<<mr<<endl;
    else if(Y[i]>=mr) cout<<ml<<endl;
  }
  return 0;
}

Measured memory_bytes: 3948
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]
dp = [[0,0,0] for _ in range(N+1)]

for i in range(1,N+1):
  dp[i][0] = max(dp[i-1][1] + abc[i-1][0], dp[i-1][2] + abc[i-1][0])
  dp[i][1] = max(dp[i-1][0] + abc[i-1][1], dp[i-1][2] + abc[i-1][1])
  dp[i][2] = max(dp[i-1][0] + abc[i-1][2], dp[i-1][1] + abc[i-1][2])

print(max(dp[N]))

Measured memory_bytes: 47348
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;


int main(){
  string S;
  bool ans=true;
  cin >>  S;
  int a=S.size();
  for(int i=0;i<a;i++){
    if(i%2==0){
      if(S[i]=='L'){
        ans=false;
      }
    }
    if(i%2==1){
      if(S[i]=='R'){
        ans=false;
      }
    }
  }
  if(ans==true){
    cout << "Yes" << endl;
  }
  if(ans==false){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back

typedef long long int ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie();
	
	vector<char> v;
	string s;
	cin >> s;
	for (ll i = 0; i < s.length(); i++) {
		if (s[i] != 'B')
			v.pb(s[i]);
		else {
			if (v.size() != 0) {
				v.pop_back();
			}
		}
	}
	for (auto x : v) {
		cout << x;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// const ll mod = 998244353ll;
const ll mod = 2000000011;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, l, r;
ll x[500005], y[500005], z[500005];
string s;

void solve(){
    ll ans = 0;
    cin >> n;
    for(ll i=1;i<=n;i++){
        if(i % 3 != 0 && i % 5 != 0)ans += i;
    }
    p(ans);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;

    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;

}
















Measured memory_bytes: 3660
#include<stdio.h>
int main()
{

    int n,a,b,c;
    scanf("%d",&n);

    if(n==1)
    {
        printf("Hello World\n");

    }
    else if(n==2)
    {
        scanf("%d%d",&a,&b);
        c=a+b;
        printf("%d\n",c);
    }



}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<P, int> PI; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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


int main(void)
{
	int h, w;
	ios::sync_with_stdio(false);
	while(cin >> h >> w && h)
	{
		SArray table(h);
		readAll(table);

		int ans = 0;
		char now = ' ';
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if(table[i][j] == '.') continue;
				ans++;
				queue<P> que;
				que.push(P(i, j));
				now = table[i][j];
				while (!que.empty())
				{
					P p = que.front(); que.pop();
					if(table[p.first][p.second] != now) continue;
					table[p.first][p.second] = '.';
					for (int k = 0; k < 4; k++)
					{
						int nr = dr[k] + p.first, nc = dc[k] + p.second;
						if(!inRange(h, nr) || !inRange(w, nc)) continue;
						que.push(P(nr, nc));
					}
				}
			}
		}

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

Measured memory_bytes: 1256