akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int MN = 200005;

int N, Q, A[MN], C[MN], _S[MN * 2], *S = _S + MN, Ans;

int main() {
	scanf("%d%d", &N, &Q);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), ++C[A[i]];
	for (int i = 1; i <= N; ++i) ++S[i], --S[i - C[i]];
	for (int i = N; i >= -N; --i) S[i] += S[i + 1], Ans += i > 0 && !S[i];
	while (Q--) {
		int p, x;
		scanf("%d%d", &p, &x);
		--C[A[p]];
		if (!--S[A[p] - C[A[p]]]) if (A[p] - C[A[p]] > 0) ++Ans;
		if (!S[x - C[x]]++) if (x - C[x] > 0) --Ans;
		++C[x];
		A[p] = x;
		printf("%d\n", Ans);
	}
	return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
int N,M,Zf,Zl;
cin>>N>>M>>Zf>>Zl;
vector<int> X(N),Y(M);
for(int i=0;i<N;i++){
    cin>>X.at(i);
}
for(int i=0;i<M;i++){
    cin>>Y.at(i);
}
bool war=false;
for(int i=Zf+1;i<=Zl;i++){
    if(war) break;
    war=true;
    for(int j=0;j<N;j++){
       if(X.at(j)>=i){
         war=false;
       }
    }
    for(int k=0;k<M;k++){
        if(Y.at(k)<i){
            war=false;
        }
    }
}
if(war)cout<<"No War"<<endl;
else cout<<"War"<<endl;
}

