akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////


int main() {
	int N, K; cin >> N >> K;
	int h[100100];
	int ans = 0;
	REP(i, N) {
		cin >> h[i];
		if (h[i] >= K)ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){

	int n;
	
	while(cin>>n){

		int sum = 100000;


		for(int i=0;i<n;i++){

			sum *= 105/100.0;

			if((int)sum%1000>=1){
				sum /= 1000;
				sum *= 1000;
				sum += 1000;
			}
		}
		printf("%d\n",(int)sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main() {
	int n, t, sum = 0, s, f;
	while(cin >> n&&n != 0) { 
		sum = 0;
		cin >> t;
		for (int i = 0; i < t; i++) {
			cin >> s >> f;
			sum += (f - s);
		}
		if (n <= sum) { cout << "OK" << endl; }
		else { cout << n - sum << endl; }
	}
}

Measured memory_bytes: 3112
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
using namespace std;
#define MAX 500000

int N, H[MAX + 1];

void maxHeapify(int ix) {
	int max = ix, l = ix * 2, r = l + 1;

	if ((l <= N) && (H[l] > H[max])) max = l;
	if ((r <= N) && (H[r] > H[max])) max = r;

	if (max != ix) {
		swap(H[ix], H[max]);
		maxHeapify(max);
	}
}

void buildMaxHeap() {
	for (int i = N / 2; i >= 1; i--) maxHeapify(i);
}

int main() {

	cin >> N;
	for (int i = 1; i <= N; i++) cin >> H[i];

	buildMaxHeap();

	for (int i = 1; i <= N; i++) cout << " " << H[i];
	cout << endl;

	return 0;
}


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

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

    int del = a - b;
    int move = c - del;

    int ans;

    if (del >= c){
        ans = 0;
    }
    else{
        ans = c - del;
    }

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

Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp;


fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {

    let (n, w): (usize, usize) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1])
    };

    let mut wv = Vec::new();
    for _ in 0..n {
        let temp: Vec<i64> = read_vec();
        wv.push((temp[0], temp[1]));
    }
    //dp_tableを品物の個数と価値を横軸と縦軸にして作成する
    // 重さが記録されていくので、実現不可能な重さで初期化する
    let mut dp: Vec<Vec<i64>> = vec![vec![1000000001; 100001]; n+1];
    dp[0][0] = 0;

    for i in 1..n+1 {
        for v in 0..100001 {
            if v < wv[i-1].1 as usize{
                dp[i][v] = dp[i-1][v];
            } else {
                dp[i][v] = cmp::min(dp[i-1][v], dp[i-1][v-wv[i-1].1 as usize] + wv[i-1].0);
            }
        }
    }

    let mut ans = 0;
    for i in 0..100001 {
        if dp[n][i] <= w as i64 {
            ans = i;
        }
    }
    println!("{}",ans );
}


Measured memory_bytes: 106748
n, k = [int(i) for i in input().split()]
ans = 0
if k == 0:
    ans = n*n
else:
    for b in range(k+1, n+1):
        # number of perfect cycle
        ans += max(n // b, 0) * (b-k)
        r = n % b
        ans += max(r - k+1, 0)
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ab = sc.next() + sc.next();
        int abInt = Integer.parseInt(ab);
        
        int root = (int) Math.sqrt(abInt);
        if (root * root == abInt) {
            System.out.println("Yes");
            
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]

class Util():
    def round_up(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

N = cin.int()
dp = [0] * (N + 1)
dp[0] = 0
for i in range(1,N + 1):
    dp[i] = i
    p = 1
    while p <= i:
        dp[i] = min(dp[i],dp[i - p] + 1)
        p *= 6
    p = 1
    while p <= i:
        dp[i] = min(dp[i],dp[i - p] + 1)
        p *= 9
print(dp[N])


Measured memory_bytes: 42348
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  list<int>st[1000];
  list<int>::iterator it;
  int n,tc,q,t,s;
  ll x;
  cin>>n>>tc;
  while(tc--)
  {
    cin>>q;
    if(q==0)
    {
      cin>>t>>x;
      st[t].push_back(x);
    }
    else if(q==1)
    {
      cin>>t;
      for(it=st[t].begin();it!=st[t].end();it++)
      {
        if(it!=st[t].begin())cout<<" ";
        cout<<*it;
      }
      cout<<endl;
    }
    else if(q==2)
    {
      cin>>s>>t;
      st[t].splice(st[t].end(),st[s]);
    }
  }
}



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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;


lli n, a, b, common ;
vector <lli> data;

bool checker(lli x){
	vector <lli> temp;
	lli i;
	for(i = 0; i < n; ++i)
		temp.pb(data[i]-x*b);

	for(i = 0; i < n; ++i){
		if(temp[i] > 0){
			
			if(temp[i] % common)
				x = x - temp[i]/common - 1;
			else
				x = x - temp[i]/common;
		}
	}
	if( x >= 0)
		return true;
	return false;
}
int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	fastIO;
	cin >> n >> a >> b;
	common = a-b;
	lli i, t;

	for(i = 0; i < n; ++i)
	{
		cin >> t;
		data.pb(t);
	}

	lli upper = 1000000000, lower = 0, mid;

	while(true){

		if(lower == upper){
			cout << lower << "\n";
			break;
		}
		if(upper == lower+1){
			if(checker(lower))
				cout << lower << "\n";
			else
				cout << upper << "\n";
			break;
		}
		mid = (lower+upper)/2;

		if(checker(mid)){
			upper = mid;
		}
		else{
			lower = mid+1;
		}
	}
}

Measured memory_bytes: 2924
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100000 + 10 ;
int main(int argc, char *argv[])
{
	int n,i,j,maxa=0;
	int a[maxn]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&j);
		a[j]++;
		a[j+1]++;
		a[j-1]++;
	}
	for(i=0;i<100000;i++)
	{
		if(maxa<a[i])maxa=a[i];
	}
	printf("%d\n",maxa);
	return 0;
}

