akhauriyash/Code-Regression huggingface dataset:
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	fio();
	cin>>n>>s;
	cev=1;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1])continue;
		cev++;
	}
	cout<<cev<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int dp[5005][5005];
int main(void){
	int N;
	cin >> N;
	string s;
	cin >> s;
	for(int i=0;i<N;i++)if(s[i]==s[N-1])dp[i][N-1] = 1;
	for(int i=N-2;i>=0;i--)for(int j=N-1;j>=0;j--){
		if(s[i]==s[j]){
			if(i+1>=0&&i+1<=N-1&&j+1<=N-1&&j+1>0)dp[i][j] = dp[i+1][j+1]+1;
			else dp[i][j] = 1;
		}
	}
	int ans = 0;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)ans = max(ans,min(abs(i-j),dp[i][j]));
	cout << ans << endl;
}

Measured memory_bytes: 98048
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<char>> grid(H, vector<char>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> grid[i][j];

	int ans = 0;
	for (int bith = 0; bith < (1 << H); bith++) {
		for (int bitw = 0; bitw < (1 << W); bitw++) {

			auto tmp = grid;
			int cnt = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if ((bith & (1 << i)) || (bitw & (1 << j))) tmp[i][j] = '.';
					if (tmp[i][j] == '#') cnt++;
				}
			}
			if (cnt == K) ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}



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

