akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define MAXN 200005

typedef long long lint;

int N, A[MAXN];

lint solve() {
	lint ans = 0ll;
	int s = 0;
	for(int i = 0; i < N; i++) {
		s += A[i];
		if(i % 2) {
			int d = max(0, 1 - s);
			ans += d;
			s += d;
		}
		else {
			int d = max(0, s + 1);
			ans += d;
			s -= d;
		}
		//printf("i = %d, s = %d, ans = %d\n", i, s, ans);
	}
	return ans;
}

int main() {
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", A + i);

	lint ans = solve();
	for(int i = 0; i < N; i++) A[i] *= -1;
	printf("%lld", min(ans, solve()));
	return 0;
}


Measured memory_bytes: 640
/*
Author: Hamza Hasbi
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define uld unsigned long double
#define ui unsigned int
#define ud unsigned double
#define uf unsigned float
#define pi 2*acos(0.0)
#define module cin.ignore()
#define rep(i,l,r) for(auto i=l;i<=r;i++)
#define range(x,y) for(auto x:y)
//inline lcm(int a,int b) {return a*b/__gcd(a,b);}
//inline gcd(ll a,ll b) {return 1LL*b == 0 ? a : gcd(1LL*b, a*1LL % b*1LL);}
using namespace std;
int n,m;
map<int,vector<int>>graph;
map<int,int>vis;
void bfs(int node){
    queue<int>q;
    vis[node]=0;
    q.push(node);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(auto u:graph[v]){
            if(!vis.count(u)){
                vis[u]=vis[v]+1;
                q.push(u);
            }
        }
    }
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    scanf("%d%d",&n,&m);
    vis.clear();
    while(m--){
        int from,to;
        scanf("%d%d",&from,&to);
        graph[from].push_back(to);
        graph[to].push_back(from);

    }
    bfs(1);
    //cout<<vis[n]<<endl;
    
    if(vis.count(n) && vis[n]>0 && vis[n]<=2 ) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}

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

int main(){
  int N,loop;
  cin >> N;
  vector<int> X(N);
  for(loop=0;loop<N;loop++){
    cin >> X[loop];
  }
  vector<int> Xcp(N);
  Xcp=X;
  sort(X.begin(),X.end());
  int left,centre,right;
  left=X[N/2-1];
  right=X[N/2];
  if(left==right){
    for(loop=0;loop<N;loop++){
      cout << left << endl;
    }
  }else{
    for(loop=0;loop<N;loop++){
      if(Xcp[loop]<right){
        cout << right << endl;
      }else{
        cout << left << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3712
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
def rl(s): return xrange(len(s))

INF = 2147483647


import sys
stdin = sys.stdin

ai, ao, at, aj, al, aS, az = map(int, stdin.readline().strip().split())


rr = 0

triples = min([ai, aj, al])
for t in range(max(0, triples-1), triples+1):
    here = ao + 3*t
    here += (2*((ai - t) // 2)
          +2*((aj - t) // 2)
          +2*((al - t) // 2))
    rr = max(rr, here)

print rr


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int n;
int dp[55][55][22][33];
vs v;

ll solve(int u, int d, int p, int c)
{
	if (dp[u][d][p][c] >= 0) return dp[u][d][p][c];
	if (u == d) return 1;
	if (v[u].size() == p)
	{
		if (c != 0) return 0;
		else if (d - u == 1) return 1;
		else if (v[u + 1].size() > p) return solve(u + 1, d, p, c);
	}
	if (c == 26) return 0;
	ll res = 0;
	FOR(i, u, d + 1)
	{
		res += (solve(u, i, p + 1, 0) * solve(i, d, p, c + 1)) % MOD;
		res %= MOD;
		if (i != d && v[i][p] != '?' && v[i][p] != 'a' + c) break;
	}
	return dp[u][d][p][c] = res;
}

int main()
{
	MS(dp, -1);
	cin >> n;
	v.resize(n);
	REP(i, n)
	{
		cin >> v[i];
	}
	cout << solve(0, n, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 11812
S=input()
mozi_1=int(S[0:2])
mozi_2=int(S[2:4])
if 1<=mozi_1<=12 and 1<=mozi_2<=12:print("AMBIGUOUS")
elif 1<=mozi_1<=12 and (13<=mozi_2<=99 or mozi_2==0):print("MMYY")
elif 1<=mozi_2<=12 and (13<=mozi_1<=99 or mozi_1==0):print("YYMM")
else:print("NA")

#print(mozi_1)
#print(mozi_2)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    string s;
    cin>>s;
    
    int n=(int)s.size();
    string ans;
    rep(i,n) ans+="x";
    dunk(ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    string s,t;
    cin >> s >> t;
    
    if(s.size() < t.size()){
        pr("UNRESTORABLE");
        return 0;
    }

    bool af = false;

    RREP(i, s.size() - t.size() + 1){
        bool flag = true;
        REP(j, t.size()){
            if(s[i+j] != '?' && s[i+j] != t[j])  flag = false;
        }
        if(flag){
            REP(j, t.size()){
                s[i+j] = t[j];
            }
            af = true;
            break;
        }
    }

    REP(i, s.size()){
        if(s[i]=='?')s[i] = 'a';
    }

    if(af) pr(s);
    else pr("UNRESTORABLE");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	char A[h + 1][w + 1];
	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++)
	{
		if(i == 0)
		{
			for(int j = 0; j < w + 2; j++)
			{
				cout << '#';
			}
			cout << endl;
		}
		for(int j = 0; j < w; j++)
		{
			if(j == 0)
			{
				cout << '#';
			}
			cout << A[i][j];
			if(j == w - 1)
			{
				cout << '#';
			}
		}
		cout << endl;
		if(i == h - 1)
		{
			for(int j = 0; j < w + 2; j++)
			{
				cout << '#';
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define REV(i,a,b) for(i=a-1;i>=b;i--)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define mp make_pair
#define ord(v) sort(v.begin(),v.end());
const ll MAXN=2*1e5+10;
#define MAX 2*1e9
#define fi first
#define se second
#define pi 3.141592653589793238
#define rem 1000000007
#define eps 1e-9
// fflush(stdout);
//lower_bound,upper_bound,equal_range
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int n;
	cin>>n;
	vector<vector<int>>v(3,vector<int>(n+1,0));
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>v[j][i];
		}
	}
	vector<vector<int>>dp(3,vector<int>(n+1,0));
	for(int i=1;i<=n;i++)
	{
		dp[0][i]=max(dp[1][i-1],dp[2][i-1])+v[0][i];
		dp[1][i]=max(dp[0][i-1],dp[2][i-1])+v[1][i];
		dp[2][i]=max(dp[0][i-1],dp[1][i-1])+v[2][i];
	}
	cout<<max({dp[0][n],dp[1][n],dp[2][n]});
	return 0;
}

Measured memory_bytes: 5880
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;



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

	cout << ((n - 1) * n) / 2 + ((m - 1) * m) / 2 << endl;



}




Measured memory_bytes: 256
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed=True):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    N = iip(False)
    A = iip()
    A.sort()

    nm = 0
    for i in A:
        if i < 0:
            nm += 1

    A = [abs(i) for i in A]
    if nm % 2 == 0:
        print(sum(A))
    else:
        A.sort()
        #print(A)
        print(sum(A) - 2*A[0])


#####################################################ライブラリ集ここから

def fprint(s):
    for i in s:
        print(i)

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Measured memory_bytes: 69100
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    std::cout << std::max(0, -a + b + c) << std::endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n;cin>>n;
	int a[100000];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	
	if(n==2)
	{
		cout<<a[1]<<" "<<a[0]<<endl;
		return 0;
	}
	
	cout<<a[n-1]<<" ";
	for(int i=0;i<n-1;i++)
	{
		if(abs(a[n-1]-2*a[i+1])>abs(a[n-1]-2*a[i]))
		{
			cout<<a[i]<<endl;
			break;
		}
	}
	return 0;
}
	
	
	

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<pair<pair<string, int>, int>> P(N);
  for (int i = 0; i < N; i++){
    string s;
    int p;
    cin >> s >> p;
    P.at(i).first = make_pair(s, -p);
    P.at(i).second = i;
  }
  sort(P.begin(), P.end());
  for (int i = 0; i < N; i++)
    cout << P.at(i).second + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string S;
    cin>>S;
    ll a=0, b=0, c=0;
    rep(i, S.size()){
        if(S[i]=='a') a++;
        if(S[i]=='b') b++;
        if(S[i]=='c') c++;
    }
    ll Minim=min({a, b, c});
    ll Maxim=max({a, b, c});
    if(Maxim-Minim<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin >> k;
    cout << a[k-1] << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n, x, t;
    cin >> n >> x >> t;

    cout << t * ((n - 1) / x + 1) << endl;

}   

Measured memory_bytes: 3632
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = collections.Counter(["".join(sorted(list(str(input().rstrip('\n'))))) for _ in range(n)])
    cnt = 0
    for k, v in s.items():
        for i in range(1, v):
            cnt += i
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 19772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#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()

ll f(ll n) {
    if (n == 1) return 1;
    return f(n / 2) * 2 + 1;
}

void solve() {
    ll h;
    cin >> h;
    cout << f(h) << endl;
    return ;
}

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


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $n);
$in = explode(' ', fgets(STDIN));
$ans;
for($i = 0; $i < 100; $i++) {
    $sum = 0;
    foreach($in as $v) {
        $sum += ($v - $i) ** 2;
    }
    $ans[] = $sum;
}
echo min($ans), PHP_EOL;

Measured memory_bytes: 4604
package main

import (
	"fmt"
	"sort"
)

/*
1.入力された値をソートする
2.最高値をそれぞれ交互に取っていく
*/

