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

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

		//配列array
		int n = src.nextInt();
		int[] array = new int[n];
		for (int i=0; i<n; i++) 
			array[i] = src.nextInt();
		
		//配列array2
		int m = src.nextInt();
		int[] array2 = new int[m];
		for (int i=0; i<m; i++) 
			array2[i] = src.nextInt();
		
		for (int i=0; i<Math.min(n,m); i++) {

			if (array[i] < array2[i]) {
				System.out.println(1); return;

			}else if (array[i] > array2[i]) {
				System.out.println(0); return;
			}
		}
		System.out.println(array.length<array2.length?1:0);
	}
}


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

int main() {
  int N;
  cin >> N;
  
  for(int i;i<N;i++){
    string A;
    cin >> A;
    if( A == "Y" ){
      cout << "Four" << endl;
      break;
    }
    if(i == N-1){
      cout << "Three" << endl;
    }
  }  
}


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

int main(){
	ll n; cin >> n;
	vector<string> s(n); rep(i,n)cin >> s[i];
	sort(s.begin(), s.end());
	vector<pair<string,ll>> p(n+2); p[0].first = s[0];
	rep(i,n)p[i].second = 1;
	ll now = 0;
	ll m = 0;
	for(ll i = 1;i<n;i++){
		if(p[now].first != s[i]){
			now++;
			p[now].first = s[i];
		}
		else p[now].second++;
	}
	rep(i,n)m = max(m,p[i].second);
	rep(i,n){
		if(p[i].second == m){
			cout << p[i].first << endl;
		}
	}
}

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

int main() {
    
    int i, arr[5];
    for(i=1; i<=5; i++){
        cin >> arr[i];
        if(arr[i]==0){
            cout << i << endl;
            break;
        }
    }
    
    
    
    
    
    
	return 0;
}

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

namespace ConsoleApplication26 {
    class Program {
        static void Main(string[] args) {
            string[] str = Console.ReadLine().Split(' ');
            int k = int.Parse(str[0]);
            int s = int.Parse(str[1]);
            var result = Method(k, s);
            Console.WriteLine(result);
        }

