akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int m, k;
	cin >> m >> k;

	if ((1 << m) <= k) {
		cout << -1 << endl;
		return 0;
	}

	if (k == 0) {
		vector<int> v;
		rep(i, 1 << m) rep(_, 2) {
			if (i or _) cout << ' ';
			cout << i;
		}
		cout << endl;
		return 0;
	}

	int sum = 0;
	rep(i, 1 << m) sum = sum xor i;
	if (k == (sum xor k)) {
		deque<int> d;
		d.emplace_back(k);
		rep(i, 1 << m) {
			if (i == k) continue;
			d.emplace_front(i);
			d.emplace_back(i);
		}
		d.emplace_back(k);

		bool f = false;
		while (not d.empty()) {
			if (f) cout << ' ';
			cout << d.front();
			d.pop_front();
			f = true;
		}
		cout << endl;
		return 0;
	}

	cout << -1 << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define p_b push_back
#define pll pair < ll , ll >

using namespace std;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin >> n >> k;
    ll ch  = 0;
    while(n)
    {
        n/=k;
        ch++;
    }
    cout << ch;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  flag=1;
  Sort(P);
  rep(i,1,N)if(P[i]==P[i-1])flag=0;
  if(flag)Out("YES");
  else Out("NO");
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,ans;
char s[200005];

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	int lst=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='S') lst++;
		else{
			if(!lst) ans++;
			else lst--;
		}
	}
	cout<<ans+lst<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<int> PRIME = divisor(M);
  int ANS = 1;
  for (int i = 0; i < PRIME.size(); i++)
  {
    if(M/PRIME[i]>=N)
    {
      ANS = max(ANS,PRIME[i]);
    }
  }
  
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    int n;
    cin >> n;
    vl v(n),s(n);
    rep(i,n){
        cin >> v[i];
        s[i] =v[i];
    }
    sort(all(s));
    ll a=s[n/2];
    ll b=s[n/2-1];
    rep(i,n){
        if(v[i]<=b)cout << a << endl;
        else cout << b << endl;
    }
}

Measured memory_bytes: 5376
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	
	static char[] chars;
	static{
		String v="abcdefghijklmnopqrstuvwxyz";
		chars=(v.toUpperCase()+v).toCharArray();
	}
	static int getIndex(char c){
		return c<='Z'?c-'A':c-'a'+26;
	}
	
	public static void main(String[] __){
		while(true){
			int n=s.nextInt();
			if(n==0) return;
			
			int[] key=IntStream.range(0,n).map(i->s.nextInt()).toArray();
			char[] str=s.next().toCharArray();
			
			for(int i=0;i<str.length;i++){
				str[i]=chars
						[(getIndex(str[i])
						-key[i%key.length]
						+chars.length)
						%chars.length];
			}
			System.out.println(String.valueOf(str));
		}
	}
}

Measured memory_bytes: 36748
#include <iostream>
using namespace std;
int main (void) {
    int N;
    string S;

    cin >> N;
    cin >> S;

    int x = 0;
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::ios_base::sync_with_stdio(0);
    int x,y;
    std::cin >> x >> y;
    int64_t sum = 0;
    if (x <= 3) sum += (4-x) * 100000;
    if (y <= 3) sum += (4-y) * 100000;
    if (x==y && y==1) sum += 4 * 100000;
    std::cout << sum;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

t = int(input())

nabcd = [tuple(map(int,input().split())) for i in range(t)]

INF = float('inf')
from functools import lru_cache

for n,a,b,c,d in nabcd:

    @lru_cache(None)
    def dfs(now):
        if now == 0:
            return 0
        elif now == 1:
            return d
        elif now == 2:
            return min(d+a, d*2)
        elif now <0:
            return INF

        tmp = now*d

        # over 2
        sho = now//2+1
        fusoku = sho*2 - now
        over2 = dfs(sho)+d*fusoku+a

        # not over 2
        sho = now//2
        amari = now-sho*2
        nver2 = dfs(sho)+d*amari+a

        # over 3
        sho = now//3+1
        fusoku = sho*3 - now
        over3 = dfs(sho)+d*fusoku+b

        # not over 3
        sho = now//3
        amari = now-sho*3
        nver3 = dfs(sho)+d*amari+b

        # over 5
        sho = now//5+1
        fusoku = sho*5 - now
        over5 = dfs(sho)+d*fusoku+c

        # not over 5
        sho = now//5
        amari = now-sho*5
        nver5 = dfs(sho)+d*amari+c

        return min(tmp,over2,nver2,over3,nver3,over5,nver5)

    ans = dfs(n)
    print(ans)


Measured memory_bytes: 102032
import math

defi = input().split()
Number = int(defi[0])
Distance = int(defi[1])
count = 0

P = [input().split() for i in range(Number)]

for i in range(Number):
  test = math.sqrt(float(P[i][0])*float(P[i][0]) + float(P[i][1])*float(P[i][1]))
  if(float(Distance) >= test):
    count += 1

print(count)



Measured memory_bytes: 120140
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 pr(cei(n,2));
 return 0;}