const ll MAXX = 1e18L + 1;
int main()
{
    int n;
    ll w;
    scanf("%d %lld", &n, &w);
    ll wt[n];
    int val[n];
    int sum_val = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> wt[i] >> val[i];
        sum_val += val[i];
    }

    //Now to achieve profit of value sum_val, using n items of weights and values
    //dp[item][profitval] = minweight(using nth item , not using nth item)
    //dp[item][profitval] = minweight(dp[item-1][profitval - val[item]] + weight[item],dp[item-1][profitval]);
    ll dp[n + 1][sum_val + 1];
    dp[0][0] = 0; //0 profit using 0 items
    for (int i = 1; i <= n; i++)
        dp[i][0] = 0; //can achieve a profit value of 0 by using i items
    for (int j = 1; j <= sum_val; j++)
        dp[0][j] = MAXX; //can't achieve profitvalue of j with 0 items

    for (int item = 1; item <= n; item++)
    {
        for (int v = 1; v <= sum_val; v++)
        {
            dp[item][v] = dp[item - 1][v];
            if (val[item - 1] <= v && dp[item - 1][v - val[item - 1]] != MAXX)
            {
                dp[item][v] = min(dp[item][v], dp[item - 1][v - val[item - 1]] + wt[item - 1]);
            }
        }
    }
    ll ans = 0;
    for (int v = 1; v <= sum_val; v++)
    {
        if (dp[n][v] <= w)
        {
            ans = max(ans, (ll)v);
        }
    }
    printf("%lld \n", ans);
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<int> a(n + 1);
   rep(i, 0, n) cin >> a[i];
   a[n] = INF;
   rep(i, 0, n) {
      if (i == 0 || a[i] > a[i - 1]) a[i]--;
      if (a[i] > a[i + 1]) {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,count1=0,count2=0,k;
  cin >> N;
  vector<string> nin(N);
  for(int i=0;i<N;i++) cin >> nin.at(i);
  cin >> M;
  vector<string> min(M);
  for(int i=0;i<M;i++) cin >> min.at(i);
  for(int i=0;i<N;i++){
    if(nin.at(i) == "0") continue;
    if(N>=M) k = N;
    else k = M;
    for(int j=0;j<k;j++){
      if(j<N){
        if(nin.at(i) == nin.at(j)){
          count1++;
          nin.at(j) == "0";
        }
      }
      if(j<M){
        if(nin.at(i) == min.at(j)){
        count1--;
        min.at(j) == "0";
        }
      }
    }
    if(count1>count2) count2 = count1;
    count1 = 0;
  }
  cout << count2;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i,k,which=0;
  int term=7;
  int number_terms=1; 
  scanf("%d",&k);  
    
  while(number_terms<=k){
    if(term%k == 0){
      printf("%d",number_terms);
      which=1;
      break;
    }
    term=(term*10+7)%k;
    number_terms++;
  }

  if(which==0){
    printf("-1");
  }
  
  return 0;
}

Measured memory_bytes: 1732
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,b,a[li],k,flag,cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d",&n,&m);
	if(n>=13){printf("%d\n",m);return 0;}
	else if(n>=6 && n<=12){printf("%d\n",m/2);return 0;}
	else{printf("0\n");return 0;}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
const int Maxn=100;
int n;
int d[Maxn+5][2];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&d[i][0],&d[i][1]);
	}
	for(int i=1;i<=n-2;i++){
		if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 1664
def setHeapDown_max(heap, pos):
    targetkey = heap[pos]
    while pos > 0:
        parentpos = (pos - 1) >> 1
        parent = heap[parentpos]
        if parent < targetkey:
            heap[pos] = parent
            pos = parentpos
            continue
        break
    heap[pos] = targetkey

def setHeapUp_max(heap, pos):
    endpos = len(heap)
    targetkey = heap[pos]
    childpos = 2*pos + 1
    while childpos < endpos:
        rightpos = childpos + 1
        if rightpos < endpos and not heap[rightpos] < heap[childpos]:
            childpos = rightpos
        childkey = heap[childpos]
        if targetkey > childkey:
            break
        heap[pos] = childkey
        pos = childpos
        childpos = 2*pos + 1
    heap[pos] = targetkey

def heapPush_max(heap, key):
    heap.append(key)
    setHeapDown_max(heap, len(heap) - 1)

def heapPop_max(heap):
    lastkey = heap.pop()
    if heap:
        returnkey = heap[0]
        heap[0] = lastkey
        setHeapUp_max(heap, 0)
        return returnkey
    return lastkey


import sys

S = []

ans = []

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        heapPush_max(S, k)
    elif x[1] == 'x':
        ans.append(heapPop_max(S))
    else:
        pass

print(*ans, sep = '\n')

Measured memory_bytes: 208376
N = int(input())
S = input()

SS = list(S)

NN = N // 2

count = 0

if N % 2 == 1:
    print('No')
else:
    for i in range(NN):
        if SS[i] != SS[i+NN]:
            count += 1
            print('No')
            break
    if count == 0:
        print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
long long a[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	int fu=0;
	long long sum=0;
	int flag=0;
	long long minn=0x3f3f3f3f;
	for(int i=1; i<=n; i++)
	{
		scanf("%lld",&a[i]);
		sum+=abs(a[i]);
		if(a[i]<0)
			fu++;
		if(a[i]==0)
			flag=1;
		if(a[i]==0)
			continue;
		minn=min(minn,abs(a[i]));
	}
	long long ans;
	if(flag||fu%2==0)
		ans=sum;
	else if(fu%2==1)
		ans=sum-minn*2;
//	printf("%lld %lld\n",sum,minn);
	printf("%lld",ans);
	

}

Measured memory_bytes: 1024
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	var mask int
	k := getNextInt(scanner)
	for i := 0; i < k; i++ {
		b := getNextInt(scanner)
		mask = mask | (1 << uint(b))
	}
	mask = mask ^ math.MaxInt32
	for i := 0; i < 1<<uint(n); i++ {
		if 0 != i&mask {
			continue
		}
		fmt.Fprintf(writer, "%d:", i)
		for j := 0; j < n; j++ {
			if (i>>uint(j))&1 == 1 {
				fmt.Fprint(writer, " ")
				fmt.Fprint(writer, j)
			}
		}
		fmt.Fprintln(writer, "")
	}
}



