akhauriyash/Code-Regression huggingface dataset:
/*Bismillahir Rahmanir Rahim
->>Code by Ashraful Islam Paran
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int MX=2e5+5;
#define f(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define endl "\n"
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl

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

    string s;
    int a[MX]={0},p{0};
    cin>>s;
    f(i,0,s.size())
    {
        a[s[i]]++;
    }
    for(int i=97;i<=122;i++)
    {
        if(a[i]%2)
        {
            p=1;
        }
    }
    if(p)
    {
        no;
    }
    else
        yes;

    return 0;
}



Measured memory_bytes: 4384
a=int(input())

t = list(map(int,input().split()))

res = [float('inf')]*a
res[0] = 0

for i in range(1, a):
    for j in range(i-2, i):
        res[i] = min([res[i], res[j]+abs(t[i]-t[j])])
        
print(res[-1])

Measured memory_bytes: 13928
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    //S
    String s = sc.next();
    String ans = "Yes";
    
    int sL = s.length();

    if (sL%2 == 0){
      if(sL==2 && (!(s.equals("hi")))){
            ans = "No";
      } else {
        for(int i = 0; i<sL-2; i++){
          String s1 = s.substring(i, i+2);
          if (!(s1.equals("hi"))){
            ans = "No";
            break;
          }
          i++;
        }
      }
     } else {
        ans = "No";
     }
    
    System.out.println(ans);
  }
}

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



int main(){
  int N, K;
  cin >> N >> K;
  vector<long long> V(N);
  rep(i, N){
    cin >> V[i];
  }
  rep(i, N-K){
    if(V[i]<V[i+K]){
      cout << "Yes" << endl;
    }
    else{
       cout << "No" << endl;
    }
  }
}
    

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    string s;
    cin>>n>>s;
    ll mn,cnt=0;
    for(ll i=1;i<n;i++){
        if(s[i]=='E') cnt++;
    }
    mn=cnt;
    for(ll i=1;i<n;i++){
        if(s[i]=='E') cnt--;
        if(s[i-1]=='W') cnt++;
        mn=min(mn,cnt); 
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 900
N = int(input())
T = [int(x) for x in input().split(' ')]
V = [int(x) for x in input().split(' ')]
V.append(0)
s = sum(T)
time = [s]
for i in range(N):
    s -= T[N - 1 - i]
    time.append(s)
time.reverse()

s = 0
answer = 0.0
for i in range(N):
    t = T[i]
    limit = V[i]
    g = V[i + 1]
    for j in range(i + 2, N + 1):
        if V[j] + time[j] - time[i + 1] < g:
            g = V[j] + time[j] - time[i + 1]
    x = (s + g + t) / 2.0
    if t <= limit - s and g >= limit:
        answer += 0.5 * t * (2.0 * s + t)
        s += t
    elif g >= limit:
        answer += 0.5 * (limit ** 2 - s ** 2) + limit * (t - limit + s)
        s = limit
    elif t <= g - s:
        answer += 0.5 * t * (2.0 * s + t)
        s += t
    elif x >= limit and s - g < t:
        answer += limit ** 2 - 0.5 * (s ** 2 + g ** 2) + limit * (t - 2.0 * limit + s + g)
        s = g
    elif s - g < t:
        answer += x ** 2 - 0.5 * (s ** 2 + g ** 2)
        s = g
    elif s - g == t:
        answer += 0.5 * (s + g) * t
        s = g
    else:
        print("error")
        break

print(answer)


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];

			KeyValuePair<int, int>[] work = new KeyValuePair<int, int>[n];
			for (int i = 0; i < n; i++) {
				vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
				int a = vs[0];
				int b = vs[1];
				work[i] = new KeyValuePair<int, int>(a, b);
			}
			work = work.OrderBy(p => p.Key).ToArray();

			long ans = 0;
			PriorityQueue<KeyValuePair<int, int>> queue = new PriorityQueue<KeyValuePair<int, int>>((x, y) => y.Value.CompareTo(x.Value));
			int j = 0;
			for (int i = 1; i <= m; i++) {
				while (j < work.Length && work[j].Key <= i) {
					queue.Enqueue(work[j]);
					j++;
				}
				if (queue.Count > 0) {
					var w = queue.Dequeue();
					ans += w.Value;
					//System.Diagnostics.Debug.WriteLine($"{i}\t{w.Key}\t{w.Value}");
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
	#region 優先度付きキュー PriorityQueue<T>
	public class PriorityQueue<T> // where T : IComparable
	{
		private readonly List<T> _Heap;
		private readonly Func<T, T, int> _Compare;

		public int Count { get { return _Heap.Count; } }

		public PriorityQueue() : this(Comparer<T>.Default.Compare) { }
		public PriorityQueue(bool reverse) : this((x, y) => Comparer<T>.Default.Compare(reverse ? y : x, reverse ? x : y)) { }
		public PriorityQueue(Comparer<T> comparer) : this(comparer.Compare) { }
		public PriorityQueue(Func<T, T, int> compare)
		{
			_Heap = new List<T>();
			_Compare = compare;
		}

		public void Enqueue(T item)
		{
			_Heap.Add(item);
			int i = _Heap.Count - 1;
			while (i > 0) {
				int p = (i - 1) / 2;
				if (_Compare(_Heap[p], item) <= 0) {
					break;
				}
				_Heap[i] = _Heap[p];
				i = p;
			}
			_Heap[i] = item;
		}

		public T Dequeue()
		{
			int size = _Heap.Count - 1;
			T ret = _Heap[0];
			T x = _Heap[size];
			int i = 0;
			while (i * 2 + 1 < size) {
				var a = i * 2 + 1;
				var b = i * 2 + 2;
				if (b < size && _Compare(_Heap[b], _Heap[a]) < 0) {
					a = b;
				}
				if (_Compare(_Heap[a], x) >= 0) {
					break;
				}
				_Heap[i] = _Heap[a];
				i = a;
			}
			_Heap[i] = x;
			_Heap.RemoveAt(size);
			return ret;
		}

		public T Peek()
		{
			return _Heap[0];
		}

		public void Clear()
		{
			_Heap.Clear();
		}

		public List<T>.Enumerator GetEnumerator()
		{
			return _Heap.GetEnumerator();
		}

		public override string ToString()
		{
			return string.Join(" ", _Heap);
		}
	}
	#endregion
}


Measured memory_bytes: 22336
# 2019-11-11 14:35:02(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    x, y = (int(i) for i in sys.stdin.readline().split())
    ans = x + y // 2
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	var n, k int
	fmt.Scan(&n, &k)
	A := make([]int, n)
	for i := range A {
		A[i] = nextInt()
	}
	lb, ub := 0, int(1e9+1)
	for ub-lb > 1 {
		mid := (lb + ub) / 2
		c := 0
		for _, a := range A {
			tmp := a / mid
			if a%mid == 0 {
				tmp--
			}
			c += tmp
		}
		if k >= c {
			ub = mid
		} else {
			lb = mid
		}
	}
	fmt.Println(ub)
}


Measured memory_bytes: 5936
N = int(input())
A = list(map(int,input().split()))

ans = 1
up = None
for a,b in zip(A,A[1:]):
    if a==b: continue
    if a<b:
        if up is None:
            up = True
        elif not up:
            ans += 1
            up = None
    else:
        if up is None:
            up = False
        elif up:
            ans += 1
            up = None
print(ans)

Measured memory_bytes: 15020
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int h, w; cin >> h >> w;
    int a[h][w], b[h][w];
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> b[i][j];
    bool dp[2][80][6401];
    int cur = 0, prev = 1;
    for (int i = 0; i < h; i++) {
        memset(dp[cur], 0, sizeof(dp[cur]));
        for (int j = 0; j < w; j++) {
            int v = abs(a[i][j] - b[i][j]);
            if (i == 0 && j == 0) {
                dp[cur][0][v] = true;
                continue;
            }
            if (i > 0) {
                for (int x = 0; x <= 6400; x++) {
                    if (x+v <= 6400) dp[cur][j][x] |= dp[prev][j][x+v];
                    if (0 <= x-v) dp[cur][j][x] |= dp[prev][j][x-v];
                    else dp[cur][j][x] |= dp[prev][j][v-x];
                }
            }
            if (j > 0) {
                for (int x = 0; x <= 6400; x++) {
                    if (x+v <= 6400) dp[cur][j][x] |= dp[cur][j-1][x+v];
                    if (0 <= x-v) dp[cur][j][x] |= dp[cur][j-1][x-v];
                    else dp[cur][j][x] |= dp[cur][j-1][v-x];
                }
            }
        }
        swap(prev, cur);
    }

    for (int x = 0; ; x++) {
        if (dp[prev][w-1][x]) { cout << x << endl; break; }
    }
}


Measured memory_bytes: 1280
#include<iostream>
#include<math.h>
#include<stdio.h>  // printf() を使いたい

int main(){
  double x1,y1,x2,y2;
  std::cin >> x1 >> y1 >> x2 >> y2;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}




Measured memory_bytes: 3208
N = int(input())
S = list(input())
ls = ["A", "B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(S)):
    for j in range(26):
        if S[i] == ls[j]:
            S[i] = ls[(j+N) % 26]
            break

print(*S, sep = "")

Measured memory_bytes: 4724
//#include <bits/stdc++.h>
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

int f(int n, int cnt) {
  if (n < 10) return cnt;
  int maxnum = -1;
  string s;
  s = to_string(n);
  rep(i, s.size()) {
    string t = s.substr(0, i + 1);
    string u = s.substr(i + 1);
    int forward = atoi(t.c_str());
    int backward = atoi(u.c_str());
    // cout << forward << endl;
    int tmp = forward * backward;
    cmax(maxnum, tmp);
  }
  return f(maxnum, cnt + 1);
}

signed main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    cout << f(n, 0) << endl;
  }
  return 0;
}



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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

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

int main()
{
	int d,v,t; cin>>d>>v>>t;
  	if(v*t>=d) cout<<"Yes";
  	else cout<<"No";
}


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

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


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

int n, k, mx, lt, rt, a[55];
vector<int> vt;

int main() {
	int i, j, c, s;
	cin >> n >> k;
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	for(lt=0; lt<=n; lt++) {
		for(rt=0; lt+rt<=min(n,k); rt++) {
			vt.clear();
			for(i=0; i<lt; i++) vt.push_back(a[i]);
			for(j=n-1, c=0; c<rt; j--, c++) vt.push_back(a[j]);
			sort(vt.begin(), vt.end());
			c = k-lt-rt;
			for(i=0; i<vt.size() && i<c && vt[i]<0; i++);
			for(s=0; i<vt.size(); i++) s += vt[i];
			mx = max(mx, s);
		}
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

s = input()
n = len(s)
a = []
for i in range(int((n-1)/2)):
    a.append(s[i])
b = []
for i in range(int(((n+3)/2)-1), len(s)):
    b.append(s[i])
if a == b:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3896
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 1e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, a[N], m, b[N];

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

	int cur = 1;
	for (int i = 0; i <= n; ++i) {
		if (a[i] > cur) {
			cout << -1;
			return 0;
		}

		b[i] = cur - a[i];
		cur = min(INF, (cur - a[i])*2);
	}

	b[n] = 0;
	for (int i = n; i > 0; --i) 
		b[i - 1] = min(b[i - 1], a[i] + b[i]);
	int ans = 0;
	for (int i = 0; i <= n; ++i)
		ans += a[i] + b[i];
	cout << ans << endl;
}





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

int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i,n) cin >> h[i];
  int ans = 1;
  int m = h[0];
  for(int i = 1; i < n; i++) {
    if(h[i] >= m) ans++;
    m = max(h[i],m);
  } 
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
 
int main()
{
    std::string s;
    std::cin >> s;
    bool flag = true;

    for(int i=0; i<s.length(); i+=2)
    {
        if(s[i]=='L') flag = false;
    }

    for(int i=1; i<s.length(); i+=2)
    {
        if(s[i]=='R') flag = false;
    }


    if(flag) std::cout << "Yes\n";
    else std::cout << "No\n";
    return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    int minN = INT_MAX;
    for (int i = -100; i <= 100; i++){
        int cost = 0;
        for (int k = 0; k < (int)a.size(); k++){
            cost += pow(a[k]-i,2);
        }
        minN = min(minN,cost);
    }
    cout << minN << endl;


    return 0;
}


Measured memory_bytes: 256
coins = [10, 50, 100, 500]
flg = 0
while 1:
    subtotal = int(input())
    if subtotal == 0:
        break
    if flg == 1:
        print()
    s_purse = list(map(int, input().split()))
    ans = [0, 0, 0, 0]
    for id in range(len(coins)):
        if id == 0: 
            continue
        payable = 0
        for i in range(len(coins) - id):
            payable += coins[i] * s_purse[i]
        while 1:
            if payable < subtotal:
                ans[-id] += 1
                s_purse[-id] -= 1
                subtotal -= coins[-id]
            else:
                break
    if 0 < subtotal:
        ans[0] += subtotal // 10
        s_purse[0] -= subtotal // 10
        subtotal -= coins[0] * ans[0]
    
    charge = -subtotal
    cha_coins = [charge//10, 0, 0, 0]
    hitsuyou = [5, 2, 5]

    for i in range(len(coins) - 1):
        if hitsuyou[i] <= cha_coins[i]:
            cha_coins[i + 1] = cha_coins[i] // hitsuyou[i]
            cha_coins[i] = cha_coins[i] % hitsuyou[i]
        if hitsuyou[i] <= cha_coins[i] + s_purse[i]:
            ans[i] += (cha_coins[i] + s_purse[i]) // hitsuyou[i] * hitsuyou[i] - cha_coins[i]
            cha_coins[i + 1] += (cha_coins[i] + s_purse[i]) // hitsuyou[i] 

    for i in range(len(coins)):
        if ans[i]:
            print(coins[i], int(ans[i]))
    flg = 1


Measured memory_bytes: 5628
#include <algorithm>
 #include <iostream>
 #include <vector>
 using namespace std;
 typedef long long ll;
 const int INF = 1 << 30;
 const ll INFll = 1ll << 60;
 
 int main() {
	 int a, b;
	 cin >> a >> b;

	 if(a <= 12) b /=2;
	 if(a <= 5) b =0;

 	cout << b << endl;
 	return 0;
 }


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

int a[2*100001], b[2*100001];

int main() {
  int n, m = 0; cin >> n;

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

  for(int i=n; i>0; --i){
    int sum = 0;
    for(int k=i; k<=n; k+=i) sum += b[k];
    if(a[i] != sum%2) {
      b[i] = 1;
      ++m;
    }
  }

  cout << m << endl;
  for(int i=1; i<=n; ++i) if(b[i] == 1) cout << i << endl;
}


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

using namespace std;

int main() {
	
	int n;
	string str;
	cin >> n >> str;
	if(n >= str.length())cout << str;
	else {
		for(int i = 0; i < n; i++)
			cout << str[i];
		cout << "...";
	}
	return 0;
}

Measured memory_bytes: 3124
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int N, x[100], y[100], h[100];

	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d%d%d", &x[i], &y[i], &h[i]);

	for (int cy = 0; cy <= 100; cy++) {
		for (int cx = 0; cx <= 100; cx++) {
			int height = -1;
			for (int i = 0; i < N; i++) {
				if (h[i] != 0) {
					if (height == -1)
						height = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
					else if (h[i] + abs(cx - x[i]) + abs(cy - y[i]) != height) {
						height = -2;
						break;
					}
				}	
			}
			if (height != -2) {
				for (int i = 0; i < N; i++) {
					if (h[i] == 0) {
						if (height > abs(cx - x[i]) + abs(cy - y[i])) {
							height = -2;
							break;
						}
					}
				}
			}
			if (height != -2)
				printf("%d %d %d\n", cx, cy, height);
		}
	}

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define true 1
#define false 0

int A[20],n;

int solve(int i,int m){
  int res;
if(m == 0) return true;

if(i >= n) return false;

res = solve(i + 1, m) || solve(i + 1, m - A[i]);
return res;
   }


int main(){
  int q,m[200];
  int 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[i]);
  }

   for(i=0; i<q; i++){
     if(solve(0,m[i])==true) printf("yes\n");
     else printf("no\n");
  }

   return 0;
}




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

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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int digit = to_string(i).length();
        if (digit%2 == 1) ans++;
    }

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



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

int main() {

  int N,Y;
  cin >> N >> Y;
  int x,y,z,ans=0,money;
  for(x=0;x<=N;x++){
      if(x*10000>Y){
          break;
      }
      for(y=0;y<=N-x;y++){
          z = N-x-y;
          money = 10000*x+5000*y+1000*z;
          if(money==Y){
              ans=1;
              cout << x << " " << y << " " << z << endl;
              break;
          }
      }
      if(ans == 1){
          break;
      }
  }
  if(ans == 0){
      cout << -1 << " " << -1 << " "<< -1 << endl;
  }

}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL dp[101][100005] = {{0}};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,W;
    cin>>N>>W;
    vector<PLL> item(N);
    REP(i,N){
        LL w,v;
        cin>>w>>v;
        item[i] = MP(w,v);
    }

    dp[0][item[0].first] = item[0].second;
    REP(i,N-1){
        REP(j,W+1)if(j == 0 || dp[i][j] != 0){
            // 入れない
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);

            // 入れる
            LL k = j + item[i+1].first;
            if(k > W)continue;
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + item[i+1].second);
        }
    }
    PUTS(*max_element(dp[N-1], dp[N]));
}

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

int main(){
  int l,m,n;

  while(true){
    cin >> l;
    if(!l)break;

    int f = 1;
    for(int i=0;i<12;i++){
      cin >> m >> n;
      l -= m-n;
      if(l<=0 && f){
	cout << i+1 << endl;
	f = 0;
      }
    }
    if(l>0)cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<utility>
#define For(a,b) for(int i=(a);i<(b);i++)
#define Rep(n) for(int i=0; i<(n); ++i)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
//----------program from here----------

int main(){
    char s[4];
    cin >> s;
    sort(s, s+4);
    cout << (s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]?"Yes":"No") << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
input=sys.stdin.readline
n,k,q=map(int,input().split())
p={}
for i in range(n):
    p[i]=k-q
for i in range(q):
    a=int(input())
    p[a-1]+=1
for i in range(n):
    if p[i]>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
// ------------------------
void solve() {
    int A, B; cin >> A >> B;
    int plus = A + B;
    int minus = A - B;
    int times = A * B;
    cout << max( { plus, minus, times } ) << "\n";
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int H,W,h,w,a[550][551];
int main(){
	read(H,W);read(h,w);
	if(H%h==0)if(W%w==0)return puts("No"),0;
	puts("Yes");
	rep(i,1,h)rep(j,1,w)a[i][j]=1e3;
	a[h][w]=-(1e3*(h*w-1)+1);
	rep(i,1,H)rep(j,1,W)
		if(i>h)a[i][j]=a[i-h][j];else if(j>w)a[i][j]=a[i][j-w];
	rep(i,1,H)rep(j,1,W)printf("%d%c",a[i][j],(j==W)?'\n':' ');
}

Measured memory_bytes: 2816
n, m, x = input().split()
n = int(n)
m = int(m)
x = int(x)
c = [0 for _ in range(n+1)]
a = input().split()
for i in range(m):
    c[int(a[i])]=1
print(min(sum(c[:x]),sum(c[x:])))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
int n,a[maxn],b[maxn],c[maxn],dp[maxn][4];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=max(dp[i][0],max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]));
		dp[i][1]=max(dp[i][1],max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]));
		dp[i][2]=max(dp[i][2],max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]));
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}
//Phoenix-ZH

Measured memory_bytes: 6332
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            string S = Console.ReadLine();
            long K = long.Parse(Console.ReadLine());
            for(var i=0;i<K;i++){
                if(S[i]!='1'){
                    Console.WriteLine(S[i]);
                    return;
                }
            }
            Console.WriteLine('1');
        }
    } 
}

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<char>> c(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c[i][j];
        }
    }

    for(int i=1; i<=2*h; i++){
        for(int j=0; j<w; j++){
            cout << c[(i+1)/2 - 1][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int N,c[10005],p[10005],i,j,t;
int main()
{
	for(;scanf("%d",&N),N;)
	{
		memset(c,0,sizeof(c));
		memset(p,0,sizeof(p));
		for(i=1;i<N;i++)
			p[i*i%N]=1;
		for(i=0;i<=10000;i++)
			for(j=0;j<=10000;j++)
				if(i!=j&&p[i]&&p[j])
				{
					t=i-j;
					if(t<0)t+=N;
					if(t>(N-1)/2)t=N-t;
					c[t]++;
				}
		for(i=1;i<=(N-1)/2;i++)
			printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 684
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a+b)==c)
        printf("%d",c+b);
    else if(a+b<c)
        printf("%d",(a+b)+b+1);
    else if(a+b>c)
            printf("%d",b+c); 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
  int a, b, c, d, e, X, Y;
  //  double  c;
  int  A[101]={};
//  int  B[100003]={};
  int  L[1003]={};

  int  flag[103]={};

//  long long  a, b, c, d, X, Y;
char s[101][101]={};
  long long JPY;
  double BTC;
char t[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
  double tmp=0;
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int cnt=0;
  int num=0;
//  double ans=0.0;
  int ans=0.0;
  int max=0;
  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%d%d", &a, &b, &c);

  for(i=1;i<101;i++){
//           printf("%d cnt%d\n",i, cnt);
    if((a%i)==0){
      if((b%i)==0){
        A[cnt]=i;
        cnt++;
      }
    }
  }
  printf("%d\n",A[cnt-c]);

  //    if(max < cnt - max)  printf("Yes\n");
//    else  
  
return 0;
}


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

int N;
vector<int> a, b;

int main () {
  cin >> N;
  a.resize(N+1);
  b.resize(N+1, 0);
  rep(i,N) cin >> a[i+1];

  for(int i = N; i >= 1; i--) {
    for(int j = i; j <= N; j += i) b[i] ^= b[j];
    b[i] = (b[i] != a[i]);
  }

  int M = 0;
  vector<int> c;
  for(int i = 1; i <= N; i++) if(b[i]) c.push_back(i);
  cout << c.size() << endl;
  for(int i = 0; i < c.size(); i++) {
    cout << c[i];
    printf(i == c.size() - 1 ? "\n" : " ");
  }

  return 0;
}


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int z,x;
    cin>>z>>x;
    if(z<x){
        cout<<"0\n";
    }
    else if(z>x){
        cout<<"10\n";
    }
    else if(z==x){
         cout<<"10\n";
    }
    return 0;
}

Measured memory_bytes: 256
/*
C++ のソースコードのテンプレート
特にAOJ-ITP1に使いやすい
*/
#define _USE_MATH_DEFINES