Measured memory_bytes: 3600
h, w = map(int, input().split())
s = [input() for _ in range(h)] # #.のグリッドの場合
seen = [[0] * w for _ in range(h)]
seen[0][0] = 1
dp = [[99] * w for _ in range(h)]
dp[0][0] = 0
current = '.'

if s[0][0] == '#':
    dp[0][0] = 1
    current = '#'

from collections import deque
step = [(0,1), (0,-1), (1,0), (-1,0)]
que = deque()
que.append((0, 0))
#import numpy as np
while que:
    x, y = que.popleft()
    for tx, ty in step:
        current = s[x][y]
        xi, yi = x + tx, y + ty
        if xi < 0 or yi < 0 or xi >= h or yi >= w:
            continue
        if s[xi][yi] == s[x][y]:
            dp[xi][yi] = min(dp[x][y], dp[xi][yi])
            if seen[xi][yi] == 0:
                seen[xi][yi] = seen[x][y] + 1
                que.append((xi, yi))
        if s[xi][yi] != s[x][y]:
            if s[xi][yi] == '.':
                dp[xi][yi] = min(dp[x][y], dp[xi][yi])
            else:
                dp[xi][yi] = min(dp[x][y]+1, dp[xi][yi])
            if seen[xi][yi] == 0:
                seen[xi][yi] = seen[x][y] + 1
                que.append((xi, yi))
    #print(np.array(seen))
#print(np.array(dp))
print(dp[h-1][w-1])