Measured memory_bytes: 256
/*~~~~~~~~~~~~~~~~~ K++ code ~~~~~~~~~~~~~~~~~~~
in(n, x)
kluster<int> klst <<
for(i, n){
    in(tmp)
    push(klst, tmp)
}
sort(klst, 0)
if(n==1) out(abs(x-klst[0])); return 0
gcm <<
gcm = klst[0]-klst[1]
for(i in (1~n-1)){
    gcm = gcd(gcm, klst[i]-klst[i-1])
}
mini << 1e9
for(i, n){
    mini = min(mini, abs(x-klst[i]))
}
gcm = gcd(mini, gcm)
out(gcm)
@:
int gcd(int a, int b){
   if (b == 0) return a;
   return gcd(b, a % b);
}
:@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

struct struct_0_ {;;;
    int m_0;;
};;;
bool comp_klst_(const struct_0_& a, const struct_0_& b){;;;
    if(a.m_0 != b.m_0){;;;;
        return (a.m_0 < b.m_0);;
    };;;;
    return (1);;
};;;
bool comp_klst_0_(const struct_0_& a, const struct_0_& b){;;;
    return (a.m_0 < b.m_0);;
};;;
;;
;
int gcd(int a, int b){;;
   if (b == 0) return a;;
   return (gcd(b, a % b));;
};;
;;

int main(){
  ;;
    int n, x;
    cin >> n >> x;
    ;
    vector<struct_0_> klst;;
    for(int i = 0; i <  n; ++i){;;;
        int tmp;
    cin >> tmp;
    ;
        klst.push_back({tmp});
    };;;
    sort(klst.begin(), klst.end(), comp_klst_0_);;
    if(n==1) {;cout << (abs(x-klst[0].m_0)) << endl;; return (0);};
    int gcm;;
    gcm = klst[0].m_0-klst[1].m_0;
    if(1<n-1){;
        for(int i = 1; i <= n-1; ++i){;;;
        gcm = gcd(gcm, klst[i].m_0-klst[i-1].m_0);
    }
    ;}
    else {;
        for(int i = 1; i >= n-1; --i){;;;
        gcm = gcd(gcm, klst[i].m_0-klst[i-1].m_0);
    }
    ;};;;;
    int mini = 1e9;;
    for(int i = 0; i <  n; ++i){;;;
        mini = min(mini, abs(x-klst[i].m_0));
    };;;
    gcm = gcd(mini, gcm);
    cout << (gcm) << endl;;
    ;
}

Measured memory_bytes: 892
#include<iostream>
#include<string.h>
using namespace std;
int main(void){
    string X;
    int s=0,len;
    cin>>X;
    len=X.length();
    for(int i=0;i<X.length();i++){
        if(X[i] == 'S') s++;
        if(s>0 && X[i] == 'T') {
            len -= 2;
            s--;
        }
    }
    cout<<len<<endl;
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:left+n1]
    R = A[mid:mid+n2]
    L.append(float('inf'))
    R.append(float('inf'))
    
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
    
if __name__ == '__main__':

    n = int(input())
    S = [int(s) for s in input().split(" ")]
    cnt = 0

    mergeSort(S, 0, n)

    print(" ".join(map(str, S)))
    print(cnt)


Measured memory_bytes: 66732
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res
 
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
def pow_k(x, n):
 
    if n == 0:
        return 1
 
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
 
    return K * x
def main():  #startline-------------------------------------------
    n, d = map(int, input().split())
    ans = 0
    xy = [list(map(int, input().split())) for i in range(n)]
    for i in range(n):
        if np.sqrt(xy[i][0] ** 2 + xy[i][1] ** 2) <= d:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 75808
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<string.h>
#include<math.h>
ll ar1[10000000],ar2[1000000];
ll siv()
{
    ll b=1,i,a=1000000,j;
    for(i=4; i<=a; i+=2)ar1[i]=1;
    for(i=3; i*i<=a; i+=2)if(ar1[i]==0)for(j=i*i; j<=a; j+=2*i)ar1[j]=1;ar2[b++]=2;
    for(i=3;i<=a;i+=2)if(ar1[i]==0)ar2[b++]=i;return b;
}
struct fun{
char name[100];
ll dur;
};
int main()
{
    ll n,k,i,j;
    struct fun m[1005];
    cin>>n;
    k=0;
    for(i=1;i<=n;i++)
    {
        cin>>m[i].name;
        cin>>m[i].dur;
    }
    char s1[100];
    cin>>s1;
    for(i=1;i<=n;i++)
    {
        if(strcmp(s1,m[i].name)==0){k=i;break;}
    }
    ll s=0;
    for(i=k+1;i<=n;i++)
    {
        s+=m[i].dur;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n,q,l,r;
    string s;
    cin>>n>>q>>s;
    vector<ll> sum(s.size(),0);
    // return 0;
    repl(i,1,s.size()){
        // cout<<s.substr(i-1, 2)<<endl;
        if(s.substr(i-1, 2)=="AC") sum[i] += sum[i-1]+1;
        else sum[i] += sum[i-1];
    }
    rep(i,q) {
        cin>>l>>r;
        l--;r--;
        cout<<sum[r]-sum[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
list_prob = []
dict_prob = {}
for i in range(0,n):
    list_prob.append(list((map(str, input().split()))))
for i in range(0,n):
    if list_prob[i][0] == "insert":
        dict_prob[list_prob[i][1]] = 1
    else:
        try:
            dict_prob[list_prob[i][1]]
            print("yes")
        except KeyError:
            print("no")



Measured memory_bytes: 248104
/**
 *   author: Shubham Srivastava
 *   created: 26 January 2020  00:24:22
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
ll parent[2000005];


ll helper(vector <ll> &weight, vector <ll> &value, ll w, ll i, ll n, vector <vector <ll> > &dp){
	if(w <= 0 || i == n)
		return 0;
	if(dp[i][w] != -1)
		return dp[i][w];
	if(weight[i] > w)
		return dp[i][w] = helper(weight,value,w,i+1,n,dp);
	return dp[i][w] = max(value[i]+helper(weight,value,w-weight[i],i+1,n,dp), helper(weight,value,w,i+1,n,dp));

}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,w;cin>>n>>w;
   	vector <vector <ll> > dp(n+1, vector <ll> (w+1,-1));
    vector <ll> weight(n), value(n);
    for(ll i=0;i<n;i++){
    	cin>>weight[i]>>value[i];
    }
    cout<<helper(weight,value,w,0,n,dp);
return 0;
}

Measured memory_bytes: 80256
n = int(input())
a = list(map(int,input().split()));
q = int(input())
aa = 0;
for i in range(n):
    aa += a[i];

b = [input().split() for l in range(q)]

bu = [0]*(100000);

for i in range(n):
    bu[a[i]-1] += 1;
    
for x in range(q):
    c = int(b[x][0])
    d = int(b[x][1])
    aa += (d-c)*(bu[c-1]);
    bu[d-1] += bu[c-1];
    bu[c-1] = 0;
    print(aa);
    

Measured memory_bytes: 43436
//Gaurav Singh (saintpopo)
#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;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ii pair<ll,ll>;
#define vi vector<int>;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(int i = a; i < b; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
    IOS
   // io_set();
    string s;
    cin >> s;
    ll i,f=0;
    fo(i, 0, sz(s)){
        if(s[i] == '9'){
            f=1;
        }
    }
    if(f){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

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

void print_a(int a[], int n) {
    int i;
    for (i = 0; i < n - 1; i++) {
        cout << a[i] << " ";
    }
    cout << a[i] << endl;
}

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

    int a[n];

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

    print_a(a, n);

    for (int i = 1; i < n; i++) {
        int tmp;
        int j = i;
        while (j > 0 && a[j - 1] > a[j]) {
            tmp = a[j];
            a[j] = a[j - 1];
            a[j - 1] = tmp;

            j--;
        }

        print_a(a, n);
    }

    return 0;
}


Measured memory_bytes: 3136
N=int(input())
s=len(str(N))
ans=0

if s==6:
    ans = 10**(1-1)*9+10**(3-1)*9+10**(5-1)*9
elif s==5:
    ans = 10**(1-1)*9+10**(3-1)*9+(N-10000+1)
elif s==4:
    ans = 10**(1-1)*9+10**(3-1)*9
elif s==3:
    ans = 10**(1-1)*9+(N-100+1)
elif s==2:
    ans = 10**(1-1)*9
else:
    ans = N-1+1

print(ans)


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

int main(){
  stack<int> p;
  string str;
  bool a;
  while(1){
    getline(cin,str);
    a = true;
    if(str == ".") break;
    for(int i=0;i<str.length();i++){
      char ch = str[i];
      if(ch == '(') p.push(1);
      if(ch == '[') p.push(2);
      if(ch == ')'){
        if(p.empty()){
          a = false;
          break;
        }
        if(p.top() == 1){
          p.pop();
        } else{
          a = false;
          break;
        }
      }
      if(ch == ']'){
        if(p.empty()){
          a = false;
          break;
        }
        if(p.top() == 2){
          p.pop();
        }else{
          a = false;
          break;
        }
      }
    }
    if(!p.empty()) a = false;
    cout << (a?"yes":"no");
    while(!p.empty()){
      p.pop();
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3152
import java.util.Scanner;

class Solver{
	Scanner sc =new Scanner(System.in);
	
	
	void run(){
		int n = sc.nextInt();
		
		int e = 0;
		int w = 0;
		String buf  = sc.next();
		
		int[] ew = new int[n];
		int[] we = new int[n];

		int c = 0;
		for(char ch : buf.toCharArray()){
			if(ch == 'E'){
				e++;
			}else{
				w++;
			}
			ew[c] = w;
			we[c] = e;
			c++;
		}
		
		int res = we[n-1] - we[0];
		for(int i = 1; i < n ; i++){
			res = Math.min(res,ew[i-1] + we[n-1] - we[i]);
		}
		
		System.out.println(res);
		
	}
}

public class Main {
	public static void main(String[] args){
		Solver s  = new Solver();
		s.run();
	}
}


Measured memory_bytes: 31764
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const string YES = "YES";
const string NO = "NO";

void solve(long long N, long long A, long long B, long long C, long long D){
    /*
    A = abs(B - A);

    --N;
    if (A > D * N) {
        cout << NO << endl;
        return;
    }

    int E = C * N;
    int F = N * (D - C) + 1;
    int G = 2 * C - F;
    cerr << D - C << " " << F << " " << G << " " << E << endl;

    if (G <= 0) {
        cout << YES << endl;
        return;
    }

    if (F + G == 0) {
        cout << (A == 0 ? YES : NO) << endl;
    }

    E %= F + G;

    cerr << A << " " << (A + F + G - E) % (F + G) << endl;

    if ((A + F + G - E) % (F + G) < F) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
    */
    for(int m = 0; m < N; ++m) {
        if (-D * m + C * (N - m - 1) <= B - A && B - A <= -C * m + D * (N - m - 1)) {
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(N, A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
S = [0 for _ in range(N + 1)]
MOD = defaultdict(int)
for i in range(1, N + 1):
    S[i] = S[i - 1] + A[i - 1]
for n in S:
    MOD[(n % M)] += 1
ans = 0
for key in MOD:
    n = MOD[key]
    ans += n * (n - 1) // 2
print(ans)

Measured memory_bytes: 16808
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;



int main() {
	int n;
	vector<int>a;
	cin >> n;
	a.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	int cnt = 0;
	int target = 1;
	int ans=0;
	int asize = 0;
	while (true) {
		if (n == cnt || asize == a.size()) break;
		if (a[ans] == target) {
			target++;
			ans++;
		}
		else {
			//a.erase(a.begin());
			ans++;
			asize++;
		}
		cnt++;
	}
	if (asize == a.size()) cout << -1 << endl;
	else cout << asize << endl;
	
	return 0;
}


Measured memory_bytes: 1024
import Data.List
import Control.Monad

toFloat :: Int -> Double
toFloat = fromRational . toRational


solveSub :: [[Int]] -> Double
solveSub [_] = 0.0
solveSub (l1:l2:ss)  = l12 + solveSub (l2:ss)
                            where
                                x1 = l1!!0
                                y1 = l1!!1
                                x2 = l2!!0
                                y2 = l2!!1
                                l12 = sqrt $ toFloat ((x1-x2)^2 + (y1-y2)^2)

solve :: [[[Int]]] -> Double
solve [] = 0.0
solve (s:ss) = solveSub s + solve ss

main = do
    n <- readLn :: IO Int
    xyn <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
    let perm_xyn = permutations xyn
    print $ (solve $ perm_xyn) / (toFloat (length $ perm_xyn))


Measured memory_bytes: 13088
#!/usr/bin/env python3
import sys

s = input()

swox = "".join(list(filter("x".__ne__, list(s))))

# print(s, swox)
def is_palind(a):
    for i in range(len(a)//2):
        if a[i] != a[-i-1]:
            return False
    return True

if not is_palind(swox):
    print(-1)
    sys.exit(0)
#
l = 0
r = -1
count = 0
# print(s)
while True:
    # print(l, r+len(s))
    # print(s[l],s[r])
    if l >= r+len(s):
        break
    if s[l] == "x" and s[r] == "x":
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        count += 1
    elif s[r] == "x":
        r -= 1
        count += 1
    else:
        l += 1
        r -= 1
print(count)


Measured memory_bytes: 50444
#include <stdio.h>
 
int main()
{
 
  int i;
  char S[100];
  scanf("%s", S);
  for(i=0; S[i]!='\0'; ++i);
  if(i<3 && i>20){
  	printf("error");
  }else{
  for(i=0; i<3; i++){
    printf("%c",S[i]);
  	}
  }
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e15
ll Q;
ll f, x,xa,bb,al,ah;
ll i, j, k,l;
vector<ll> anss;
priority_queue<ll,vector<ll>,greater<ll>> aqh;
priority_queue<ll> aql;

int main(){
    scanf("%lld", &Q);
    j = 0;
    f = 0;
    x = 0;
    aql.push(-INF);
    aqh.push(INF);
    fornum(i,0,Q){
        ll q;
        scanf("%lld", &q);
        if(q==1){
            ll a, b;
            scanf("%lld%lld", &a, &b);
            bb += b;
            if(aql.size()==aqh.size()){
                ll qa = aqh.top();
                if(qa<a){
                    aqh.pop();
                    aqh.push(a);
                    aql.push(qa);
                    ah -= qa - x;
                    al += x - qa;
                    ah += a - x;
                }else{
                    aql.push(a);
                    al += x - a;
                }
            }else{
                ll qa = aql.top();
                if(a<qa){
                    aql.pop();
                    aql.push(a);
                    aqh.push(qa);
                    al -= x - qa;
                    ah += qa - x;
                    al += x - a;
                }else{
                    aqh.push(a);
                    ah += a-x;
                }
            }
            ll nx = aql.top();
            al += (aql.size() - 1) * (nx - x);
            ah -= (aqh.size() - 1) * (nx - x);
            x = nx;
            j++;
        }else{
                printf("%lld %lld\n", x, al + ah + bb);
        }
        //printf("b%lld %lld\n", aql.top(), aqh.top());
    }
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    int ans=0;
    int end_a=0, begin_b=0, b_and_a=0;
    for(int i=0; i<n; ++i){
        string s; cin >> s;
        for(int i=0; i<s.size()-1; ++i){
            if(s[i]=='A' && s[i+1]=='B') ++ans;
        }
        if(s[0]=='B' && s[s.size()-1]=='A') ++b_and_a;
        else if(s[0]=='B') ++begin_b;
        else if(s[s.size()-1]=='A') ++end_a;
    }
    if(b_and_a==0){
        ans+=min(end_a, begin_b);
    } else{
        ans+=b_and_a-1;
        if(end_a){
            --end_a;
            ++ans;
        }
        if(begin_b){
            --begin_b;
            ++ans;
        }
        ans+=min(end_a, begin_b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

bool gtp[100000]={};
long R,S,P;
long point(char hand){
    if (hand=='r'){
        return P;
    }else if(hand=='s'){
        return R;
    }else{
        return S;
    }
}

int main()
{

    long N,K;
    std::cin >> N >> K;
    std::cin >> R >> S >> P;
    std::string T;
    std::cin >> T;
    long count=0;
    for(long i=0; i<N-K; i++){
        if(T[i]!=T[i+K]){
            if(gtp[i]==0){
                count+=point(T[i]);
            }
        }else{
            if(gtp[i]==0){
                gtp[i+K]=1;
                count+=point(T[i]);
            }
        }
    }
    
    for(long i=N-K; i<N; i++){
        if(gtp[i]==0){
            count+=point(T[i]);
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 512
import collections
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
result=[]
for i in range(a):
    n=c[i][1:]
    result+=n
ans=collections.Counter(result)
ans1,ans2=zip(*ans.most_common())
ans2=list(ans2)
print(ans2.count(a))

Measured memory_bytes: 9480
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    string s;
    cin>>s;
    ll q;
    cin>>q;
    ll rev = 0;
    string pre="",bck="";
    for(ll i=0;i<q;i++){
        int t;
        cin>>t;
        if(t==1){
            rev++;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if(f==1){
                if(rev%2==0)pre.push_back(c);
                else bck.push_back(c);
            }
            else{
                if(rev%2==0)bck.push_back(c);
                else pre.push_back(c);
            }
        }
    }
    ll len1 = pre.length();
    ll len2 =bck.length();
    if(rev%2==0){
        for(ll i=0;i<len1;i++){
            cout<<pre[len1-1-i];
        }
        cout<<s;
        for(ll i=0;i<len2;i++){
            cout<<bck[i];
        }
        cout<<endl;
    }
    else{
        for(ll i=0;i<len2;i++){
            cout<<bck[len2-1-i];
        }
        ll len = s.length();
        for(ll i=0;i<len;i++){
            cout<<s[len-1-i];
        }
        cout<<pre<<endl;
    }
    return 0;

}


Measured memory_bytes: 1088
n = int(input())
hash_lst = [0 for _ in range(100)]

for i in range(1, n+1):
    start = str(i)[0]
    end = str(i)[-1]
    hash_lst[int(start + end)] += 1

ans = 0
for j in range(1, 10):
    j = str(j)
    for k in range(1, 10):
        k = str(k)
        ans += hash_lst[int(j + k)] * hash_lst[int(k + j)]

print(ans)

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

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

const ll INF = 1LL << 60;

int main(){
  ll n;
  cin >> n;
  string f;

  ll m[100]={0};
  FOR(i,n){
    cin >> f;
    if(f[0]=='M')m[0]++;
    if(f[0]=='A')m[1]++;
    if(f[0]=='R')m[2]++;
    if(f[0]=='C')m[3]++;
    if(f[0]=='H')m[4]++;
  }
  ll ans=0;
  ans+=m[0]*m[1]*m[2];
  ans+=m[0]*m[1]*m[3];
  ans+=m[0]*m[1]*m[4];
  ans+=m[0]*m[2]*m[3];
  ans+=m[0]*m[2]*m[4];
  ans+=m[0]*m[3]*m[4];
  ans+=m[1]*m[2]*m[3];
  ans+=m[1]*m[2]*m[4];
  ans+=m[1]*m[3]*m[4];
  ans+=m[2]*m[3]*m[4];
  cout << ans << endl;
}


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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) clog << #x << ": " << x << endl;
#endif

int ans[333][333][333];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    int K; cin >> K;
    
    for(int i=0; i<n; i++) for(int k=0; k<=K; k++) ans[i][0][k] = 0;
    for(int i=0; i+1<=n; i++) for(int k=0; k<=K; k++) ans[i][1][k] = 1;
        
    for(int l=2; l<=n; l++){
        for(int i=0; i+l<=n; i++){
            for(int k=0; k<=K; k++){
                int r = -2;
                if(s[i] == s[i+l-1]) r = ans[i+1][l-2][k];
                if(k > 0) r = max(r, ans[i+1][l-2][k-1]);
                ans[i][l][k] = max( max(ans[i][l-1][k], ans[i+1][l-1][k]), 2 + r );
                //~ cerr << i << ' ' << l << ' ' << k << ' ' << ans[i][l][k] << endl;
            }
        }
    }
    //~ cerr << 0 << ' ' << n << ' ' << K << ' ' << ans[0][n][K] << endl;
    cout << ans[0][n][K] << '\n';
}


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

using ll=long long;
ll n,ans,M=10000000LL;

int main(){
  cin>>n;
  for(long long i=2;i*i<=n;i++){
    int j=i;
    while(!(n%j))ans++,n/=j,j*=i;
    while(!(n%i))n/=i;
  }
  cout<<ans+(n!=1)<<endl;
}


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

int main(){
    vector<int> a(3);
    for(int i = 0;i < 3;i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    cout << abs(a.at(1) - a.at(0)) + abs(a.at(2) - a.at(1)) << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)    {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

char a[30][30]={};
char n='#';
char o='.';						       

int dfs(int score,int x,int y)
{
  a[y][x]=n;
  score++;
  dprintf("x,y=%2d,%2d = %d\n",x,y,score);
  if(a[y+1][x]==o)
    score=dfs(score,x,y+1);
  if(a[y-1][x]==o)
    score=dfs(score,x,y-1);
  if(a[y][x+1]==o)
    score=dfs(score,x+1,y);
  if(a[y][x-1]==o)
    score=dfs(score,x-1,y);
  
  return score;
}

signed main(void)
{
  while(1)
    {
      in(int,w,h);
      if(w==0)
	break;
      int i,j;
      rep(i,30)rep(j,30)a[i][j]=0;
      int x,y;
      rep(i,h)
	rep(j,w)
	{
	  scanf(" %c",&a[i][j]);
	  if(a[i][j]=='@')
	    x=j,y=i;
	}
      cout<<dfs(0,x,y)<<endl;
    }
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n, x, t; scanf("%d%d%d", &n, &x, &t);
  printf("%d", (n+x-1)/x*t);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
int n, m;
ll x[1111], y[1111];
ll d[44];
string order[1111];

ll gv(ll u, ll v)
{
	return abs(u)+abs(v);
}

void activate(ll D, ll cut)
{
	int i;
	for(i=1 ; i<=n ; i++)
	{
		if(gv(x[i],y[i]-D)<=cut) y[i]-=D, order[i].push_back('U');
		else if(gv(x[i],y[i]+D)<=cut) y[i]+=D, order[i].push_back('D');
		else if(gv(x[i]-D,y[i])<=cut) x[i]-=D, order[i].push_back('R');
		else if(gv(x[i]+D,y[i])<=cut) x[i]+=D, order[i].push_back('L');
		else assert(false);
	}
}

void fuck(void)
{
	cout<<-1;
	exit(0);
}

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int i; cin>>n;
	for(i=1 ; i<=n ; i++) cin>>x[i]>>y[i];
	for(i=1 ; i<=n-1 ; i++) if(abs(x[i]+y[i]-x[i+1]-y[i+1])%2) fuck();
	for(i=30 ; i>=0 ; i--) 
	{
		m++; d[m]=(1LL<<i);
		activate(1LL<<i,1LL<<i);
	}
	if(abs(x[1]+y[1])%2==1)
	{
		m++; d[m]=1;
		activate(1,0);
	}
	cout<<m<<"\n";
	for(i=1 ; i<=m ; i++) cout<<d[i]<<" ";
	for(i=1 ; i<=n ; i++) cout<<order[i]<<"\n";
	return 0;
}

// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 512
<?php
$S = str_split(trim(fgets(STDIN)));
$long = count($S);
$ans = 1000;
for ($i = 0;$i<$long-2;$i++){
  $num = $S[$i].$S[$i+1].$S[$i+2];
    if ($ans>abs(753-$num)){
      $ans = abs(753-$num);
    }
}
echo $ans;

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

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

	int ans=0;
	for(int i=0;i<k;i++)ans+=a[i];

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
numberlist = dict()
for i in range(N):
    if A[i] in numberlist:
        numberlist[A[i]] += 1
    else:
        numberlist[A[i]] = 1
numberlist = sorted(numberlist.items(), key=lambda x: x[1])
#print(numberlist)
ans = 0
index = 0
lenlist = len(numberlist)
while(1):
    if index >= lenlist - K:
        break
    ans += numberlist[index][1]
    index += 1
print(ans)


Measured memory_bytes: 39044
solve :: String -> String -> String -> Char -> String
solve [] _ _ 'a' = "A"
solve _ [] _ 'b' = "B"
solve _ _ [] 'c' = "C"
solve a b c next
  | next == 'a' = solve (tail a) b c (head a)
  | next == 'b' = solve a (tail b) c (head b)
  | next == 'c' = solve a b (tail c) (head c)

main :: IO ()
main = do
  sa <- getLine
  sb <- getLine
  sc <- getLine
  putStrLn $ solve sa sb sc 'a'

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string ans="ABC";
    ans+=s;
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3568
n,m,x = map(int,input().split())

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

grid = [0] * n

for i in range(1,n+1):
	if i in A:
		grid[i-1] = 1
        
x_0 = grid[:x].count(1)
x_n = grid[x:].count(1)

print(min(x_0,x_n))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int list[100][100];

int main(){
    int n,m;
    cin >> n >> m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            list[i][j] = 0;
    
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        list[a][b] = list[b][a] = 1;
    }
    vector<int> v(n - 1);
    for(int i=1;i<n;i++) v[i-1] = i;
    sort(v.begin(),v.end());
    int ans = 0;

    do{
        int now = 0;
        for(int i=0;i<v.size();i++){
            if(list[now][v[i]] == 0) break;
            now = v[i];
            if(i == v.size() - 1)ans++;             
        }
    }while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code
int co[30];
int main()
{
string s;
cin>>s;
rep(i, 0, s.length())
{
  int curr = s[i] - 'a';
  if(co[curr] >= 1)
  {
    cout<<"no"<<endl;
    return 0;
  }
  co[curr]++;
}
cout<<"yes"<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    // Input numbers
    long long a;
    double b;
    cin >> a >> b;

    int b_100 = round(b*100);

    // Output
    cout << (long long)((a*b_100)/100) << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S[0]==S[1]&&S[1]==S[2])
    cout << "No" << endl;
  else if(S[0]==S[1]){
    if(S[2]==S[3]){
      cout << "Yes" << endl;
    }
    else
      cout << "No" << endl;
  }
  else if(S[0]==S[2]){
    if(S[1]==S[3]){
      cout << "Yes" << endl;
    }
    else
      cout << "No" << endl;
  }
  else if(S[0]==S[3]){
    if(S[1]==S[2])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else
    cout << "No" << endl;
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
constexpr int MOD = 1e9 + 7;

int dp[100010];
bool solve() {
    int N, L;
    cin >> N >> L;
    REP(i, N + 1) dp[i] = 0;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(all(A));
    dp[0] = 1;
    FOR(i, 0, N) {
        int x = A[i];
        int idx = lower_bound(all(A), x - L) - A.begin();
        dp[i + 1] = dp[i] * (i - idx + 1);
        dp[i + 1] %= MOD;
    }
    cout << dp[N] << endl;
}

signed main() {
    // while (solve())
    solve();
}


Measured memory_bytes: 4428
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=INT64_MAX;
const int32_t LOG=21;
const int MOD=MOD2;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
            int n;
            cin>>n;
            int sum=0;
            rep(i,1,n+1)
            {
                 if(i%3!=0 && i%5!=0)
                 sum+=i; 
            }
            cout<<sum<<endl;  
      }

      return 0;                         
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/


Measured memory_bytes: 3660
import os
import sys
from fractions import gcd
from functools import reduce

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

g = reduce(gcd, A)
ok = False
for a in A:
    if a == K:
        ok = True
    if a > K:
        ok |= (a - K) % g == 0
if ok:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 14512
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	println(((a + b) >= c ? "Yes" : "No"));
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define PI 3.14159265359
 
int main(){
  ll X, A, B, i, j;
  
  cin >> X;
  
  for (ll A = -119; A <= 119; A++){
    for(ll B = -119; B <= 119; B++){
      if(pow(A, 5) - pow(B, 5) == X){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

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

typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++) // no semicoron
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>0;i--)
#define FORD(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

using namespace std;

int main(){
    long double L;

    cin >> L;

    cout << fixed;
    cout << setprecision(12) << pow(L/3, 3) << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    while(1){
        string s; cin>>s;
        if(s == "#") return 0;
        int y, m, d; cin>>y>>m>>d;

        if(31 < y || (y == 31 && 4 < m)){
            cout << "? " << y - 30 << " " << m << " " << d << endl;
        }
        else{
            cout << s << " " << y << " " << m << " " << d << endl;
        }
    }
}


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

using namespace std;
typedef long long int ll;

int dh[4] = {1,0,-1,0};
int dw[4] = {0,1,0,-1};

int main()
{
   int n;
   cin >> n;
   vector<int>fib(n+1);
   fib[0] = 1;
   fib[1] = 1;
   for(int i = 2; i <= n; i++)
   {
       fib[i] = fib[i-1]+fib[i-2];
   }
   cout << fib[n] << endl;
}


Measured memory_bytes: 3128
#include<iostream>
using namespace std;
int main() {
    int n;
    int min = 1000000, max = -1000000;
    long sum = 0;
    int a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a < min) min = a;
        if (a > max) max = a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}



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

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<int> black;
    int ans=N;
    int min=N;
    for(int i=0;i<N;i++){
        if(S[i]=='#')black.push_back(i);
    }
    if(black.size()==0){
        cout<<0;
        return 0;
    }
    for(int i=0;i<black.size();i++){
        int temp=black.size()-i;
        int tmp=i+N-black[i]-temp;
        min=std::min(tmp,min);
    }
    min=std::min(min,(int)black.size());
    cout <<min;
    return 0;
}

Measured memory_bytes: 1532
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

# 合計で倒せる数
cnt = 0
# 次の街を助けることのできる数
help_cnt = 0
for i in range(n):
    # 自分の街で倒す数 = min(街のモンスター - 前の街の勇者が助けた数, 自分が倒せる数)
    now_kill_cnt = min(a[i]-help_cnt, b[i])

    # 次の街を助けることのできる数を更新
    # min(次の街のモンスター数, 余力)
    help_cnt = min(a[i+1], b[i]-now_kill_cnt)
    cnt += now_kill_cnt
    cnt += help_cnt


print(cnt)


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

using namespace std;
typedef long long ll;


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

    int k = n%10;

    if (k==3)
        cout << "bon\n";
    else if (k==0||k==1||k==6||k==8)
        cout << "pon\n";
    else cout << "hon\n";


    return 0;
}



Measured memory_bytes: 3636
N = int(input())

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

lis = []

x = 0

for i in range(N):

    if i % 2 == 0:
        x += A[i]

    else:
        x -= A[i]

lis.append(x)

for i in range(N-1):

    lis.append( 2* A[i] - lis[-1] )

nlis = map(str,lis)
ans = " ".join (nlis)
print(ans)

    



    


Measured memory_bytes: 84324
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cctype>
using namespace std;

int main(){
    int A,B,C;cin>>A>>B>>C;
  if(A<=C&&C<=B){
    puts("Yes");
  } else {
    puts("No");
  }
}

Measured memory_bytes: 256