#include <iostream> // 標準入出力
#include <fstream>  // ファイル入出力
#include <string>   // 文字列関係
#include <vector>   // 可変の配列
#include <cmath>    // 数学系
#include <iomanip>  // streamの書式関係
#include <algorithm>// max関数など

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // 要素数が可変のベクトル
using std::fixed;         // ストリームの設定をデフォルトにする
using std::setprecision;  // 引数に小数点以下の桁数を指定することが出来る

int main() {
	vector<long long> A;
	vector<long long> B;
	int num;

	cin >> num;
	A.resize(num);
	B.resize(num);
	for (size_t i = 0; i < num; i++)
	{
		cin >> A[i] >> B[i];
	}

	// Aの値が最大のときの引数を保持
	size_t n = 0;
	for (size_t i = 1; i < num; i++)
	{
		if (A[i] > A[n]) {
			n = i;
		}
	}

	// Aの値の最大値の値+数え上げた数
	cout << A[n] + B[n] << endl;



	return 0;
}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double
#define endl "\n"

int main()
{
	IOS;
	ll a,b;
	cin >>a>>b;
	ll k=(a+b)/2;
	if((a+b)%2==0)
		cout <<k<<endl;
	else
		cout <<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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 cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)res=res*x%m;
		y>>=1;x=x*x%m;
	}
	return res;
}
int perm[1000001],inv[1000001];
void init_perm(){
	perm[0]=1;
	REP(i,1000001)perm[i]=perm[i-1]*i%mod;
	inv[1000000]=mod_pow(perm[1000000],mod-2);
	for(int i=999999;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}

int N,X[100005];
signed main(){
	init_perm();
	cin>>N;
	rep(i,N)cin>>X[i];
	int now=0,ans=1;
	rep(i,N){
		if(X[i]<(now+1)*2-1){
			ans*=(now+1);ans%=mod;
		}else now++;
	}
	cout<<ans*perm[now]%mod<<endl;
}


Measured memory_bytes: 16640
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false); cin.tie(0)
#define int long long
#define ull unsigned long long
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int maxn = 2e5 + 10;
int n,a[maxn],b[maxn];
signed main() {
  IO;
  cin >> n;
  rep(i,1,n) cin >> a[i];
  rep(i,1,n) cin >> b[i];
  reverse(b + 1,b + 1 + n);
  int l = 0, r = -1;
  rep(i,1,n) if(a[i] == b[i]) {l = i; break; }
  per(i,n,1) if(a[i] == b[i]) {r = i; break; }
  rep(i,1,n) {
    if (b[i] != a[l] && a[i] != a[l] && l <= r) {
      swap(b[i], b[l]);
      l++;
    }
  }
  if(l <= r) cout << "No" << '\n';
  else{
    cout << "Yes" << '\n';
    rep(i,1,n) cout << b[i] << ' ';
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 6640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  C *= 2;
  LL vmin = 1e18;
  for (int i = 0; i <= max(X, Y); ++i) {
    LL v = i * C;
    if (X > i) v += (X - i) * A;
    if (Y > i) v += (Y - i) * B;
    vmin = min(v, vmin);
  }
  cout << vmin << endl;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  int k =s.size();
  int count=0;
  for(int i=0;i<k/2;i++){
	if(s[i]!=s[k-i-1])count++; 
	}
	cout<<count<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return true;
    }
    else { // 発見できなかったとき
        return false;
    }
}

