akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m, x;
    cin >> n >> m >> x;

    bool chk = true;
    vi c(n);
    vvi a(n, vi(m, 0));
    vi sum(n, 0);

    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
            sum[j] += a[i][j];
            if(i == n-1 && sum[j]<x) chk = false;
        }
    }
    if(!chk){
        cout << -1 << endl;
        return 0;
    }

    ll ans = INFLL;
    for(ll bit=0; bit<(1<<(n+1)); bit++){
        chk = true;
        sum.assign(n, 0);
        ll money = 0;
        for(ll j=0; j<n; j++){
            ll mask = (1<<j);
            if(bit&mask){
                money += c[j];
                rep(k, m){
                    sum[k] += a[j][k];
                }
            }
        }
        rep(k, m) if(sum[k] <x){
            chk = false;
            break;
        }
        if(chk) chmin(ans, money);
    }
    cout << ans << endl;
}

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

int main(){
    ll N;
    cin >> N;
    if (N % 2 == 1) cout << 0 << endl;
    else if (N < 10) cout << 0 << endl;
    else{
        string str = to_string(N);
        int len = str.size();
        ll divide = 10;
        ll ans = 0;
        rep(i,25){
            ans += (N / divide);
            divide *= 5;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int n,m;
	cin>>n>>m;
	map<int,int>mm;
	multiset<int>ss;
	for(int i=0;i<m;i++)mm[i]=i;
	for(int i=0;i<m;i++)ss.insert(0);
	for(int i=1,add=1;i<=n;i++){
		int a,b,c,d;
		cin>>a>>b;
		c=-1;
		for(auto j=mm.lower_bound(--a);j!=mm.end()&&j->F<=b;mm.erase(j++)){
			d=j->F;
			c=max(c,mm[d]);
			ss.erase(ss.find(d-mm[d]));
		}
		if(c+1&&b<m)mm[b]=c,ss.insert(b-c);
		if(ss.size())cout<<*ss.begin()+add<<endl,add++;
		else puts("-1");
	}
}


Measured memory_bytes: 22304
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

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

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

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

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

const int MAX = 200000 + 47;

int A[MAX];
set<int> sett;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);

	int n, x;
	cin >> n >> x;

	int sz = 2 * n - 1;
	if (x == 1 || x == sz)
	{
		cout << "No" << endl;
		return 0;
	}

	n--;
	A[n] = x;
	sett.insert(x);

	A[n - 1] = x - 1;
	sett.insert(x - 1);

	A[n + 1] = x + 1;
	sett.insert(x + 1);

	if (x + 2 <= sz)
	{
		A[n - 2] = x + 2;
		sett.insert(x + 2);
	}

	if (x - 2 >= 1)
	{
		A[n + 2] = x - 2;
		sett.insert(x - 2);
	}

	int p = 1;
	FOR(i, 0, sz)
	{
		if (A[i]) continue;
		while (sett.find(p) != sett.end()) p++;
		A[i] = p;
		p++;
	}

	cout << "Yes" << endl;
	FOR(i, 0, sz)
	{
		cout << A[i] << "\n";
	}
}

Measured memory_bytes: 2304
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: usize,
    }
    if n % 500 <= a {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL; 
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
bool vis[100000],ok=1;
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
LL modexpo(LL a, LL b) {
  LL ans=1;
  a=a%mod;
  while(b>0){
    if((b&1)==1){
      ans=((ans%mod)*(a%mod))%mod;
    }
    b=b>>1;
    a=((a%mod)*(a%mod))%mod;
  }
  return ans; 
}
LL invmod(LL n){
  return modexpo(n,mod-2);
}
LL comb(LL n,LL r){
  if(r==0){
    return 1;
  }
  LL fact[n+1];
  fact[0] = 1; 
    for (LL i = 1; i <= n; i++){
       fact[i] = (fact[i - 1] * i) %mod;}
    return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) %mod; 
}
LL gcd(LL a, LL b) {
  if (a == 0){
       return b;
       }  
    return gcd(b % a, a);  
}
LL lcm(LL a, LL b) {
  return (a*b)/gcd(a,b);
}
void solve(LL k){
string a; 
cin>>a; 
if(a[a.size()-1]=='s'){
  cout<<a+"es"<<endl; 
}
else{
  cout<<a+"s"<<endl; 
  }
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
  if(ok==0){
    break; 
  }
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 3640
using System;
public class Hello{
    public static void Main(){
       int X = int.Parse(Console.ReadLine());
       int A = int.Parse(Console.ReadLine());
       int B = int.Parse(Console.ReadLine());
       
       X -= A;
       while(X >= B){
           X -= B;
       }
       Console.WriteLine(X);
    }
}

Measured memory_bytes: 11092
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}


