akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long r){
 cout << r * r << endl;
}

signed main(){
  long long r;
  scanf("%lld",&r);
  solve(r);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <complex>
#include <queue>
#include <stack>


#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const ld pi = acos(-1.0);
const ld e  = exp(1.0);


int main(){
	
	int n;
	scanf("%d", &n);
	printf("ABC%d\n", n);
    return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """41 2
5 6"""
        output = """30"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 2
5 6"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """11 2
5 6"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3"""
        output = """9"""
        self.assertIO(input, output)


def resolve():
    n, a = read()
    result = think(n, a)
    write(result)


def read():
    n, m = read_int(2)
    return n, read_int(m)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, a):
    total = sum(a)
    return -1 if n < total else n - total


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    resolve()

Measured memory_bytes: 72280
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    if n == 0:
        return False
    lpabcdefsm = [input().split() for _ in range(n)]
    ans = []
    for A in lpabcdefsm:
        l = A[0]
        p, a, b, c, d, e, f, s, m = map(int, A[1:])
        time = a + b + c + (d + e) * m
        score = f * s * m - p
        ans.append((score / time, l))
    ans.sort(key=lambda x: (-x[0], x[1]))
    for _, i in ans:
        print(i)
    print("#")
    return True


#main
if __name__ == '__main__':
    while solve():
        pass



Measured memory_bytes: 8372
def factorization(n: int) -> list:
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    n = int(input())
    if n == 1:
        print(0)
        return
    factors = factorization(n)
    ans = 0

    for _, e in factors:
        ei = 1
        while ei <= e:
            e -= ei
            ei += 1
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63220
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, x;
    cin >> n >> x;
    int l[n];
    REP(i,n) cin >> l[i];
    int d[n+1];
    d[0] = 0;
    for (int i = 1; i <= n; i++) {
        d[i] = d[i-1] + l[i-1];
    }
    int cnt = 0;
    REP(i,n+1) {
        if (d[i] <= x) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include <algorithm>
using namespace std;
 
int main(){
  long long X;
  cin >> X;
  if(X == 2){
    cout << X;
    return 0;
  }
  if(X%2 == 0) X += 1;
  while(true){
    bool f = false;
    for(int i=3;i<=sqrt(X);i+=2){
      if(X%i == 0) f = true;
    }
    if(f == false) break;
    X += 1;
    if(X%2 == 0) X+=1;
  }
  cout << X;
  return 0;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


   cin>>n;

   ll ara[n+2];

   l=1;

   for(i=0; i<n; i++)
   {
       cin>>ara[i];

       l=lcm(l,ara[i]);
   }

   for(i=0; i<n; i++)
   {
       sum+=(l/ara[i]);
   }


    double s=sum,L=l;

      L=L/s;

      cout<<setprecision(10)<<fixed<<L<<endl;






}



Measured memory_bytes: 3840
#include <stdio.h>

int max(int i, int j)
{
  if(i<j) return j;
  return i;
}

int main()
{
  int W, N;
  int weight[1001], value[1001];
  int **d;
  int maxvalue, minweight;
  int count=0;
  int i, j;

  while(1){
    count++;
    scanf("%d",&W);
    if(W==0) break;
    scanf("%d",&N);
    d=(int**)malloc(sizeof(int*)*(N+1));
    for(i=0; i<=N; i++) d[i]=(int*)malloc(sizeof(int)*(W+1));
    for(i=0; i<N; i++){
      scanf("%d,%d",&value[i+1],&weight[i+1]);
    }
    for(i=0; i<=N; i++) d[i][0]=0;
    for(j=0; j<=W; j++) d[0][j]=0;
    for(i=1; i<=N; i++){
      for(j=1; j<=W; j++){
	if(j-weight[i]<0) d[i][j]=d[i-1][j];
	else d[i][j]=max(d[i-1][j],d[i-1][j-weight[i]]+value[i]);
      }
    }
    maxvalue=d[N][W];
    minweight=W;
    for(j=W-1; j>0; j--){
      if(d[N][j]==maxvalue) minweight=j;
      else break;
    }
    printf("Case %d:\n", count);
    printf("%d\n", maxvalue);
    printf("%d\n", minweight);
    free(*d);
    free(d);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main()
{
	int a, b, c, d, e, k;

	std::cin >> a >> b >> c >> d >> e >> k;

	if(e - a <= k)
	{
		std::cout << "Yay!" << std::endl;
	}
	else
	{
		std::cout << ":(" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
using namespace std;
const int N = 1e6 + 5;
const ll inf = -1e18;
const int MOD = 1e9 + 7;



int main(){
   fast;
   ll n, k;
   cin >> n >> k;
   if(n % k == 0)
   	cout << 0;
   else
   	cout << 1;




   return 0;
} 

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;


  if (A <= C && C <= B) {
    cout << "Yes" << endl;
    return 0;
  }
  if (B <= C && C <= A) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  
  return 0;
}

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

const int inf = 1 << 28;

int main(void){
	int n,m;
	while(cin >> n >> m,n){
		vector<int> s(n),d(m);
		rep(i,n) cin >> s[i];
		rep(i,m) cin >> d[i];
		
		vector<int> dp(1<<n,inf);
		dp[0] = 0;
		rep(i,m) dp[0] += d[i];

		rep(mask,1<<n)rep(i,n){
			if(mask &(1<<i)) continue;
			int cur = 0;
			rep(j,n) if(mask &(1<<j)) cur+=s[j];
			int nxt = cur + s[i];

			int ncost = dp[mask];
			rep(j,m){
				if(d[j]<=cur) continue;
				const int ctar = abs(d[j]-cur);
				const int ntar = abs(d[j]-nxt);
				if(ctar > ntar) ncost += ntar - ctar;
			}	

			dp[mask|(1<<i)] = min(dp[mask|(1<<i)],ncost);
		}
		cout << dp[(1<<n)-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 10010;
const int MAXM = 10;
const int MAXK = 510;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    int sum = 0;
    FOR(i,1,n-1) sum += a[i];
    if (sum > a[n]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: char,
        b: char,
    }

    if a.to_digit(16).unwrap()>b.to_digit(16).unwrap() {
       println!(">"); 
    } else if a.to_digit(16).unwrap()==b.to_digit(16).unwrap() {
        println!("=");
    } else if a.to_digit(16).unwrap()<b.to_digit(16).unwrap() {
        println!("<");
    }

}


Measured memory_bytes: 2156
#include<stdio.h>

#define N 100000

int partition(int A[], int p, int r){
  int temp,x,i,j;
  
  x = A[r];
  i = p-1;
  for (j = p; j< r; j++){
    if (A[j] <= x){
      i = i+1;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  
  return i+1;
}
  

void print(int A[], int n,int mid){
  int i;
  for ( i = 1; i <=n; i++ ){
    if ( i > 1 ) printf(" ");
    if (i==mid) printf("[");
    printf("%d", A[i]);
    if (i==mid) printf("]");
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <=n; i++ ) scanf("%d", &A[i]);
  int mid = partition(A, 1, n);
  
  print(A, n, mid);

  return 0;
}


Measured memory_bytes: 2088
<?php
	$n = trim(fgets(STDIN));
    $V = explode(" ",trim(fgets(STDIN)));
    $C = explode(" ",trim(fgets(STDIN)));

	$sumV = 0;
	$sumC = 0;

	for($i=0; $i<$n; $i++){
    	if(($V[$i] - $C[$i]) > 0){
        	$sumV += $V[$i];
          	$sumC += $C[$i];
        }
    }

	echo $sumV - $sumC;
?>

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

using namespace std;

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

    int d = min(a+b, c*2);

    int n = min(x,y);
    int cost = d*n;
    n = abs(x-y);

    if(x>y){
        if(2*c<a){
            cost += 2*c*n;
        }
        else{
            cost += a*n;
        }
    }
    else{
        if(2*c<b){
            cost += 2*c*n;
        }
        else{
            cost += b*n;
        }
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>

using namespace std;

int INF = 1000000007;

array<int, 100000> FCT;

int modmulti(int a, int b)
{
    int res = 0;
    int mod = a % INF;
    while (b > 0)
    {
        if ((b & 1) == 1)
        {
            res += mod;
            if (res > INF)
            {
                res -= INF;
            }
        }
        mod <<= 1;
        if (mod > INF)
        {
            mod -= INF;
        }
        b >>= 1;
    }
    return res;
}

void factorial(int x)
{
    FCT[0] = 1;
    FCT[1] = 1;
    for (int i = 2; i <= x; i++)
    {
        FCT[i] = modmulti(FCT[i - 1], i);
    }
}

int main()
{
    int N, M;
    if (scanf("%d%d", &N, &M) < 2) return 0;

    if (N == M || N == M + 1 || M == N + 1)
    {
        if (N <= M) factorial(M);
        else factorial(N);

        int ans = modmulti(FCT[N], FCT[M]);

        if (N == M) ans = modmulti(ans, 2);

        printf("%d\n", ans);
    }
    else printf("%d\n", 0);

    return 0;
}


Measured memory_bytes: 512
A, B = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

A_divisors = make_divisors(A)
ans = 1
m = []
for d in A_divisors:
    if d == 1: continue
    if B%d==0:
        for mi in m:
            if d%mi == 0:
                break
        else:
            ans += 1
            m.append(d)
            continue
        
print(ans)


Measured memory_bytes: 3316
x,y,z=map(int,input().split())
if (x+y) <= (x+z)  and (x+y)<= (y+z):
  print(x+y)
elif (x+z) <= (x+y) and (x+z) <= (y+z):
  print(x+z)
elif (y+z) <= (x+y) and (y+z) <= (x+z):
  print(y+z)
else:
  print(x+z)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    string ans = "No";
    rep1(i, n){
        if (s[i]==t[i]) ans = "Yes";
        else{
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

	map<ll, ll> A;
	vector<ll> V(n);

	for (ll i = 0; i < n; i++)
	{
		cin >> V[i];
		A[V[i]] = A[V[i]] + 1;
	}

	auto n1 = (*A.rbegin()).first;
	auto c1 = (*A.rbegin()).second;
	auto n2 = (*(++A.rbegin())).first;
	
	for (auto v: V)
	{
		cout << ( (v != n1 || (v == n1 && c1 > 1)) ? n1 : n2 ) << endl;
	}


	return 0;
}

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

int main() {
    int r;
    int D;
    int x[11]={0};

    cin >> r;
    cin >> D;
    cin >> x[0];

    for (int i=1; i<=10; i++) {
        x[i] = r * x[i-1] - D;
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int n; 
int main(){
	cin>>n;
	
	if(n<1200)cout<<"ABC";
	else if(n<2800)cout<<"ARC";
	else cout<<"AGC";
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
#define debug(x) cout << #x << " = " << (x) << endl
#define debugv(x) cout << #x << " = "; VOUT(x);
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN(n);
  vi a(n);
  VIN(a);

  deque<ll> ansv;
  ansv.pb(a[0]);
  FOR(i,1,n) {
    ll now = a[i];
    if (now <= ansv[0]) {
      ansv.push_front(a[i]);
    } else {
      ll index = lower_bound(ALL(ansv), now) - ansv.begin();
      //debug(index);
      ansv[index-1] = a[i];
    }
    //debugv(ansv);
  }

  OUT(ansv.size());
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(3*N);
    REP(i, 3*N) cin >> a[i];
    sort(All(a));
    int ans = 0;
    for(int i=3*N-1; i>=N; i-=2){
        ans += a[i-1];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560
N,x=map(int,input().split())
a=list(map(int,input().split()))
s=0
if a[0]>x:
    s+=a[0]-x
    a[0]=x
for i in range(1,N):
    if a[i-1]+a[i]>x:
        s+=a[i-1]+a[i]-x
        a[i]=x-a[i-1]
print(s)

Measured memory_bytes: 14540
import sys
sys.setrecursionlimit(10**9)

n = int(input())
edges = [[] for _ in range(n)]
costs = [-1]*n
def dfs(current):

    for nex, cost in edges[current]:
        if costs[nex] != -1:
            continue
        costs[nex] = costs[current] + cost
        dfs(nex)

for i in range(n-1):
    a, b, c = map(int,input().split())
    a -= 1
    b -= 1
    edges[a].append((b, c))
    edges[b].append((a, c))

q, k = map(int, input().split())
k -= 1
costs[k] = 0
dfs(k)

res = []
for _ in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    res.append(costs[x]+costs[y])

for ans in res:
    print(ans)


Measured memory_bytes: 132692
def A():
    N, R = map(int, input().split())
    if N >= 10:
        print(R)
    else:
        print(R + 100*(10-N))

def B():
    N, K = map(int, input().split())
    n = N
    ans = 1
    while n >= K:
        q, r = divmod(n, K)
        ans += 1
        n = q
    print(ans)
B()

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    print(s.replace(","," "))
    
main()

Measured memory_bytes: 3064
#include<stdio.h>

int main() {
	int i,counta=0,countb=0,countc=0;
	char a[4];

	scanf("%s", a);

	for (i = 0; i < 3; i++) {
		switch (a[i]) {
		case 'a':
			counta++;
			break;
		case 'b':
			countb++;
			break;
		case 'c':
			countc++;
			break;
		

		}
	}
	if (counta == 1 && countb == 1 && countc == 1)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
N=int(input())
a=[int(i) for i in input().split()]

#最大値と最小値の検索
max_a=-100000000
min_a=100000000
max_index=-1
min_index=-1
for i in range(N):
    if a[i] > max_a:
        max_a=a[i]
        max_index=i
    if a[i] < min_a:
        min_a=a[i]
        min_index=i

tezyun=[]
#全て同じ数
if min_a==max_a:
    None
#全てのaiが0以上
elif min_a>=0:
    for i in range(1,N):
        tezyun.append([i,i+1])
#全てのaiが0以下
elif max_a<=0:
    for i in reversed(range(1,N)):
        tezyun.append([i+1,i])
#正負がまじっている
else:
    count=0
    if abs(max_a)>=abs(min_a):
        for i in range(N):
            if a[i]<0:
                a[i]=a[i]+a[max_index]
                tezyun.append([max_index+1,i+1])
                count+=1
        for i in range(1,N):
            tezyun.append([i,i+1])
    elif abs(max_a)<abs(min_a):
        for i in range(N):
            if a[i]>0:
                a[i]=a[i]+a[min_index]
                tezyun.append([min_index+1,i+1])
                count+=1
        for i in reversed(range(1,N)):
            tezyun.append([i+1,i])

print(len(tezyun))
for te in tezyun:
    print(te[0],te[1])


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

before = A[0]
is_ascending = None
ans = 0
for a in A:
    d = a - before
    if d == 0:
        pass
    else:
        if is_ascending == None:
            is_ascending = d > 0
        elif (is_ascending and d < 0) or (not is_ascending and d > 0):
            ans += 1
            is_ascending = None
    
    before = a

print(ans+1)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

ll INF = 1LL << 30;

int main()
{
  int N,K;
  cin >> N >> K;
  vint H(N);
  cin >> H;
  vll dp(N);
  REP(i,N) dp[i] = INF;
  dp[0] = 0;
  REP(now,N){
    for(int next=now+1; next<=min(N,now+K); next++){
      chmin(dp[next],dp[now]+abs(H[now]-H[next]));
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll    long long
#define pb          push_back
#define F first
#define S second
#define    endl        '\n'
#define all(v) (v).begin(), (v).end()
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    string sep;
    for (const auto &x : v) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename T, size_t size> ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os   << '(' << p.first << ", " << p.second << ')';
}
void dbg_out()
{
    cerr << endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}

#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
const int N = 1000 + 5;
void solve()
{
    string a,b;
    ll n,m;

    cin>>a>>b;
    n=a.size();
    m=b.size();
    ll ans=1e9;
    for(int i=0;i+m<=n;i++)
        {
            ll j=0,tot=0;
            while(j<m)
            {
                tot+=a[j+i]!=b[j];
                j++;
            }
            ans=min(ans,tot);

        }
        cout<<ans;
}
int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    ll TESTS = 1;
    // cin >> TESTS;
    for(int t = 1; t <= TESTS; t++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3620
import copy

N=int(input())
A=[]
for _ in range(N):
    A.append(int(input()))

A_max=max(A)
ind_max=A.index(A_max)
B=copy.copy(A)
B.remove(A_max)
B_max=max(B)

for i in range(N):
    if i!=ind_max:
        print(A_max)
    else:
        print(B_max)


Measured memory_bytes: 14560
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a < b)
    {
        int t = a;
        a = b;
        b = t;
    }
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    int n;
    cin >> n;
    int rgcd[n + 2], lgcd[n + 2], a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (n == 2)
    {
        cout << max(a[0], a[1]) << endl;
        return 0;
    }
    lgcd[0] = 0;
    lgcd[1] = a[0];
    lgcd[n + 1] = 0;

    rgcd[0] = 0;
    rgcd[n] = a[n - 1];
    rgcd[n + 1] = 0;

    for (int i = 2; i < n + 1; i++)
    {
        lgcd[i] = gcd(lgcd[i - 1], a[i - 1]);
    }
    for (int i = n - 1; i >= 1; i--)
    {
        rgcd[i] = gcd(rgcd[i + 1], a[i - 1]);
    }
    int ans = 0;
    for (int i = 1; i < n + 1; i++)
    {
        ans = max(ans, gcd(rgcd[i + 1], lgcd[i - 1]));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<int>x(n);
    rep(i, n) cin >> x[i];
    ll ans = 1e15;
    rep(p, 101){
        ll sum = 0;
        rep(i, n){
            sum += (x[i] - p)*(x[i] - p);
        }
        ans = min(sum, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <utility>
#include <set>

using namespace std;

using i64=long long;
using vx=vector<i64>;
using pii=pair<int, int>;
using sp=set<pii>;

static const int dI[]={-1, -1, -1, 0, 0, 0, 1, 1, 1};
static const int dJ[]={-1, 0, 1, -1, 0, 1, -1, 0, 1};

void count_black(
    const pii &coord, sp &blacked, vx &num_black, sp &visited, int H, int W
) {
    for (int k=0; k<9; ++k) {
        int I=coord.first+dI[k], J=coord.second+dJ[k];

        if (!(1<=I && I<H-1 && 1<=J && J<W-1)) continue;
        if (visited.count(pii(I, J))) continue;

        int cur=0;
        for (int m=0; m<9; ++m)
            if (blacked.count(pii(I+dI[m], J+dJ[m])))
                ++cur;

        ++num_black[cur];
        visited.insert(pii(I, J));
    }
}

int main() {
    int H, W, N;
    scanf("%d %d %d", &H, &W, &N);

    sp blacked;
    for (int i=0; i<N; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        blacked.insert(pii(--a, --b));
    }

    sp visited;
    vx num_black(11);

    for (pii coord: blacked)
        count_black(coord, blacked, num_black, visited, H, W);

    num_black[0] = (H-2LL)*(W-2LL);
    for (int i=1; i<=9; ++i)
        num_black[0] -= num_black[i];

    for (int i=0; i<=9; ++i)
        printf("%lld\n", num_black[i]);

    return 0;
}


Measured memory_bytes: 47104
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

class LazySegmentTree {
private:
	int size_;
	vector<long long> v, lazy;
	void update(int a, int b, long long x, int k, int l, int r) {
		push(k, l, r);
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			push(k, l, r);
		}
		else {
			update(a, b, x, k * 2, l, (l + r) >> 1);
			update(a, b, x, k * 2 + 1, (l + r) >> 1, r);
			v[k] = merge(v[k * 2], v[k * 2 + 1]);
		}
	}
	long long query(int a, int b, int k, int l, int r) {
		push(k, l, r);
		if (r <= a || b <= l) return ll(1e18);
		if (a <= l && r <= b) return v[k];
		long long lc = query(a, b, k * 2, l, (l + r) >> 1);
		long long rc = query(a, b, k * 2 + 1, (l + r) >> 1, r);
		return merge(lc, rc);
	}
 
public:
	LazySegmentTree() : v(vector<long long>()), lazy(vector<long long>()) {};
	LazySegmentTree(int n) {
		for (size_ = 1; size_ < n;) size_ <<= 1;
		v.resize(size_ * 2,ll(1e18));
		lazy.resize(size_ * 2,ll(1e18));
	}
	inline void push(int k, int l, int r) {
		if (lazy[k] != ll(1e18)) {
			v[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2] = lazy[k];
				lazy[k * 2 + 1] = lazy[k];
			}
			lazy[k] = ll(1e18);
		}
	}
	inline long long merge(long long x, long long y) {
		return min(x, y);
	}
	inline void update(int l, int r, long long x) {
		update(l, r, x, 1, 0, size_);
	}
	inline long long query(int l, int r) {
		return query(l, r, 1, 0, size_);
	}
};
vector<ii> a[222222];
ll dp[222222];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,c; cin>>l>>r>>c;
		l--; r--;
		a[r].pb({l,c});
	}
	LazySegmentTree st(n+10);
	for(int i=0;i<n;i++) dp[i]=ll(1e18);
	dp[0]=0; st.update(0,1,0);
	for(int i=1;i<n;i++)
	{
		for(ii x:a[i])
		{
			int l=x.fi;
			ll c=x.se;
			//cerr<<l<<' '<<i<<' '<<st.query(l,i)<<'\n';
			ll mn = st.query(l,i);
			dp[i]=min(dp[i],mn+c);
		}
		st.update(i,i+1,dp[i]);
		//cerr<<i<<' '<<dp[i]<<'\n';
	}
	if(dp[n-1]>ll(1e17)) dp[n-1]=-1;
	cout<<dp[n-1]<<'\n';
	
}	


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

int main() {
    long int x,y;
    cin>>x>>y;
    
    if(y%2)
    {
        cout<<"No\n";
    }
    else
    {
       if(y<=4*x)
       {
       y/=2;
       if(y>=x)
       {
           cout<<"Yes\n";
       }
       else
       {
           cout<<"No\n";
       }
       }
       else
       {
           cout<<"No\n";
       }
    }
    return 0;
}

Measured memory_bytes: 3632
using System;

class AtCoder
{
    private void Solve()
    {
        string strs = Console.ReadLine();
        int count = 0;

        for (int i = 0; i < strs.Length; ++i)
        {
            foreach (char c in strs)
            {
                if (c == strs[i])
                {
                    ++count;
                }
            }
            if (count % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
            count = 0;
        }
        Console.WriteLine("Yes");
    }

    static void Main()
    {
        new AtCoder().Solve();
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	int N;
	vector<int> stairs;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		stairs.push_back(tmp);
	}
	bool flag = true;
	for (int i = N-1; i > 0; i--) {
		if (stairs[i] - stairs[i - 1] <= -2) {
			flag = false;
			break;
		}
		else if (stairs[i] - stairs[i - 1] <= -1) {
			stairs[i - 1]--;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 892
#include<stdio.h>
int main(void){
    int n,j,max,min;
    scanf("%d",&n);
    int a[n];
    for(j=0;j<n;j++){
        scanf("%d",&a[j]);
    }
    max=a[1]-a[0];
    min=a[0];
    for(j=1;j<n;j++){
    	 if(a[j]-min>max)
    max=a[j]-min;
        if(a[j]<min)
        min=a[j];
   
        
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 2524
import numpy as np
def resolve():
    N = int(input())
    A = np.array(list(map(int, input().split())))

    cnt = np.zeros(10**6 + 10, np.int32)
    for x in A:
        if cnt[x] > 1:
            continue
        cnt[::x] += 1
    ret = 0
    for x in A:
        ret += cnt[x] == 1

    print(ret)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 51624
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0;
  cin >> N;
  vector<ll>A(N);
  rep(i,N){
    cin >> A[i];
  }
  ll ans = 0;
  rep(i,N){
    if(i % 2 == 0 && A[i] % 2 == 1){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3620
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var) \
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

constexpr auto no_value = numeric_limits<uint64_t>::max();

struct GraphParser {
  GraphParser(vector<vector<int>>& edges_)
      : edges(edges_), start(edges.size(), 0), end(edges.size(), 0) {
    //
  }

  void run() {
    t = 0;
    for (size_t i = 0; i < edges.size(); ++i) {
      if (!start[i]) {
        recur(i);
      }
    }
  }

  vector<vector<int>>& edges;
  vector<int> start;
  vector<int> end;
  int t;

 private:
  void recur(int cur) {
    if (start[cur]) {
      return;
    }
    start[cur] = ++t;
    for (auto&& e : edges[cur]) {
      recur(e);
    }
    end[cur] = ++t;
  }
};

int main() {
  int n;
  cin >> n;
  vector<vector<int>> edges(n, vector<int>());
  for (int i = 0; i < n; ++i) {
    int u;
    int k;
    cin >> u >> k;
    edges[u - 1].reserve(k);
    for (int j = 0; j < k; ++j) {
      int v;
      cin >> v;
      edges[u - 1].push_back(v - 1);
    }
  }

  GraphParser p(edges);
  p.run();
  for (int i = 0; i < n; ++i) {
    cout << (i + 1) << " " << p.start[i] << " " << p.end[i] << endl;
  }
}

Measured memory_bytes: 3100
// abc104_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(3);}} premain;


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll D, G;
    cin >> D >> G;

    vector<ll> p(D), c(D);
    REP(i, D) cin >> p[i] >> c[i];

    int ans = INF;
    REP(pattern, 1 << D){

        int score = 0;
        int cnt = 0;
        REP(i, D){
            if ((pattern >> i)&1){
                score += (i+1)*100*p[i] + c[i];
                cnt += p[i];
            }
        }

        if (score >= G){
            ans = min(ans, cnt);
            continue;
        }

        REP_REV(i, D){
            if (((pattern >> i)&1) == 0){
                int n = (G - score + ((i+1)*100)-1) / ((i+1)*100);
                if (n <= p[i]){
                    cnt += n;
                    score += n * (i+1) * 100;
                } else {
                    score += p[i] * (i+1) * 100;
                }
                break;
            }
        }

        if (score >= G){
            ans = min(ans, cnt);
        }
    }

    print(ans);

    return 0;
}





Measured memory_bytes: 256
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.lang.System.out;

// AOJ
public class Main {
	final Scanner sc=new Scanner(System.in);
	final int[] vx={0,1,0,-1}, vy={-1,0,1,0};
	final int[] vvx={0,1,0,-1,-1,1,1,-1}, vvy={-1,0,1,0,-1,-1,1,1};
	static class Point{
		int x, y;
		Point(int x, int y){	this.x=x;	this.y=y;}
		Point(){	this.x=0; this.y=0;}
		@Override public String toString(){	return "("+this.x+","+this.y+")";}
		static boolean ok(int x,int y,int X,int Y,int min){	return (min<=x&&x<X)&&(min<=y&&y<Y);}
		static boolean ok(int x,int y,int X,int Y){	return ok(x,y,X,Y,0);}
	}
	public static void main(String[] args) {
		new Main().AOJ1160();
	}
	
	void AOJ1160(){
		while(sc.hasNext()){
			int W=sc.nextInt(),H=sc.nextInt();
			if((W|H)==0)	break;
			boolean[][] b=new boolean[W][H];
			for(int y=0; y<H; y++){
				for(int x=0; x<W; x++)	b[x][y]=(sc.nextInt()==1);
			}
			boolean[][] close=new boolean[W][H];
			LinkedList<Point> open=new LinkedList<Point>();
			int ans=0;
			for(int x=0; x<W; x++){
				for(int y=0; y<H; y++){
					if(b[x][y]&&!close[x][y]){
						open.add(new Point(x,y));
						ans++;
						while(!open.isEmpty()){
							Point now=open.poll();
							for(int i=0; i<8; i++){
								int xx=now.x+vvx[i],yy=now.y+vvy[i];
								if(!Point.ok(xx, yy, W, H))	continue;
								if(!b[xx][yy])	continue;
								if(close[xx][yy])	continue;
								open.add(new Point(xx,yy));
								close[xx][yy]=true;
							}
						}
					}
				}
			}
			out.println(ans);
		}
	}
	
	void A(){
		
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;cin>>N;
	int cur=0;
	rep(i,N){
		int a;cin>>a;
		if(a==cur+1)cur++;
	}
	if(cur==0){
		cout<<-1<<endl;
	}
	else{
		cout<<N-cur<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

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

    string ans = "";

    REP(i, s.size()){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(s[i] == 'B'){
            if(ans.size() > 0) ans.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}


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

void DumpHistgram(int n, int array[]) {
  int max = 0;
  for(int i = 0; i < (int)n; ++i) {
    max = std::max(max, array[i]);
  }
  for(int i = 0; i < (int)n; ++i) {
    printf("%3d : ", i);
    for(int j = 0; j < (int)array[i]*30/max; ++j) {
      std::cout << '*';
    }
    std::cout << std::endl;
  }
}

int main() {
  int n, w;
  while( std::cin >> n >> w, not ( n == 0 and w == 0 ) ) {
    int h[200] = {};
    double level[200];
    for(int i = 0; i < (int)n; ++i) {
      int t;
      std::cin >> t;
      h[t/w] += 1;
    }
    //DumpHistgram(10, h);
    int max = h[0];
    for(int i = 0; i < (int)200; ++i) {
      max = std::max(max, h[i]);
    }
    int right = 0;
    for(int i = 0; i < (int)200; ++i) {
      if( h[i] != 0 ) right = i;
    }
    for(int i = 0; i < (int)right + 1; ++i) {
      level[i] = 1.0 - 1.0 * i / (right);
    }
    double res = 0.0;
    for(int i = 0; i < (int)right + 1; ++i) {
      res += level[i] * ((double)h[i] / max);
    }
    printf("%.20lf\n", res + 0.01);
  }
  
  return 0;
}

Measured memory_bytes: 3120
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
using namespace std;
using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
gp_hash_table<int,int>dp[33];
int n,m;
int maxstep;
int fact[100005],inv[100005],sum[33];
vector<int>factor;
int C(int _n,int _m){
	return fact[_n]*inv[_m]%mod*inv[_n-_m]%mod;
}
signed main(){
	cin>>n>>m;
	if(m==1){
		cout<<1<<endl;
		return 0;
	}
	for(int i=2;i*i<=m;i++)if(m%i==0)factor.push_back(i);
	for(int i=1;i*i<m;i++)if(m%i==0)factor.push_back(m/i);
	int tmp=m;
	for(int i=2;i*i<=tmp;i++){
		while(tmp%i==0)tmp/=i,maxstep++;
	}
	if(tmp!=1)maxstep++;
//	cout<<maxstep<<endl;
	sort(factor.begin(),factor.end());
	fact[0]=1;inv[0]=1;
	for(int i=1;i<=n;i++)fact[i]=fact[i-1]*i%mod,inv[i]=modpow(fact[i],mod-2,mod);
	dp[0][1]=1;
	for(int i=0;i<maxstep;i++){
//		cerr<<i<<" "<<dp[i].size()<<endl;
		for(auto p:dp[i]){
			for(auto x:factor){
				if(p.first*x>m)break;
				dp[i+1][p.first*x]+=p.second;
				dp[i+1][p.first*x]%=mod;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=maxstep;i++){
		(ans+=C(n,i)*dp[i][m])%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

// 桁、自由、0、7、5、3
int dp[40][2][2][2][2]{};
long long ten_pow[40]{};
long long n;

int rc(int, bool, bool, bool, bool, bool);

int main()
{
	scanf("%lld", &n);
	std::fill(dp[0][0][0][0], dp[0][0][0][0] + 40 * 16, -1);
	for (int j = 0; j < 2; j++)
		for (int k = 0; k < 2; k++)
			for (int l = 0; l < 2; l++)
				for (int m = 0; m < 2; m++)
					dp[0][j][k][l][m] = k * l * m;

	int digit{};
	ten_pow[0] = 1;
	for (int i{}; ten_pow[i] <= n; i++)
	{
		ten_pow[i + 1] = ten_pow[i] * 10;
		digit++;
	}
	ten_pow[digit + 1] = ten_pow[digit] * 10;

	printf("%d\n", rc(digit, false, false, false, false, true));
	return 0;
}

int rc(int digit, bool freedom, bool seven, bool five, bool three, bool zero)
{
	if (dp[digit][freedom][seven][five][three] >= 0)
		return dp[digit][freedom][seven][five][three];
	int num[3]{3, 5, 7}, sum{};
	for (int i = 0; i < 3; i++)
	{
		if (!freedom && n / ten_pow[digit - 1] % 10 < num[i])
			break;
		if (n / ten_pow[digit - 1] % 10 == num[i])
			sum += rc(digit - 1, freedom, seven || i == 2, five || i == 1, three || i == 0, false);
		else
			sum += rc(digit - 1, true, seven || i == 2, five || i == 1, three || i == 0, false);
	}
	if (zero)
		sum += rc(digit - 1, true, seven, five, three, zero);
	dp[digit][freedom][seven][five][three] = sum;
	return sum;
}

Measured memory_bytes: 256
#from collections import deque
#import sys
#sys.setrecursionlimit(10**7)
#input = sys.stdin.readline
def isprime(n):
  if n <= 1:
    return False
  else:
    for i in range(2,(int(n**0.5)+2)):
      if n%i == 0:
        return False
    return True

def solve():
  n = int(input())
  query = []
  for i in range(3,2222):
    if isprime(i):
      if i%5 == 1:
        query.append(i)
  for i in range(n):
    print(query[i],end =" ")
      
solve()

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int n;
string s, t;
bool out(int m, int c, char up, char down){
	int tmp = c;
	for (int i = 0; i < n; ++ i){
		tmp -= s[i] == up;
		if (tmp == 0)
			return true;
		tmp = min(m, tmp + (t[i] == down));
	}
	for (int i = 0; i < n; ++ i){
		c += s[i] == down;
		if (c > m)
			return true;
		c = max(1, c - (t[i] == up));
	}
	return false;
}
int main(){
	int h, w, r, c;
	cin >> h >> w >> n >> r >> c;
	cin >> s >> t;
	if (out(h, r, 'U', 'D') || out(w, c, 'L', 'R'))
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main () {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if (a[0]+a[1] == a[2]) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

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

int main() {
	vector<int> h(10);
	for (int i = 0; i < 10; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end(),greater<int>());
	for (int i = 0; i < 3; i++) {
		cout << h[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    n=2*x-y
    m=2*y-x
    if n%3==0 and m%3==0 and n>=0 and m>=0:
        print(mod_comb4(n//3+m//3,n//3,mod))
    else:
        print(0)


if __name__=='__main__':
    main()

Measured memory_bytes: 39024