int main(){
    ll N;
    cin >> N;
    string s;
    string S[N+2];
    bool A_exist=false, B_exist=false;
    vector<ll> feature[5];//0:どっちもだめ、1:Aが末尾、2:Bがはじめ、3:Aが末尾かつBがはじめ
    ll cnt=0;
    llrep(i,N){
        cin >> s;
        S[i] = s;
        if(s[0]=='B'){
            if (s[s.size()-1]=='A'){
                feature[3].push_back(i);
            }else{
                feature[2].push_back(i);
            }
        }else{
            if (s[s.size()-1]=='A'){
                feature[1].push_back(i);
            }else{
                feature[0].push_back(i);
            }
        }
        llrep(j,s.size()-1){
            if (s[j]=='A' && s[j+1]=='B') cnt++;
        }
    }

    // cout << "cnt = " << cnt << endl;
    if (feature[3].size()>0){//ブロックあり
        cnt += (feature[3].size()-1);//ブロック
        if (feature[1].size()>0){
            if(feature[2].size()>0){
                cnt +=2;
                cnt += min(feature[1].size()-1, feature[2].size()-1);
            }else{
                cnt +=1;
            }
        }else{
            if (feature[2].size()>0){
                cnt +=1;
            }
        }
        // if (feature[1].size()>0){
        //     cnt ++;
        //     A_exist = true;
        // }
        // if (feature[2].size()>0){
        //     cnt ++;
        //     B_exist = true;
        // }
        // ll A_rest, B_rest;
        // if (A_exist){
        //     A_rest = feature[1].size()-1;
        // }else{
        //     A_rest = feature[1].size();
        // }
        // if (B_exist){
        //     B_rest = feature[2].size()-1;
        // }else{
        //     B_rest = feature[2].size();
        // }
        // if (feature[1].size()-1>0 && feature[2].size()-1>0){
        //     cnt += min(feature[1].size()-1, feature[2].size()-1);
        // }
    }else{//ブロックなし
        if (feature[1].size()>0 && feature[2].size()>0){
            cnt += min(feature[1].size(), feature[2].size());
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 896
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

good = []
max_c = 0

for i in range(N):
    temp = V[i] - C[i]
    if(temp > 0):
        max_c = max_c + temp 

print(max_c)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int mnum1=0,mnum2=0,mind;
    for(int i=0;i<N;i++){
        int ai;
        cin >> ai;
        if(mnum1 < ai){
            mnum1 = ai;
            mind = i;
        }else{
            if(mnum2 < ai){
                mnum2 = ai;
            }
        }
    }
    for(int i=0;i<N;i++){
        if(i != mind){
            cout << mnum1 << endl;
        }else{
            cout << mnum2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

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

  double sankakuMax = a * a * b / 2;

  if (x > sankakuMax) {
    double theta = atan((2 * b * pow(a, 2) - 2 * x) / pow(a, 3));

    cout << setprecision(10) << 360 * theta / (2 * PI) << endl;

  } else {
    double theta = atan(a * pow(b, 2) / (2 * x));

    cout << setprecision(12) << 360 * theta / (2 * PI) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
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<ll> A(N); rep(i,N) cin >> A[i];
  ll ans = 0;
  if(N%2==0){
    vector<ll> dp00(N+1, 0), dp01(N+1, 0), dp10(N+1, 0), dp11(N+1, 0);
    rep(i,N){
      dp00[i+1] = i%2? dp01[i] : -1e17;
      dp01[i+1] = dp00[i]+A[i];
      dp10[i+1] = max(dp00[i], dp11[i]);
      dp11[i+1] = dp10[i]+A[i];
    }

    ans = max(dp10[N], dp11[N]);
  }
  else{
    vector<ll> dp00(N+1, 0), dp01(N+1, 0), dp10(N+1, 0), dp11(N+1, 0), dp20(N+1, 0), dp21(N+1, 0);
    rep(i,N){
      dp00[i+1] = i%2? dp01[i] : -1e17;
      dp01[i+1] = dp00[i] + A[i];
      dp10[i+1] = max(dp00[i], dp11[i]);
      dp11[i+1] = dp10[i]+A[i];
      dp20[i+1] = max(dp10[i], dp21[i]);
      dp21[i+1] = dp20[i]+A[i];
    }
    /*
    rep(i,N+1) cout << dp00[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp01[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp10[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp11[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp20[i] << " ";
    cout << endl;
    rep(i,N+1) cout << dp21[i] << " ";
    cout << endl;
    */
    ans = max({dp20[N], dp21[N]});
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14284
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNextLine()){
			String line = scan.nextLine();
			String[] cipher = line.split(" ");
			char[][] ch = new char[cipher.length][];
			int i,j;
			
			for(i=0;i<cipher.length;i++){
				ch[i] = cipher[i].toCharArray();
			}
			
			String[] str = new String[cipher.length];
			String s = "";
			out : while(true){
				for(i=0;i<cipher.length;i++){
					for(j=0;j<cipher[i].length();j++){
						if(ch[i][j]!='.' && ch[i][j]!=' '){
							if(ch[i][j] == 'z'){
								ch[i][j] = 'a';
							}else{
								ch[i][j] = (char)(ch[i][j]+1);
							}
						}
					}
					str[i] = String.valueOf(ch[i]);
				}
				
				for(i=0;i<cipher.length;i++){
					if(str[i].equals("the") || str[i].equals("this") || str[i].equals("that")
							|| str[i].equals("the.") || str[i].equals("this.") || str[i].equals("that.")){
						break out;
					}
				}
			}
			
			for(i=0;i<cipher.length-1;i++){
				s+=(str[i]+" ");
			}
			s+=str[cipher.length-1];
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 17208
#include <stdio.h>
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    string S;
    int N;

    cin >> N >> S;

    char al[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    int x=0;

    for (int i=0; i<S.length()+1; i++) {
        for (int j=0; j<26; j++) {
            if (S[i] == al[j]) {
                if (j+N < 26) {
                    S[i] = al[j + N];
                    break;
                }
                else {
                    x = 26 - j;
                    S[i] = al[N-x];
                    break;
                }
            }
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		long k=s.nextLong();
		long[] a=new long[n],b=new long[n];
		Arrays.setAll(a,i->s.nextInt());
		Arrays.setAll(b,i->s.nextInt());
		Arrays.sort(a);
		Arrays.sort(b);
		long ng=-1,ok=1000_000_000_000_000_000L;
		while(Math.abs(ok-ng)>1){
			long mid=(ok+ng)/2,r=0;
			for(int i=0;i<n;++i){
				long v=a[n-1-i]*b[i];
				r+=mid>=v?0:(v-mid+b[i]-1)/b[i];
			}
			if(r<=k)
				ok=mid;
			else
				ng=mid;
		}
		System.out.println(ok);
	}
}


Measured memory_bytes: 104524
a, b, x = map(int, input().split())
import math

if x <= (a**2 * b)/2:
  print(180*math.atan((a*b**2)/(2*x))/math.pi)
else:
  print(180*math.atan(2*(a**2*b-x)/(a**3))/math.pi)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c||a==c&&a!=b||b==c&&b!=a)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  long long N,H,W;
  cin>>N>>H>>W;
  
  vector<vector<long long>> vec(N,vector<long long>(2));
  for(int i=0;i<N;i++){
    cin>>vec[i][0]>>vec[i][1];
  }
  
  long long sum=0;
  
  
  for(int i=0;i<N;i++){
    if(vec[i][0]>=H&&vec[i][1]>=W){
      sum++;
    }
  }
  
  
  cout<<sum<<endl;
}

Measured memory_bytes: 3676
A = list(map(int, input().split()))
n = int(input())
B = [0.25, 0.5, 1, 2]

C = []
for a, b in zip(A, B):
    c = a / b
    C.append([a, b, c])
    
C.sort(key = lambda x: x[2])

ans = 0
for i in range(len(C)):
    x = n // C[i][1]
    ans += int(x * C[i][0])
    n -= x * C[i][1]
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if(a <= 0 && 0 <= b) {
    puts("Zero");
  } else {
    if(a < 0) {
      if(b >= 0) b = -1;
      if((b - a + 1) % 2 != 0) {
        puts("Negative");
        return 0;
      }
    }
    puts("Positive");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }

    int sum=0;

    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            sum += vec.at(i) * vec.at(j);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256