Measured memory_bytes: 5268
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(h)]
    dp = [[0] * w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                dp[i][j] = 0
            elif i == 0 and j == 0:
                dp[i][j] = 1
            elif i == 0:
                dp[i][j] = dp[i][j-1]
            elif j == 0:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod
    print(dp[-1][-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 86896
a=int(input())
x = list(map(int,input().split()))
x = [0]+x+[0]
s = 0
for i in range(1,a+2):
    s+=abs(x[i-1]-x[i])
for i in range(1,a+1):
    print(s+abs(x[i-1]-x[i+1])-(abs(x[i-1]-x[i])+abs(x[i]-x[i+1])))


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

#define FOR(i,s,t) for(int i = s; i < t; i++)

using LL = long long;


int main() {

	// W<=100
	int N, H, W; cin >> N >> H >> W;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	vector<int> B(10004);
	FOR(i, 0, N) {
		if (i % 2 == 0) {// to R
			int s = W * i + a[i];
			int t = s + W;
			FOR(j, s, t) {
				B[j] = 1;
			}
		}
		else { // to L
			int s = W * i - a[i];
			int t = s + W;
			FOR(j, s, t) {
				B[j] = 1;
			}
		}
	}
	int ans = 0;
	FOR(i, 0, W*N) {
		if (!B[i]) {
			ans += H;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3148
val SUITS_LIST = arrayListOf("S","H","C","D")
val NUM_LIST   = arrayListOf(1,2,3,4,5,6,7,8,9,10,11,12,13)

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val allCards : HashMap<String, Boolean> = hashMapOf()
    (1..n).forEach {
        val suitAndNum= readLine() ?: return
        allCards[suitAndNum] = true
    }
    val lostCards: ArrayList<String> = arrayListOf()
    SUITS_LIST.forEach{ suit ->
        NUM_LIST.forEach{ num ->
            val suitAndNum = "$suit $num"
            if(allCards[suitAndNum] == null) lostCards.add(suitAndNum)
        }
    }
    lostCards.forEach { suitAndNum ->
        println(suitAndNum)
    }
}




Measured memory_bytes: 27628
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
	if(m==0) return 1;
	if(i>=n) return 0;
	int res=solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if(solve(0,M))printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N;
  cin >> N;
  int C[N];
  rep(i, N){
    cin >> C[i];
  }
  int cnt = 0;
  rep(i, N){
    if(C[i] != (i+1))
      cnt ++;
  }
  if(cnt==0|| cnt == 2){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}
  

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();


      if (a==1&&c==2||a==3&&c==4||a==5&&c==6||a==7&&c==8||a==8&&c==9||a==10&&c==11||a==12&&c==1) {
        if(b==31&&d==1){
          System.out.println(1);
          System.exit(0);
        }
      }

      if (a==2&&c==3||a==4&&c==5||a==6&&c==7||a==9&&c==10||a==11&&c==12) {
        if (b==30&&d==1) {
          System.out.println(1);
          System.exit(0);
        }
      }
      if(a==2&&c==3){
        if(b==28&&d==1){
          System.out.println(1);
          System.exit(0);
        }
      }
      System.out.println(0);
  }
}


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

int main() {
  ll h, w, m = 100000;
  cin >> h >> w;
  if(h % 3 && w % 3) {
    m = min(h, w);
    ll a, b, c;
    for(int j = 0; j < 2; j++) {
      for(int i = 0; i < h % 3; i++) {
        ll l = h / 3 + i;
        a = l * w;
        if(w % 2) {
          b = (h - l) * (w / 2);
          c = (h - l) * (w / 2 + 1);
          ll ma = max(max(a, b), c), mi = min(min(a, b), c);
          m = min(ma - mi, m);
        } else {
          b = (h - l) * w / 2;
          m = min(abs(a - b), m);
        }
      }
      swap(h, w);
    }
    cout << m << endl;
  } else
    cout << 0 << endl;
}

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

int main() {

  int N ,M;
  cin>>N;
  vector<string> vecN(N);
  for(int i=0;i<N;i++){
  	cin>>vecN.at(i);
  //  cout<<vecN.at(i)<<endl;
  }
  cin>>M;
  vector<string> vecM(M);
  for(int i=0;i<M;i++){
  	cin>>vecM.at(i);
   // cout<<vecM.at(i)<<endl;
  }
  
  int count = 0;
  int A = 0;
  for(int i =0;i<N;i++){
  	for(int j= 0;j<N;j++){
    	if(vecN.at(i)==vecN.at(j)){
        	count++;
      }
    }
    
    for(int j=0;j<M;j++){
    	if(vecN.at(i)==vecM.at(j)){
       		count--;
        }
    }
    
    if(A<count){
    	A = count;
    }
    
    count=0;
    
  }
  
  if(A>0){
  	cout<<A<<endl;
  }
  else{
  	cout<<0<<endl;
  }
  
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  vector<int>b(9);
  for(int i=0;i<9;i++)cin>>b[i];
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<9;j++){
      if(a[i]==b[j])b[j]=-1;
    }
  }
  bool ans=false;
  if(b[0]==-1 && b[3]==-1 &&b[6]==-1)ans=true;
  if(b[1]==-1 && b[4]==-1 &&b[7]==-1)ans=true;
  if(b[2]==-1 && b[5]==-1 &&b[8]==-1)ans=true;
  if(b[0]==-1 && b[1]==-1 &&b[2]==-1)ans=true;
  if(b[3]==-1 && b[4]==-1 &&b[5]==-1)ans=true;
  if(b[6]==-1 && b[7]==-1 &&b[8]==-1)ans=true;
  if(b[0]==-1 && b[4]==-1 &&b[8]==-1)ans=true;
  if(b[2]==-1 && b[4]==-1 &&b[6]==-1)ans=true;
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  
    

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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b) * a + min(n % (a + b), a)) << endl;
}