Measured memory_bytes: 3564
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> p = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            p.add(sc.nextInt());
        }
        Collections.sort(p);
        int ans = p.get(n - 1) / 2;

        for (int i = 0; i < n - 1; i++) {
            ans += p.get(i);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
n,m = map(int,input().split())
if m%2 == 1:
    a = 1
    b = a+2*(m//2)+2
    for i in range(m//2+1):
        print(a,a+2*(m//2-i)+1)
        a += 1
    for i in range(m//2):
        print(b,b+2*(m//2-i))
        b += 1
else:
    a = 1
    b = a+2*(m//2)+1
    for i in range(m//2):
        print(a,a+2*(m//2-i))
        a += 1
    for i in range(m//2):
        print(b,b+2*(m//2-i-1)+1)
        b += 1

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

int main() {
  int n;cin>>n;
  rep(i,n) {
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<(a[2]*a[2]==a[1]*a[1]+a[0]*a[0] ? "YES":"NO")<<endl;
  }
  return 0;
}



Measured memory_bytes: 3060
N,K = map(int,input().split())
A = list(map(int,input().split()))
D = {}
for i in A :
    if i in D :
        D[i] += 1
    else :
        D[i] = 1
L = list(D.values())
L = sorted(L)
ans = 0
counter = 0
for i in range(len(L)) :
    if len(L) - counter > K :
        ans += L[i]
        counter += 1
    else :
        print(ans)
        break


Measured memory_bytes: 32184
from collections import deque, defaultdict

S = input()

L = int(S)
S = S[::-1]
cnt = defaultdict(int)

tmp = 0
answer = 0
for i, s in enumerate(S):
    tmp = (tmp + int(s) * pow(10, i, 2019)) % 2019
    #print(tmp)
    if tmp % 2019 == 0:
        answer += cnt[0] + 1
    else:
        answer += cnt[tmp % 2019]
    cnt[tmp % 2019] += 1
    #print(tmp, answer)

print(answer)

Measured memory_bytes: 71764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _169B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine() ?? string.Empty);
            var A = Console.ReadLine()?.Split(' ').Select(tmp => long.Parse(tmp)).ToArray();
            var AList = new List<long>();
            AList.AddRange(A);
            long mul = 1;

            if (AList.Contains(0))
            {
                Console.WriteLine(0);
                return;
            }

            foreach (var ai in A)
            {
                try
                {
                    mul = checked(mul * ai);
                    if (mul > 1000000000000000000)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                }
                catch (OverflowException)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(mul);

        }
    }
}


Measured memory_bytes: 42844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
#define mp make_pair
 
const int N = (int)1e6 + 5;
int n, m;
vector<pil> g[N];
ll a[N][2];
bool used[N];
 
void dfs(int v) {
//	cerr << "dfs " << v << endl;
	used[v] = 1;
	for (pil e : g[v]) {
		int u = e.first;
		if (used[u]) continue;
		a[u][0] = -a[v][0];
		a[u][1] = e.second - a[v][1];
		dfs(u);
	}
}
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	scanf("%d%d", &n, &m);
	while(m--) {
		int v, u;
		ll w;
		scanf("%d%d%lld", &v, &u, &w);
		v--;u--;
		g[v].push_back(mp(u, w));
		g[u].push_back(mp(v, w));
	}
	a[0][0] = 1;
	dfs(0);
 
	ll L = (ll)1;
	ll R = (ll)1e10;
	ll F = -1;
 
	for (int v = 0; v < n; v++) {
		//cerr << "for " << v << endl;
		if (a[v][0] == 1) {
			L = max(L, 1 - a[v][1]);
		} else {
			R = min(R, a[v][1] - 1);
		}
		for (pil e : g[v]) {
			int u = e.first;
			ll x = a[v][0] + a[u][0];
			ll y = a[v][1] + a[u][1];
			if (x == 0) {
				if (y != e.second) {
					printf("0\n");
					return 0;
				}
			} else {
				ll z = e.second - y;
				if (z % 2 != 0) {
					printf("0\n");
					return 0;
				}
				z /= x;
				if (z <= 0) {
					printf("0\n");
					return 0;
				}
				if (F == -1) F = z;
				if (F != z) {
					printf("0\n");
					return 0;
				}
			}
		}
	}
 
	if (F == -1)
		printf("%lld\n", max(0LL, R - L + 1));
	else {
		if (L <= F && F <= R)
			printf("1\n");
		else
			printf("0\n");
	}
 
	return 0;
}

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


int main(){
  int n,k;
  cin >> n >> k;
  int ans=n;
  bool d[15];
  for(int i=0;i<15;++i){
    d[i]=false;
  }
  for(int i=0;i<k;++i){
    int ki;
    cin >> ki;
    d[ki]=true;
  }
  while(1){
    bool ok=true;
    int s=ans;
    while(s>0){
      if(d[s%10]==true){
        ok=false;
      }
      s=s/10;
    }
    if(ok) break;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string s;
    cin >> s;
    int c = ((s[0]=='o')?1:0) + ((s[1]=='o')?1:0) + ((s[2]=='o')?1:0) ;
    cout << (700 + c * 100) << endl;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  sort(v.begin(),v.end());
  int dp[k+1];
  memset(dp,0,sizeof(dp));
  for(int i=0;i<n;i++)
    dp[v[i]]=1;
  for(int i=v[0]+1;i<=k;i++){
    if(dp[i]==0){
     int q=0;
      for(int j=0;j<n;j++){
      if(i-v[j]>=0 && dp[i-v[j]]==0){
          q=1;
          dp[i]=1;
          break;
       }
     }
      if(q==0)
        dp[i]=0;
   }
  }
    if(dp[k]==1)
      cout<<"First";
    else
       cout<<"Second";
 }


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

using namespace std;

int main(){
    int N;cin>>N;
    vector<int> A(N,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    for(int i=1;i<N;i++){
        if(A[i-1]==A[i]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int[] ary=new int[26];
		Arrays.fill(ary, 0);
		while(sc.hasNext()) {
			String s=sc.nextLine();
			for(int i=0; i<s.length(); i++) {
				if(s.charAt(i)>='a' && s.charAt(i)<='z') {
					ary[s.charAt(i)-'a']++;
				}
				else if(s.charAt(i)>='A' && s.charAt(i)<='Z') {
					ary[s.charAt(i)-'A']++;
				}
				else {
					//
				}
			}
		}
		for(int i=0; i<26; i++) {
			System.out.println(((char) (i+'a'))+" : "+ary[i]);
		}
	}
}


Measured memory_bytes: 26148
import collections

N = int(input())
blue = [input() for i in range(N)]

M = int(input())
red = [input() for j in range(M)]

CTR_blue = collections.Counter(blue)
CTR_red = collections.Counter(red)

maxx = 0

for v in CTR_blue.keys():
    cnt = CTR_blue[v] - CTR_red[v]
    
    maxx = max(cnt, maxx)

print(maxx)

Measured memory_bytes: 3316
from bisect import bisect
 
def sieve(n):
    num = [True]*n
    num[0] = num[1] = False
    for i in xrange(2,int(n**0.5)+1):
        if num[i]:
            for j in xrange(i**2, n, i):
                num[j] = False
    return [i for i in xrange(2,n) if num[i]]
 
prime =  sieve(999999)
 
while True:
    try:
        print bisect(prime, input())
    except:
        break

Measured memory_bytes: 16580
import math

N = int(input())
A = [int(x) for x in input().split()]

if 0 in A:
    print(0)
elif sum(map(math.log, A)) > math.log(10**18*1.1):
    print(-1)
else:
    temp = 1
    for a in A:
        temp *= a
    if temp > 10 ** 18:
        print(-1)
    else:
        print(temp)

Measured memory_bytes: 22684
#include <stdio.h>
#include <stdlib.h>
#define N 200000
void hashclear(void);
void hash_inc(long int);
long int hash_getc(long int);

typedef struct {
    long int value;
    long int count;
} kv;

kv mmm[2*N];

void hash_clear(){
    long int t;
    for(t=0;t<2*N;t++){
        mmm[t].count=0;
        mmm[t].value=-1;
    }
}

void hash_inc(long int q){
    long int x=q%(N-1);
    while(mmm[x].value!=-1&&mmm[x].value!=q)
        x++;
    if (mmm[x].value==-1)
        mmm[x].value=q;
    mmm[x].count++;
}

long int hash_getc(long int q){
    long int x=q%(N-1);
    while(mmm[x].value!=q){
        if(mmm[x].value==-1) break;
        x++;
    }
    return(mmm[x].count);
}

int main(){
    long int n;
    long int a[N];

    long int i,j,c;

    hash_clear();

    scanf("%ld",&n);
    for(i=0;i<n;i++)
        scanf("%ld",&a[i]);

    for(i=0;i<n-1;i++)
            hash_inc(a[i]+i);

    c=0;
    for(j=1;j<n;j++)
            if(j-a[j]>0) c+=hash_getc(j-a[j]);

    printf("%ld\n",c);

}




Measured memory_bytes: 9536
#include <stdio.h>

int main(void){
  int i,j,l;
  int w[100],k[100];
  int sum_w=0,sum_k=0;
  int tmp;

  for(i=0;i<10;i++){
    scanf("%d",&w[i]);
  }
  for(i=0;i<10;i++){
    scanf("%d",&k[i]);
  }

  for(i=0;i<9;i++){
    for(j=9;j>i;j--){
      if(w[j]>w[j-1]){
	tmp=w[j];
	w[j]=w[j-1];
	w[j-1]=tmp;
      }
      if(k[j]>k[j-1]){
	tmp=k[j];
	k[j]=k[j-1];
	k[j-1]=tmp;
      }
    }
  }

  for(i=0;i<3;i++){
    sum_w+=w[i];
    sum_k+=k[i];
  }
  printf("%d %d\n",sum_w,sum_k);
  return(0);
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;

    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3820
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC096D_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;

            int[] primes = PrimeNumbers(55555);

            List<int> ans = new List<int>();
            for (int i = 0; i < primes.Length; i++)
            {
                if (primes[i] % 5 == 1) ans.Add(primes[i]);
                if (ans.Count == N) break;
            }

            Console.WriteLine(string.Join(" ", ans));
        }

        /// <summary>
        /// 自然数n以下の素数prime列挙 (NloglogN)
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static int[] PrimeNumbers(int n)
        {
            int max = n;
            var searchList = Enumerable.Range(2, max).ToList();

            var pList = new List<int>();
            while (searchList.Count > 0)
            {
                int cand = searchList.First();

                pList.Add(cand);

                searchList.RemoveAll(x => x % cand == 0);
            }

            return pList.ToArray();
        }
    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13664
#include<stdio.h>
int main(){
  int n,m,k,i,j;
  scanf("%d%d%d",&n,&m,&k);
  for(i=0;i<=n;i++){
    for(j=0;j<=m;j++){
      if(i*(m-j)+(n-i)*j==k){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
}

Measured memory_bytes: 128
def read(): return list(map(int, input().split()))


n = int(input())
a = read()

ans = 1145141919810893
for j in range(2):
    sum, cur = 0, 0
    for i, v in enumerate(a):
        plus = (i % 2 == j % 2)
        sum += v
        if plus and sum > 0: continue
        if not plus and sum < 0: continue

        if plus:
            cur += 1 - sum
            sum = 1
        else:
            cur += sum + 1
            sum = -1

    ans = min(ans, cur)

print(ans)

Measured memory_bytes: 14332
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mdl=1000000007;
in p2(in a){
  return 1LL<<a;
}
VI wys[2];
in nct(in n, in x, in y, in z){
  in ts=x+y+z;
  forn(z,2)
    wys[z].resize(p2(ts),0);
  in nw=0;
  in sw=1;
  wys[nw][p2(0)]=1;
  forn(zz,n){
    swap(nw,sw);
    forn(i,p2(ts)){
      wys[sw][i]%=mdl;
      wys[nw][i]=0;
    }
    in numsk;
    forn(omsk,p2(ts)){
      for(in d=1;d<=10;++d){
	numsk=p2(0);
	if(d>=ts){
	  wys[nw][p2(0)]+=wys[sw][omsk];
	  continue;
	}
	bool bad=0;
	in stt;
	forn(c,ts){
	  if(!(omsk&p2(c)))
	    continue;
	  if(c+d==ts && d<=z){
	    bad=1;
	    break;
	  }
	  stt=0;
	  if(c>=x)
	    stt=1;
	  if(c>=x+y)
	    stt=2;
	  if(stt==0 && c+d>x)
	    continue;
	  if(stt==1 && c+d>x+y)
	    continue;
	  if(stt==2 && c+d>x+y+z)
	    continue;
	  numsk|=p2(c+d);
	}
	if(bad)
	  continue;
	wys[nw][numsk]+=wys[sw][omsk];
      }
    }
  }
  in sm=0;
  forn(msk,p2(ts))
    sm+=wys[nw][msk];
  sm%=mdl;
  return sm;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,x,y,z;
  cin>>n>>x>>y>>z;
  in sm=1;
  forn(z,n)
    sm=sm*10%mdl;
  sm-=nct(n,x,y,z);
  sm%=mdl;
  if(sm<0)
    sm+=mdl;
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 2304
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(str, input().split()))

    odd = [A[i] for i in range(0, N, 2)]
    even = [A[i] for i in range(1, N, 2)]

    if len(A) % 2 == 0:
        return ' '.join(even[::-1] + odd)
    else:
        return ' '.join(odd[::-1] + even)


if __name__ == '__main__':
    print(main())


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

typedef long long ll;
#define pii pair<int ,int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

ll n , s;
ll a[MAXX];
ll b[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    ll ans = 0;
    ll m = n / 2;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i] - (i + 1);
    }
    sort(b , b + n);
    for(ll i = 0; i < n; i++){
        ans += abs(b[i] - b[m]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vi l(q);
    vi r(q);
    vi t(n,0);
    rep(i,q){
        cin >> l[i] >> r[i];
    }
    int tmp = 0;
    rep1(i,n){
        if(s[i]=='C'&&s[i-1]=='A') ++tmp;
        t[i]=tmp; 
    }
    //for(auto it : t) cout << it ;
    rep(i,q){
        cout << t[r[i]-1] - t[l[i]-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 2256
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int N;

int main() {
	cin >> N;

	string s, ps;

	cout << 0 << endl;
	cin >> s;

	int l, m, h;
	l = 0, h = N;
	while (s != "Vacant") {
		m = (l + h) * .5;

		string t;
		if ((m - l) % 2) {
			t = s == "Male" ? "Female" : "Male";
		} else {
			t = s == "Female" ? "Female" : "Male";
		}

		cout << m << endl;

		ps = s;
		cin >> s;

		if (s == "Vacant") continue;

		if (s == t) {
			l = m;
		} else {
			h = m;
			s = ps;
		}
	}

	return 0;
}


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

int main(){
    double W,H,x,y;
    cin>>W>>H>>x>>y;

    cout<<W*H/2<<" ";
    if(W/2==x&&H/2==y){
        cout<<1<<endl;
    }
    else {
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {1, 1, 0, -1, -1, 0};
int dx[] = {1, 0, -1, -1, 0, 1};
#define ceil(a, b) a / b + !!(a % b)


void solve(int t, int n) {
    int a[301], b[301];
    //cout << 1 << endl;
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    //cout << 2 << endl;
    int stx, sty;
    cin >> stx >> sty;
    //cout << 3 << endl;
    rep(i, n) {
        a[i] -= stx; b[i] -= sty;
    }
    queue<pair<pii, int> > q;
    q.push({{0, 0}, 0});
    set<pii> s;
    s.insert({0, 0});
    while (!q.empty()) {
        int x = q.front().first.first;
        int y = q.front().first.second;
        int step = q.front().second;
        //cout << x << " " << y << " " << step << endl;
        q.pop();
        if (step == t) continue;
        rep(i, 6) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx >= 31 || ny >= 31) continue;
            auto it = s.find({nx, ny});
            if (it != s.end()) continue;
            int flg = 0;
            rep(j, n) {
                if (nx == a[j] && ny == b[j]) {
                    flg = 1;
                    break;
                }
            }
            if (flg) continue;
            q.push({{nx, ny}, step + 1});
            s.insert({nx, ny});
        }
    }
    cout << s.size() << endl;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t, n;
    while (cin >> t >> n && (t || n)) {
        solve(t, n);
    }
    
}



Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int gcd(int a,int b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}
int main(){
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        ans+=s[i]-'0';
    }
    cout << ans << endl;
    return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[120][10200] = {};
int main() {
	int N;
	cin >> N;
	vector<int> c;
	vector<int> s;
	vector<int> f;
	for (int i = 0; i < N - 1; i++) {
		int a, b, d;
		cin >> a >> b >> d;
		c.push_back(a);
		s.push_back(b);
		f.push_back(d);
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = i; j < N - 1; j++) {
			if (sum < s[j]) {
				sum = s[j];
				sum = sum + c[j];
			}
			else {
				int k = sum - s[j];
				sum = sum + c[j];
				if (k % f[j] != 0) {
					sum = sum + (f[j] - k % f[j]);
				}
			}
		}
		cout << sum << endl;
	}
}

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

Measured memory_bytes: 256
#include<stdio.h>

void input(int*,int*,int*);
int min(int,int);
int main(void){
    int a,b,c;
    int ans;
    input(&a,&b,&c);
    ans=min(c,b/a);
    printf("%d\n",ans);
    return 0;
}
void input(int* a,int* b,int* c){
    scanf("%d %d %d",a,b,c);
}
int min(int p,int q){
    int min;
    if(p<q){
        min=p;
    }
    else{
        min=q;
    }
    return min;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;




int main(){
    ll n, d;
    cin >> n >> d;
    vector<ll> t(n);
    rep(i, n)   cin >> t[i];

    ll sum = 0;
    rep(i, n-1){
        if(d < t[i+1] - t[i]){
            sum += d;
        }
        else{
            sum += t[i+1] - t[i];
        }
    }

    sum += d;

    cout << sum << endl;



    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int _max(int a,int b){return a>b?a:b;}

int main(){
	
	long long ans=0;
	int n,k,i,a;
	scanf("%d%d",&n,&k);
	for(i=k+1;i<=n;i++){
		ans+=(long long)(n/i)*(i-k);
		ans+=(long long)_max(0,n%i-k+1);
	}
	if(k==0)ans-=(long long)n;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
H = list(map(int,input().split()))

for i in range(N - 1):
    if H[i] <= H[i + 1]:
        continue
    elif H[i + 1] + 1 == H[i]:
        H[i + 1] = H[i]
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 20676
import sys
input=sys.stdin.readline

def main():
    n,m,x=map(int,input().split())
    C=[]
    As=[]
    for _ in range(n):
        c,*A=map(int,input().split())
        C.append(c)
        As.append(A)
    ans=float('inf')
    for i in range(1<<n):
        S=[0]*m
        tmp=0
        for j,(c,A) in enumerate(zip(C,As)):
            if (i>>j)&1==0:
                continue
            tmp+=c
            for k,a in enumerate(A):
                S[k]+=a
        if min(S)>=x:
            ans=min(ans,tmp)
    print(-1 if ans==float('inf') else ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 68952
#include <iostream>
#include <atcoder/lazysegtree>
using namespace std;
using namespace atcoder;

long long M = 998244353;

struct S
{
    long long value;
    int size;
};

long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

S op(S a, S b)
{
    return {
        (a.value*powmod(10, b.size, M)%M+b.value)%M,
        a.size+b.size
    };
}

S e()
{
    return {0, 0};
}

vector<long long> one(1, 0);

S mapping(long long f, S x)
{
    while ((int)one.size()<=x.size)
    {
        one.push_back((one.back()*10+1)%M);
    }

    if (f>=0)
        x.value = one[x.size]*f%M;
    return x;
}

long long composition(long long f, long long g)
{
    return f<0 ? g : f;
}

long long id()
{
    return -1;
}

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

    lazy_segtree<S, op, e, long long, mapping, composition, id> LST(vector<S>(N, {1, 1}));
    for (int q=0; q<Q; q++)
    {
        int L, R, D;
        cin>>L>>R>>D;

        LST.apply(L-1, R, D);
        cout<<LST.all_prod().value<<endl;
    }
}


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

int maximum(int a, int b, int c){
    return max(max(a, b), c);
}
int main() {
    int a, b;
    int max = 0;
    cin >> a >> b;
    cout << maximum(a + b, a - b, a * b) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n,m,ans;
  cin>>n>>m;
  ans=n;
  rep(i,m){
    int a;
    cin>>a;
    ans-=a;
  }
  if(ans < 0){
    cout<<"-1"<<endl;
  }
  else{
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void) {
    int n, a[100], b[100], c[100], i, d=0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) scanf("%d",&b[i]);
    for(i=0;i<n-1;i++) scanf("%d",&c[i]);
    
    for(i=0;i<n;i++){
        d+=b[a[i]-1];
        if(i!=0){
            if(a[i]==a[i-1]+1) d+=c[a[i-1]-1];
        }
    }
    printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 1712
import sys
sys.setrecursionlimit(10 ** 7)
# O(N**2)
class SuffixArray(object):
    """
    construct:
        suffix array: O(N(logN)^2)
        lcp array: O(N)
        sparse table: O(NlogN)
    query:
        lcp: O(1)
    """

    def __init__(self, s):
        """
        s: str
        """
        self.__s = s
        self.__n = len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    # suffix array
    def __suffix_array(self):
        s = self.__s;
        n = self.__n
        # initialize
        sa = list(range(n))
        rank = [ord(s[i]) for i in range(n)]
        tmp = [0] * n
        k = 1
        cmp_key = lambda i: (rank[i], rank[i + k] if i + k < n else -1)
        # iterate
        while (k <= n):
            sa.sort(key=cmp_key)
            tmp[sa[0]] = 0
            for i in range(1, n):
                tmp[sa[i]] = tmp[sa[i - 1]] + (cmp_key(sa[i - 1]) < cmp_key(sa[i]))
            rank = tmp[:]
            k <<= 1
        self.__sa = sa
        self.__rank = rank

    # LCP array
    def __lcp_array(self):
        s = self.__s;
        n = self.__n
        sa = self.__sa;
        rank = self.__rank
        lcp = [0] * n
        h = 0
        for i in range(n):
            j = sa[rank[i] - 1]
            if h > 0: h -= 1
            if rank[i] == 0: continue
            while j + h < n and i + h < n and s[j + h] == s[i + h]: h += 1
            lcp[rank[i]] = h
        self.__lcp = lcp

    # sparse table
    def __sparse_table(self):
        n = self.__n
        logn = max(0, (n - 1).bit_length())
        table = [[0] * n for _ in range(logn)]
        table[0] = self.__lcp[:]
        # construct
        from itertools import product
        for i, k in product(range(1, logn), range(n)):
            if k + (1 << (i - 1)) >= n:
                table[i][k] = table[i - 1][k]
            else:
                table[i][k] = min(table[i - 1][k], table[i - 1][k + (1 << (i - 1))])
        self.__table = table

    def lcp(self, a, b):
        """
        a,b: int 0<=a,b<n
        return LCP length between s[a:] and s[b:]
        """
        if a == b: return self.__n - a
        l, r = self.__rank[a], self.__rank[b]
        l, r = min(l, r) + 1, max(l, r) + 1
        i = max(0, (r - l - 1).bit_length() - 1)
        table = self.__table
        return min(table[i][l], table[i][r - (1 << i)])
def main():
  N = int(input())
  S = input()
  sa = SuffixArray(S)
  ans = 0
  for i in range(N):
    for j in range(i+1, N):
      ans = max(min(j-i, sa.lcp(i,j)), ans)
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 54080
import math
N, D = map(int,input().split())
z = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N):
    if math.sqrt(z[i][0] ** 2 + z[i][1] ** 2) <= D:
        cnt += 1

print(cnt)

Measured memory_bytes: 45300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int E[5001], n[5001], C[5001], H[2501];
bool vis[2501];
void dfs(int v) {
	vis[v] = true;
	for (int p = H[v]; p; p = n[p]) {
		int to = E[p];
		if (!vis[to]) dfs(to);
	}
}

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


	int N, M, P;
	cin >> N >> M >> P;
	rep1(i, M) {
		int a;
		cin >> a >> E[i] >> C[i];
		n[i] = H[a];
		H[a] = i;
	}
	ll D[2501];
	rep1(i, N) D[i] = -2e9;
	D[1] = 0;
	int q[2501] = {};
	q[1] = 1;

	//こんな明らかに正しくない提出をして何をしたいというのかこの男は
	int cnt[2501] = {};

	rep1(k, N) {
		rep1(i, N) {
			if (q[i] == k) {
				for (int p = H[i]; p; p = n[p]) {
					int to = E[p];
					ll d = D[i] + C[p] - P;
					if (D[to] < d && cnt[to] < 1000) {
						cnt[to]++;
						D[to] = d;
						q[to] = k + 1;
					}
				}
			}
		}
	}

	rep1(i, N) {
		if ((q[i] == N + 1 || cnt[i] == 1000) && !vis[i]) dfs(i);
	}

	if (vis[N]) co(-1);
	else co(max(0ll, D[N]));


	Would you please return 0;
}

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

using namespace std;
int main(){
	intl k,a,b;
	cin>>k>>a>>b;
	if(a+1>=b){
		cout<<1+k<<endl;
	}
	else{
		intl pasos;
		if(k-(a-1)<=0){
			cout<<1+k<<endl;
		}
		else{
			intl current=a;
			pasos=k-(a-1);
			intl dif=b-a;
			current+=(pasos/2)*dif;
			if(pasos%2==1){
				current++;
			}
			cout<<current<<endl;
		}
	}
}

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

def next_lunlun(x):
    K = len(x)
    if len(x) == 1:
        return str(int(x) + 1)
    elif x[-1] == '9':
        next =  next_lunlun(x[:-1])
        if int(next[-1]) - 1 >= 0:
            return next + str(int(next[-1]) - 1)
        else:
            return next + '0'
    elif x[-2] >= x[-1]:
        return x[:-1] + str(int(x[-1]) + 1)
    else:
        next = next_lunlun(x[:-1])
        if int(next[-1]) - 1 >= 0:
            return next + str(int(next[-1]) - 1)
        else:
            return next + '0'


def solve(K: int):
    x = '0'
    for k in range(K):
        x = next_lunlun(x)
    print(x)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


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

int get_parent(vector<int> &p, int i)
{
	return p[i] == i ? i : p[i] = get_parent(p, p[i]);
}

int main()
{
	int n;
	scanf("%d", &n);
	vector<pair<int, int>> x, y;
	for (int i = 0; i < n; i++)
	{
		int xx, yy;
		scanf("%d %d", &xx, &yy);
		x.push_back({ xx, i });
		y.push_back({ yy, i });
	}

	vector<vector<int>> c;
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	for (int i = 1; i < n; i++)
	{
		c.push_back({ x[i].first - x[i - 1].first, x[i].second, x[i - 1].second });
		c.push_back({ y[i].first - y[i - 1].first, y[i].second, y[i - 1].second });
	}

	sort(c.begin(), c.end());
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		p[i] = i;
	long long ans = 0;
	for (int i = 0; i < c.size(); i++)
	{
		int px = get_parent(p, c[i][1]), py = get_parent(p, c[i][2]);
		if (px == py) continue;
		ans += c[i][0];
		p[px] = py;
	}
	printf("%lld\n", ans);

	return 0;
}

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

int main(void){
    
    
    while(1) {
        int N, A, B, C, X;
        int Y[100];
        cin >> N >> A >> B >> C >> X;
        if (N==0) break;
        for(int i=0; i<N; i++) cin >> Y[i];
        int y_index=0;
        for(int i=0; i<=10000; i++) {
            if (Y[y_index] == X) {
                y_index++;
                if (y_index == N) {
                    cout << i << endl;
                    break;
                }
            }
            X = (A * X + B) % C;
        }
        if (y_index != N) {
            cout << -1 << endl;
        }
    }
    
}

Measured memory_bytes: 1160