akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 1000005
using namespace std;
int b[N],a[N],now[N],n,k,q;
int solve(int l,int r,int x)
{
	int tmp=0;
	for(int i=l;i<=r;i++)
	{
		if(a[i]<=x)tmp++;
	}
	return min(tmp,max(0,r-l-k+2));
}
int tp[N],cnt;
bool pan(int x)
{
	for(int i=1;i<=n;i++)
	{
		int now=0,cnt=0;
		tp[++cnt]=0;
		for(int j=1;j<=n;j++)if(a[j]<b[i])tp[++cnt]=j;
		tp[++cnt]=n+1;
		for(int j=1;j<cnt;j++)
		{
			now+=solve(tp[j]+1,tp[j+1]-1,b[i]+x);
		}
		if(now>=q)return 1;
	}
	return 0;
}
int main()
{
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);
	int l=0,r=1000000000;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(pan(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	
	return 0;
}

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

int main()
{
    long long int x,i,j,k=0,l,m,n;
    scanf("%lld",&x);
    n=100;
    while(n<x)
    {
        n+=n/100;
        k++;
    }
    printf("%lld\n",k);
}


Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		
		if(A == B)
		{
			System.out.println(C);
		}
		else if(A == C)
		{
			System.out.println(B);
		}
		else
		{
			System.out.println(A);
		}

	}

}


Measured memory_bytes: 35672
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

dxdy4 = ((-1, 0), (0, -1), (0, 1), (1, 0))