Measured memory_bytes: 3604
import sys
N, X = (int(x) for x in input().split())
L = list(map(int, input().split()))

count = 0
ans = 0
for i in range(N+1):                                                                                                                                                                                        
    if count != 0:                                                                                                                                                                                          
        ans = ans + L[count - 1]                                                                                                                                                                            
    if ans > X:                                                                                                                                                                                             
        print(count)                                                                                                                                                                                        
        sys.exit()                                                                                                                                                                                          
                                                                                                                                                                                                            
    count += 1                                                                                                                                                                                              

print(N+1)


Measured memory_bytes: 3060
fun rec(s: String, input: Array<Array<String>>, pos: Int): Int {
	var p = pos
	for (i in input) {
		if (s[p] == i[0][0]) p += if (i[1][0] == 'L') -1 else 1
		if (p < 0 || p >= s.length) return p
	}
	return p
}

fun main(args: Array<String>) {
	val (n, q) = (readLine() ?: return).split(" ").map { it.toInt() }
	val s = readLine() ?: return

	val input = Array(q) { (readLine() ?: return).split(" ").toTypedArray() }

	val left = rec(s, input, 0)
	val right = rec(s, input, n - 1)
	if (left == right) {
		println(0)
		return
	}

	val leftP = when {
		left >= 0 -> 0
		else -> {
			var l = 0
			var r = n - 1
			while (l + 1 < r) {
				val m = l + (r - l) / 2
				val mid = rec(s, input, m)
				if (mid < 0) l = m
				else r = m
			}
			r
		}
	}
	val rightP = when {
		right <= n-1 -> n-1
		else -> {
			var l = 0
			var r = n - 1
			while (l + 1 < r) {
				val m = l + (r - l) / 2
				val mid = rec(s, input, m)
				if (mid > n-1) r = m
				else l = m
			}
			l
		}
	}
	println(rightP-leftP+1)
}

Measured memory_bytes: 103184
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  vector<int> b;
  rep (i, n) {
    int a;
    cin >> a;
    if (i % 2 != 0) b.push_back(a);
    else b.insert(b.begin(), a);
  }

  if (n % 2 == 0) reverse(b.begin(), b.end());
  rep (i, b.size()) {
    cout << b[i] << " ";
  }
  cout << endl;


  return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double llf;
#define ft first
#define sd second
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(b<10)a*=10;
	else if(b<100)a*=100;
	else a*=1000;
	a+=b;
	b=sqrt(a);
	if(b*b==a)puts("Yes");
	else puts("No");
}

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

using namespace std;
using i64 = int64_t;