Measured memory_bytes: 640
require 'pp'
h, w, a, b = gets.split.map(&:to_i)

# 絶対に"No"出して、全部waになるか確認しよう。
arr = Array.new(h) { Array.new(w, 1) }
# pp arr
b.times do |bb|
  w.times do |ww|
    arr[bb][ww] = -1
  end
end
# pp arr
h.times do |bb|
  a.times do |aa|
    arr[bb][aa] *= (-1)
  end
end
# pp arr

puts arr.map{|x|x.map{|xx| xx == 1 ? '1' : '0'}.join}.join("\n")


Measured memory_bytes: 13180
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	int n,i,j;
	cin>>n;
	int a[n+1][3];
	for(i=1;i<=n;i++)
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	int dp[n+1][3];
	dp[1][0]=a[1][0];
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	for(i=2;i<=n;i++){
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


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

int main(void){
  int n;cin >> n;
  string s;cin >> s;
  int m;cin >> m;
  char a = s.at(m-1);
  rep{
    if(s.at(i) != a){
      s.at(i) = '*';
    }
  }
  
  put(s);
}

Measured memory_bytes: 256
#include <iostream> 
using namespace std;
 
int main(){
    string c;
    int m; 
    while(cin>>c,c!="-"){
        for(cin>>m;m>0;m--){
            int h;
            cin >> h;
            c = c.substr(h) + c.substr(0, h);
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 3196
import sys
import math
#import random
#sys.setrecursionlimit(100000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n=inp()

i=2
fact=[]

while i*i<=n:
	cnt=0
	while n%i==0:
		n//=i
		cnt+=1
	if cnt:
		fact.append(cnt)
	
	i+=1

if n>1:
	fact.append(1)

ans=0

def koyta(n):
	i=1
	curr=0
	while i<=n:
		n-=i
		curr+=1
		i+=1
	
	return curr 

for num in fact:
	ans+=koyta(num)

print(ans)
	


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int k,t;
int ma,a;

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

	cin>>k>>t;
	REP(i,t) {
		cin>>a;
		ma=max(ma,a);
	}
	cout<<max(ma-1-(k-ma),0)<<endl;

	return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	ll n;cin >> n;
	vector<string> name(n);
	ll initial[5];
	rep(i,5){
		initial[i] = 0;
	}
	rep(i,n) {
		cin >> name[i];
		char c = name[i][0];
		if(c == 'M'){
			initial[0]++;
		}else if(c=='A'){
			initial[1]++;
		}else if(c=='R'){
			initial[2]++;
		}else if(c=='C'){
			initial[3]++;
		}else if(c=='H'){
			initial[4]++;
		}
	}
	ll ans = 0;
	rep(i,3){
		For(j,i+1,4){
			For(k,j+1,5){
				ans += initial[i] * initial[j] *initial[k];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll h,n;cin>>h>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		ll a;cin>>a;
		sum += a;
	}
	if(sum>=h){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;					// 「1からnまで」のn
	int x;					// 合計値
	int combiNum;			// 組み合わせの数
	
	while(1)
	{
		combiNum = 0;
		
		// n, xの入力
		cin >> n;
		cin >> x;
		
		if( (0 == n) && (0 == x) )
		{
			break;
		}
		
		for(int i = 1; i < n; i++)
		{
			for(int j = i + 1; j < n; j++)
			{
				for(int k = j + 1; k <= n; k++)
				{
					if(i + j + k == x)
					{
						combiNum++;
					}
				}
			}
		}
		
		cout << combiNum << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3112
using System;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split();
        var n = double.Parse(nk[0]);
        var k = double.Parse(nk[1]);

        var ans = 0d;
        for (int i = 1; i <= n; i++)
        {
            ans += (1 / n) * (1 / Math.Pow(2, f(i, k)));
        }
        Console.WriteLine(ans);
    }

    static double f(double n, double k)
    {
        var ans = 0d;
        while (n < k)
        {
            n *= 2;
            ans++;
        }
        return ans;
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(void) {
	int H, W, X, Y;
	if (scanf("%d%d%d%d", &H, &W, &X, &Y) != 4) return 1;
	puts((H * W) % 2 == 1 && (X + Y) % 2 == 1 ? "No" : "Yes");
	return 0;
}



Measured memory_bytes: 2144
#include<cstdio>
#include<cstring>

int h, w;
char s[55][55];
int dir[4][2] = { 1, 0, -1, 0, 0, 1, 0, -1 };

int main()
{
	memset(s, 0, sizeof(s));
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++)
	{
		getchar();
		for (int j = 0; j < w; j++)
		{
			scanf("%c", &s[i][j]);
		}
	}
	int flag = 1;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (s[i][j] == '#')
			{
				int f = 0;
				for (int k = 0; k < 4; k++)
				{
					int ni = i + dir[k][0];
					int nj = j + dir[k][1];
					if (ni >= 0 && ni < h && nj >= 0 && nj < w)
					{
						if (s[ni][nj] == '#')
						{
							f = 1;
							break;
						}
					}
				}
				if (f == 0)
				{
					flag = 0;
				}
			}

		}
		if (flag == 0)
		{
			break;
		}
	}
	if (flag)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
 
		if (A != 2 && B != 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int N, K, V[55];
 

int calc(int x, int y) {
	vector<int> v;
	for (int i = 0; i < x; ++i) v.push_back(V[i]);
	for (int j = 0; j < y; ++j) v.push_back(V[N - 1 - j]);

	int del = K - v.size();
	if (del < 0) return 0;

	sort(v.begin(), v.end());

	int sum = 0;
	for (int i = 0; i < v.size(); ++i) {
		if (v[i] < 0 && del > 0) --del;
		else sum += v[i];
	}

	return sum;
}


int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) cin >> V[i];
    int ans = 0;
	for (int i = 0; i <= N; ++i) for (int j = 0; j <= N - i; ++j) {
		ans = max(ans, calc(i, j));
	}

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

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int a[100001]={0};
    for (int i=0;i<N;i++) cin >> a[i];

    int res=1;
    int i=a[0];
    a[0]=-1;
    if (i == 2){
	cout << res << endl;
	return 0;
    }
    while (a[i-1] != -1){
	int x=i-1;
	i=a[i-1];
	a[x]=-1;
	res++;
	if (i == 2){
	    cout << res << endl;
	    return 0;
	}
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>

#define LL long long

using namespace std;
const int maxn=2*123456;
struct he{
    LL x,y,vx,vy;
    LL val;
}edge[maxn];
int n,m;
vector<LL> V;
LL k;
LL ai[maxn];
int a,b;
map<LL,int> M;
bool cmp(he a,he b){
    ///if(a.val!=b.val)return a.val<b.val;
    if(a.vx!=b.vx)return a.vx<b.vx;
    return a.vy>b.vy;
}
int main(){
   // cout<<LONG_LONG_MAX<<endl;
    while(scanf("%d%d",&a,&b)!=EOF){
        int t=a;
        if(b<a)t--;
        printf("%d\n",t);
    }
    
    
    return 0;
}


Measured memory_bytes: 256
lunlun = []


def dfs(x):
    lunlun.append(x)
    if x > 3234566667:
        return 0
    d = x % 10
    if d != 0:
        dfs(10*x+d-1)
    dfs(10*x+d)
    if d != 9:
        dfs(10*x+d+1)


for i in range(1, 10):
    dfs(i)

lunlun.sort()
k = int(input())
print(lunlun[k-1])

Measured memory_bytes: 16848
#include <cmath>
#include <iostream>

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

bool isPrime(int m) {
  double lim = std::sqrt(m);

  for (int i = 2; i <= lim; i++) {
    if (m % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  int n;
  std::cin >> n;
  int a[n];
  rep(i, n) { std::cin >> a[i]; }

  int cnt = 0;
  rep(i, n) {
    if (isPrime(a[i])) {
      cnt++;
    }
  }

  std::cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3136
solve :: (Int, Int) -> Int
solve (a, b) = max la lb
  where la = length $ show a
        lb = length $ show b

main :: IO ()
main = do
  n <- readLn
  let x = floor . sqrt $ fromIntegral n
  print . minimum $ solve <$> [(a, n `div` a) | a <- [1..x], n `mod` a == 0]

Measured memory_bytes: 892
#include<iostream>
using namespace std;
#define MAXN 100001

int wa[MAXN];

int main(){
	int a,ans=0,k,w;
	cin>>a;
	for(int i=1;i<=a;++i)cin>>wa[i];
	for(int i=2;i<=a;++i){
		if(wa[i-1]<=wa[i])continue;
		else if(wa[i-1]==wa[i]+1)wa[i]++;
		else {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
  int d,t,s; cin >> d >> t >> s;
  string ans = "No";
  if (d <= t*s) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
n, k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = -10**18
for now in range(n):
	ruisekiwa = []
	tansaku = set()
	for i in range(n+1):
		targ = p[now]-1
		if len(ruisekiwa) >= 1:
			ruisekiwa.append(c[targ]+ruisekiwa[-1])
		else:
			ruisekiwa.append(c[targ])
		if targ in tansaku:
			break
		now = targ
		tansaku.add(targ)
	#print(ruisekiwa)
	if len(ruisekiwa) >= k:
		tr = max(ruisekiwa[:k])
		#print(tr)
		ans = max(ans, tr)
	else:
		if ruisekiwa[0] < ruisekiwa[-1]:
			#print(ruisekiwa[-1]-ruisekiwa[0])
			ms = (k//(len(ruisekiwa)-1))*(ruisekiwa[-1]-ruisekiwa[0])
			#print(ms)
			#print(len(ruisekiwa))
			#print(ruisekiwa[:k%(len(ruisekiwa)-1)+1])
			if k%(len(ruisekiwa)-1) >= 1:
				tr = max(max(ruisekiwa[:k%(len(ruisekiwa)-1)])+ms, max(ruisekiwa)+ms-(ruisekiwa[-1]-ruisekiwa[0]))
			else:
				tr = max(ruisekiwa[:-1])+ms-(ruisekiwa[-1]-ruisekiwa[0])
			#print(tr)
			ans = max(ans, tr)
		else:
			tr = max(ruisekiwa)
			ans = max(ans, tr)
print(ans)

Measured memory_bytes: 168736
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
int64_t univMod = 1000000007;
int64_t factnum = 200000; //変更すること
vector<int64_t> modfact(factnum);
vector<int64_t> modinvfact(factnum);

void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t modpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t modinverse(int64_t n){
	return modpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = modpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t modcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(n-r))%univMod)*modinvfact.at(r))%univMod;
}

int64_t modperm(int64_t n,int64_t r){
  return (modfact.at(n)*modinvfact.at(n-r))%univMod;
}

int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}


int main(){
  int64_t h,w;
  cin >> h >> w;
  vector<int64_t> alph(26);
  rep(i,h){
    rep(j,w){
      char k;
      cin >> k;
      alph[k - 'a']++;
    }
  }
  int64_t cnt2 = 0;
  int64_t odd = 0;
  rep(i,26){
    if(alph[i] % 2 == 1){
      odd++;
      alph[i]--;
    }
    if(alph[i] % 4 != 0){
      cnt2++;
    }
  }
  if(h % 2 == 0 && w % 2 == 0){
    if(odd == 0 && cnt2 == 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if(h % 2 != 0 && w % 2 == 0){
    if(odd == 0 && cnt2 <= w/2){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if(w % 2 != 0 && h % 2 == 0){
    if(odd == 0 && cnt2 <= h/2){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(odd == 1 && cnt2 <= ((w-1)/2)+((h-1)/2)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

    
    
    
      
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define F first
#define S second


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        v.pb(x);
    }
    int sum=0;
    sort(v.begin(),v.end());
    for(int k=0;k<n;k++)
    {for(int i=k+1;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if((v[i]+v[k])>v[j] )
                sum++;
        }

    }}
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
const ll mod = 1e9+7;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,60){
        ll num0 = 0, num1 = 0;
        rep(j,n) if((a[j] >> i) & 1) num1++;
        num0 = n - num1;
        ans += ((1LL << i) % mod)*((num0*num1) % mod) % mod;
        ans %= mod;
    }
    cout << ans % mod << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    
    int ans = 0, f;
    FOR(i, 1, N){
        bool flag = false;
        FOR(x, 1, 100){
            FOR(y, 1, 100){
                FOR(z, 1, 100){
                    f = x*x + y*y + z*z + x*y + y*z + x*z;
                    if(f == i) {
                       ans++;
                    }
                    if(f > i) break;
                }
                f = x*x + y*y + 1 + x + y + x*y;
                if(f > i) break;
            }
            f = x*x + 1 + 1 + x + x + 1;
            if(f > i) break;
        }
        cout << ans << endl;
        ans = 0;
    }
}

Measured memory_bytes: 3592
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

if (a1<b1 and a2<b2) or (a1>b1 and a2>b2):
    print(0)
    exit()

if a1 > b1:
    a1,b1 = b1,a1
    a2,b2 = b2,a2

_b1 = b1 - a1
_a2 = a2 - b2

v1 = t1*_b1
v2 = t2*_a2

if v1 == v2:
    print('infinity')
    exit()

if v1 > v2:
    print(0)
    exit()

d = v2 - v1
k = v1 // d

ans = k*2 + 1
if v2*k == v1*(k+1):
    ans -= 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int count = 0, ch, result;
	while (1) {
		ch = getchar();
		if (ch == '\n') {
			printf("0\n");
			return 0;
		}
		if (ch == 'A') {
			count++;
			break;
		}
	}
	while (1) {
		ch = getchar();
		if (ch == '\n') {
			break;
		}
		count++;
		if (ch == 'Z')
			result = count;
	}
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 128
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp

if S.include?('A') && S.include?('B')
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 14372
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()
 

 
int__ main() {
	fast;
	int n; cin >> n;

	set<string> s;
	for(int i=0;i<n;i++){
		string x; cin >> x; s.insert(x);
	}

	cout << s.size() << endl;
}


Measured memory_bytes: 19200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{

    long double a,b,C, S,L,h;
    cin>> a >> b >> C;
    C = C/360.0*2.0*M_PI;
    S = a*b*(1.0/2.0)*sinl(C);
    // cout << sinl(C);
    L = a + b + sqrtl(a*a + b*b - 2 * a * b * cos(C));
    h = b * sin(C);
    cout << setprecision(10) << S << "\n";
    cout << setprecision(10) << L << "\n";
    cout << setprecision(10) << h << "\n";
    return 0;
}


Measured memory_bytes: 3488
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

n,x=map(int,input().split())
m=[int(input()) for i in range(n)]
S=sum(m)
ans+=n
mi=min(m)
x-=S
print(ans+x//mi)


Measured memory_bytes: 38384
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    string ans = "hon";
    if(n%10 == 3){
        ans = "bon";
    }else if((n%10 == 0 || n%10 == 1) || (n%10 == 6 || n%10 == 8)){
        ans = "pon";
    }
    cout << ans << endl;
    return 0;
}





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

int main() {
  int N;
  cin >> N;
  char str[N];
  cin >> str;
  int ans = 0;
  int count=0;
  for(int i=0; i < N; i++){
    if(str[i] == 'R'){
      count++;
    }
  }
  for(int i = count; i < N; i++){
    if(str[i] == 'R'){
      ans++;
    }
  }

  cout << ans << endl;

  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3776
a,b = gets.split.map(&:to_i)
ary,ans = [],[]
a.times{x = gets.chomp;ary << x unless x.count("#") == 0}
new_ary = ary.map{|row| row.split("")}.transpose
b.times{ |idx| ans << new_ary[idx] unless new_ary[idx].count("#") == 0}
ans.transpose.map{|z| puts z.join}

Measured memory_bytes: 2428
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int main(void) {
	int N; cin >> N;
	vector<int> A(N); for(auto &a:A) cin >> a;

	int res = inf;
	FOR(val,-100,100+1){
		int r = 0;
		for(auto &a:A) r += (val-a)*(val-a);
		res = min(res, r);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    V = list(map(int, input().split(" ")))
    C = list(map(int, input().split(" ")))
    L = []
    for v, c in zip(V, C):
        L.append(max(v - c, 0))
    print(sum(L))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
while True:
    (H, W) = [int(i) for i in input().split()]
 
    if H == W == 0:
        break
 
    for i in range(H):
        for r in range(W):
            if (i + r) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
            #print('#', end='') if (i + r) % 2 == 0 else print('.', end='')
        print()
    print()

Measured memory_bytes: 9040
#include<iostream>
#include<string>

using namespace std;

int main(){
	string a;
	cin >> a;
	long long ans = a.size() * (a.size() - 1) / 2 + 1;
	for(int i = 0; i < 26; i++){
		char c = 'a' + i;
		long long cnt = 0;
		for(int j = 0; j < a.size(); j++){
			if(a[j] == c) cnt++;
		}
		ans -= cnt * (cnt - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int a=in(),b=in();
    print(max(a+b,max(a-b,a*b)));
    return 0;
}

Measured memory_bytes: 128
R, G, B, N = map(int, input().split())

RGB = sorted([R, G, B], reverse=True)
max1 = N // RGB[0] 

count = 0
for r in range(max1+1):
    max2 = min([N-r, (N-r*RGB[0])//RGB[1]])
    for g in range(max2+1):
        if (N - (r*RGB[0] + g*RGB[1])) % RGB[2] == 0:
            count += 1
print(count)

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    priority_queue<int> B;
    for ( int i = 0; i < N; ++i){
        cin >> A.at(i);
        B.push(A.at(i));
    }
    
    for ( int i = 0; i < M; ++i){
        int b = B.top(); B.pop();
        b = b/2;
        B.push(b);
    }
    
    int64_t sum = 0;
    for ( int i = 0; i < N; ++i){
        int b = B.top(); B.pop();
        sum = sum + b;
    }
    cout << sum << endl;
    
    
    /*sort(A.begin(),A.end());
    for ( int i = 0; i < M; ++i){
        A.at(N-1) = A.at(N-1)/2;
        sort(A.begin(),A.end());
    }
    
    int64_t sum = 0;
    for ( int i = 0; i < N; ++i){
        sum = sum + A.at(i);
    }
    
    cout << sum << endl;*/
    
    return 0;
}


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

int main(){
    //ゴールから始めて,なるべく長い距離を使って移動を繰り返す.
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> ids;
    for(int i = 0;i < n+1;i++){
        if(s[i] == '0'){
            ids.push_back(i);
        }
    }

    vector<int> ans;

    int now = n;
    while(now != 0){
        auto itr = lower_bound(ids.begin(),ids.end(), now - m);
        int next = *itr;
        ans.push_back(now - next);
        if(now == next){
            cout << -1 << endl;
            return 0;
        }
        now = next;
    }

    for(int i = ans.size() - 1;i >= 0;i--){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4376
n, t = map(int, input().split())
r = [list(map(int, input().split())) for _ in range(n)]

sorted_by_cost = sorted(r, key=lambda x: x[0])

for i in range(n):
    if sorted_by_cost[i][1] <= t:
        print(sorted_by_cost[i][0])
        exit()
print('TLE')

Measured memory_bytes: 38512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	
	
	ll n,cnt=0;
	cin>>n;
	
	ll arr[n+1];
	
	for(ll i=1;i<=n;i++)
	{
	    cin>>arr[i];
	}
	arr[0]=0;
	sort(arr+1,arr+n+1);
	reverse(arr+1,arr+n+1);
	ll ans=0;
	vector<ll>res;
	res.push_back(arr[1]);
	for(ll i=2;i<=n;i++)
	{
	   
	        for(ll k=i;k<i+2;k++)
	        {
	           res.push_back(arr[i]);
	        }
	        
	    
	    
	    
	    
	}
	
	for(ll i=0;i<n-1;i++)
	{
	    ans+=res[i];
	}
	
	cout<<ans<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 8960
// SeeAlso: https://atcoder.jp/contests/abc154/tasks/abc154_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    if(u==s) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
	public class Main{
		public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			int count[] = {0,0,0,0};
			while(sc.hasNext()){
				String str = sc.nextLine();
				String [] blood = str.split(",");
					if(blood[1].equals("A")){
						count[0]++;
					}else if(blood[1].equals("B")){
						count[1]++;
					}else if(blood[1].equals("AB")){
						count[2]++;
					}else{
						count[3]++;
					}
			}
			for(int i = 0; i < 4; i++ ){
				System.out.println(count[i]);
			}
		}
	}		

Measured memory_bytes: 26012
#include <bits/stdc++.h>
#define ODD(n) (2*n+1)
#define OO 1e9
#define EVEN(n) (2*n)
using namespace std;
const int N = 100001;
const int M = 200001;
vector<pair<int, int>> adj[N];
int dist[N];
bool vis[N];
bool dfs(int u){
  vis[u] = 1;
  for(auto el : adj[u]){
    int v = el.first;
    int d = el.second;
    if(!vis[v]){
      dist[v] = dist[u] + d;
      if(!dfs(v))
        return false;
    }else{
      if(dist[u] + d != dist[v]){
//        cout << u << ' ' << v << ' ' << dist[u] << ' ' << dist[v] << endl;
        return false;
      }
    }
  }
  return true;
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, m;
  cin >> n >> m;

  int u, v, d;
  for(int i = 0;i < m;i++){
    cin >> u >> v >> d;
    u--, v--;
    adj[u].push_back({v, -d});
    adj[v].push_back({u, d});
  }
  for(int i = 0;i < n;i++){
    if(!vis[i]){
      if(!dfs(i)){
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  ll W,H;cin >> W>>H;
  vll p(W),q(H);
  repeat(i,W){
    cin >> p[i];
  }
  p.push_back(INF);
  repeat(i,H){
    cin >> q[i];
  }
  q.push_back(INF);
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  ll pi=0,qi=0;
  ll ans = 0;
  repeat(i,W+H){
    ll pa = pi<W? p[pi]*(H+1-qi):INF;
    ll qa = qi<H? q[qi]*(W+1-pi):INF;
    if(p[pi]<q[qi]){
      ans += pa;
      pi++;
    }else{
      ans += qa;
      qi++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int main(){
    int H,W;
    cin >> H;
    cin >> W;
    char s[H+2][W+2];
    for(int i=0;i<W+2;i++){
        s[0][i] = s[H+1][i] = '.';
    }
    for(int i=0;i<H+2;i++){
        s[i][0] = s[i][W+1] = '.';
    }
    for(int i=1;i<W+1;i++){
        for(int j=1;j<H+1;j++){
            cin >> s[j][i];
        }
    }
    bool b = true;
    for(int i=1;i<W+1;i++){
        for(int j=1;j<H+1;j++){
            if(s[j][i]=='#'){
                if(!(s[j-1][i]=='#'||s[j][i-1]=='#'||s[j+1][i]=='#'||s[j][i+1]=='#')) b = false;
            }
        }
    }
    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=200005;
//i_am_noob
int n,x[maxn],y[maxn],minn[2],maxx[2];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    minn[0]=minn[1]=inf,maxx[0]=maxx[1]=-inf;
    cin >> n;
    rep(n) cin >> x[i] >> y[i];
    rep(n) minn[0]=min(minn[0],x[i]+y[i]),maxx[0]=max(maxx[0],x[i]+y[i]),minn[1]=min(minn[1],y[i]-x[i]),maxx[1]=max(maxx[1],y[i]-x[i]);
    print1(max(maxx[0]-minn[0],maxx[1]-minn[1]));
    return 0;
}


Measured memory_bytes: 6768
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
using namespace std;

#define FOR(i,a,n) for(int i = (a); i < (n); ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using P = pair<int,int>;
vector<P> R;
vector<P> B;

int main() {
  int n; cin >> n;
  int a, b, c, d;
  R.resize(n); B.resize(n);
  REP(i, n) {
    cin >> a >> b;
    R[i] = make_pair(a,b);
  }
  REP(i, n) {
    cin >> c >> d;
    B[i] = make_pair(c,d);
  }
  whole(sort,R);
  whole(sort,B);
  int r = 0;
  b = 0;
  set<int> S;
  int ans = 0;
  REP(i, 2*n) {
    if (r < n && (b >= n || R[r].first < B[b].first)) {
      S.insert(R[r].second);
      r++;
    } else {
      int r = 0;
      for (int y = B[b].second; y >= 0 && r == 0; y--) {
        r = S.erase(y);
      }
      ans += r;
      b++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;

    vector<int> ans(n + 1);
    for(int i=1; i<=100; i++) {
        for(int j=1; j<=100; j++) {
            for(int k=1; k<=100; k++) {
                int x = (i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
                if (x > n) break;
                ans[x]++;
            }
        }
    }

    for(int h=1; h<=n; h++) {
        cout << ans[h] << endl;
    }
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        char prev = 'o';
        for (int i = 1; i < n; i++) {
            if (arr[i] == 'x' && arr[i - 1] == 'x') {
                System.out.println(i);
                return;
            }
        }
        System.out.println(n);
    }
}


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

using namespace std;

int main (void) {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a.at(i);
    }

    int a_idx = 0;
    int n = a.at(a_idx);
    for ( int row = 0; row < H; row++ ) {
        vector<int> ans(W);
        for ( int col = 0; col < W; col++ ) {
            if ( n == 0 ) {
                a_idx++;
                n = a.at(a_idx);
            }
            ans.at(col) = a_idx + 1;
            n--;
        }
        for ( int i = 0; i < W; i++ ) {
            if ( row % 2 == 0 ) {
                cout << ans.at(i);
            }
            else {
                cout << ans.at(W-i-1);
            }
            if ( i != W-1 ) {
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll>a(n);
    rep(i, 0, n)cin >> a[i];
    ll ans = 0;
    if(a[0]>x){
        ans += (a[0]-x);
        a[0]=x;
    }
    rep(i, 1, n){
        if(a[i]+a[i-1]>=x){
            if(x-a[i-1]>=0){
                ans += (a[i]-x+a[i-1]);
                a[i] = x-a[i-1];
            }else{
                ans += (a[i]-x+a[i-1]);
                a[i] = 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4060