        private static int Method(int k, int s) {//

            int result = 0;

            for (int x = 0; x <= k; x++) {
                if (x == s) {
                    result++;
                    break;
                }
                for (int y = 0; y <= k; y++) {
                    if (x + y == s) {
                        result++;
                        break;
                    }
                    if (x + y + k >= s) {
                        result++;
                    }

                }
            }
            return result;
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    
    ans += (r - l + 1);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
l = len(s)-1
ans = 0

for j in range(2**l):
  L = 0
  for i in range(l):
    if (j>>i)&1 == 1:
      m = s[L:i+1]
      ans += int(m)
      L = i+1
  ans += int(s[L:])
print(ans) 

Measured memory_bytes: 3064
r, g, b, n = map(int, input().split())
L = [r, g, b]
L.sort(reverse=True)
r, g, b = L[0], L[1], L[2]
ans = 0
for i in range(n//r + 1):
  for j in range((n - i * r) // g + 1):
    if (n - i * r - j * g) % b == 0:
      ans += 1
print(ans) 

Measured memory_bytes: 41436
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ll MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    string s;
    cin>>s;
    
    VEC(ll,a,0);
    ll t=0;char ts='R';
    REP(i,s.length()){
        if(ts=='R'&&s[i]=='R'){
            t++;
        }else if(ts=='R'&&s[i]=='L'){
            a.push_back(t);
            t=1;
            ts='L';
        }else if(ts=='L'&&s[i]=='L'){
            t++;
        }else if(ts=='L'&&s[i]=='R'){
            a.push_back(t);
            t=1;
            ts='R';
        }
    }
    a.push_back(t);
    REP(i,a.size()){
        if(abs(a[i]-a[i+1])%2==0){
            ll t=(a[i]+a[i+1])/2;
            REP(j,a[i]-1)cout<<0<<" ";
            cout<<t<<" "<<t<<" ";
            REP(j,a[i+1]-1)cout<<0<<" ";
        }else{
            ll t=(a[i]+a[i+1])/2;
            if(a[i]%2==0){
                REP(j,a[i]-1)cout<<0<<" ";
                cout<<t<<" "<<t+1<<" ";
                REP(j,a[i+1]-1)cout<<0<<" ";
            }else{
                REP(j,a[i]-1)cout<<0<<" ";
                cout<<t+1<<" "<<t<<" ";
                REP(j,a[i+1]-1)cout<<0<<" ";
            }
        }
        i++;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 105
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int main() {
	int k,ans=7,num=1;
	cin>>k;
	rep1(i,2,k){
		if(i==2&&ans%k==0) break;
		ans=(ans*10+7)%k;
		if(ans==0) {
			num=i;
			break;
		}
		if(i==k) num=-1;
	}
	cout<<num;
	return 0;
}


Measured memory_bytes: 3672
import numpy as np
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n=int(input())
p=list(map(float,input().split()))

dp=np.zeros(n+1)
dp[0]=1
for i in range(n):
      dp[1:]=dp[1:]*(1-p[i])+dp[:-1]*p[i]
      dp[0]=dp[0]*(1-p[i])
print(np.sum(dp[1+n//2:]))

Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue<ll> pq;
int main(void){
	int n; scanf("%d",&n);
	ll sum =0;
	for(int i=0;i<n;i++){
		ll x,y; scanf("%lld %lld",&x,&y);
		pq.push(x+y);
		sum += x;
	}
	int p = 0;
	while(!pq.empty()){
		ll t = pq.top(); pq.pop();
		if(p%2==1) sum-=t;
		p++;
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define M 1000000007
int h, w;
bool G[1001][1001];
int dp[1001][1001];

int main() {
    cin >> h >> w;
    reps(y, h) reps(x, w) {
        char c;
        cin >> c;
        G[y][x] = (c == '#');
    }
    reps(y, h) reps(x, w) {
        if (x == 1 && y == 1) {
            dp[y][x] = 1;
            continue;
        }
        if (!G[y][x])
            dp[y][x] = (dp[y - 1][x] + dp[y][x - 1]) % M;
    }
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 8528
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int a,b,c;
	cin>>a>>b>>c;

	if((a+b+c)>=22)
	{
		cout<<"bust";
	}
	else
	{
		cout<<"win";
	}

}

Measured memory_bytes: 3576
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

loop do
    a,b=get_i
    break if a.zero? and b.zero?
    n=gets.to_i
    map=array(a,0,b)
    n.times do|i|
        x,y=get_i
        x-=1
        y-=1
        map[y][x]=1
    end
    dp=array(a,0,b)
    dp[0][0]=1
    b.times do|i|
        a.times do|j|
            next if i.zero? and j.zero?
            if map[i][j].zero?
                if i-1>=0
                    dp[i][j]+=dp[i-1][j]
                end
                if j-1>=0
                    dp[i][j]+=dp[i][j-1]
                end
            end
        end
    end
    puts dp[b-1][a-1]
end


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

int h, w, grid[505][505];

int main()
{
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> grid[i][j];
    
    int res[303030][4], cnt = 0;
    rep(i, h)
    {
        rep(j, w - 1)
        {
            if(grid[i][j] % 2 == 1)
            {
                grid[i][j + 1]++;
                res[cnt][0] = i + 1; res[cnt][1] = j + 1; res[cnt][2] = i + 1; res[cnt][3] = j + 2;
                cnt++;
            }
        }
    }
    rep(i, h - 1)
    {
        if(grid[i][w - 1] % 2 == 1)
        {
            grid[i + 1][w - 1]++;
            res[cnt][0] = i + 1; res[cnt][1] = w; res[cnt][2] = i + 2; res[cnt][3] = w;
            cnt++;
        }
    }

    cout << cnt << endl;
    rep(i, cnt)
    {
        rep(j, 4)
        {
            cout << res[i][j] << ((j == 3)? "\n" : " ");
        }
    }
    
    
    return 0;
}

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

using namespace std;

#define ll unsigned long long
#define endl "\n"
#define MOD 1000000007

vector <ll> ad[200006];
vector <ll> vis(200006,0);

ll ans=0, n, m;

void addedge(ll x, ll y){
  ad[x].push_back(y);
  ad[y].push_back(x);
}

ll dfs(ll node){
  vis[node]=1;
  ++ans;
  for(ll x:ad[node]){
    if(!vis[x]){
      dfs(x);
    }
  }
  return ans;
}

void solve(){
  string s;
  cin >> s;
  ll ct=0, ans=0;
  for(char x:s){
	if(x=='R')
		++ct;
	else if(x=='S'){
		ct=0;
	}	  	
	ans=max(ct, ans);
  }
  cout << ans << endl;
}  

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


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

int main(){
    int N;
    cin >> N;
  int X[N];
  int Y[N];
  for(int i=0;i<N;i++){
        cin>>X[i]>>Y[i];
  }
    int ans=0;
    for(int i=0;i<N;i++){
       for(int j=0;j<N;j++){
           if(i==j) continue;
           int p=X[i]-X[j];
           int q=Y[i]-Y[j];
           int count=0;
           for(int k=0;k<N;k++){
              for(int l=0;l<N;l++){
                  if(X[k]-X[l]==p&&Y[k]-Y[l]==q)count++;
              }
           }
           ans=max(ans,count);
       }
    }
  cout<<N-ans<<endl;
  return 0;
}

Measured memory_bytes: 3592
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)
	b := 0
	for i := 0; i < n; i++ {
		b ^= a[i]
	}
	for i := 0; i < n; i++ {
		fmt.Fprint(wr, a[i]^b, " ")
	}
	fmt.Fprintln(wr)
}


Measured memory_bytes: 7288
A, B, C, X, Y = map(int, input().split())
a = A * X + B * Y
b = C * max(X, Y) * 2
c = A * (X - Y) + 2 * C * Y
d = B * (Y - X) + 2 * C * X
e = max(c, d)
ans = min(a, b, e)
print(ans)

Measured memory_bytes: 9052
import sys
import time

sys.setrecursionlimit(10000)
INF = float('inf')


class WeightedUnionFind:
    def __init__(self, nodes):
        """
        :param collections.Iterable nodes:
        """
        self._parents = {k: k for k in nodes}
        self._ranks = {k: 0 for k in nodes}
        self._sizes = {k: 1 for k in nodes}
        # 直近の親からの重み。root なら 0
        self._weights = {k: 0 for k in nodes}

    def unite(self, x, y, w):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :param w: x と y の重みの差; (重み y) - (重み x)
        :return:
        """
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return

        # rank が小さい方が下
        if self._ranks[rx] > self._ranks[ry]:
            # x が root
            self._parents[ry] = rx
            self._sizes[rx] += self._sizes[ry]
            # root 間の重みに変換
            self._weights[ry] = w + self._weights[x] - self._weights[y]
        else:
            # y が root
            self._parents[rx] = ry
            self._sizes[ry] += self._sizes[rx]
            # root 間の重みに変換
            self._weights[rx] = -w + self._weights[y] - self._weights[x]
            if self._ranks[rx] == self._ranks[ry]:
                self._ranks[ry] += 1

    def find(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        root = self.find(self._parents[x])
        self._weights[x] += self._weights[self._parents[x]]
        self._parents[x] = root
        return root

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.find(x)]

    def weight(self, x):
        """
        :param x:
        :return:
        """
        # 経路圧縮
        self.find(x)
        return self._weights[x]

    def diff(self, x, y):
        """
        (y の重み) - (x の重み)
        :param x:
        :param y:
        :return:
        """
        if self.find(x) == self.find(y):
            return self._weights[y] - self._weights[x]
        return float('inf')


N, M = list(map(int, input().split()))

uf = WeightedUnionFind([i + 1 for i in range(N)])

ok = True
for _ in range(M):
    l, r, d = list(map(int, input().split()))
    if uf.find(l) == uf.find(r) and uf.diff(l, r) != d:
        ok = False
        break
    uf.unite(l, r, d)

if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 37784
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		int a, b;
		Scanner input = new Scanner(System.in);
		a = input.nextInt();
		b = input.nextInt();
		if(a==b){
			System.out.println("a == b");
		}
		else if (a>b) {
			System.out.println("a > b");	
		}
		else 
			System.out.println("a < b");
	}
}

Measured memory_bytes: 26112
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define MOD 1000000007

void Solve()
{
	ld r;
	cin>>r;
	
	cout<< fixed<< setprecision(20)<<2*atan(1)*4*r;
	
}


signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 3796
#!/usr/bin/env ruby
require 'set'

def main
    n,y = gets.chomp.split(" ").map(&:to_i)
    # a = y/10000
    # b = (y - 10000*a)/5000
    # c = (y - 10000*a - 5000*b)/1000

    (0..y/10000).reverse_each do |a|
        (0..((y - 10000*a)/5000)).reverse_each do |b|
            c = (y - 10000*a - 5000*b)/1000
            if a+b+c==n
                puts "#{a} #{b} #{c}"
                return
            end
        end
    end
    puts "-1 -1 -1"
end

main

Measured memory_bytes: 24700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << "\n";
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
p = 1
while True:
    p = A[p-1]
    cnt += 1
    if p == 2 or cnt > n:
        break
if p == 2:
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 7452
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

int gcdCalc(int a, int b) {
    while (b != 0) {
        unsigned r = a % b;
        a = b;
        b = r;
    }
    return a;
}

void solve(int test, istream &in) {
    int x;
    in >> x;
    int gcd = gcdCalc(x, 360);
    int k = 360 / gcd;
    printf("%d\n", k);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
	//FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
	//FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        solve(test, f);
    }
	return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};




ll s_p(ll x, ll d){
  ll sum=1;
  while(d>0){
    if(d&1)
      sum=(sum*x)%MOD;
    x = x*x%MOD;
    d /= 2;
  }
  
  return sum;
}


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

  ll n, a, b;
  cin >> n >> a >> b;

  ll com_child = 1;
  ll com_mother = 1;
  ll com_a, com_b;
  for (ll i = 1; i <= b; i++) {
      com_child = com_child * (n - (i - 1))%MOD;
    com_mother = com_mother * i % MOD;
      if (i == a)
          com_a = com_child*s_p(com_mother, MOD-2)%MOD;
      if (i == b)
          com_b = com_child*s_p(com_mother, MOD-2)%MOD;
  }

  ll power = 2;
  ll com_n = s_p(power, n)-1;

  
  ll ans = (com_n - com_a - com_b + 2*MOD) % MOD;
  cout << ans << endl;


}



Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long int LL;

LL K;
LL MAXV = 1ll << 60;

LL digit(LL v) {
    LL ret = 0;
    while (v > 0) {
        ret += v % 10;
        v /= 10;
    }
    return ret;
}

bool cmp(LL a, LL b) {
    if (a * digit(b) != b * digit(a))
        return a * digit(b) < b * digit(a);
    return a < b;
}

LL get(LL v) {
    vector <LL> tmp;
    LL a = 10, b = 9, t = v;
    tmp.push_back(v);
    while (t > 0) {
        t /= 10;
        tmp.push_back(v - v % a + b);
        a *= 10;
        b = b * 10 + 9;
    }
    sort(tmp.begin(), tmp.end(), cmp);
    //printf("%lld: %lld, len=%d\n", v, tmp[0], (int)tmp.size());
    return tmp[0];
}

int main() {
    scanf("%lld",&K);
    LL cur = 0;
    while (K--) {
        cur = get(cur+1);
        printf("%lld\n",cur);
    }
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
ll n;cin>>n;ll sum=0;
rp(i,n){
    if(i%3!=0&&i%5!=0)sum+=i;
} 
cout<<sum<<endl;
}

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

int main() {
  int K,A,B,i;
  cin >> K >> A >> B ;
  
  for(i = A; i<=B; i++)
  {
    if((i % K) == 0)
    {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
 
int main() {
	int number = 0;
	int train = 0;
	int taxi = 0;
 
	scanf("%d", &number);
 
	scanf("%d", &train);

	scanf("%d", &taxi);
  	rewind(stdin);
 
	if (taxi > (number*train)) {
		printf("%d", (number*train));
	}
	else {
		printf("%d", taxi);
	}
 
	return 0;
}

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

string CounterPart(char symbol) {
	string ret;
	if (symbol == 'A') {
		ret = "T";
	} else if (symbol == 'T'){
		ret = "A";
	} else if (symbol == 'C'){
		ret = "G";
	} else if (symbol == 'G'){
		ret = "C";
	}
	return ret;
}

int main() {
	string b, a;
	cin >> b;
	for (int i = 0; i < b.size(); ++i ) {
		a += CounterPart(b[i]);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main(void) {
	string s;
	cin >> s;
	int ans = 0, temp = 0;
	s.push_back('Q');
	rep(i, 0, s.size()) {
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')temp++;
		else ans = max(temp, ans), temp = 0;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3664
fun main(args: Array<String>) = println(run {
    tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }

    val l = IntArray(n)
    val r = IntArray(n)
    l[0] = a.first()
    r[n-1] = a.last()
    for (i in 1..l.lastIndex) {
        val j = r.lastIndex-i
        l[i] = gcd(l[i-1], a[i])
        r[j] = gcd(r[j+1], a[j])
    }
    
    ((1..n-2).map { i ->
        gcd(l[i-1], r[i+1])
    }+l[n-2]+r[1]).max()!!

})



Measured memory_bytes: 59344
#include<iostream>
using namespace std;
int main()
{
    int i,j,k,l,b,f,r,v,n;
    int a[4][3][10]={0};
    cin>>n;
    while(n-- >0)
    {
        cin>>b>>f>>r>>v;
        for(i=0;i<4;i++)
        {
            for(j=0;j<3;j++)
            {
                for(k=0;k<10;k++)
                    if(i==(b-1)&&j==(f-1)&&k==(r-1))
                        a[i][j][k]+=v;
            }
        }
    }
    for(i=0;i<4;i++)
        {
            for(j=0;j<3;j++)
            {
                for(k=0;k<10;k++)
                {
                        cout<<" "<<a[i][j][k];
                }
                cout<<endl;
            }
                if(i<3)
                    cout<<"####################\n";
        }
        return 0;
}



Measured memory_bytes: 3048
N,M=map(int,input().split())
slist=[]
for i in range(M):
    slist.append(list(map(int,input().split())))

ans=["0"]*N

for i in range(M):
    if ans[slist[i][0]-1]=="0":
        ans[slist[i][0]-1]=slist[i][1]
    elif ans[slist[i][0]-1]!=slist[i][1]:
        ans=["-1"]
        break



if N>1:
    if ans[0]=="0":
        ans[0]=1
    elif ans[0]==0:
        ans=["-1"]
        

for i in range(len(ans)):
    if ans[i]=="0":
        ans[i]=0

print(*ans,sep=(""))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if (n%1000==0)   printf("%d",0);
	else   
	{
		int cnt=n/1000+1;
		printf("%d",cnt*1000-n);
	}
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
    int n,m,R;cin>>n>>m>>R;
    vector<int> r(R);
    rep(i,0,R-1){
        int x;cin>>x;
        --x;r[i]=x;
    }
    vector<vector<ll>> C(n,vector<ll>(n,2000000000));
    rep(i,0,n-1)C[i][i]=0;
    rep(i,0,m-1){
        ll a,b,c;cin>>a>>b>>c;
        --a,--b;
        C[a][b]=C[b][a]=c;
    }
    rep(k,0,n-1)rep(i,0,n-1)rep(j,0,n-1){
        C[i][j]=min(C[i][j], C[i][k] + C[k][j]);
    }
    ll ans = 2000000000;
    sort(all(r));
    do{
        ll tmp = 0;
        rep(i,1,R-1){
            tmp += C[r[i-1]][r[i]]; 
        }
        ans = min(ans, tmp);
    }while(next_permutation(all(r)));
    cout<<ans<<endl;
}


Measured memory_bytes: 1144
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
bool BinarySearch(int A[], int sz, int key)
{
    int left = -1, right = sz;
    while(right - left > 1)
    {
        int mid = (left + right) / 2;
        if(A[mid] == key) return true;
        else if(A[mid] < key) left = mid;
        else right = mid;
    }
    return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int S[n + 1];
    for(int i = 0; i < n; i++) cin >> S[i];
    int q; cin >> q;
    int T[q + 1];
    for(int i = 0; i < q; i++) cin >> T[i];
    int cnt = 0;
    for(int i = 0; i < q; i++)
    {
        if(BinarySearch(S, n, T[i])) cnt++;
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 3664
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 3000
t = [True] * m
for _ in range(m):
    p = [0] * m
    for i in range(n):
        for x in a[i]:
            if t[x - 1]:
                p[x - 1] += 1
                break
    ma = max(p)
    ans = min(ans, ma)
    t[p.index(ma)] = False
print(ans)


Measured memory_bytes: 43100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    cout << ceil(((double)(n-1))/(k-1));
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	string s;
	cin >> s;
	int k = -1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'C') {
			k = i;
			break;
		}
	}
	if (k != -1) {
		bool h = false;
		for (int i = k+1; i < s.size(); i++) {
			if (s[i] == 'F') {
				h = true;
			}
		}
		if (h) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

bool find_number_1s(int n,int i)
{
    return n&(1<<i);
}
int add(int x,int y)
{
    return x+y;
}
int sub(int x,int y)
{
    return x-y;
}
int main()
{
    int n,m,k;
    cin >> n >> m >> k;
     vector<int> cost_to;
    vector<vector<int> > v;
   
    add(23,90);
    ll maxi= 1e12;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        cost_to.push_back(x);
        vector<int> fek;
        for(int j=0;j<m;j++)
        {
            int x;
            cin >> x;
            fek.push_back(x);
        }
        v.push_back(fek);
    }
     add(23,45);
    for(int i=1;i<(1<<n);i++)
    {
        int num = i;
       
        vector<int> S;
        add(67,45);
        for(int j=0;j<n;j++)
        {
            
            if( find_number_1s(num,j) ) 
            {
               sub(34,50) ;
                S.push_back(j);
            }
                

        }
        if(S.size()>0)
        {
                
                vector<ll> addi;
                for(int j=0;j<m;j++)
                    addi.push_back(v[S[0]][j]);
                ll kil = cost_to[S[0]];
                add(23,45);
                for(int j=1;j<S.size();j++)
                {
                    kil += cost_to[S[j]];
                    for(int l=0;l<m;l++)
                    {
                        int cur = v[S[j]][l];
                        addi[l] += cur;
                        
                    }
                    
                }
                
                bool possible = true;
                for(int j=0;j<m;j++)
                {
                    if(addi[j]<k)
                    {
                        possible = false;
                        break;
                    }
                }
                
                if(possible)
                {
                    maxi= min(maxi,kil);
                }
                
        }
        
    }
    if(maxi==1e12)
    {
        maxi=-1;
    }
    cout << maxi<<endl;
    
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,a,b = map(int, input().split())

res=0

for i in range(1,n+1):
  s=str(i)
  m = 0
  for j in range(0,len(s)):
    m = m + int(s[j])
  if a <= m and m <= b:
    res = res + i
print(res)



Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define PER(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)((x).size()))
#define ALL(t) t.begin(),t.end()
#define clr(x) memset(x,0,sizeof(x))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
template<class T> ostream &operator<<(ostream &os, vector<T> V){ os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]"; } 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) { return os<<"("<<P.fi<<","<<P.se<<")"; }
#define flash ios_base::sync_with_stdio(0);
#define read freopen("1.in","r",stdin);
#define write freopen("1.out","w",stdout);
inline bool EQ(ld a,ld b) {return fabs(a-b)<=(1e-7);}
const ll mod=(1e9+7);
const ld pi=(acos(-1));
//CUT BEGINS

int a[100005];

int main() {
	clr(a);
	int n; cin>>n;
	REP(i,1,n) {
		int data;
		cin>>data;
		a[data]++,a[data+1]++,a[data-1]++;
	}
	int ans=0;
	REP(i,0,100002) ans=max(ans,a[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<cstring>
#define int long long
#define max(a,b) (a>b)?a:b
using namespace std;
const int N=1e6+10;
int f[N];
int find(int k){
	if(f[k]==k)	{
		return k;
	}else{
		return f[k]=find(f[k]);
	}
}
int n,m;
bool c[N];
signed main(){
	scanf("%lld %lld ",&n,&m);
	for(int i=1;i<=n;i++)
		f[i]=i;
	for(int a,b,i=1;i<=m;i++){
		scanf("%lld %lld",&a,&b);
		f[find(a)]=find(b);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!c[find(i)]){
			c[find(i)]=1;
			ans++;
		}
	}
	printf("%lld \n",(max(ans-1,(int)0)));
}




Measured memory_bytes: 4560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  string s;
  cin >> n >> k >> s;
  char c = s[0];
  ll ans = 0, now = 0;
  rep2(i, 1, n) {
    if(s[i] == c)
      now++;
    else {
      ans += now;
      now = 0;
      c = s[i];
    }
  }
  ans += now;
  ans += k * 2;
  cout << min(ans, n - 1) << endl;
}

Measured memory_bytes: 3764
#include<iostream>                                                     
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

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

using namespace std;

int main(){
    int n, d; cin >> n >> d;
    int ans = n / (2 * d + 1); 
    n % (2 * d + 1) ? cout << ans + 1 : cout << ans;
}


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

signed main(void)
{
	priority_queue<int> q;
	int n, m;
	long long ans;

	cin >> n >> m;
	rep(i, n)
	{
		int a;
		cin >> a;
		q.push(a);
	}
	rep(i, m)
	{
		int p;
		p = q.top();
		q.pop();
		q.push(p / 2);
	}
	ans = 0;
	while(!q.empty())
	{
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-08-18 14:44:25 +0900
# LastModified: 2020-09-11 15:35:56 +0900
#


import os
import sys


def pivot_index(change_box, i, which):
    if which == 0:
        for cb in change_box:
            if cb >= i:
                return cb
    else:
        for j in range(len(change_box)-1, -1, -1):
            if change_box[j] <= i:
                return change_box[j]


def main():
    S = input()
    change_box = []
    floor_chart = 1
    i = 0
    while i < len(S)-1:
        if S[i] != S[i+1] and floor_chart == 1:
            floor_chart = 0
            change_box.append(i)
        elif S[i] != S[i+1] and floor_chart == 0:
            floor_chart = 1
        i += 1

    ans = [0]*len(S)
    one_cool = 0
    hash_one = 0
    for i in range(len(S)):
        if S[i] == 'R':
            if hash_one == 1:
                hash_one = 0
                one_cool += 1
            pidx = change_box[one_cool]
            cool = pidx - i
            if cool % 2 == 0:
                ans[pidx] += 1
            else:
                ans[pidx+1] += 1

        else:
            pidx = change_box[one_cool]+1
            hash_one = 1
            cool = i - pidx
            if cool % 2 == 0:
                ans[pidx] += 1
            else:
                ans[pidx-1] += 1
    print(ans[0], end='')
    for i in range(1, len(ans)):
        print(" {}".format(ans[i]), end='')
    print()


if __name__ == "__main__":
    main()


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int64 n, m;
  cin >> n >> m;
  int64 x = min(n, m / 2);
  int64 ans = x;
  m -= 2 * x;
  ans += m / 4;
  cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;

#define forr(a,b,c) for(int a=(int)b;a<(int)c;a++)

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

	int n;
	cin>>n;
	int ara[n];
	int cnt=0;
	for(int i=0;i<n;i++) cin>>ara[i];
	for(int i=0;i<n;i++) if(ara[i]!=i+1) cnt++;
	
	if(cnt>2) cout<<"NO";
	else cout<<"YES";
	
		
		
	
	        
	return 0;
}



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

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 0;
    ans = max(a, b);

    if ( a > b ) a--;
    else b--;

    cout << ans + max(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
int main() {
	int n;
	while(scanf("%d",&n),n) {
		double x1,y1,z1,w1,x2,y2,z2,w2;
		for(int i=0;i<n;i++) {
			scanf("%lf %lf %lf %lf",&x1,&y1,&z1,&w1);
			scanf("%lf %lf %lf %lf",&x2,&y2,&z2,&w2);
			double x3,y3,z3,w3;
			x3=x1*x2-y1*y2-z1*z2-w1*w2;
			y3=x1*y2+y1*x2+z1*w2-w1*z2;
			z3=x1*z2-y1*w2+z1*x2+w1*y2;
			w3=x1*w2+y1*z2-z1*y2+w1*x2;
			cout<<x3<<' '<<y3<<' '<<z3<<' '<<w3<<endl;
		}
	}
}

Measured memory_bytes: 1296
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Dec  1 17:02:49 2018
//
package main

import "fmt"

type pos struct {
	x, y int
}

var n int

func pow(n int) int {
	if n == 0 {
		return 1
	}
	return 2 * pow(n-1)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	fmt.Scan(&n)

	poss := make([]pos, n)
	for i := range poss {
		fmt.Scan(&poss[i].x, &poss[i].y)
	}

	parity := (abs(poss[0].x) + abs(poss[0].y)) % 2
	for _, p := range poss {
		if (abs(p.x)+abs(p.y))%2 != parity {
			fmt.Println(-1)
			return
		}
	}

	var dist []int
	if parity == 0 {
		dist = []int{1}
	} else {
		dist = []int{}
	}

	for i := 0; i < 33; i++ {
		dist = append(dist, pow(i))
	}

	fmt.Println(len(dist))

	for i, d := range dist {
		fmt.Print(d)
		if i < len(dist)-1 {
			fmt.Print(" ")
		} else {
			fmt.Println()
		}
	}

	for _, p := range poss {
		x, y := p.x, p.y
		route := ""
		for i := len(dist) - 1; i >= 0; i-- {
			d := dist[i]
			if abs(x) > abs(y) {
				if x > 0 {
					route += "R"
					x -= d
				} else {
					route += "L"
					x += d
				}
			} else {
				if y > 0 {
					route += "U"
					y -= d
				} else {
					route += "D"
					y += d
				}
			}
		}

		for i := len(route) - 1; i >= 0; i-- {
			fmt.Print(string(route[i]))
		}
		fmt.Println()
	}
}


Measured memory_bytes: 2176
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 #define trace(x) cerr << #x << ": " << x << " " << endl;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}


int32_t main()
{
    IOS
       
            
    int n;
    cin>>n;
    int a[n-1];
    for(int i=0;i<n-1;++i)
        cin>>a[i];
    int b[n];
    b[0]=a[0];
    b[1]=a[0];
    for(int i=1;i<n-1;++i)
    {
        if(a[i]<=b[i])
        {
            b[i]=a[i];
            b[i+1]=a[i];
        }
        else
        {
            b[i+1]=a[i];
        }
    }
    int sum=0;
    for(int i=0;i<n;++i)sum+=b[i];
        cout<<sum;
 
}

Measured memory_bytes: 256
//abc125_a.cpp
//Tue Apr 30 16:33:30 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b,t;
	cin >> a >> b >> t;

	int x = t/a;

	cout << x*b << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll dp[200010][5];
const ll INF = -1e16;
ll a[200010],n;
ll func(ll here, ll ch) {
	if (here >= n)
	{
		if (ch == 0)
			return 0;
		else
			return INF;
	}
	if (ch < 0)return INF;
	ll& ret = dp[here][ch];
	if (ret != -1)return ret;
	ret = INF;

	ret = max(ret, func(here + 2, ch) + a[here]);
	ret = max(ret, func(here + 1, ch - 1));
	return ret;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	ll sum = 0;
	sum = n / 2;
	sum += sum;
	if (n % 2)
		a[n] = -1e10;
	n++;
	printf("%lld", func(0, n-sum));
}

Measured memory_bytes: 15784
#include<iostream>
#include <bits/stdc++.h>
const int N = 1e6 + 7 ;
using namespace std;

int n,m;
int u,v;
int ans[N] = {0};
vector<int> s[N];

void bfs(){
	queue<int> q;
	q.push(1);
	ans[1] = 1;
	while(!q.empty()){
		int tmp = q.front();
		q.pop();
		for(auto w:s[tmp]){
			if(ans[w] == 0){
				ans[w] = tmp;
				q.push(w);
			}
		}
	}
}

int main(){
	cin >> n >> m;
	for(int i= 0; i< m; i++){
		cin >> u >> v;
		s[v].push_back(u);
		s[u].push_back(v);
	}
	bfs();
	for(int i = 1; i <=n; i++){
		if(ans[i] == 0){
			cout << "No";
			return 0; 
		} 
	}
	cout << "Yes" << endl;
	for(int i = 2; i<= n; i++){
		cout << ans[i] << endl;
	}
	
	return 0; 
}



Measured memory_bytes: 31468
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100005],s1[100005];
    int n,a1[100005],i;
    double a,b;
    scanf("%d",&n);
    priority_queue<double, std::vector<double>, std::greater<double> > q;
    for(i=0;i<n;i++)
    scanf("%d",&a1[i]),q.push((double)a1[i]);

    while(q.size()>1)
    {
        a=q.top();
        q.pop();
        b=q.top();
        q.pop();
        q.push((a+b)/2);
    }
    printf("%lf",q.top());
}

Measured memory_bytes: 256