signed main(){
    
    int n;
    cin >> n;
    vector<i64> x(n), r(n);
    for(int i = 0; i < n; ++i)
        cin >> x[i] >> r[i];
    
    auto f = [&](double y){
        double mi = -1e18, ma = 1e18;
        for(int i = 0; i < n; ++i){
            if(r[i] * r[i] - y * y < 0)
                return false;
            double v = sqrt(r[i] * r[i] - y * y);
            if(mi < x[i] - v)
                mi = x[i] - v;
            if(ma > x[i] + v)
                ma = x[i] + v;
        }
        return mi <= ma;
    };
    double ok = 0, ng = 1e9 + 3;
    for(int i = 0; i < 500; ++i){
        double mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    printf("%.20lf\n", ok);
    
    return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = { -1, 1, 0, 0, 1, -1, -1, 1};

void solve() {
    int n;
    cin >> n;
    vi a(n+1), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n-1) cin >> b[i];
    int ans = 0;
    rep(i, 0, n-1){
        debug() << imie(a[i]) imie(b[i]) imie(ans);
        if(b[i] >= a[i]){
            ans += a[i];
            b[i]-=a[i];
            a[i] = 0;
        }else{
            ans += b[i];
            a[i]-=b[i];
            b[i] = 0;
        }
        if(b[i] >= a[i+1]){
            ans += a[i+1];
            b[i] -= a[i+1];
            a[i+1] = 0;
        }else{
            ans += b[i];
            a[i+1] -= b[i];
            b[i] = 0;
        }
    }
    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
	// test
	solve();
	return 0;
}


Measured memory_bytes: 8432
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int h,w;
    R(h,w);
    if(h==1||w==1)W(1);
    else W((h*(LL)w+1)/2);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const ll M = 998244353;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
    ll n,a,b,k;
    cin >> n >> a>> b >> k;
    
    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    
    
    ll ans = 0;
    for(ll x = 0; x<=n; x++){
        if((k-a*x)%b !=0 ) continue;
        ll y = (k-a*x)/b;
        if(y<0 || y>n) continue;
        ans += comb(n, x)* comb(n, y) % M;
        ans %= M;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    set<int> s;
    int n;
    VI a;
    scanf("%d",&n);
    REP(i,n){
        int tmp;
        scanf("%d",&tmp);
        a.pb(tmp);
        s.insert(tmp);
    }
    SORT(a);

    int ans = 0;
    for(set<int>::iterator it=s.begin();it!=s.end();it++){
        int item = *it;
        int num = UB(all(a),item) - LB(all(a),item);
        if(num>=item) ans += num - item;
        else ans += num;
    }

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

Measured memory_bytes: 5112
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 998244353;
const double PI = 2 * acos(0);

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	while (M--) {
		int x;
		scanf("%d", &x);
		N -= x;
	}
	if (N < 0) printf("-1\n");
	else printf("%d\n", N);
}


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

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MAX_N 5001
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
string s, ans;

int gcd(int a, int b){
	if (b == 0)return false;

	if (b == 1)return true;

	return gcd(b, a%b);
}

int main(){
	cin >> n;
	cin.ignore();
	REP(i, n){
		getline(cin, s);
		bool f = 0;
		for (int j = 1; j < 26; j++){
			if (!gcd(26, j))continue;
			for (int k = 0; k < 26; k++){
				//cout << j << " " << k << endl;
				REP(l, s.size()){
					if (s[l]<'a' || s[l]>'z'){
						ans += s[l];
						continue;
					}
					ans += (j*(s[l] - 'a') + k) % 26 + 'a';
				}
				if (ans.find("this") != -1
					|| ans.find("that") != -1)f = 1;
				if (f)break;
				ans.clear();
			}
			if (f)break;
		}

		cout << ans << endl;
		ans.clear();
	}
}

Measured memory_bytes: 1212
import itertools

h,w,k=map(int, input().split())

cij=[[""]*w for i in range(h)]
for i in range(h):
    cij[i]=list(input())

icnt=0
for i in itertools.product([0,1], repeat=h):
    for j in itertools.product([0,1], repeat=w):
        csum=0
        for ii in range(h):
            if i[ii]==1:
                for jj in range(w):
                    if j[jj]==1:
                        if cij[ii][jj]=="#":
                            csum+=1
        if csum==k:
            icnt+=1

print(icnt)
    

Measured memory_bytes: 9152
def func(N):
    tmp=N
    arr=[]
    for i in range(2,int(-(-N**0.5//1))+1):
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
            
    if tmp!=1:
        arr.append([tmp, 1])
    if arr==[]:
        arr.append([tmp,1])
   
    return arr

N=int(input())
a=func(N)
ans=0
if a[0][0]==1:
        print(0)
        exit()
        
b=[1,3,6,10,15,21,28,36,45]
for i in a:
    for j in range(len(b)):
       if  i[1]<b[j]:
          ans+=j
          break
print(ans)
    
            

Measured memory_bytes: 9420
rgb = set(["r","g","b"])
while 1:
	worm = raw_input()
	if worm == "0": break
	n = len(worm)
	que = [worm]
	ref = set(worm)
	L = 1
	cnt = flag = 0
	while 1:
		for r in range(L):
			Worm = que.pop(0)
			if Worm in ref: continue
			else: ref.add(Worm)
			if len(set(Worm)) == 1:
				flag = 1
				break
			for i in range(n-1):
				if Worm[i] != Worm[i+1]:
					worm = Worm[:]
					nextclr = list(rgb-set(worm[i:i+2]))[0]
					worm = worm[:i] + 2*nextclr + worm[i+2:]
					if worm not in que: que.append(worm)
		L = len(que)
		if flag or L == 0: break
		cnt += 1
		if cnt > 15: break
	print cnt if flag else "NA"

Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
string a,b;
typedef long long LL;
const int MOD=1e9+7;
int n,dom[2][100],cnt,rez=1,dp[100];
int main()
{
    cin>>n;
    cin>>a>>b;
    int i=0;
    while(i!=n){
        if(a[i]==b[i]){
            if(i==0){
                rez=(rez*3)%MOD;
            }
            else{
                if(a[i-1]==b[i-1]){
                    rez=(rez*2)%MOD;
                }
            }
            i++;
        }
        else{
            if(i==0){
                rez=(rez*6)%MOD;
            }
            else{
                if(a[i-1]==b[i-1]){
                    rez=(rez*2)%MOD;
                }
                else{
                    rez=((LL)rez*3)%MOD;
                }
            }
            i+=2;
        }
    }
    printf("%d",rez);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c; 
  vector<int>p(a);
  for(int i=0;i<a;++i){
    cin>>p.at(i);   
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  vector<int>q(b);
  for(int i=0;i<b;++i){
    cin>>q.at(i);   
  }
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  vector<int>r(c);
  for(int i=0;i<c;++i){
    cin>>r.at(i);   
  }
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  
  vector<int>ans(x+y);
  for(int i=0;i<x;++i){
    ans.at(i)=p.at(i);
  }
  for(int i=0;i<y;++i){
    ans.at(i+x)=q.at(i);
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<min(c,x+y);++i){
    if(ans.at(i)<=r.at(i)){
      ans.at(i)=r.at(i);
    }
    else{
      break;
    }
  }
  long to=0;
  for(int i=0;i<x+y;++i){
    to+=ans.at(i);
  }
    cout<<to<<endl;
  

}







Measured memory_bytes: 2176
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  int n,d,x,a;
  cin >> n >> d >> x;
  REP(i,n){
    cin >> a;
    x += (d-1)/a;
  }
  cout << x+n;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int l = sc.nextInt();
        int[] res = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            res[i] = l + i;
            max += res[i];
        }
        int sub = Integer.MAX_VALUE;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int nokori = max - res[i];
            if (Math.abs(max - nokori) <= sub) {
                sub = Math.abs(max - nokori);
                ans = nokori;
            }
        }
        System.out.println(ans);
    }
}

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: 20692
#include <iostream>

using namespace std;

int main()
{
    int N, ans;
    int a[2][100];

    cin >> N;
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < N; j++)
            cin >> a[i][j];

    ans = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp = 0;

        int j = 0;
        while (j <= i)
        {
            tmp += a[0][j];
            j++;
        }
        j--;
        while (j < N)
        {
            tmp += a[1][j];
            j++;
        }

        if (ans < tmp)
            ans = tmp;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int a,b,c;
  cin >> a >> b >> c;
  int ans = a+b+c+max({a,b,c})*9;
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
	int tate, yoko, menseki, shuu;
	
	scanf("%d %d", &tate, &yoko);
	menseki = tate * yoko;
	shuu = (tate + yoko) * 2;
	printf("%d %d\n", menseki, shuu);
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vec1 players(n, k);

  int a;
  while(cin >> a) {
    players.at(a-1)++;
  }

  for(int i = 0; i < players.size(); i++) {
    if(players.at(i) - q > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(a: int, b: int, c: int):
    ret = NO
    s = a + b + c
    if s % 2 == 0 and (a == s // 2 or b == s // 2 or c == s // 2):
        ret = YES
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 10;
const int maxv = 1e6 + 10;
const ll mod = 1e9 + 7;
int a[maxn], mind[maxv], cnt[maxv], maxcnt[maxv];
vector<int> prime, E[maxv];
bool flag[maxv], in[maxv];
ll ans;
ll inv[maxv];
void dfs(int rt)
{
	for(auto v : E[rt])
	{
		int d = v / rt;
		++cnt[d];
		maxcnt[d] = max(maxcnt[d], cnt[d]);
		dfs(v);
		--cnt[d];
	}
}
int main()
{
	inv[1] = 1;
	for(int i = 2; i < maxv; ++i)
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	for(int i = 2; i < maxv; ++i)
	{
		if(!flag[i])
			prime.push_back(i), mind[i] = i;
		for(auto v : prime)
		{
			if(1ll * v * i >= maxv)
				break;
			flag[v * i] = 1;
			mind[v * i] = v;
			if(i % v == 0)
				break;
		}
	}
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		in[a[i]] = 1;
	}
	for(int i = maxv - 1; i > 1; --i)
		if(in[i])
		{
			in[i / mind[i]] = 1;
			E[i / mind[i]].push_back(i);
		}
	dfs(1);
	ll lcm = 1;
	for(int i = 2; i < maxv; ++i)
		while(maxcnt[i])
		{
			--maxcnt[i];
			lcm = lcm * i % mod;
		}
	for(int i = 1; i <= n; ++i)
		ans = (ans + lcm * inv[a[i]]) % mod; 
	printf("%I64d\n", ans);
	return 0;
}
		

Measured memory_bytes: 46200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
const int mod = 998244353;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
template<typename T>
struct BIT {
int n;
vector<T> d;
BIT(int n=0):n(n),d(n+1) {}
void add(int i, T x=1) {
for (i++; i <= n; i += i&-i) {
d[i] += x;
}
}
T sum(int i) {
T x = 0;
for (i++; i; i -= i&-i) {
x += d[i];
}
return x;
}
};
mint f(int a,int b,int c, int d){
    mint res=0;
    vector<int> num={a,b,c,d};
    vector<mint> o(4),ox(4);
    for(int i=0;i<4;i++){
        ox[i]=mint(2).pow(num[i]);
        o[i]=ox[i]-1;
    }
    res+=ox[0]*o[1]*o[2]*ox[3];
    res+=o[0]*ox[1]*ox[2]*o[3];
    res-=o[0]*o[1]*o[2]*o[3];
    res+=ox[0]*ox[1]*ox[2]*ox[3];
    return res;
}
int main(){
    int n;cin >> n;
    vector<P> p(n);
    for(int i=0;i<n;i++) cin >> p[i].first >> p[i].second;
    {
        map<int,int> mp;
        for(int i=0;i<n;i++){
            mp[p[i].first]=0;
        }
        int j=0;
        for(auto&& pp: mp) pp.second=j++;
        for(int i=0;i<n;i++) p[i].first=mp[p[i].first];
    }
    {
        map<int,int> mp;
        for(int i=0;i<n;i++){
            mp[p[i].second]=0;
        }
        int j=0;
        for(auto&& pp: mp) pp.second=j++;
        for(int i=0;i<n;i++) p[i].second=mp[p[i].second];
    }
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    vector<int> d(n);
    sort(p.begin(),p.end());
    for(int i=0;i<2;i++){
        BIT<int> bit(n);
        for(int j=0;j<n;j++){
            a[j]=bit.sum(p[j].second);
            b[j]=j-a[j];
            bit.add(p[j].second);
        }
        reverse(p.begin(),p.end());
        swap(a,c);
        swap(b,d);
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        reverse(c.begin(),c.end());
        reverse(d.begin(),d.end());
    }
    mint ans=0;
    for(int i=0;i<n;i++){
        ans+=f(a[i],b[i],c[i],d[i]);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 13184