def main():
    H, W = map(int, readline().split())
    Ch, Cw = map(int, readline().split())
    Dh, Dw = map(int, readline().split())
    S = [readline().strip() for _ in range(H)]

    Ch -= 1
    Cw -= 1
    Dh -= 1
    Dw -= 1

    dist = [[-1] * W for _ in range(H)]
    dist[Ch][Cw] = 0
    queue = deque([(Ch, Cw)])
    while queue:
        x, y = queue.popleft()
        for dx, dy in dxdy4:
            nx, ny = x + dx, y + dy
            if (
                0 <= nx < H
                and 0 <= ny < W
                and (dist[nx][ny] == -1 or dist[nx][ny] > dist[x][y])
                and S[nx][ny] == '.'
            ):
                dist[nx][ny] = dist[x][y]
                queue.appendleft((nx, ny))
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and dist[nx][ny] == -1 and S[nx][ny] == '.':
                    dist[nx][ny] = dist[x][y] + 1
                    queue.append((nx, ny))

    print(dist[Dh][Dw])
    return


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    string s; cin>>s;
    int N = sz(s);
    map<char, int> cnt;
    for(int i = 0; i < N; i++)cnt[s[i]]++;
    if(abs(cnt['a']-cnt['b'])<=1&&abs(cnt['b']-cnt['c'])<=1&&abs(cnt['c']-cnt['a'])<=1)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] l = new int[n];
        int[] r = new int[n];
        int max = 0;
        for(int i = 1; i < n; i++) {
            l[i] = gcd(l[i-1], a[i-1]);
        }
        for(int i = n-2; i >=0; i--) {
            r[i] = gcd(r[i+1], a[i+1]);
        }
        for(int i = 0; i < n; i++) {
            max = Math.max(max, gcd(l[i], r[i]));
        }
        System.out.println(max);
    }

    private static int gcd(int a, int b) {
        if(a < b) return gcd(b, a);
        if(b == 0) return a;
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 51176
n=int(input())
s=input()
m=n+5
w=0
e=0
for i in range(1,n):
    if s[i]=='E':
        e+=1
m=min(m,w+e)
for i in range(1,n):
    if s[i-1]=='W':
        w+=1
    if s[i]=='E':
        e-=1
    m=min(m,w+e)
print(m)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(b, a));
    }
    sort(all(v));
    int t = 0;
    rep(i, n) {
        t += v[i].S;
        if(t > v[i].F) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6128
#!/usr/bin/env python3
n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    g[a].append(b)
    g[b].append(a)


def dfs(used, s):
    global ans
    used[s] = True
    for t in g[s]:
        if not used[t]:
            dfs(used[:], t)
    if all(used):
        ans += 1


used = [False] * n
ans = 0
dfs([False] * n, 0)
print(ans)


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

int N, M;
vector<int> G[111111];
bool visited[111111];

void rec(int v){
	visited[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(visited[G[v][i]]) continue;
		rec(G[v][i]);
	}
	return ;
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	fill(visited, visited + N, false);
	int res = 0;
	for(int i = 0; i < N; i++){
		if(!visited[i]){
			rec(i);
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 9216
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func combi(n int, k int) int {
	a := 1
	b := 1
	for i := 0; i < k; i++ {
		a *= n - i
		b *= (k - i)
	}
	return a / b
}

func check(s string, k int) bool {
	l := len(s)
	var c int
	for i := 0; i < l; i++ {
		a, _ := strconv.Atoi(s[i : i+1])
		if a != 0 {
			c++
		}
		if c > k {
			return false
		}
	}
	if c == k {
		return true
	}
	return false
}

func run(s string, k int) int {
	l := len(s)
	dp := make([][]int, l)
	dpm := make([][]int, l)
	a := make([]int, l)
	for i := 0; i < l; i++ {
		a[i], _ = strconv.Atoi(s[i : i+1])
		dp[i] = make([]int, 3+1)
		dpm[i] = make([]int, 3+1)
	}
	// init
	for i := 0; i < l; i++ {
		dp[i][0] = 1
	}
	dp[0][1] = a[0]
	dp[0][2] = 0
	dp[0][3] = 0

	for i := 1; i < l; i++ {
		for j := 1; j <= 3; j++ {
			if dp[i-1][j-1] == 0 {
				dp[i][j] = 0
			} else if check(s[0:i], j-1) {
				dp[i][j] = dp[i-1][j] + dp[i-1][j-1]*9 - (9 - a[i])
			} else {
				dp[i][j] = dp[i-1][j] + dp[i-1][j-1]*9
			}
		}
	}
	return dp[l-1][k]
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	s := next()
	k := nextInt()
	fmt.Println(run(s, k))
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int X, A;
  cin >> X >> A;
  if (X < A)
    cout << 0 << endl;
  else
    cout << 10 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int MM = 2e4 + 4;
int main() {
	int n;
	cin >> n;
	vector <int> w(n), s(n), v(n), p(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> s[i] >> v[i];
		p[i] = i;
	}
	sort(p.begin(), p.end(), [&](int i, int j) {
		return w[i] + s[i] < w[j] + s[j];
	});
	vector <ll> DP(MM, 0);
	for(int i : p) {
		vector <ll> ls = DP;
		for(int j = 0; j <= s[i]; j++) {
			if(j + w[i] < MM) {
				DP[j + w[i]] = max(DP[j + w[i]], ls[j] + v[i]);
			}
		}
	}
	cout << *max_element(DP.begin(), DP.end());
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    rep(i,n) if(a[i]==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=1;
    ll mx = 1e18;
    rep(i, n)
    {
        if(a[i]>mx/ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
        if (ans > mx){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4376
#include <stdio.h>

int main(void)
{
	int alpha=0;
	int beta=0; /*Óa,Ób,Îpüc*/
	int charley=0;
	int rect = 0;/*·û`Ì*/
	int rhom = 0;/*Ðµ`Ì*/


	while(1){
	if(scanf("%d",&alpha) == EOF)
		break;
	scanf(",%d",&beta);
	scanf(",%d",&charley);

	if( charley*charley == alpha*alpha + beta*beta )
		rect++;

	if( alpha == beta )
		rhom++;

	}


	printf("%d\n",rect);
	printf("%d\n",rhom);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n;
    cin>>n;
    ll b = 0, w = 0;
    vll ball(2 * n);
    map<ll,ll> idx;
    rep(i,2*n){
        char ci;
        cin >> ci;
        ll ai;
        cin >> ai;
        ai--;
        if (ci=='B'){
            ball[i] = ai;
            idx[ai] = i;
        }
        else{
            ball[i] = ai + n;
            idx[ai + n] = i;
        }
    }
    vvll sb(2 * n + 1, vll(n + 1, 0));
    vvll sw(2 * n + 1, vll(n + 1, 0));
    vll now_b(n, 0), now_w(n, 0);
    repr(i,2*n-1,-1){
        rep(j,n){
            sb[i][j + 1] = sb[i][j] + now_b[j];
            sw[i][j + 1] = sw[i][j] + now_w[j];
        }
        if (ball[i]<n){
            now_b[ball[i]]++;
        }
        else{
            now_w[ball[i] - n]++;
        }
    }
    vvll dp(2 * n + 1, vll(n + 1, infl));
    dp[0][0] = 0;
    rep(i,2*n){
        rep(j,n+1){
            if (i-j<0)
                continue;
            if (j<n){
                dp[i + 1][j + 1] 
                = min(dp[i + 1][j + 1], dp[i][j] + sb[idx[j]][j] + sw[idx[j]][i - j]);
            }
            if (i-j<n){
                dp[i + 1][j] 
                = min(dp[i + 1][j], dp[i][j] + sw[idx[n + i - j]][i - j] + sb[idx[n + i - j]][j]);
            }
        }
    }
    cout << dp[2 * n][n] << endl;
}


Measured memory_bytes: 188544
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);
#define tie cin.tie(0);
#define x first
#define y second
#define ll long long
#define mod 666013

using namespace std;

int n, cnt;
string a[] = {"dreamer", "dream", "eraser", "erase" , "aser", "ase"};
string s;
string rs[100005];
bool b[100005];


int main(){
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		bool u = 0;
		//cout << s[i] << "! "; 
		for (int j = 0; j < 6; j++)
		{
			//cout << a[j] << " -> ";
			if (s[i] == a[j][0])
				{
					int z = 0, ii = i;
					for (z = 0; z < a[j].size() && ii < s.size(); z++, ii++)
						if (s[ii] != a[j][z]) break;
					if (z == a[j].size()){rs[++cnt] = a[j], u = 1, i = ii-1; break;}
				}
		//	cout << u << "\n";
		}
		if (!u) rs[++cnt] = s[i];
	}
	for (int i = 1; i <= cnt; i++)
	{
		if (rs[i] == "dreamer" || rs[i] == "erase") continue;
		if (rs[i] == "dream") continue;
		if (rs[i] == "eraser") continue;
		if ((rs[i] == "aser" || rs[i] == "ase") && rs[i-1] == "dreamer") continue;
		return cout << "NO", 0;
	}
	cout << "YES";
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  sort(A.begin(), A.end());
  int min = A.at(0);
  reverse(A.begin(), A.end());
  int max = A.at(0);
  cout << max - min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
ll nod(ll n) 
{ 
    return floor(log10(n) + 1); 
} 
ll power(ll a,ll n,ll m)
{
	ll ans=1;
	a=a%m;
	if(a==0)return 0;
	while(n)
	{
		if(n%2)
		ans*=a;
		else
		{
			a=a*a;
			n=n/2;
		}
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll ans=0,cnt=0;
	string s;
	cin>>s;
	if(s=="SSS"){cout<<0<<endl;
		return 0;
		}
	for(ll i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1] && s[i]=='R')cnt++;
		else cnt=0;
		ans=max(ans,cnt+1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	string S=in<string>();
	
	cout << 2*min(count(ALL(S),'1'),count(ALL(S),'0')) << endl;
	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if( A > 12 ){
    cout << B << endl;
  }else if( A <= 5){
    cout << 0 << endl;
  }else if( A > 5 && A < 13 ){
    cout << B / 2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long int llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	string s;
	cin >> s;
	int start = 0, ans = 0;
	int n = s.length();
	loop(i, n){
		if(s[i] == 'R') start++;
		else{
			start = 0;
		}
		ans = max(ans, start);
	}
	cout << ans;
}




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



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

int main(){
  string s,t;
  cin >> s >> t;
  
  int n = s.size();
  
  s+=s;
  
  for(int i = 0;i<n;i++){
    if(s.substr(i, n) == t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	int n=s.size(), ret=0;
	for (int i=0; i<n; i++)
		if(s[i]!=t[i])
			ret++;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3796
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    h,w=map(int,input().split())
    s=""
    for _ in range(h):
        s+=input()
    sc=list(Counter(s).values())
    cunt_1=(h%2)*(w%2)
    cunt_2=(h%2)*(w//2)+(w%2)*(h//2)
    cunt_4=(h//2)*(w//2)
    #print(sc)
    for i,scc in enumerate(sc):
        if scc>=4:
            x=min(scc//4,cunt_4)
            sc[i]-=x*4
            cunt_4-=x
    for i,scc in enumerate(sc):
        if scc>=2:
            x=min(scc//2,cunt_2)
            sc[i]-=x*2
            cunt_2-=x
    for i,scc in enumerate(sc):
        if scc>=1:
            x=min(scc,cunt_1)
            sc[i]-=x
            cunt_1-=x
    print("Yes" if all(scc==0 for scc in sc) else "No")

        

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (W, H, N) = (input[0], input[1], input[2])
var (minX, minY, maxX, maxY) = (0, 0, W, H)
for _ in 0..<N {
    let input = readLine()!.characters.split(" ").map{Int(String($0))!}
    let (x, y, a) = (input[0], input[1], input[2])
  	switch a {
    case 1:
        minX = max(minX, x)
    case 2:
        maxX = min(maxX, x)
    case 3:
        minY = max(minY, y)
    case 4:
        maxY = min(maxY, y)
    default:
      	break
    }
}
print(max(0,maxX-minX) * max(0,maxY-minY))

Measured memory_bytes: 4208
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const foo = (str) => str.split(' ').map(v => parseInt(v, 10));

const number = foo(inputs[0])[0];

const table = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
let result = [];

solve(number);

console.log(result.reverse().join(''));

function solve(value) {
  if (value > 26) {
    if (value % 26 === 0) {
      result.push(table[25]);

      solve(Math.floor((value - 26) / 26));
    } else {
      result.push(table[(value % 26) - 1]);

      solve(Math.floor(value / 26));
    }
  } else {
    result.push(table[value - 1]);
  }
}


Measured memory_bytes: 29560
#include<stdio.h>
int main(void){
  int num;
  int moti[100];
  int i,j;
  int kaburi = 0;
  
  if(scanf("%d\n",&num));
  for(i=0;i<num;i++){
    if(scanf("%d\n",&moti[i]));
  }
  
  for(i=0;i<num;i++){
    if(moti[i] == 0){
      continue;
    }
    for(j=i+1;j<num;j++){
      if(moti[i] == moti[j] && moti[j] != 0){
        kaburi += 1;
        moti[j] = 0;
      }
    }
  }  
   printf("%d",num - kaburi); 
  return 0;
}

Measured memory_bytes: 128
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 200005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x,y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)

using namespace std;
int n,p;
ll ans = 0;
vector<int> sum(maxn);
int main()
{
   ios_base::sync_with_stdio(NULL);
   cin.tie(NULL);
   cout.tie(NULL);
    cin >> n;
    cout << ((n & 1) ? n/2 + 1 : n/2);    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    vector<int> v(a);
    for(int i=0;i<a;i++)cin >> v[i];
    sort(v.begin(),v.end());
    int x = v[a/2-1],y = v[a/2];
    cout << y-x << endl;
}


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<998244353>;

const int MAXN = 2.1e5;
int N;
bool X[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	string X_; cin >> X_;
	for (int i = 0; i < N; i++) {
		X[i] = bool(X_[i] - '0');
	}

	num ans = 0;
	unordered_map<int, num> weights;
	for (int p = 2*N; p >= 1; p--) {
		if ((2 * N) % p != 0) {
			continue;
		}
		if (N % p == 0) {
			continue;
		}
		assert(p % 2 == 0);

		num weight = p;
		for (auto it : weights) {
			if (it.first % p == 0) {
				weight -= it.second;
			}
		}
		weights[p] = weight;

		num xval = 0;
		for (int i = 0; i < (p/2); i++) {
			xval *= 2;
			xval += X[i];
		}
		bool canEqual = true;
		for (int i = 0; i < N; i++) {
			bool v = X[i % (p/2)] ^ ((i / (p/2)) & 1);
			if (v < X[i]) {
				canEqual = true;
				break;
			} else if (v > X[i]) {
				canEqual = false;
				break;
			} else {
				continue;
			}
		}
		if (canEqual) xval++;
		//cerr << p << ' ' << xval << ' ' << weight << '\n';
		ans += xval * weight;
	}
	cout << ans << '\n';

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    pair<int,int> a[n];
    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        a[i] = make_pair(t,i+1);
    }
    sort(a,a+n);
    for(int i=0; i<n; i++){
        cout << a[i].second << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
    ll n, k;
    ll ans=0;
    cin>>n>>k;
    rep(i, n+2){
        if(i<k){
            continue;
        }else{
            ans=(ans+i*(n-i+1)+1)%P;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	string s; ll w; cin >> s >> w;
	for (ll i = 0; i < s.size(); i += w) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int k, n;
int a[200010];
int dist[200010];

int main()
{
	scanf("%d%d", &k, &n);
	scanf("%d", &(a[0]));
	for (int i = 1 ; i < n ; i++) {
		scanf("%d", &(a[i]));
		dist[i] = a[i] - a[i - 1];
	}
	dist[0] = a[0] + k - a[n - 1];
	
	int maxDist = 0;
	for (int i = 0 ; i < n ; i++) {
		if (dist[i] > maxDist) {
			maxDist = dist[i];
		}
	}
	
	int ans = k - maxDist;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if(a<=5)
		cout<<0;
	else if(a>=6 && a<=12)
		cout<<b/2;
	else 
		cout<<b;
	return 0;
}

Measured memory_bytes: 3624
/**
 *	author: tanishq_code_c
**/
#include <bits/stdc++.h>
using namespace std;



void __print(int x) {cerr << x;}; void __print(long x) {cerr << x;}; void __print(long long x) {cerr << x;}; void __print(unsigned x) {cerr << x;}; void __print(unsigned long x) {cerr << x;}; void __print(unsigned long long x) {cerr << x;}; void __print(float x) {cerr << x;}; void __print(double x) {cerr << x;}; void __print(long double x) {cerr << x;}; void __print(char x) {cerr << '\'' << x << '\'';}; void __print(const char *x) {cerr << '\"' << x << '\"';}; void __print(const string &x) {cerr << '\"' << x << '\"';}; void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif


#define int             							long long
#define setbits(x)     							    __builtin_popcountll(x)
#define zerobits(x)     							__builtin_ctzll(x)
#define mod             							1000000007
#define inf            							    1e18
#define endl            							'\n'
#define pb              							push_back
#define all(x)          							x.begin(),x.end()
#define ff              							first
#define ss              							second
#define rep(i,n)                                    for(int i = 0; i < n; i++)



void t_c_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("inp.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif*/
	string s; cin >> s;
	int ans = 0;
	int mx = -inf;
	for (int i = 0; i < (int)s.size();) {
		ans = 0;
		if (s[i] != 'R') {
			i++;
			continue;
		}
		int j = i;
		while (j < (int)s.size() and s[j] == 'R') {
			ans++;
			j++;
		}
		dbg(ans);
		mx = max(ans, mx);
		i = j;
	}
	cout << (mx == -inf ? 0 : mx) << endl;
}

int32_t main()
{
	t_c_c();
	return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >>  B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
    
    else{
      cout << "Right" << endl;
    }
  }

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char c;
	int w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	int ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
long double wss[18]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072};
int main(){
	long double n,m;
	n=read();
	m=read();
	long double ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i>=m)
		{
			ans+=(n-i+1)/n;
			break;
		}
		long double w=1.0/n;
		for(int j=0;j<=17;j++)
		{
			if(i*wss[j]>=m)
			{
				break;
			}
			w/=2;
		}
		ans+=w;
	}
	printf("%.12Lf\n",ans);
	return 0;
}

Measured memory_bytes: 3668
s = list(input())

s1 = list(s[0:int(len(s) / 2 + 0.5)])
s2 = list(s[int(len(s) / 2):len(s)])

s2.reverse()

count = 0

for i in range(int(len(s) / 2+0.5)):
   if s1[i] != s2[i]:
      count += 1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>


typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

template <typename T>
T gcd(T a, T b) {
	if (a < b) gcd(b, a);
	T r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

template <typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	for (ll i = 0; i < n; i++) {
		ll a;
		cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << endl;
}



Measured memory_bytes: 3112
#include<iostream>

using namespace std;

int main()
{
	int num;

	while(cin>>num){
		int answer = 0;
		for(int a = 0;a != 10;++a){
			for(int b = 0;b != 10;++b){
				for(int c = 0;c != 10;++c){
					for(int d = 0;d != 10;++d)
						if(a+b+c+d==num)
							answer++;
				}
			}
		}
		cout <<answer<<endl;
	}

	return 0;	
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

int main (){
    int n;
    cin >> n;
    deque<int>d;
    rep(i,n){
        int a;
        cin >> a;
        if(i%2==0) d.push_back(a);
        else d.push_front(a);
    }
    if(n%2==1) reverse(d.begin(),d.end());
    for(auto p:d){
        cout << p << " " ;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define P 1000000007
#define ll long long
#define ld long double
#define N (1<<17)
#define pii pair<int, int>
#define F first
#define S second

using namespace std;

int n, a[444];
ll d[444][444], s[444];

ll dp(int l, int r){
	if(l==r) return a[l];
	if(d[l][r]) return d[l][r];

	d[l][r] = 1e18;

	for(int i=l; i<r; i++){
		ll ls = dp(l, i);
		ll rs = dp(i+1, r);
		ll t = s[r+1]-s[l];
		if(l!=i) t += ls;
		if(r!=i+1) t+= rs;
		d[l][r] = min(d[l][r], t);
	}
	return d[l][r];
}

int main(){

	cin >> n;
	for(int i=0; i<n; i++){cin >> a[i]; s[i+1] = s[i]+a[i];}

	cout << dp(0, n-1) << endl;

	return 0;

}


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

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

const long long INF = 1LL << 60;


int main(void){
	ll n;cin >> n;
	if(n%2==1){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	while(n>0){
		ans += n/10;
		n /= 5;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[6];
    rep(i,3){
        cin >> A[i];
    }
     sort(A,A+3);
    cout << (A[0]==5 && A[1]==5 && A[2]==7 ? "YES" : "NO")<< endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int count = 0;
		int ans = 0;

		for(int i=0; i<s.length(); i++) {
			if(s.charAt(i)=='A' || s.charAt(i)=='C' || s.charAt(i)=='G' || s.charAt(i)=='T') {
				count++;
			}else {
				count = 0;
			}
			if(count > ans) {
				ans = count;
			}
		}

		System.out.println(ans);







//		String s = sc.next();
//		int count=0;
//		int max = 0;
//
//		for(int i=0 ; i<s.length(); i++) {
//			if(s.charAt(i)=='A' || s.charAt(i)=='C' || s.charAt(i)=='G' || s.charAt(i)=='T') {
//				count++;
//				if(count > max) {
//					max = count;
//				}
//			}else {
//				count = 0;
//			}
//		}
//
//		System.out.println(max);

		sc.close();

	}

}


Measured memory_bytes: 35648
#include<bits/stdc++.h>
#define append emplace_back
#define endl "\n"
#define N 1000000
#define M 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define sort(v) sort(v.begin(),v.end())
using namespace std;
int main()
{
	IOS;
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int i = 0;
	while(a>0 && c>0)
	{
		if(i)
			a-= d;
		else
			c-=b;
		i = 1-i;
	}
	if(c<=0)
		cout << "Yes"<<endl;
	else
		cout << "No"<<endl;
	return 0;
}


Measured memory_bytes: 3652
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		String S = reader.next();
		int cnt = 0;
		for (int i=0; i<S.length(); i++) {
		    if (S.charAt(i) == 'x') cnt++;
		}
		if (cnt > 7) System.out.println("NO");
		else System.out.println("YES");
	}
	
	public static void solver(int H, int W, boolean[][] matrix) {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 23124
import sys
n = int(input())
if n==4:
    print(4)
    sys.exit()
elif n==2:
    print(4)
    sys.exit()
elif n==1:
    print(4)
    sys.exit()
a = n
b = 0
i = 1
while True:
    if a%2==0:
        b = a//2
    else:
        b = 3*a+1
    i+=1
    a = b
    # print(a)
    if b ==4:
        break
print(i+3)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <array>
using namespace std;
int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A;
	string str;
	cin >> A >> str;
	if ((int)str.size() <= A)
	{
		cout << str;
	}
	else
	{
		string tmp;
		for (int i = 0; i < A; i++)
			tmp += str[i];
		tmp += "...";
		cout << tmp;
	}
	return 0;
}

Measured memory_bytes: 3652
a,b,c,x,y = gets.split.map(&:to_i)
sum = 0
if a + b >= 2 * c
  s = [x,y].min
  x-=s
  y-=s
  sum += c * 2 * s
else
  s = [x,y].min
  sum += a * s
  sum += b * s
  x -= s
  y -= s
end

if x != 0
  if a > 2 * c
    sum += 2 * c * x
  else
    sum += a * x
  end
elsif y != 0
  if b > 2 * c
    sum += 2 * c * y
  else
    sum += b * y
  end
end
puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long long n, m, k;
    cin >> n >> m >> k;
    if (n >= k)
        cout << n - k << ' ' << m;
    else
    {
        if (m - abs(k - n) < 0)
            cout << 0 << ' ' << 0;
        else
            cout << 0 << ' ' << m - abs(k - n);
    }
}

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

using namespace std;

int n;
string event;

int main() {
  cin >> n;

  for (int i=0; i<n; i++) {
    // puts("hello");

    int out_count = 0;
    bool first_base = false;
    bool second_base = false;
    bool third_base = false;
    int score = 0;

    while(cin >> event) {
      // cout << "score:" << score << endl;
      // cout << "out:" << out_count << endl;
      // cout << event << endl;
      
      if (event == "HIT") {
	if (third_base) {
	  third_base = false;
	  score++;
	}
	if (second_base) {
	  second_base = false;
	  third_base = true;
	}
	if (first_base) {
	  first_base = false;
	  second_base = true;
	}
	first_base = true;
      } else if (event == "HOMERUN") {
	if (third_base) {
	  score++;
	  third_base = false;
	}
	if (second_base) {
	  score++;
	  second_base = false;
	}
	if (first_base) {
	  score++;
	  first_base = false;
	}
	score++;
      } else if (event == "OUT") {
	out_count++;
	if (out_count >= 3) {
	  break;
	}
      }
    }
    
    printf("%d\n", score);
  }
}

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

using ll = long long;

int main() {
    int n, x; cin >> n >> x;
    vector<int> m(n);
    for(int i = 0; i < n; ++i) {
        cin >> m[i];
    }
    cout << n + (x - accumulate(begin(m), end(m), 0)) / *min_element(begin(m), end(m)) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  if(n<3 || n>20){return 0;}

  int p[n];
  int i,j;
  int a=0;
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    if(p[i] > n || p[i] < 1){
      return 0;
    }
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(p[i] == p[j]){
        return 0;
      }
    }
  }

  for(i=1;i<n-1;i++){
    if(p[i]>p[i+1] && p[i]<p[i-1]){
      a++;
    }
    else if(p[i]<p[i+1] && p[i]>p[i-1]){
      a++;
    }
  }

  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
string s;
cin >> s;
int n;
for(int i=0;i < 15;i++){
if(s[i] == 'x'){n ++ ;}
else if(s[i] != 'o'){break;}
}
if(n < 8){cout << "YES";}
else{cout << "NO";}
}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,h[100010],dp[100010];

int main()
{
	rep(i,100005) dp[i]=1e18;
	dp[0]=0;
	cin>>n>>k;
	rep(i,n) cin>>h[i];
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=k&&i-j>=0;j++) dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		//cout<<i<<' '<<dp[i]<<endl;
	}
	cout<<dp[n-1]<<endl;
	rt0;
}

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

#define rep(i,n) for(int i=0;i<(int)n;++i)
int max(const int a, const int b) {
  return a > b ? a : b ;
}

int H, W, C;
int base[10][10];
int copy[10][10], visit[10][10];
const int di[] = {1, -1, 0, 0};
const int dj[] = {0, 0, -1, 1};

void rec(int base_color, int color, int i, int j) {
  // printf(">>%2d %2d %2d %2d\n", base_color, color, i, j);
  if (visit[i][j]) return;
  visit[i][j] = 1;
  rep(z,4) {
    int ni = i+di[z], nj = j+dj[z];
    if (ni < 0 || nj < 0 || H <= ni || W <= nj) continue;
    if (visit[ni][nj] || (base_color != copy[ni][nj])) continue;
    if (color == copy[ni][nj]) continue;
    copy[ni][nj] = color;
    rec(base_color, color, ni, nj);
  }
}

void update(int color) {
  // memset(visit, 0, sizeof (visit));
  rep(i,H) rep(j,W) visit[i][j] = 0;
  int prev_color = copy[0][0];
  copy[0][0] = color;
  rec(prev_color, color, 0, 0);
}

void debug() {
  rep(h,H) {
    rep(w,W) printf("%2d", copy[h][w]);
    puts("");
  }
}

int t_ans = 0;


void calc_rec(int i, int j) {
  if (visit[i][j]) return;
  t_ans++;
  visit[i][j] = 1;
  rep(z,4) {
    int ni = i+di[z], nj = j+dj[z];
    if (ni < 0 || nj < 0 || H <= ni || W <= nj) continue;
    if (visit[ni][nj] || copy[ni][nj] != copy[i][j]) continue;
    calc_rec(ni, nj);
  }
}

int calc() {
  memset(visit, 0, sizeof (visit));
  t_ans = 0;
  calc_rec(0, 0);
  return t_ans;
}

int solve() {
  int ans = 0;
  rep(i,6) rep(j,6) rep(k,6) rep(l,6) {
    if (i==j || j==k || k==l || l+1==C)
      continue;
    rep(h,H) rep(w,W) copy[h][w] = base[h][w];
    int ch[5] = {i+1, j+1, k+1, l+1, C};
    rep(z,5) {
      update(ch[z]);
      /* if (ch[0] == 6 && ch[1] == 3 && ch[2] == 4 && */
      /*     ch[3] == 2 && ch[4] == 5) { */
      /*   puts(""); */
      /*   debug(); */
      /* } */
    }
    ans = max(ans,calc());
  }
  return ans;
}

int main() {
  while(scanf("%d%d%d", &H, &W, &C), H|W) {
    rep(i,H) rep(j,W) scanf("%d", base[i]+j);
    printf("%d\n",solve());
  }
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
string s[55];
int used[55][26];
int minAlpha[26];

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>s[i];
    for(int i=0;i<N;++i){
        for(int j=0;j<s[i].size();++j){
            char c = s[i][j];
            used[i][c-'a']++;
        }
    }
    for(int i=0;i<26;++i){
        int Alpha = INF;
        for(int j=0;j<N;++j){
            Alpha = min(Alpha,used[j][i]);
        }
        minAlpha[i] = Alpha;
    }
    for(int i=0;i<26;++i){
        for(int j=0;j<minAlpha[i];++j){
            printf("%c",i+'a');
        }
    }
    //for(auto a : ans)cout<<a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	while(cin>>n>>m,n,m){
		int num[101]={},ans=101;
		for(int i=0,x,y;i<n;i++){
			cin>>x;
			for(;x>0;x--){
				cin>>y;
				num[y]++;
				if(num[y]>m){
					m=num[y];
					ans=y;
				}
				else if(num[y]==m)ans=min(ans,y);
			}
		}
		if(ans==101)cout<<0<<endl;
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void)
{
        int n,r,x;
        int i;

        scanf("%d",&n);


        if(n==1 || n==2){
                printf("2\n");
                return 0;
        }

        i = 2;
        x = n * i;
        r = n % i;
        while(r!=0){
                n = i;
                i = r;
                r = n % i;
        }

        printf("%d\n",x/i);
        return 0;
}


Measured memory_bytes: 128