*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;
 
int main() {
    // 入力
    char  S[4];
    for (int i = 0; i < 4; ++i) cin >> S[i];
    
    int ans= 0;
    for (int i = 0; i < 4; ++i){
        if (S[i]=='+') ++ans;
        else --ans;
    }
    //出力
    cout << ans << endl;
}
 


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
if N > 1:
    A[0] -= 1
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i+1] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")


Measured memory_bytes: 14396
#include <stdio.h>
int main(void){
   
   
   int n,k,p,i,stone;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
       scanf("%d %d",&k,&p);
       stone=k%p;
       if(stone==0){
           stone=p;
       }
       
       
       printf("%d\n",stone);
       
       
   }
}


Measured memory_bytes: 2056
import sys
bbn=1000000007
	
#+++++


def mkm2(a_ll):
	ccc=0
	for i, c in enumerate(a_ll):
		ccc += ((-2)**i)*(c==1)
	return ccc

def show(a_ll):
	ret = ''.join([str(i) for i in a_ll[::-1]])
	return ret


def main():
	a = int(input())
	if a == 0:
		return 0
	a=-a
	
	ret=[]
	while mkm2(ret) < a and False:
		ret.append(0)
		ret.append(1)
		pa(mkm2(ret))
		pa(ret)
	
	while a != 0:
		if a %(-2)==0:
			ret.append(0)
		else:
			ret.append(1)
		a = a // (-2)
		
	pa(mkm2(ret))
	print(show(ret))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        sc.close();

        if(X <= Y){
            System.out.println(Math.min(A*X + B*Y, 
                                Math.min(2*C*X + (Y-X)*B, 
                                        2*C*Y)));

        } else {
            System.out.println(Math.min(A*X + B*Y, 
                                Math.min(2*C*Y + (X-Y)*A, 
                                        2*C*X)));
        }
    }
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, a, b;
    cin >> n >> a >> b;
    ll dist = abs(a - b);
    if (dist % 2 == 0) {
        cout << (dist / 2) << endl;
        return 0;
    }
    ll ans = LONG_LONG_MAX;
    ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d %d", &a, &b);
	
	if (a > b){
		printf("a > b\n");
	}
	else if (a < b){
		printf("a < b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}
	
	return (0);
}

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int count=0;
  for(int i=1;i<n-1;i++){
    if((p[i-1]<p[i] && p[i]<p[i+1])||(p[i-1]>p[i] && p[i]>p[i+1])){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10**9 + 10

num = min(a) + min(b)
if num < ans:
    ans = num

for m in range(M):
    x, y, c = list(map(int, input().split()))
    calc = a[x-1] + b[y-1] - c
    if calc < ans:
        ans = calc

print(ans)

Measured memory_bytes: 18608
n, m = gets.split(" ").map(&:to_i)
a = gets.split(" ").map(&:to_i)
sum = a.inject(:+)
v = []
a.each{|x|
	z=x
	while true do
	y = z/2
	t = z-y
	z = y
	if t>0
		v.push(t)
	else
		break
	end
	end
}
p sum - v.sort!.reverse!.take(m).inject(:+)


Measured memory_bytes: 57600
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define LEN 54
#define BASE 2 //小数部の開始桁
#define SIZE 52 //小数部の桁数

ll mult;
ll POW[63];
int S[LEN],A[LEN];
char buf[SIZE+1];


//SにAをadd_count回足す関数
void calc(ll add_count){

	ll work[LEN];

	int tmp,kuriagari;

	//Aをまとめて加算する
	for(int digit = 62; digit >= 0 && add_count > 0; digit--){
		if(add_count < POW[digit])continue;

		add_count -= POW[digit];

		for(int i = 0; i < LEN; i++)work[i] = 0;

		//Aを左にdigitビットシフトした数列を作成
		for(int i = 0; i < LEN; i++){
			if(i+digit == LEN)break;
			work[i] = A[i+digit];
		}

		kuriagari = 0;
		//数列を右から足し算
		for(int i = LEN-1; i >= 0; i--){
			tmp = work[i]+S[i]+kuriagari;
			S[i] = tmp%2;
			kuriagari = tmp/2;
		}
	}
}

void func(){

	//Sの初期化
	for(int i = 0; i < LEN; i++){
		S[i] = 0;
	}

	scanf("%s",buf);

	//SとAの、初期設定
	S[0] = 0;
	A[0] = 0;
	S[BASE-1] = 1;
	A[BASE-1] = 1;

	for(int i = 0; i < SIZE; i++){
		S[BASE+i] = buf[i]-'0';
		A[BASE+i] = buf[i]-'0';
	}

	ll e = 0;

	ll num_S,num_A,next = POW[53],diff,add_count;

	while(mult > 0){

		//次に、Sの桁が繰り上がるまでの、最小加算回数を求める

		//S,Aをlong long intで表す
		num_S = 0;
		for(int digit = 1; digit < LEN; digit++){
			num_S += S[digit]*POW[53-digit];
		}
		num_A = 0;
		for(int digit = 1; digit < LEN; digit++){
			num_A += A[digit]*POW[53-digit];
		}

		//★もう足しても意味がない★
		if(num_A == 0){
			break;
		}

		//nextとの差分
		diff = next-num_S;

		if(diff%num_A == 0){ //ぴったり繰り上がる

			add_count = diff/num_A;

		}else{

			add_count = diff/num_A+1;
		}

		if(add_count > mult){ //加算回数を超過する場合

			//SにAをmult回足す
			calc(mult);

			mult = 0;

		}else{

			//SにAをadd_count回足す
			calc(add_count);

			for(int i = 52; i >= 0; i--){
				S[i+1] = S[i];
				A[i+1] = A[i];
			}
			S[0] = 0;
			A[0] = 0;

			mult -= add_count;
			e++;
		}
	}

	//指数部の表示
	for(int i = 11; i >= 0; i--){
		if(e < POW[i]){
			printf("0");
		}else{
			printf("1");
			e -= POW[i];
		}
	}

	//仮数部の表示
	for(int i = 0; i < SIZE; i++){
		printf("%d",S[BASE+i]);
	}

	printf("\n");
}


int main(){

	POW[0] = 1;
	for(int i = 1; i <= 62; i++){
		POW[i] = 2*POW[i-1];
	}

	while(true){
		scanf("%lld",&mult);
		if(mult == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

typedef struct cc {
  char com[9];
  char str[L];
} C;

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if (ch == 'C') return 2;
  else if (ch == 'G') return 3;
  else if (ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M-1));}

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d", &n);
  C *com_line = (C *)malloc(sizeof(C)*n);
  for(i=0;i<n;i++) scanf("%s %s", com_line[i].com, com_line[i].str);
  for(i=0;i<n;i++){
    if(com_line[i].com[0] == 'i'){
      insert(com_line[i].str);
    } else {
      if(find(com_line[i].str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 37380
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 10

int main(){

    long long N, H; cin >> N >> H;
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    REP(i,N) cin >> a[i] >> b[i];

    sort(b.begin(), b.end());
    long long ans = 0LL;
    long long a_max = *max_element(a.begin(), a.end());
    for(int i=N-1; i>=0; --i){
        if(H>0 && a_max<b[i]){
            H-=b[i];
            ans++;
        }
    }

    if(H>0){
        ans = ans + H/a_max;
        if(H%a_max!=0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>

// ref : https://img.atcoder.jp/abc104/editorial.pdf
using ll = long long;

int main(){
    int d, g;
    std::cin >> d >> g;
    std::vector<ll> p(d), c(d);
    for(int i = 0; i < d; i++){
        std::cin >> p[i] >> c[i];
    }

    // 完全に解くかどうか
    ll ans = 10 * 100;
    for(int bit = 0; bit < (1 << d); bit++){
        ll score = 0;
        ll numSolved = 0;
        ll bit0max = -1;
        for(int i = 0; i < d; i++){
            if(bit & (1 << i)){
                // 完全に解く
                numSolved += p[i];
                score += 100 * (i + 1) * p[i] + c[i];
            }else{
                bit0max = i;
            }
        }

        // 中途半端に解く問題なしでいけるか？
        if(score >= g){
            ans = std::min(ans, numSolved);
        }else{
            // 中途半端に解く必要あり
            if(bit0max == -1) continue;
            for(int i = 1; i < p[bit0max]; i++){
                score += 100 * (bit0max + 1);
                numSolved++;
                if(score >= g){
                    ans = std::min(ans, numSolved);
                }
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m,x=INTM()
    A=LIST()
    money=[0]*(n+1)
    for i in A:
        money[i]=1
    sum0 = sum(money[0:x+1])
    sumn = sum(money[x:n])
    print(min(sum0,sumn))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
#define debug(x) cerr << #x << ":" << x << endl;

int main()
{
  int N, T;
  cin >> N >> T;
  vector< int64 > a(N);
  vector< int64 > mn(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (i > 0) mn[i] = min(a[i], mn[i - 1]);
    else mn[i] = a[i];
  }

  map< int64, int > mp;
  for (int i = 0; i < N; ++i) {
    mp[a[i] - mn[i]]++;
  }

  int ans = 0;
  for (auto &&m : mp) ans = m.second;
  cout << ans << endl;
  
  return 0;
}


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

template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
typedef pair<long long, long long> P;

void solve(int w, int h){
	vector<string> a;
	readVector(h, a);
	int b[h][w];
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
			b[i][j] = 0;
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j){
			int t = 0;
			if(a[i][j] == 'B') t = 1;
			else if(a[i][j] == 'W') t = 2;
			if(t > 0){
				queue<P> q;
				for(int k=0; k<4; ++k){
					int nx = i+dx[k];
					int ny = j+dy[k];
					if(0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.' && (b[nx][ny]&t) == 0){
						q.push(P(nx, ny));
						b[nx][ny] += t;
					}
				}
				while(!q.empty()){
					P p = q.front();
					q.pop();
					for(int k=0; k<4; ++k){
						int nx = p.first+dx[k];
						int ny = p.second+dy[k];
						if(0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.' && (b[nx][ny]&t) == 0){
							q.push(P(nx, ny));
							b[nx][ny] += t;
						}
					}
				}
			}
		}
	int x = 0, y = 0;
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j){
			if(b[i][j] == 1) ++x;
			if(b[i][j] == 2) ++y;
		}
	cout << x << " " << y << "\n";
//	for(int i=0; i<h; ++i)
//		for(int j=0; j<w; ++j)
//			cout << b[i][j] << (j==w-1 ? "\n" : " ");
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int w, h;
		cin >> w >> h;
		if(w == 0 && h == 0) return 0;
		solve(w, h);
	}
}


Measured memory_bytes: 3152
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

using LL = long long;


vector<pair<int, int>> a[15];
int res[15];
int hon[15];
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        for (int j = 0; j < t; j++) {
            int x, y;
            cin >> x >> y;
            a[i].emplace_back(x, y);
        }
    }

    int ans = 0;
    int st[16], tp = 0;
    for (int i = 0; i < 1 << n; i++) {
        for (int i = 0 ; i < n; i++) {
            res[i] = -1;
            hon[i] = 0;
        }
        tp = 0;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                hon[n - j - 1] = 1;
                res[n - j - 1] = 1;
                st[tp++] = n - j - 1;
            }
        }
        bool f = true;
        while(tp) {
            tp--;
            int now = st[tp];
            for(auto t : a[now]) {
                int x = t.first - 1, y = t.second;
                if (res[x] == -1) {
                    res[x] = y;
                    if (y == 1) {
                        st[tp++] = x;
                    }
                }
                else if (res[x] != y) {
                    f = false;
                    break;
                }
            }
            if (!f) break;
        }
        if(f) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (res[i] == 1) cnt++;
            }
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = input()
l1 = "KUPC"
l2 = [0] * 4

for i in range(len(n)):
   for j in range(len(l1)):
      if n[i] == l1[j]:
         l2[j] += 1

#print(l2)
print(min(l2))



Measured memory_bytes: 5568
#include<bits/stdc++.h>
using namespace std;
const int _=1e5+5;
int a[_],b[_],c[_],n,m;
bitset<405>A[405];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=m;++i)cin>>a[i]>>b[i];
	for(int i=1;i<=n;++i){
		A[i][i]=1;
		for(int j=m;j;--j){
			if(A[i][a[j]]&&A[i][b[j]]){c[i]=1;break;}
			if(A[i][a[j]])A[i][b[j]]=1;
			if(A[i][b[j]])A[i][a[j]]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			ans+=(!(A[i]&A[j]).count()&&!c[i]&&!c[j]);
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s1, s2, s3, s4, s5;
  for (int i=0; i<5; ++i) {
    string s;
    cin >> s;
    if (s == "0") {
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a>=13){
    cout << b << endl;
  } else if(5>=a){
    cout << 0 << endl;
  } else {
    cout << b/2 << endl;
  }
}


Measured memory_bytes: 256
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0
maxL = 0
minR = INF 
[n,m] = inpl()
for i in range(m):
    [L,R] = inpl()
    maxL = max(maxL,L)
    minR = min(minR,R)

ans = minR - maxL +1





print(max(ans,0))

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

int main() {
  long double A, B; cin >> A >> B;
  cout << (ll)(A * B) << endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

#define inf  1000000007
#define ll long long
#define PA pair<int,int>
#define PPAP pair<int,pa>
#define  MP make_pair
#define  PB push_back
#define VI vector<int>

using namespace std;
long long  mod = 1000000007;

int main(){
	int a,b,c,d,e,f;
	double max = 0;
	int sw = 0;
	int su = 0;
	cin >> a >> b >> c >> d >> e >> f;
	for(int i=0;i<=f/(100*a);i++){
		for(int j=0;j<=f/(100*b);j++){
			int su_max = (i*a+j*b)*e;
			for(int k=0;k<=su_max/c;k++){
				int l = min((f-k*c-i*100*a-j*100*b),((i*a+j*b)*e-k*c));
				if(l<=0)continue;
				l = l/d;
				int  w = (i*100*a+j*100*b);
				int  s = (k*c+l*d);
				double p = (double)s/(double)(s+w);
				if(p>max){
					max = p;
					sw = s+w;
					su = s;
				}
			}
		}
	}
	if(max!=0){
		cout << sw << " " << su << endl;
	}else{
		cout << 100*a <<  " " << 0 << endl;
	}
	return 0;
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 100010;

int n;
int num[MAXN];
int to[MAXN];
int all[MAXN];
int tot[MAXN];

int main()
{
	in(n);
	FOR(i, 1, n) in(num[i]);
	FOR(i, 1, n) all[i] = num[i];
	std::sort(all + 1, all + n + 1);
	all[0] = std::unique(all + 1, all + n + 1) - all - 1;
	FOR(i, 1, all[0]) to[i] = all[i];
	FOR(i, 1, n) tot[std::lower_bound(all + 1, all + all[0] + 1, num[i]) - all]++;

	LL ans = 0;
	
	FOR(i, 1, all[0]) {
		if (tot[i] < to[i]) ans += tot[i];
		else ans += tot[i] - to[i];
	}

	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
l = [int(input()) for _ in range(n)]

b = 0
c = 0
s = {0}
while b != 1:
  c += 1
  b = l[b] - 1
  if b == 1:
    print(c)
    exit()
  if b in s:
    break
  s.add(b)

print(-1)

Measured memory_bytes: 16012
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define rep(i,n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	string S;
	cin >> S;
	int N = S.length();
	string ans = "Yes";

	rep(i,N){
		if(S[i]!=S[N-i-1]){
			ans="No";
			cout << ans << endl;
			return 0;
		}
	}

	for(int i=0; i<(N-1)/2; i++){
		if(S[i]!=S[(N-1)/2-i-1]){
			ans="No";
			cout << ans << endl;
			return 0;
		}
	}

	for(int i=(N+3)/2-1; i<N; i++){
		if(S[i]!=S[N-i-1]){
			ans="No";
			cout << ans << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
int main(){

  int n,m;
  cin >> n >> m;

  int a[n*m] ;
  int b[m] ;

  memset(a,0,n*m*sizeof(int));
  memset(b,0,m*sizeof(int));

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

  for(int j=0;j<n;j++){

    int sum=0;
    for(int i=0;i<m;i++){
      sum += a[i+j*m] * b[i];
    }
    cout << sum << endl;
  }

}



Measured memory_bytes: 3132
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const ll LINF = (ll)1 << 60;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h,r;
  cin>>h>>r;
  if(0<=h+r && h+r<r){
    cout<<0<<'\n';
  }
  else if(h+r<0){
    cout<<-1<<'\n';
  }
  else{
    cout<<1<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3172
#include <stdio.h>
#include <stdlib.h>

#define N	5000
#define MD	1000000007

int vv[N + 1], ff[N + 1], gg[N + 1];

long long choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
}

int *oj[N], oo[N];

void link(int i, int j) {
	int o = oo[i]++;

	if (o >= 2 && (o & o - 1) == 0)
		oj[i] = (int *) realloc(oj[i], o * 2 * sizeof *oj[i]);
	oj[i][o] = j;
}

int sz[N], n, c;

int dfs(int p, int i) {
	int o, centroid;

	sz[i] = 1;
	centroid = 1;
	for (o = 0; o < oo[i]; o++) {
		int j = oj[i][o];

		if (j != p) {
			if (dfs(i, j))
				return 1;
			if (sz[j] * 2 > n)
				centroid = 0;
			sz[i] += sz[j];
		}
	}
	if ((n - sz[i]) * 2 > n)
		centroid = 0;
	if (centroid) {
		if (c != -1)
			return 1;
		c = i;
	}
	return 0;
}

int main() {
	static int dp_[N + 1];
	int m, h, i, j, k, l, o, ans;

	init();
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		oj[i] = (int *) malloc(2 * sizeof *oj[i]);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		link(i, j), link(j, i);
	}
	c = -1;
	if (dfs(-1, 0)) {
		printf("%lld\n", (long long) ff[n / 2] * ff[n / 2] % MD);
		return 0;
	}
	dp_[0] = 1, m = 0;
	for (o = 0; o < oo[c]; o++) {
		int s;

		j = oj[c][o], s = sz[j] < sz[c] ? sz[j] : n - sz[c];
		for (k = m; k >= 0; k--) {
			int x = dp_[k];

			if (x == 0)
				continue;
			for (l = 1; l <= s; l++) {
				int c = choose(s, l);

				dp_[k + l] = (dp_[k + l] + (long long) c * c % MD * ff[l] % MD * x) % MD;
			}
		}
		m += s;
	}
	ans = 0;
	for (k = 0; k <= n; k++)
		ans = (ans + (long long) dp_[k] * ff[n - k] * (k % 2 == 0 ? 1 : -1)) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2324
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    int N;
    cin >> N;

    string s = N < 30 ? "No": "Yes";

    cout << s << endl;
    return 0;
}



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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
const int N = 101;
int dis[N][N];
int32_t main(){
	fast;
	int n,m;
	cin >> n >> m;
	
	vector<pair<int,pair<int,int>>> edge(m);
	f(i,0,N)	f(j,0,N)	dis[i][j] = inf;
	f(i,0,N)	dis[i][i] = 0;
	f(i,0,m)
	{
		int x,y,c;
		cin >> x >> y >> c;
		edge[i] = mp(x,mp(y,c));
		dis[x][y] = min(dis[x][y] , c);
		dis[y][x] = min(dis[y][x] , c);
	}
	
	for(int i=1 ; i<=n ; i++)
	{
		for(int j=1 ; j<=n ; j++)
		{
			for(int k=1 ; k<=n ; k++)
				dis[j][k] = min(dis[j][k] , dis[j][i] + dis[i][k]);
		}
	}
	
	int ans = 0;
	int vis[m] = {0};
	for(int i=0 ; i<m ; i++)
	{
		for(int j=1 ; j<=n ; j++)
		{
			for(int k=1 ; k<=n ; k++)
			{
				int u = edge[i].F;
				int v = edge[i].S.F;
				int c = edge[i].S.S;
				if(dis[j][u]  + c + dis[v][k] == dis[j][k] || dis[j][v]  + c + dis[u][k] == dis[j][k] )
					vis[i] = 1;
			}
		}
	}
	f(i,0,m)	if(vis[i] == 0)	ans++;
	cout << ans;
	
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b,p,q,r;
	cin>>a>>b>>p>>q>>r;
	double time=(double)(b*p-(b-a)*q)/(q+r)+b;
	printf("%.16lf",time);
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mxN =150000;
int32_t main(){
  ios_base::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);

     int n,k; cin>>n>>k;
     int a[n]; for(int i=0;i<n;i++) cin>>a[i];
     
     int dp[n];
      dp[n-1]=0;
      dp[n-2]=abs(a[n-1]-a[n-2]);
     
     for(int i=n-3;i>=0;i--){
     	 
     	 int res=INT_MAX;
     	 for(int j=i+1;j<n and j<=i+k;j++){
     	 	
     	 	    res=min(res,abs(a[i]-a[j])+dp[j]);
		  }
		  dp[i]=res;
     	
	 }
	 cout<<dp[0];




 return 0;}



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

int main()
{
    // freopen("input01.txt", "r", stdin);
    // freopen("output01.txt", "w", stdout);
    int n,d;
    cin>>n>>d;
    int a,b,ct=0;
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        if((int)ceil(sqrt(pow(a,2) + pow(b,2))) <=d)
            ct++;
    }
    cout<<ct;
    return 0;
}


Measured memory_bytes: 3628
def resolve():
    N,K = map(int,input().split())
    A = [int(i)-1 for i in input().split()]
    visited =[False]*N
    steps = [K for i in range(N)]

    current = 0
    while True:

        if K == 0:
            print(current+1)
            return
        if not visited[current]:
            visited[current]=True
            steps[current]=K
            current=A[current]
            K-=1
        else:
            K= K % (steps[current]-K)
            break
    
    while K != 0:

        current= A[current]
        K-=1
    print(current+1)




if __name__ == "__main__":
    resolve()


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  int k;
  cin >> k;

  { // special case
    set<int> z;
    for (char c : s)
      z.insert(c);
    if (z.size() == 1)
      return 0 * printf("%lld\n", 1LL * n * k / 2);
  }

  long long ans = 0;

  vector<string> v;
  {
    int i = 0;
    while (i < n) {
      int j = i;
      string t;
      while (j < n && s[i] == s[j])
        t.push_back(s[j++]);
      v.push_back(t);
      i = j;
    }
  }
  
  if (s.front() == s.back()) {
    ans += 1LL * v.front().size() / 2;
    ans += 1LL * v.back().size() / 2;
    ans += 1LL * (v.front().size() + v.back().size()) / 2 * (k - 1);
    v.erase(v.begin());
    v.pop_back();
  }

  for (int i = 0; i < int(v.size()); ++i)
    ans += 1LL * v[i].size() / 2 * k;

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define vb vector<bool>
#define lli long long int
#define vvi vector<vector<int>>
#define loop(n) for (int i = 0; i < n; i++)
using namespace std;

auto SpeedUp = []() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

lli dfs(int src, vvi &graph, vector<lli> &dp)
{
    if (dp[src] != 0)
        return dp[src];
    lli myans = 0;
    for (int e : graph[src])
        myans = max(myans, dfs(e, graph, dp) + 1);
    return dp[src] = myans;
}

lli solve()
{
    int n, m, a, b;
    cin >> n >> m;
    vvi graph(n + 1); //crating graph
    while (m--)
    {
        cin >> a >> b;
        graph[a].push_back(b);
    }

    vector<lli> dp(n + 1, 0);
    lli ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans = max(ans, dfs(i, graph, dp));
    }
    return ans;
}

int main()
{
    cout << solve() << '\n';
    return 0;
}

Measured memory_bytes: 12080
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int ct = 0, cb = 0;
	for(int i = 0; i < n; ++i){
		bool ok = false;
		if(s[i] != 'c' && ct < a + b){
			if(s[i] == 'a'){
				ok = true;
				++ct;
			}
			else if(++cb <= b){
				ok = true;
				++ct;
			}
		}
		puts(ok ? "Yes" : "No");
	}
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

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

    vector<string> S(N);

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

    vector<int> min_count(26, 100);

    for(int i=0;i<N;i++){
        vector<int> count(26);
        //cout << S[i] << " "<< S[i].size()<< endl;
        for(int j=0; j<S[i].size(); j++){
            int idx = S[i][j] - 'a';
            //cout << S[i][j] << endl;
            count[idx]++;
        }
        for (int k=0;k<26;k++){
            //cout << char(k+'a') << " "<< count[k]<< endl;
            min_count[k] = min(min_count[k], count[k]);
        }
    }

    for (int k=0;k<26;k++){
        for(int i=0;i<min_count[k]; i++){
            cout << char(k+'a');
        }
    }
    cout << endl;
    

    //cout << cntmax << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
using namespace std;
#define N 5000

int main(void)
{
	while(1) {
		int n;
		long an[N] = {0}, sum = 0, max = LONG_MIN;
		cin >> n;

		if(n == 0)	break;

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

		for(int i = 0; i < n; i++) {
			sum = 0;
			for(int j = i; j < n; j++) {
				sum += an[j];
				if(sum > max) {
					max = sum;
				}
			}
		}

		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#スタックのデータ構造を用いて解く場合の、サンプル例
N=input()
stack=[]
count=0
for n in N:
    #初めのループは配列がからなので、素直に最初の数字(0 or 1)を格納する
    if not stack:
        stack.append(n)
    #配列の最後の要素が、新たな要素と異なるのであれば、キューブを削除（配列の最後の要素を消す）した上でカウンターに２を足す
    elif stack[-1]!=n:
        stack.pop()
        count += 2
    #配列の最後の要素が、新たな要素と同じであれば、キューブを積み上げる（配列の最後に要素を追加）
    else:
        stack.append(n)
print(count)

Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = 998244353LL;
const double pi = acos(-1.0);

//文字列分割
vector<string> split(string str, char del) {
	vector<string> re; string sub;
	for (char c : str) {
		if (c == del) re.push_back(sub), sub.clear();
		else sub += c;
	}
	re.push_back(sub);
	return re;
}

//小文字に変換
string StoLower(string s) {
	string ret;
	for (auto a : s)ret += tolower(a);
	return ret;
}

int main() {
	string S; getline(cin, S);
	VS S2 = split(S, ' ');
	VS s;
	for (auto aaa : S2) {
		s.pb(StoLower(aaa));
	}

	string a1, a2 = s[0];
	int c1 = -1;
	map<string, int> ma;
	for (auto aa : s) {
		ma[aa]++;
		if (sz(a2) < sz(aa))a2 = aa;
	}
	for (auto aa : ma) {
		if (c1 < aa.second) { c1 = aa.second; a1 = aa.first; }
	}
	cout << a1 << " " << a2 << endl;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b+MOD*1000) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp, tmp);
	if(b & 1) tmp = mulMod(tmp, a);
	return tmp;
}

/////////////////////////////////////////////////////////

const int N = 1e5;

int n,m;
ll ans;
vi divi;
ll val[N + 5];

void input(){
	cin >> n >> m;
}

void output(){
	cout << ans << endl;
}

void getDiv(){
	int sq = sqrt(n);
	REP(i,1,sq){
		if(n % i == 0){
			divi.PB(i);
			if(n/i != i) divi.PB(n/i);
		}
	}
	sort(divi.begin(), divi.end());
}

void process(){
	ll v;
	ans = 0;
	getDiv();
	FOR(i,divi.size()){
		val[i] = fast(m, (divi[i] + 1) / 2);
		FOR(j,divi.size()){
			if(divi[j] >= divi[i]) break;
			if(divi[i] % divi[j] == 0){
				val[i] = addMod(val[i], -val[j]);
			}
		}
		v = divi[i];
		if(v % 2 == 0){
			v /= 2;
		}
		ans = addMod(ans, mulMod(v, val[i]));
	}
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	input();
	process();
	output();
	return 0;
}

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

int main()
{
    int n;
    std::priority_queue<long long, std::vector<long long>, std::greater<long long>> forward;
    std::priority_queue<long long> back;
    long long sum[2]{};

    scanf("%d", &n);
    long long *mid_table = new long long[n];
    for (int i = 0; i < n; i++)
    {
        long long tmp;
        scanf("%lld", &tmp);
        sum[0] += tmp;
        forward.push(tmp);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", mid_table + i);
    }
    for (int i = 0; i < n; i++)
    {
        long long tmp;
        scanf("%lld", &tmp);
        sum[1] += tmp;
        back.push(tmp);
    }
    long long *sum_forward = new long long[n + 1], *sum_back = new long long[n + 1];
    sum_forward[0] = sum[0];
    for (int i = 0; i < n; i++)
    {
        forward.push(mid_table[i]);
        sum_forward[i + 1] = sum_forward[i] + mid_table[i] - forward.top();
        forward.pop();
    }
    sum_back[n] = sum[1];
    for (int i = n - 1; i >= 0; i--)
    {
        back.push(mid_table[i]);
        sum_back[i] = sum_back[i + 1] + mid_table[i] - back.top();
        back.pop();
    }
    long long max{-100000000000000};
    for (int i = 0; i < n + 1; i++)
    {
        max = std::max(max, sum_forward[i] - sum_back[i]);
    }
    printf("%lld\n", max);
    
    delete[] mid_table;
    delete[] sum_forward;
    delete[] sum_back;
    return 0;
}

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


int main(){

    int N;
    cin >> N;


    bool buy = false;

    for( int i = 0; i <= 100/7; i++ ){
        for( int j = 0; j <= 100/4; j++ ){
            if( 7*i + 4*j == N ){
                buy = true;
                break;
            }
        }
    }

    if( buy ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256