akhauriyash/Code-Regression huggingface dataset:
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	H := sc.nextIntSlice(N)
	dp := make([]int, N)
	for i := 1; i < N; i++ {
		dp[i] = dp[i-1] + abs(H[i]-H[i-1])
		for j := 2; j <= K; j++ {
			if i >= j {
				dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]))
			} else {
				break
			}
		}
	}

	fmt.Fprintln(wtr, dp[N-1])
	wtr.Flush()
}


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

int main() {
    int n, pm, pe, pj;
    while (cin >> n, n) {
        for (int i=0; i<n; ++i) {
            cin >> pm >> pe >> pj;
            if (max(pm, max(pe, pj)) == 100) {
                cout << "A" << endl;
            } else if (180 <= pm + pe) {
                cout << "A" << endl;
            } else if (240 <= pm + pe + pj) {
                cout << "A" << endl;
            } else if (210 <= pm + pe + pj) {
                cout << "B" << endl;
            } else if (150 <= pm + pe + pj && 80 <= max(pm, pe)) {
                cout << "B" << endl;
            } else {
                cout << "C" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int a, b;
string s;
bool flag = true;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b;
    a--, b--;
    cin >> s;
    erep(i, 0, a) {
        if (s[i] == '-') flag = false;
    }
    if (s[a+1] != '-') flag = false;
    erep(i, a+1+1, a+b+1+1) {
        if (s[i] == '-') flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  int N, d[100];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> d[i];

  set<int> mochis;
  for (int i = 0; i < N; i++) mochis.insert(d[i]);
  cout << mochis.size() << endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		String s = String.valueOf(n);

		for (int j = 0; j < s.length(); j++) {
			sum += Character.getNumericValue(s.charAt(j));
		}

		if (n % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 22228
import sys
input=sys.stdin.readline

s=input()


if 0<int(s[:2])<13:
	upper=True
else:
	upper=False

if 0<int(s[2:])<13:
	low=True
else:
	low=False

if upper and low:
	print("AMBIGUOUS")

elif not upper and low:
	print("YYMM")

elif upper and not low:
	print("MMYY")
else:
	print("NA")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
        string a,b;
        int q;
        cin>>q;
        while(getline(cin,a)){
            bool flg=0;
            b=a;
            for(int x=1;x<=26;x++){
                for(int y=1;y<=26;y++){
                    if(b.find("this")!=string::npos||b.find("that")!=string::npos){
                        cout<<b<<endl,flg=1;break;
                    }
                    else{

                        for(int i=0;i<a.length();i++){
                            if(a[i]>='a'&&a[i]<='z'){
                                b[i]=((((a[i]-'a')*x)+y)%26)+'a';
                            }
                        }
                    }
                }
                if(flg==1)break;
            }
        }
    return 0;
}

Measured memory_bytes: 1216
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int W = sc.nextInt();
        
        if(S <= W){
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }
    }
}


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

int main() {
  	int l,N,i=0,j=0,sum=0;
  	cin >> N;
  	int p[N];
  	while(cin>>l){
    	p[i]=l;
		i++;
    }
  	for(i=0; i<N; i++){
    	for(j=i+1; j<N; j++){
          	//cout << i << " " << j << endl;
        	sum += p[i]*p[j];
        }
    }
  	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int N,count=0;

    std::cin >> N;

    char S[N+1];

    std::cin >> S;

    for(int i=0;i<(N-2);i++){
        if(S[i]=='A'){
            if(S[i+1]=='B'){
                if(S[i+2]=='C'){
                    count += 1;
                }
            }
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
/*input
3
4 7
2 9
6 2
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define pii pair<ll,ll>
#define list vector<ll>
#define mp make_pair
#define vp vector< pair<ll,ll> >
#define in insert
#define pb push_back
#define ft first
#define sd second
#define matrix vector< vector<ll> >
#define all(x) x.begin(),x.end()
#define line string
#define rall(x) x.rbegin(),x.rend()
#define f(i,n) for(ll i=1;i<=n;i++) 
ll mod=(ll)(1e9+7);
ll total[101];
ll N;
ll solve(ll pos,ll cnt,ll foo)
{
	if(cnt==0)return foo;
	ll ans=0;
	for(ll i=1;i<=N;i++)
		if(i!=pos)
			{
					ans+=solve(i,cnt-1,foo+total[pos]);
			}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vp a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i].ft>>a[i].sd;
	sort(a.begin(),a.end());
	ll pos=a[n-1].ft;
	ll score=a[n-1].sd;
	ll cnt=0;
	if(score>0)cnt+=score;
	cnt+=pos;
	cout<<cnt<<endl;
	return 0 ;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringTokenizer;

class Main
{
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static Scanner sc = new Scanner(new InputStreamReader(System.in));

	public static void main (String[] args) throws java.lang.Exception {
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int[] A = new int[n];
		for (int i=0; i<n; i++) {
			A[i] = Integer.parseInt(st.nextToken());
		}

		int q = Integer.parseInt(br.readLine());
		int[] w = new int[q];
		st = new StringTokenizer(br.readLine());
		for (int i=0; i<q; i++) {
			w[i] = Integer.parseInt(st.nextToken());
		}

		solve(n, A, q, w);
	}

	public static void solve(int n, int[] A, int q, int[] w) {
		for (int i=0; i<q; i++) {
			boolean result = recursive(n, A, 0, w[i]);
			String ans = result ? "yes" : "no";
			System.out.println(ans);
		}
	}

	public static boolean recursive(int n, int[] A, int indicator, int remain) {
		if (remain == 0) return true;
		if (indicator == n || remain < 0) return false;

		return recursive(n, A, indicator+1, remain) || recursive(n, A, indicator+1, remain - A[indicator]);
	}
}

Measured memory_bytes: 19076
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            int A = fs.nextInt();
            int B = fs.nextInt();
            int C = fs.nextInt();
            int D = fs.nextInt();

            System.out.println(Math.min(A, B) + Math.min(C, D));
        }
    }
}

class FastScanner {
    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() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        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 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();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=_sz(s);
    if(n<=k){
        cout<<s;
    }
    else{
        s=s.substr(0,k)+"...";
        cout<<s<<nl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(void){
  int A,B,C;
  while(A>100||A<-100||B>100||B<-100||C>100||C<-100||(A!=B&&B!=C&&C!=A)||(A==B&&B==C)) scanf("%d %d %d",&A,&B,&C);
  if((A-B)==0) printf("%d\n",C);
 if ((B-C)==0) printf("%d\n",A);
 if ((A-C)==0) printf("%d\n",B);
  return 0;
}

Measured memory_bytes: 128
H,W,A,B = map(int,input().split())
ans = [[0 for i in range(W)] for j in range(H)]

for h in range(B):
    for w in range(A,W):
        ans[h][w] = 1

for h in range(B,H):
    for w in range(A):
        ans[h][w] = 1

for a in ans:
    for n in a:
        print(n,end='')
    print() 

Measured memory_bytes: 18544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1LL<<62


ll a[100010],cha[32][100010];
int main() {
	ll n ,C;
	cin>>n>>C;
	for(int i=0;i<n;i++){
		int l,r,c;
		cin>>l>>r>>c;
		c--;
		for(int j=l;j<=r;j++){
			cha[c][j]=1;
		}
	}
	for(int i=0;i<C;i++){
		for(int j=0;j<100010;j++){
			if(cha[i][j]==1){
				a[j]++;
			}
		}
	}
	ll ans=0;
	for(int i=0;i<100010;i++ ){
		ans=max(ans,a[i]);
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 25600
import java.util.*;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long amt = 0;
    for(long i=1;i<=x;i++){
      if(i%3!=0&&i%5!=0)
        amt+=i;
    }
    System.out.println(amt);
  }
}

Measured memory_bytes: 35788
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
//#include "mylibrary.hpp"



using namespace std;

int main(){
    int N,M;
    int ANS[3];
    vector<int> s;
    vector<int> c;
    
    for(int i=0;i<3;i++) ANS[i]=-1;
    
    cin >> N >> M;
    
    int i,j,k;
    for(i=0;i<M;i++){
        int temp_s, temp_c;
        cin >> temp_s >> temp_c;
        s.push_back(temp_s);
        c.push_back(temp_c);
    }
    
    //s,cチェック
    for(i=0;i<M;i++){
        for(j=i+1;j<M;j++){
            if(s.at(i)==s.at(j) && c.at(i)!=c.at(j)){
                cout << -1 << endl;
                return 0;
            }
                
        }
    }
    
    for(i=0;i<M;i++){
        ANS[s.at(i)-1] = c.at(i);
    }
    
//    cout << "c代入直後のANS配列" << endl;
//    for(i=0;i<N;i++){
//        cout << ANS[i] << " ";
//    }
//    cout << endl;
//    
    if(ANS[0]==0 && N!=1){
        cout << -1 << endl;
        return 0;
    }
    
    if(N==3){
        if(ANS[0]==-1) ANS[0]=1;
        if(ANS[1]==-1) ANS[1]=0;
        if(ANS[2]==-1) ANS[2]=0;
    }
    if(N==2){
        if(ANS[0]==-1) ANS[0]=1;
        if(ANS[1]==-1) ANS[1]=0;
    }
    if(N==1){
        if(ANS[0]==-1) ANS[0]=0;
    }
    
    for(i=0;i<N;i++){
        cout << ANS[i];
    }
    cout << endl;
    
    return 0;
 
}


Measured memory_bytes: 256
var
	i,cnt:Longint;
	s,pre,now:String;
begin
	readln(s);
	for i:=1 to length(s)do begin
		now:=now+s[i];
		if pre<>now then begin
			pre:=now;
			now:='';
			inc(cnt);
		end;
	end;
	writeln(cnt);
end.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;

LL seg[4*200005], lazy[4*200005];

void push_down(int n, LL v){
    lazy[n+n] += v;
    lazy[n+n+1] += v;
}

void update(int n, int s, int e, int l, int r, LL v){
    if(lazy[n] != 0){
        seg[n] += lazy[n];
        if(s != e) push_down(n, lazy[n]);
        lazy[n] = 0;
    }
    if(s > r || l > e) return;
    if(l <= s && e <= r){
        seg[n] += v;
        if(s != e) push_down(n, v);
        return;
    }
    int mid = (s+e)/2;
    update(n+n, s, mid, l, r, v);
    update(n+n+1, mid+1, e, l, r, v);
    seg[n] = max(seg[n+n], seg[n+n+1]);
}

LL query(int n, int s, int e, int l, int r){
    if(lazy[n] != 0){
        seg[n] += lazy[n];
        if(s != e) push_down(n, lazy[n]);
        lazy[n] = 0;
    }
    if(s > r || l > e) return -1e18;
    if(l <= s && e <= r) return seg[n];
    int mid = (s+e)/2;
    return max(query(n+n, s, mid, l, r), query(n+n+1, mid+1, e, l, r));
}

vector<int> add[200005], del[200005];
LL dp[200005];
int l[200005], r[200005], a[200005];

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d", &l[i], &r[i], &a[i]);
        add[l[i]].push_back(i);
        del[r[i]].push_back(i);
    }
    LL ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<add[i].size();j++){
            int idx = add[i][j];
            update(1, 0, n, 0, l[idx]-1, a[idx]);
        }
        dp[i] = query(1, 0, n, 0, i-1);
        update(1, 0, n, i, i, dp[i]);
        ans = max(ans, dp[i]);
        for(int j=0;j<del[i].size();j++){
            int idx = del[i][j];
            update(1, 0, n, 0, l[idx]-1, -a[idx]);
        }
    }
    printf("%lld\n", ans);
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	int count = 1;
	int sum = 0;
	for(int i = 0; i<a; i++)
	{
		int temp;
		cin >> temp;
		sum += temp;
		if(sum <= b) count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := nextInt()
	fmt.Println(n * n * n)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int N,A;
    cin >> N >> A;
    if (A >= N){
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 0; i < A+1; i++){
        int n = N - i;
        if (n%500 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 1;

		while(true) {

			int x = Integer.parseInt(br.readLine());

			if(x == 0) {
				break;
			}else{
				System.out.println("Case " + i + ": " + x);
				i++;
			}
		}
	}

}

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

/*
int main() {
    string S, T;
    int AC=0;
    std::cin >> S >> T;
    for(int i=0; i<3; i++){
        if(S[i]==T[i]){
            AC++;
        }
    }
    std::cout << AC << std::endl;
    return 0;
}
 */

int main(){
    int A,B;
    int hole=1;
    int tap=0;
    std::cin >> A >> B;
    while(hole<B){
        hole+=A-1;
        tap++;
    }
    std::cout << tap << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val sc: Scanner = new Scanner(input)
    val s = sc.next.toCharArray.zipWithIndex.filter {case (_, idx) => idx % 2 == 0}.map(_._1)
    new String(s)
  }

  val tests = List(
    """atcoder""".stripMargin -> """acdr""",
    """aaaa""".stripMargin -> """aa""",
    """z""" -> "z",
    "fukuokayamaguchi" -> "fkoaaauh"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

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

long long arr[105], x;
int n;
int main(){
 scanf("%d%lld", &n, &x);
 for(int i=0;i<n;i++) scanf("%lld", arr + i);
 sort(arr, arr+n);
 int sum = 0 , res = 0;
 for(int i=0;i<n;i++) {
 sum += arr[i];
 if(sum <= x ) res++;
else {
printf("%d", res);
return 0;
}
}
if(sum != x) res--;
printf("%d", res);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main() {
	int n; scanf("%d",&n);
	ll a[n+1];
	n+=1;
	rep(i,1,n) scanf("%lld",a+i);
	a[0]=mod;
	sort(a,a+n);
	reverse(a,a+n);
	ll ans=a[1];
	rep(i,3,n) ans += min(a[(i+1)/2], a[(i-1)/2]);
	printf("%lld\n",ans);
}


Measured memory_bytes: 5380
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

int main()
{
	int n;
	cin >> n;
	vector<int> A(n);

	REP(i, n) cin >> A[i];

	int max = *max_element(A.begin(), A.end());
	vector<int> B(max + 1);

	REP(i, n) {
		++B[A[i]];
	}

	REP(i, max + 1)
		REP(j, B[i]) {
			cout << i;
			if(i == max && j == B[i] - 1) cout << endl;
			else cout << ' ';
		}
	return 0;
}

Measured memory_bytes: 9044
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=300+10;
char a[maxn][maxn];
int ans[maxn][maxn];
int main()
{
    int n,m,s;
    scanf("%d%d%d",&n,&m,&s);
    int cnt=1;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='#')
                ans[i][j]=cnt++;
        }
    }
    for(int i=1; i<=n; i++)
    {
        int temp=0,cn;
        for(int j=1; j<=m; j++)
        {
            if(a[i][j]=='#')
            {
                temp=j;
                // cout<<ans[i][j]<<endl;
                for(int k=j-1; ans[i][k]==0&&k>=1; k--)
                {
                    ans[i][k]=ans[i][j];
                    //cout<<k<<" ";
                }
                //cout<<endl;
            }
        }
        if(temp!=0)
        {
            int cn=ans[i][temp];
            for(; temp<=m; temp++)
                ans[i][temp]=cn;
        }
    }



    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(ans[i][j]==0)
            {
                int k=i;
                while(ans[k][j]==0&&k<=m)
                    k++;
                int cn=ans[k][j];
                //cout<<"cn i,j:"<<cn<<" "<<i<<" "<<j<<endl;
                while(k>=i)
                    ans[k][j]=cn,k--;
            }
        }
    }
    int i=n;
    for(int j=1; j<=m; j++)
    {
        if(ans[i][j]==0)
        {
            int k=i;
            while(ans[k][j]==0&&k>=1)
                k--;
            int cn=ans[k][j];
            //cout<<"cn i,j:"<<cn<<" "<<i<<" "<<j<<endl;
            while(k<=i)
                ans[k][j]=cn,k++;
        }
    }
  for(int i=1;i<=n;i++);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
            printf("%d ",ans[i][j]);
        printf("\n");
    }

}


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

int main(){
	long long n, m, x, y, z, r;
	vector<long long> v;
	long long  adj[205][205];
	cin >> n >> m >> r;

	for( int i = 0; i < n; ++i )
		for( int j = 0; j < n; ++j ){
			if( i == j ) adj[i][j] = 0;
			else adj[i][j] = 100000000005;
		}
		

	for( int i = 0; i < r; ++i ){
		cin >> x;
		x--;
		v.push_back(x);
	}

	for( int i = 0; i < m; ++i ){
		cin >> x >> y >> z;
		x--; y--;
		if( adj[x][y] > z ){
			adj[x][y] = z;
			adj[y][x] = z;
		}
	}
	
	for( int i = 0; i < n; ++i )
		for( int j = 0; j < n; ++j )
			for( int k = 0; k < n; ++k )
				adj[j][k] = min(adj[j][k], adj[j][i] + adj[i][k]);


	/*for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j )
			cout << adj[i][j] << " ";
		cout << endl;
	}*/

	long long mini = 100000000005;
	sort(v.begin(), v.end());
	do{
		long long tot = 0;
		for( int i = 0; i < r-1; ++i )
			tot += adj[v[i]][v[i+1]];
			
		mini = min(mini, tot);
	} while( next_permutation(v.begin(), v.end()));
	cout << mini << endl;
	return 0;
	
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











ll n, m, sum, a;



void solve()
{
	cin >> n >> m;
	sum = 0;
	for(int i = 1; i <= m; i++)
	{
		cin >> a;
		sum += a;
	}
	if(sum > n)cout << "-1\n";
	else cout << n - sum << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];
    int ans = INF;
    rep(i, (1 << d))
    {
        int sum = 0, num = 0;
        rep(j, d)
        {
            if (i & (1 << j))
            {
                sum += p[j] * 100 * (j + 1) + c[j];
                num += p[j];
            }
        }
        if (sum >= g)
        {
            ans = min(ans, num);
            continue;
        }
        for (int j = d - 1; j >= 0; j--)
        {
            if (i & (1 << j))
                continue;
            int n = ((g - sum) / 100 + (j + 1) - 1) / (j + 1);
            if (p[j] >= n)
            {
                sum = g;
                num += n;
                break;
            }
            else
            {
                sum += p[j] * 100 * (j + 1) + c[j];
                num += p[j];
                if (sum >= g)
                    break;
            }
        }
        if (sum >= g)
            ans = min(ans, num);
    }
    cout << ans << endl;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    
    int ans = 0;

    if(N>1) ans += N*(N-1)/2;
    if(M>1) ans += M*(M-1)/2;

    cout << ans << endl;

}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int bubbleSort(int a[], int n) {
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = n - 1; j > i; j--) {
            if (a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                cnt++;
            }
        }
    }
    rep(k, n) {
        if (k) cout << " ";
        cout << a[k];
    }
    return cnt;
}

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

    int n;
    cin >> n;
    int a[n];
    rep(i, n) { cin >> a[i]; }
    // check
    // rep(i, n) {
    //     if (i > 0) cout << " ";
    //     cout << a[i];
    // }

    int cnt = bubbleSort(a, n);
    cout << endl;
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADodecagon solver = new ADodecagon();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADodecagon {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long r = in.nextInt();
            out.println(3 * r * r);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> q(N);
    vector<int> r(N);
    rep(i,N){
        cin >> p[i];
    }
    rep(i,N){
        cin >> q[i];
    }

    r = p;
    sort(r.begin(),r.end());
    int a,b;
    int j = 0;
    do{
        if(p == r) a = j;
        if(q == r) b = j;
        j++;
    }while(next_permutation(r.begin(),r.end()));

    int ans = abs(a-b);
    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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 psort(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    int N;
    ll M;
    M=0;
    cin >> N;
    pii A[200007];
    rep(i,N){
        cin >> A[i].first  >> A[i].second;
    }
    psort(A,N);
    rep(i,N){
        M+=A[i].first;
        if(M>A[i].second){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
}

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

int main(){
  int n,d;
  cin>> n >>d;
  vector<vector<int>> p(n,vector<int> (d));
  for (int i=0; i<n; i++){
    for (int j=0; j<d; j++) cin>> p.at(i).at(j);
  }
  
  int ans=0;
  double distance;
  for (int i=0; i<n-1; i++){
    for (int j=i+1; j<n; j++){
      distance=0;
      for (int k=0; k<d; k++) {
        distance+=pow(p.at(i).at(k)-p.at(j).at(k),2);
      }
      distance=sqrt(distance);
      if (distance==(int)distance) ans++;
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int p[30005]={0},a[30005]={0},b[30005]={0};
int main()
{	
if (0) {
puts("adsfasfdsa");
}
for (int i = 1; i <= 3; ++i) {
  a[i] = i * i;
}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	a[1]=100000;
	for(int i=2;i<=n;i++)a[i]=a[i-1]+30000;
	for(int i=1;i<=n;i++)b[n-i+1]=a[i];
	for(int i=1;i<=n;i++)b[p[i]]+=i;
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
	cout<<'\n';
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
using namespace std;
int m[3][3];
int win,lose;

void slove_yoko(){
	if(m[0][0]==1 && m[0][1]==1 && m[0][2]==1){ win=1; lose=0;}
	if(m[1][0]==1 && m[1][1]==1 && m[1][2]==1){ win=1; lose=0;}
	if(m[2][0]==1 && m[2][1]==1 && m[2][2]==1){ win=1; lose=0;}

	if(m[0][0]==0 && m[0][1]==0 && m[0][2]==0){ win=0; lose=1;}
	if(m[1][0]==0 && m[1][1]==0 && m[1][2]==0){ win=0; lose=1;}
	if(m[2][0]==0 && m[2][1]==0 && m[2][2]==0){ win=0; lose=1;}
}

void slove_tate(){
	if(m[0][0]==1 && m[1][0]==1 && m[2][0]==1){ win=1; lose=0;}
	if(m[0][1]==1 && m[1][1]==1 && m[2][1]==1){ win=1; lose=0;}
	if(m[0][2]==1 && m[1][2]==1 && m[2][2]==1){ win=1; lose=0;}

	if(m[0][0]==0 && m[1][0]==0 && m[2][0]==0){ win=0; lose=1;}
	if(m[0][1]==0 && m[1][1]==0 && m[2][1]==0){ win=0; lose=1;}
	if(m[0][2]==0 && m[1][2]==0 && m[2][2]==0){ win=0; lose=1;}
}

void slove_naname(){
	if(m[0][0]==1 && m[1][1]==1 && m[2][2]==1){ win=1; lose=0;}
	if(m[0][0]==0 && m[1][1]==0 && m[2][2]==0){ win=0; lose=1;}
	
	if(m[0][2]==1 && m[1][1]==1 && m[2][0]==1){ win=1; lose=0;}
	if(m[0][2]==0 && m[1][1]==0 && m[2][0]==0){ win=0; lose=1;}
}

void winer(){
	if(win==1) cout << 'o' << endl;
	if(win==0) cout << 'x' << endl;
	if(win==9 && lose==9) cout << 'd' << endl;
}

int main(){
	string s;
	while(cin >> s){
		int count=0;
		win=9; lose=9;
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(s[count] == 'o') m[i][j] = 1;
				if(s[count] == 'x') m[i][j] = 0;
				if(s[count] == 's') m[i][j] = 9;
				count++;
			}
		}
		slove_yoko();
		slove_tate();
		slove_naname();
		winer();
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> C, S, F;
	for (int i = 0; i < N; i++) {
		int c, s, f;
		if (i != N - 1) cin >> c >> s >> f;
		else c = s = f = 0;
		C.push_back(c);
		S.push_back(s);
		F.push_back(f);
	}
	for (int i = 0; i < N; i++) {
		int sum = S[i];
		for (int j = i; j < N - 1; j++) {
			if (sum < S[j]) sum = S[j];
			else if (sum % F[j] == 0);
			else sum = sum + F[j] - (sum % F[j]);
			sum += C[j];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef pair< int, int > Pi;
const int INF = 1 << 30;
struct edge: vector< Pi > {
  void add_edge(int to, int cost){
    push_back(Pi(to,cost));
  }
} info[100000];
int hoge[100000];

void bfs(const int& st, const int& V){
  fill_n( hoge, V, INF);
  queue< int > que;
  que.push(st);
  hoge[st] = 0;
  while(!que.empty()){
    int p = que.front();
    que.pop();
    for(int i = 0 ; i < info[p].size() ; i++){
      int cost = info[p][i].second;
      int to = info[p][i].first;
      if( cost + hoge[p] < hoge[to]){
        que.push(to);
        hoge[to] = cost + hoge[p];
      }
    }
  }
}

int main(){
  int V, E, r;
  scanf("%d %d %d", &V, &E, &r);
  for(int i = 0; i < E; i++){
    int s, t, d;
    scanf("%d %d %d", &s, &t, &d);
    info[s].add_edge( t, d);
  }
  bfs(r,V);
  for(int i = 0 ; i < V ; i++ ){
    if( hoge[i] == INF ) puts("INF");
    else printf("%d\n", hoge[i]);
  }
}

Measured memory_bytes: 10532
N = int(input())
tem = 0
Flag = False

for i in range(N):
    D1,D2 = map(int,input().split())
    
    if D1 == D2:
        tem += 1
        if tem == 3:
            Flag = True
    else:
        tem = 0


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

Measured memory_bytes: 9176
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    q = deque()
    q.extend(A)
    M = q.pop()
    x = q.popleft()
    operation = []
    while len(q) > 0:
        y = q.pop()
        if y < 0:
            operation.append((M, y))
            M -= y
        else:
            operation.append((x, y))
            x -= y

    operation.append((M, x))
    M -= x

    print(M)
    for x, y in operation:
        print('{} {}'.format(x, y))

if __name__ == '__main__':
    main()


Measured memory_bytes: 20116
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int h,w;cin>>h>>w;
    string s[h];
    rep(i,0,h)cin>>s[i];
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='.')continue;
            int y=0;
            rep(k,0,4){
                int nh=i+dh[k],nw=j+dw[k];
                if(nh<0||nh>=h||nw<0||nw>=w)continue;
                if(s[nh][nw]=='#'){
                    y=1;
                    break;
                }
            }
            if(y==0){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    a=S.count("a")
    b=S.count("b")
    c=S.count("c")
    
    aa=max(a,b,c)
    cc=min(a,b,c)
    bb=a+b+c-aa-cc
    
    pre="e"
    now="d"
    
    N=len(S)
    for i in range(N):
        if now!="a" and pre!="a":
            aa-=1
            pre=now
            now="a"
        elif now!="b" and pre!="b":
            bb-=1
            pre=now
            now="b"
        else:
            cc-=1
            pre=now
            now="c"
            
    if (aa,bb,cc) == (0,0,0):
        print("YES")
    else:
        print("NO")

main()


Measured memory_bytes: 67672
#include <iostream>
using namespace std;
void func(int x,int y);
int h,w;
char a[111][111];
int dx[4]={0,-1,0,1};
int dy[4]={-1,0,1,0};
int nx,ny;
int cnt=0;
int main(){
  int fx,fy;
  while(1){
    cin >> w >> h;
    if(h==0 && w==0)break;
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	cin >> a[i][j];
	if(a[i][j]=='@'){
	  fx=i;
	  fy=j;
	}
      }
    }
    func(fx,fy);
    cout << cnt << endl;
    cnt=0;
  }
}


void func(int x,int y){
  if(x>h || x<=0 || y>w || y<=0 || a[x][y]=='#' || a[x][y]=='0')return;
  cnt++;
  a[x][y]='0';
  for(int i=0;i<4;i++){
    nx=dx[i]+x;
    ny=dy[i]+y;
    func(nx,ny);
  }
  
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <vector>
#include <string.h>
#include <algorithm>
#include <map>
#include <string>
#include <deque>

#pragma warning(disable:4996)
#define MAX_K 15

int main(void) {
	char S[MAX_K + 1];
	scanf("%s", &S[0]);
	int len = strlen(S);
	for (int i = len; i < MAX_K; ++i) {
		S[i] = 'o';
	}
	S[MAX_K] = '\0';
	int win = 0;
	for (int i = 0; i < MAX_K; ++i) {
		if (S[i] == 'o') ++win;
	}
	if (win >= 8) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

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

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

    if(k<=a) a = a - k;
    else{
        if(b >= k-a) b = b - k + a;
        else b = 0;
        a=0;
    }

    cout << a << " " <<  b << endl;
} 

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

int main(){
	//入力を受け取る
	int N, X, T;
	cin >> N >> X >> T;

	//たこ焼きを焼く回数を求める
	int times = (N + X - 1) / X;

	//答えを求める
	int ans = times * T;

	//答えを出力する
	cout << ans << endl;
}




Measured memory_bytes: 3620
#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>;
 
int main(){
    long double a;
    long double b;
    long double c;
 
    cin >> setprecision(4) >> a;
    cin >> setprecision(4) >> b;
 
    c = a*b;
    cout << ll(c) << endl;;
}

Measured memory_bytes: 3692
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[1001];
int main()
{
  ll n, m, cnt = 0, sumOfVote = 0, flag = 0;
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", a + i);
    sumOfVote += a[i];
  }
  for (int i = 0; i < n; i++)
  {
    if (a[i] >= (double)sumOfVote / (4 * m))
      cnt++;
    if (cnt >= m)
    {
      flag = 1;
      break;
    }
  }
  puts(flag ? "Yes" : "No");
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    int N;
    cin>>N;
    vector<ll> A(N),B(N);
    rep(i,N) cin>>A[i]>>B[i];
    sort(all(A));
    sort(all(B));
    if(N%2==0){
        ll mi=A[N/2-1]+A[N/2];
        ll ma=B[N/2-1]+B[N/2];
        cout<<ma-mi+1<<endl;
    }
    else{
        ll mi=A[N/2],ma=B[N/2];
        cout<<ma-mi+1<<endl;
    }
}

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

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

    string s;
    cin >> s;
    int n = s.size();

    vector<int> l, r, ans;
    l.resize(n, -1);
    r.resize(n, -1);
    ans.resize(n, 0);

    // fill left
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'L') {
            l[i] = s[i - 1] == 'L' ? l[i - 1] + 1 : 0;
        }
    }

    // fill right
    for (int i = n - 2; i >= 0; --i) {
        if (s[i] == 'R') {
            r[i] = s[i + 1] == 'R' ? r[i + 1] + 1 : 0;
        }
    }

    // fill ans
    for (int i = 0; i < n; ++i) {
        int index = i;
        if (s[i] == 'L') {
            index -= l[i] + (l[i] & 1);
        } else {
            index += r[i] + (r[i] & 1);
        }
        ans[index]++;
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i];
        if (i < n - 1) cout << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1872