func main() {
	var N, a int
	var numbers []int
	//受け付ける数値の数
	fmt.Scan(&N)

	//具体的な数値の入力
	for i := 0; i < N; i++ {
		fmt.Scan(&a)

		numbers = append(numbers, a)
	}

	//numbersを降順にソート
	sort.Sort(sort.Reverse(sort.IntSlice(numbers)))

	dif := 0

	//差分を求める
	for key, val := range numbers {
		if key%2 == 0 {
			dif += val
		} else {
			dif -= val
		}
	}

	fmt.Println(dif)
}


Measured memory_bytes: 1856
A,B = map(int,input().split())
lis = []
lis2 = []
dic = {}

for i in range(10 ** 6):

    i += 1
    if A % i == 0:

        if B % i == 0 and i not in dic:

            dic[i] = 0
            lis.append(i)

        if B % (A // i) == 0 and A // i not in dic:
            lis.append(A // i)
            dic[A//i] = 0

lis.sort()

ans = []
#print (lis)

for i in lis:

    flag = True
    for j in ans:

        if i % j == 0 and j != 1:
            flag = False
            break

    if flag:
        ans.append(i)

#print (ans)
print (len(ans))


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int i,a[m],b[m],c[n]={0};
	for(i=0;i<m;i++)
	{
		cin>>a[i]>>b[i];
		c[a[i]-1]++;
		c[b[i]-1]++;
	}
	for(i=0;i<n;i++)
	{
		cout<<c[i]<<endl;
	}
}

Measured memory_bytes: 3620
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let xs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans = ref 0
let _ = Array.iter (fun x -> ans := !ans + 2 * min x (k - x)) xs; Printf.printf "%d\n" !ans

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

int main() {
  string s;
  cin >> s;
  bool a = false;
  bool b = false;
  for(int i=0; i<3; i++) {
    if(s[i] == 'A') a = true;
    if(s[i] == 'B') b = true;
  }
  if(a && b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 053 
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/11
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
using namespace std;

char s[200000];

void solve() {
    
    int cnt_a = 0;
    int cnt_z = 0;
    bool is_find_a = false;
    bool is_find_z = false;
    for (int i=0;i<strlen(s)-1;i++) {
        if (is_find_a) {
            if (is_find_z) {
                printf("%ld\n", strlen(s)-cnt_z-cnt_a);
                return;
            }
        } else if (!strncmp(&s[i], "A", 1)) {
            cnt_a = i;
            is_find_a = true;
        }
        if (is_find_z) {
            ;
        } else if (!strncmp(&s[strlen(s)-1-i], "Z", 1)) {
            cnt_z = i;
            is_find_z = true;
        }
    }
    printf("%ld\n", strlen(s)-cnt_z-cnt_a);
}

int main() {

    scanf("%s", s);

    solve();

}

Measured memory_bytes: 888
alpha = "abcdefghijklmnopqrstuvwxyz"
string = ""
a = input().strip().lower()
try:
    while len(a) > 0:
        string +=a
        a = input().strip().lower()
except:
    pass

word_l = dict()
for a in alpha:
    word_l[a] = 0
for i in string: 
    if i in word_l:
        word_l[i] += 1
for val,ind in word_l.items():
    print("{} : {}".format(val,ind ))


Measured memory_bytes: 5560
use std::process;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn answer(d: char) -> ! {
    println!("{}", d);
    process::exit(0);
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let s = sc.chars();
    let k = sc.value::<i64>() - 1;  // 0-based

    for i in 0.. {
        let c = s[i];
        if k == i as i64 && c == '1' {
            answer('1');
        }
        if c != '1' {
            answer(c);
        }
    }

    assert!(false);
}


Measured memory_bytes: 4352
import heapq

class BalancingTree:
    def __init__(self):
        self.p = []
        self.q = []

    def insert(self, x):
        heapq.heappush(self.p, x)

    def erase(self, x):
        heapq.heappush(self.q, x)

    def minimum(self):
        while self.q and self.p[0] == self.q[0]:
            heapq.heappop(self.p)
            heapq.heappop(self.q)
        return self.p[0] if self.p else -1


n, q = map(int, input().split())
events = []
for _ in range(n):
    s, t, x = map(int, input().split())
    events.append((s-x, 1, x))
    events.append((t-x, 0, x))
for _ in range(q):
    d = int(input())
    events.append((d, 2, 0))

events.sort()
bt = BalancingTree()
for _, i, k in events:
    if i == 1:
        bt.insert(k)
    elif i == 0:
        bt.erase(k)
    else:
        print(bt.minimum())


Measured memory_bytes: 80572
#include<cstdio>
#include<iostream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
long long n,a[1000000+100],pok;long long cnt;
map< long long ,long long >mapa;
vector< long long > v;
map<long long ,bool >o;
int main()
{
    cin>>n;
    for (long long i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        mapa[a[i]]++;
        if (mapa[a[i]]>=2&&o[a[i]]==false)v.push_back(a[i]),o[a[i]]=true;
    }
   sort(v.begin(),v.end());
   if (v.size()==1&&mapa[v[0]]>=4){cnt=v[0]*v[0];cout<<cnt<<endl;return 0;}
   if (v.size()<2){cout<<0<<endl;return 0;}
   if (mapa[v[v.size()-1]]>=4){cnt=v[v.size()-1]*v[v.size()-1];cout<<cnt<<endl;return 0;}
   cnt=v[v.size()-1]*v[v.size()-2];
cout<<cnt<<endl;
return 0;
}


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

#define MAX_N 100005

int N;
int A[MAX_N];
vector<int> colors;

int main() {
  cin >> N;
  int n;
  rep(i, N) cin >> A[i];
  rep(i, N) {
    auto it = lower_bound(colors.rbegin(), colors.rend(), A[i]);
    if(it == colors.rbegin()) {
      colors.push_back(A[i]);
    } else {
      *(--it) = A[i];
    }
  }
  cout << colors.size() << endl;
  return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(a<b)puts("0");
	else puts("10");
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc075/tasks/abc075_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    REP(i, M) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    int ans = 0;
    REP(i, M) {
        UnionFind uf(N);
        REP(j, M) {
            // １箇所を除いて併合
            if (i != j) {
                uf.unite(a[j], b[j]);
            }
        }
        // 除外した１ヶ所が同じグループでなければ橋
        if (!uf.same(a[i], b[i])) {
            ans++;
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<string>s(n);
    rep(i, n)   cin >> s[i];
    sort(s.begin(), s.end());
    vector<pair<int, string> >dic;
    dic.emplace_back(0, s[0]);
    int ptr = 0;
    rep(i, n){
        if(s[i] == dic[ptr].second){
            dic[ptr].first++;
        }else{
            dic.emplace_back(1, s[i]);
            ptr++;
        }
    }
    sort(dic.rbegin(), dic.rend());
    vector<string>ans;
    int M = dic[0].first;
    for(int i = 0; M == dic[i].first; i++)  ans.push_back(dic[i].second);
    sort(ans.begin(), ans.end());
    rep(i, ans.size()){
        cout << ans[i] << endl;
    }
}


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

int main() {
    int a, b;
    cin >> a >> b;
    rep(i, 10010) {
        if (i*8/100==a&&i/10==b) {
            cout << i << endl;
            return 0;
        }
    } 

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            var h = new HashSet<int>(a);

            Console.WriteLine(n == h.Count() ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 35764
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val m = scn.nextInt()
	val h = IntArray(n){scn.nextInt()}
	val arr = BooleanArray(n){true}
	repeat(m){
		val a = scn.nextInt()-1
		val b = scn.nextInt()-1
		if (h[a]<=h[b]) arr[a] = false
		if (h[b]<=h[a]) arr[b] = false
	}
	println(arr.count{it})
}

Measured memory_bytes: 60224
#include <iostream>
#include <map>

using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define out(v) cout<<v<<"\n"

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

  map<char, ll> m;
  rep(i, N) {
    string S;
    cin >> S;
    ++m[S[0]];
  }
  string MARCH = "MARCH";
  ll ans = 0;
  rep(i, 5) rep(j, i+1, 5) rep(k, j+1, 5) {
    ans += m[MARCH[i]] * m[MARCH[j]] * m[MARCH[k]];
  }
  out(ans);

  return 0;
}


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

signed main(){
  int N,M;
  cin>>N>>M;
  if(N>=10||M>=10){
    cout<<-1<<endl;
    return 0;
  }
  cout<<N*M<<endl;
}

Measured memory_bytes: 256
import bisect

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

ruiseki = [0]*(n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + a[i]

def solve(min_power):
    ans = 0
    for pos in range(n):
        tmp = min_power - a[pos]
        next_pos = bisect.bisect_left(a, tmp, pos) - pos
        times = n - pos - next_pos
        if times == n - pos:
            ans += 2 * (times - 1) + 1 
        else:
            ans += 2 * times
    if ans >= m:
        return True
    else:
        return False

ok = 0
ng = 10** 9
while abs(ok - ng) > 1:
    mid =  (ok + ng) // 2 
    if solve(mid):
        ok = mid
    else:
        ng = mid

cnt = 0
ans = 0

for pos in range(n):
    tmp = ok - a[pos]
    next_pos = bisect.bisect_left(a, tmp, pos) - pos
    times = n - pos - next_pos
    if times == n - pos:
        cnt += 2 * (times - 1) + 1 
        ans += 2 * (ruiseki[n] - ruiseki[n-times+1] + (times-1)*a[pos]) + 2*a[pos]
    else:
        cnt += 2 * times
        ans += 2 * (ruiseki[n] - ruiseki[n-times] + (times)*a[pos])

print(ans - (cnt-m)*ok)


Measured memory_bytes: 57748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		if(((Math.abs(b - a) <= d) && (Math.abs(c - b) <= d)) || (Math.abs(c - a) <= d)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}

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

struct man { int id, num; } p[100005];

inline bool cmp(man x, man y) { return x.num < y.num; }
int n;

int main() {
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) scanf("%d",&p[i].num), p[i].id = i;
    sort(p + 1, p + n + 1, cmp);
    for (int i = 1; i <= n; i++) cout << p[i].id << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf (long long) 1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
//#define rep(i,n)  for(int i=0;i<n;i++)
//#define repd(i,n) for(int i=n-1;i>=0;i--)
//#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;
 
int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int powm(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }
 
 int min2(int x,int y)
 {
     if(x<=y)
     return x;
     else 
     return y;
 }
void compute()
{
    int n,d;
    cin>>n >>d;
    int cnt=0;
    double k,x,y;
    while(n--)
    {
         x,y;
         cin>>x >>y;
        // p=x*x 
         k=sqrt(x*x + y*y);
       // cout<<k<<" ";
        if(k<=d)
        cnt++;
        
    }
    cout<<cnt;
    
    

 
} 
 
int main()
{
#ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("log.txt", "w", stderr);
#endif
 //   int t;
   // scanf("%d", &t);
    //while (t--)
    //{
        compute();
   // } //end while
#ifdef debug
    fprintf(stdout, "\nTIME: %.3lf sec\n", (double)clock() / (CLOCKS_PER_SEC));
#endif
    return 0;
} //end main*

Measured memory_bytes: 3796
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> x(N),y(N);
    ll xMIN = 1e18, xMAX = 0, yMIN = 1e18, yMAX = 0;
    int numMIN = -1;
    rep(i,N) {
        cin >> x[i] >> y[i];
        if (x[i] > y[i]) swap(x[i],y[i]);
        if (chmin(xMIN,x[i])) numMIN = i;
        chmax(xMAX,x[i]);
    }
    
    vector<int> idx(N);
    iota(all(idx),0);
    sort(all(idx),[&](int i, int j){return y[i] > y[j];});
    yMAX = y[idx[0]];
    ll XX = 0;
    yMIN = y[idx.back()];
    ll ans = (xMAX-xMIN)*(yMAX-yMIN);
    rep(i,N) {
        int u = idx[i];
        if (u==numMIN) break;
        chmax(XX,x[u]);
        yMAX = max(XX,y[idx[i+1]]);
        chmin(yMIN,x[u]);
        chmax(xMAX,y[u]);
        chmin(ans,(xMAX-xMIN)*(yMAX-yMIN));
    }

    cout << ans << ln;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    vector<int> A;

    for(int i = 0; i < N; i++){
        int a;
        cin >> a;

        A.push_back(a);
    }

    int ans = 1000000;

    for(int i = -100; i < 101; i++){
        int s = 0;
        for(int j = 0; j < A.size(); j++){
            s += (A[j] - i)*(A[j] - i);
        }

        ans = min(ans, s);
    }

    cout << ans << endl;

    return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  else return abs(__gcd(a,b));
}

int32_t main(){
  DESYNC;
  int n,m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int mmc = (n*m)/gcd(n,m);
  bool ok = false;
  map<int,char> pos;
  for(int i=0; i<n; i++){
    pos[i*(mmc/n) + 1] = s[i];
  }
  for(int i=0; i<m; i++){
    int p = i*(mmc/m) + 1;
    if(pos.count(p) && pos[p] != t[i]) ok = true;
  }
  if(ok)cout << -1 << endl;
  else cout << mmc << endl;
}



Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
	string S;
	cin >> S;

	long long ans = 0;
	for (int i = 0; i < pow(2, S.size() - 1); i++){
		string sub;
		sub += S[0];
		for (int j = 0; j < S.size() - 1; j++){
			if (i & (1 << j)){
				ans += stoll(sub);
				sub = "";
			}
			sub += S[j + 1];
		}
		if (sub != ""){
			ans += stoll(sub);
		}
	}

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


Measured memory_bytes: 256
import itertools

N = int(input())
XY = [tuple(map(int,input().split())) for _ in range(N)]

def get_circle_center_and_radius(x1, y1, x2, y2, x3, y3):
  d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
  x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
  y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / -d
  r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
  return x, y, r

def check_line(x1,y1,x2,y2,x3,y3):
  if x1 == x2 == x3:
    return True
  elif y1 == y2 == y3:
    return True
  elif (y2-y1)*(x3-x1) == (y3-y1)*(x2-x1):
    return True
  else:
    return False

def check_r(x,y,r):
  res = True
  for i in range(N):
    x1,y1 = XY[i]
    if ((x-x1)**2+(y-y1)**2)**0.5 > r:
      res = False
      break
  return res

mnr = float('inf')

for i,j in list(itertools.combinations(range(N),2)):
  x1,y1 = XY[i]
  x2,y2 = XY[j]
  x = (x1+x2)/2
  y = (y1+y2)/2
  r = (((x2-x1)**2+(y2-y1)**2)**0.5)/2
  if check_r(x,y,r) and mnr > r:
    mnr = r    

for i,j,k in list(itertools.combinations(range(N),3)):
  x1,y1 = XY[i]
  x2,y2 = XY[j]
  x3,y3 = XY[k]
  if check_line(x1,y1,x2,y2,x3,y3):
    continue
  x,y,r = get_circle_center_and_radius(x1,y1,x2,y2,x3,y3)
  if check_r(x,y,r) and mnr > r:
    mnr = r

print(mnr)


Measured memory_bytes: 51032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,ll>;
const ll inf = 1e15;
const int mod = 10007;

int main() {
    int v, e, s;
    cin >> v >> e >> s;
    vector<vector<P>> cost(v);
    rep(i,e) {
        int s, t, d;
        cin >> s >> t >> d;
        cost[s].push_back(P(t,d));
    }
    vector<ll> d(v,inf);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0,s));
    while (!q.empty()) {
        P e = q.top(); q.pop();
        int v = e.second;
        if (e.first > d[v]) continue;
        for (int i = 0; i < cost[v].size(); i++) {
            P edge = cost[v][i];
            if (chmin(d[edge.first],d[v]+edge.second)) q.push(P(d[edge.first],edge.first));
        }
    }
    rep(i,v) {
        if (d[i] == inf) {
            cout << "INF" << endl;
            continue;
        }
        cout << d[i] << endl;
    }
}


Measured memory_bytes: 19400
n, m = tuple(map(int, input().split()))
h = list(map(int, input().split()))
ans = set([])

for _ in range(m):
    a, b = tuple(map(int, input().split()))
    if h[a-1] > h[b-1]:
        ans.add(b)
    elif h[a-1] < h[b-1]:
        ans.add(a)
    else:
        ans.add(a)
        ans.add(b)

print(n-len(ans))


Measured memory_bytes: 20048
#include <stdio.h>
int main()
{
	int a[3],i,m=0,s=0;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<3;i++){
		if(m<a[i])
			m=a[i];
		s+=a[i];
	}
	printf("%d",s-m);
	return 0;
}


Measured memory_bytes: 128
using System;
public class Checker
{
	public static void Main()
  	{
      	int counter = 0;
      	bool judge = false;
      	var l = new string[2];
      
    	for (int i = 0; i < 2; i++)
    	{
        	l[i] = Console.ReadLine();
    	}
      
      	string secondLine = l[1];
      	var nums = secondLine.Split(' ');
      
      	foreach (string num in nums)
        {
          	var f = int.Parse(num);
          
          	if (f % 2 == 0)
    		{
    			if (f % 3 == 0 || f % 5 == 0)
        		{
                  	judge = true;
        		}
      			else
        		{
        			judge = false;
                  	break;
        		}
    		}
  			else
    		{
              	counter++;
    		}
        }
      	if (judge == true || counter == int.Parse(l[0]))
        {
        	Console.WriteLine("APPROVED");
        }
      	else
        {
        	Console.WriteLine("DENIED");
        }
  	}
}

Measured memory_bytes: 11092
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  }
}


Measured memory_bytes: 67820
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  int H,W;
  int i,j,k;

  for(i=0;i<300;i++){
    cin >>H >>W;
    if(H==0 && W==0) break;

    for(j=1;j<=H;j++){
      for(k=1;k<=W;k++){
	if((j+k)%2==0){
	  cout <<"#";
	}
	  else cout <<".";
      }
      cout <<endl;
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[3];
    short m,i;
    m=0;
    cin>>s;
    for(i=0;i<strlen(s);++i)
    if(s[i]=='1')
      m++;
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    string s;
    cin >> s;
    if(s=="SUN"){
        cout<<7<<endl;
    }else if(s=="MON"){
        cout<<6<<endl;
    }else if(s=="TUE"){
        cout<<5<<endl;
    }else if(s=="WED"){
        cout<<4<<endl;
    }else if(s=="THU"){
        cout<<3<<endl;
    }else if(s=="FRI"){
        cout<<2<<endl;
    }else if(s=="SAT"){
        cout<<1<<endl;
    }
    return 0;
}

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


int main() {
    int N,D;
    int c=0;
    double x,y,dis;
    cin >> N >> D;
	for (int i=0;i<N;i++){
     cin >> x >> y;
     dis = sqrt(x*x+y*y);
      if (dis<=D){
        c++;
      }
    }
  cout << c << endl;
  return 0;
  
    }
  

Measured memory_bytes: 3780
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s[MAX];
  scanf("%s", s);
  int n = strlen(s);
  rep(i, 0, n) {
    if (s[i] == '1') printf("9");
    else printf("1");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#旧版のa[n-1]分を訂正してテスト
n = int(input())
a = []
for _ in range(n):
    a_ = int(input())
    a.append(a_)

ans = 0

for i in range(n-1):
    if a[i]&1:
        ans += a[i]//2
        a[i] = 1
    elif a[i] ==0:
        pass
    else:
        ans += a[i]//2-1
        a[i] = 2

for i in range(n-1):
    if a[i] == 2:
        ans += 1
        a[i] = 0
    else:
        ad = min(a[i],a[i+1])
        ans += ad
        a[i+1] -= ad
ans += a[n-1]//2
print(ans)


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

int main(){
	int n;
	cin>>n;
	for(int x=0;x<n;x++){
		int a;
		cin>>a;
		int ar[100];
		int dif[100];
		for(int i=0;i<a;i++){
			cin>>ar[i];
			}
			
		for(int i=0;i<a-1;i++){
			dif[i]=ar[i+1]-ar[i];
			}	
			
		sort(dif,dif+a-1);
		int l=dif[a-2];
		int s=dif[0];
		
		if(l<0)l=0;
		if(s>0)s=0;
		cout<<l<<' '<<abs(s)<<endl;	
		}
		return 0;
	}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 107;

int A[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	int len = 0, ans = 0;
	FOR(i, 0, n)
	{
		cin >> A[i];
		if(i != 0 && A[i] == A[i - 1])
			len++;
		else
		{
			ans += len >> 1;
			len = 1;
		}
	}
	ans += len >> 1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input().strip())
data = list(reversed(sorted(map(int, input().split()))))

cnt = {x: 0 for x in data}
for x in data:
    cnt[x] += 1

ans = 0
t = 2 ** 30
for x in data:
    while t // 2 > x:
        t = t // 2
    while cnt[x] > 0:
        cnt[x] -= 1
        if t-x in cnt and cnt[t-x] > 0:
            cnt[t-x] -= 1
            ans += 1

print (ans)



Measured memory_bytes: 34736
#include <iostream>

using namespace std;

int n, q, m;
int A[2000];
bool found;

void solve(int i, int s) {
    if (found) return;
    if (s == 0) {
        found = true;
        return;
    };
    if (i < n) {
        solve(i + 1, s - A[i]);
        solve(i + 1, s);
    }
}

int main() {

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

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> m;
        //
        found = false;
        solve(0, m);
        if (found) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<iomanip>

using namespace std;



int main() {
	int i,j,k,n,v;
	int box[100] = {};
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> box[i];
	}
	for (i = 0; i < n; i++) {
		if (i == (n - 1)) { cout << box[i]; }
		else { cout << box[i] << " "; }
	}
	cout << endl;
	for (i = 1; i < n ;i++) {
		v = box[i];
		j = i - 1;
		while (j >= 0 && box[j] > v) {
			box[j+1] = box[j];
			j--;
		}
		box[j + 1] = v;
		for (k = 0 ;k < n; k++) {
			if (k == (n - 1)) { cout << box[k]; }
			else { cout << box[k] << " "; }
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3100