akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	hs := make([]int, n)
	for i := 0 ; i < n;i++ {
		var h int
		fmt.Scan(&h)
		hs[i] = h

	}

	ans := make(map[int]bool, n)
	for i := 0; i < n; i++ {
		ans[i] = true
	}

	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if hs[a-1]> hs[b-1] {
			ans[b-1] = false
		} else if hs[a-1] < hs[b-1] {
			ans[a-1] = false
		} else {
			ans[a-1] = false
			ans[b-1] = false
		}
	}
	cnt := 0
	for i := 0; i < n; i++ {
		if ans[i] == true {
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 8060
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cmath>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
const int N = 2e5 + 5;
int n, a[N], b[N], ans[N], tmp[N];
vector<int> G[N];
struct tree 
{ 
	int l, r, dat; 
}t[N << 2];
int ls(int p) 
{ 
	return p << 1; 
}
int rs(int p) 
{
 return ((p << 1) | 1); 
}
void build(int p, int l, int r) 
{
	t[p].l = l, t[p].r = r;
	if (l == r) 
	{ 
		t[p].dat = a[l]; 
		return ; 
	}
	int mid = (l + r) >> 1;
	build(ls(p), l, mid);
	build(rs(p), mid + 1, r);
	t[p].dat = max(t[ls(p)].dat, t[rs(p)].dat);
}
void change(int p, int x, int v) 
{
	if (t[p].l == t[p].r) 
	{ 
		t[p].dat = v; 
		return ; 
	}
	int mid = (t[p].l + t[p].r) >> 1;
	if (x <= mid) 
		change(ls(p), x, v);
	else 
		change(rs(p), x, v);
	t[p].dat = max(t[ls(p)].dat, t[rs(p)].dat);
}
int ask(int p, int l, int r) 
{
	if (l <= t[p].l && r >= t[p].r) 
		return t[p].dat;
	int mid = (t[p].l + t[p].r) >> 1;
	int val = 0;
	if (l <= mid) 
		val = max(val, ask(ls(p), l, r));
	if (r > mid) 
		val = max(val, ask(rs(p), l, r));
	return val;
}
void dfs(int x, int fa)
{
	ans[x] = ask(1, 1, a[x] - 1) + 1;
	int tmp = ask(1, a[x], a[x]);
	if (ans[x] > tmp)
		change(1, a[x], ans[x]);
	ans[x] = max(ans[fa], ans[x]);
	for (int i = 0; i < (int)G[x].size(); i++)
		if (G[x][i] != fa)
			dfs(G[x][i], x);
	change(1, a[x], tmp);
	return;
}
int main() 
{
	rd(n);
	build(1, 1, n);
	for (int i = 1; i <= n; i++)
		rd(a[i]), b[i] = a[i];
	sort(b + 1, b + n + 1);
	int m = unique(b + 1, b + n + 1) - b - 1;
	for (int i = 1; i <= n; i++)
		a[i] = lower_bound(b + 1, b + m + 1, a[i]) - b;
	for (int i = 1, u, v; i < n; i++)
		rd(u), rd(v), G[u].push_back(v), G[v].push_back(u);
	dfs(1, 0);
	for (int i = 1; i <= n; i++)
		pt(ans[i]), ph;
    return 0;
}

Measured memory_bytes: 33884
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 3e5 + 1;

int n, m, k;
int a[N], f[N];
int dp[1 << 13];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for(int i = 1 ; i < (1 << n); i++)
		dp[i] = 1e16;
   	for(int i = 1; i <= m; i++){
   		int cs;
   		cin >> cs >> k;
   		int mask = 0;
   		for(int i = 1 ; i <= k ; i++){
   			int x; 
   			cin >> x;
   			x--;
			mask += (1 << x);
        }
		for(int submask = mask; submask; submask = (submask - 1) & mask)
        	dp[submask] = min(dp[submask] , cs);
	}
	
   	for(int i = 0 ; i < (1 << n) ; i++)
   		for(int j = 0 ; j < (1 << n) ; j++)
			dp[i|j] = min(dp[i|j] , dp[i] + dp[j]);
	if(dp[(1 << n) - 1] >= 1e16)
		ret(-1);
	cout << dp[(1 << n) - 1];

}


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

#define TYPE 26

int main() {

	int64_t d;
	cin >> d;

    vector<int64_t> c(TYPE);
    for(int i=0;i<TYPE;i++){
        cin>>c.at(i);
    }

    vector<vector<int64_t>> s(d, vector<int64_t>(TYPE));
    for(int i=0;i<d;i++){
        for(int j=0;j<TYPE;j++){
            cin>>s.at(i).at(j);
        }
    }

    vector<int64_t> last(TYPE,0);
    int64_t satisfaction=0;
    for(int i=0;i<d;i++){
        int64_t t;
        cin>>t;

        satisfaction+=s.at(i).at(t-1);
        last.at(t-1)=i+1;

        int64_t degrade=0;
        for(int j=0;j<TYPE;j++){
            degrade+=c.at(j)*(i+1-last.at(j));
        }
        satisfaction-=degrade;

        cout<<satisfaction<<endl;
    }

	return 0;
}

Measured memory_bytes: 3672
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const LL K=100*1000+1;
LL U=1LL<<60;
int rep[K];
int Find(int i){
	while(rep[i]!=i){
		i=rep[i]=rep[rep[i]];
	}
	return i;
}
void Union(int a,int b){
	a=Find(a);
	b=Find(b);
	rep[b]=a;
}
vector<P> path[K];
LL pos[K];
bool dfs(int r){
	for(auto p:path[r]){
		if(pos[p.first]!=U) {
			if (pos[p.first]!=pos[r]+p.second){
				return false;
			}
		}
		else{
			pos[p.first]=pos[r]+p.second;
			if(!dfs(p.first)){
				return false;
			}
		}
	}
	return true;
}
int main() {
	int N;
	int M;
	cin >> N >> M;
	for(int i=0;i<N;i++){
		pos[i]=U;
		rep[i]=i;
	}
	for(int i=0;i<M;i++){
		int l,r,d;
		cin >> l >> r >> d;
		l--;
		r--;
		path[l].push_back(P(r,d));
		path[r].push_back(P(l,-d));
		Union(l,r);
	}

	for(int i=0;i<N;i++){
		if(rep[i]==i){
			pos[i]=0;
			if(!dfs(i)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	

	return 0;
}



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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
typedef pair<int, int> Pair;

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> A(N), B(N), C(N), D(N);
  for (int i = 0; i < N; i++) cin >> C.at(i) >> D.at(i);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  vector<int> ordAB(N);
  iota(ordAB.begin(), ordAB.end(), 0);
  sort(ordAB.begin(), ordAB.end(),
       [&](int i, int j) { return B.at(i) < B.at(j); });
  int answer = 0;
  vector<bool> used(N);
  for (int i = 0; i < N; i++) {
    int j = ordAB.at(i);
    int x = -1;
    int k0 = -1;
    for (int k = 0; k < N; k++) {
      if (used.at(k)) continue;
      if (C.at(k) >= A.at(j)) continue;
      if (D.at(k) >= B.at(j)) continue;
      if (C.at(k) <= x) continue;
      x = C.at(k);
      k0 = k;
    }
    if (k0 < 0) continue;
    used.at(k0) = true;
    answer++;
  }
  cout << answer << endl;
  return 0;
}



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

#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define MOD 1000000007
typedef long long int lli;
typedef pair<lli, lli> pii;

int N;

lli range_cover(pii A, pii B) {
  if (A.first > B.first) swap(A, B);
  if (A.second <= B.first)  return 0;
  if (B.second <= A.second) return B.second - B.first;
  return A.second - B.first;
}

int main()
{
  cin >> N;
  vector<lli> T(N);
  vector<lli> A(N);
  REP(i, N) cin >> T[i];
  REP(i, N) cin >> A[i];

  vector<pii> TT(N);
  vector<pii> AA(N);

  int m = -1;
  REP(n, N) {
    if (m < T[n]) {
      TT[n] = pii(T[n], T[n]+1);
      m = T[n];
    } else {
      TT[n] = pii(1, T[n]+1);
    }
  }

  m = -1;
  for (int n = N-1; n >= 0; n--) {
    if (m < A[n]) {
      AA[n] = pii(A[n], A[n]+1);
      m = A[n];
    } else {
      AA[n] = pii(1, A[n]+1);
    }
  }

  // REP(n, N) printf("(%lld, %lld) ", AA[n].first, AA[n].second); printf("\n");
  // REP(n, N) printf("(%lld, %lld) ", TT[n].first, TT[n].second);

  lli cnt = range_cover(TT[0], AA[0]);
  for (int n = 1; n < N; n++) {
    cnt *= range_cover(TT[n], AA[n]);
    cnt %= MOD;
  }

  cout << cnt << endl;

  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long want;
  cin >> want;
  long long total = 100;
  long long ans = 0;
  while(total < want){
    total *= 1.01;
    ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    cout << a[2]*10 + a[0] + a[1] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d,e;
scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
int num[5];
num[0]=a;
num[1]=b;
num[2]=c;
num[3]=d;
num[4]=e;
int tmp=0;
int i=0,j=0;
for(i=0;i<=3;i++)
   for(j=0;j<=3;j++)
       if(num[j]>=num[j+1]){
	      tmp=num[j];
		  num[j]=num[j+1];
		  num[j+1]=tmp;
		  }
		  
printf("%d %d %d %d %d\n",num[4],num[3],num[2],num[1],num[0]);
return 0;
}

Measured memory_bytes: 596
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] a = new int[n];
		for( int i=0 ; i<n ; i++ ) {
			a[i] = sc.nextInt();
		}

		Pair[] p = new Pair[m];
		for( int i=0 ; i<m ; i++ ) {
			p[i] = new Pair(sc.nextInt(),sc.nextInt());
		}

		Arrays.sort(a);
		Arrays.sort(p);

		int s=0;
		for( int i=0 ; i< m ; i++) {
			int b = p[i].r;
			int c = p[i].l;
			
			while( b>0 && s<n && a[s] < c ) {
				a[s] = c;
				s++;
				b--;
			}
		}
		
		long ans = 0;
		for( int i=0 ; i< n ; i++) {
			ans += a[i];
		}
		System.out.println(ans);
		
	}

	public static class Pair implements Comparable<Pair>{
		int r = 0;
		int l = 0;
		
		public Pair(int weight, int limit) {
			super();
			this.r = weight;
			this.l = limit;
		}

		@Override
		public int compareTo(Pair o) {
			if(false)
				// ASC
				return (l - o.l);
			else
				// DESC
				return -(l - o.l);
		}
	
	}
}



Measured memory_bytes: 64684
N = int(input())
S = input()


num2alpha = lambda c: chr(c+64)
alpha2num = lambda c: ord(c) - ord('A') + 1

ans = []
for character in S:
  try:
    num = alpha2num(character)
    new_num = (num + N) % 26
    if new_num == 0:
      new_num = 26
    new_chr = num2alpha(new_num)
    ans.append(new_chr)
  except:
    break

ans = ''.join(ans)
print(ans)

Measured memory_bytes: 3064
from copy import deepcopy

N = int(input())
T = [int(n) for n in input().split()]
M = int(input())
PX = []
for _ in range(M):
    PX.append(tuple([int(n) for n in input().split()]))

for p, x in PX:
    NT = deepcopy(T)
    NT[p - 1] = x
    print(sum(NT))


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

using namespace std;

#define int long long

int n, val[2][3];

int32_t main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for (int _ = 0; _ < 2; ++_) for (int i = 0; i < 3; ++i) {
        cin >> val[_][i];
    }

    for (int _ = 0; _ < 2; ++_) {
        vector<int> id;
        for (int i = 0; i < 3; ++i) if (val[_][i] < val[_ ^ 1][i]) id.push_back(i);
        if (id.size() == 1) n = n / val[_][id.back()] * val[_ ^ 1][id.back()] + n % val[_][id.back()];
        else if (id.size() == 2) {
            int mx = 0;
            for (int i = 0; val[_][ id[0] ] * i <= n; ++i) {
                mx = max(mx, i * val[_ ^ 1][ id[0] ] + (n - val[_][ id[0] ] * i) / val[_][id.back()] * val[_ ^ 1][id.back()]
                         + (n - val[_][ id[0] ] * i) % val[_][id.back()]);
            }
            n = mx;
        }
        else if (id.size() == 3) {
            int mx = 0;
            for (int i = 0; val[_][ id[0] ] * i <= n; ++i) {
                for (int j = 0; val[_][ id[0] ] * i + val[_][ id[1] ] * j <= n; ++j) {
                    mx = max(mx, val[_ ^ 1][ id[0] ] * i + val[_ ^ 1][ id[1] ] * j +
                             (n - val[_][ id[0] ] * i - val[_][ id[1] ] * j) / val[_][id.back()] * val[_ ^ 1][id.back()]
                             + (n - val[_][ id[0] ] * i - val[_][ id[1] ] * j) % val[_][id.back()]);
                }
            }
            n = mx;
        }
    }

    cout << n;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int64_t kosuu(int64_t n, int64_t x)
{
    if (n == -1)
        return 0;
    else
        return n / x + 1;
}

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

    int64_t t;
    t = kosuu(b,x) - kosuu(a - 1,x);

    printf("%ld\n", t);
}

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

int main(){
  string s;
  cin >> s;
  vector<char> a(4);
  for(int i=0;i<4;i++){
    a.at(i) = s.at(i);
  }
  string A = "No";
  if(a.at(0) == a.at(1) && a.at(2) == a.at(3) && a.at(0) != a.at(2)){
    A = "Yes";
  }
  if(a.at(0) == a.at(2) && a.at(1) == a.at(3) && a.at(0) != a.at(1)){
    A = "Yes";
  }
  if(a.at(0) == a.at(3) && a.at(1) == a.at(2) && a.at(0) != a.at(1)){
    A = "Yes";
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double EPS = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp);
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "(" << p.first << ":" << p.second << ")";
    return os;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", ";
        a = 1; os << tp;
    }
    return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int K, A, B; cin >> K >> A >> B;
    FOR(i, A, B+1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 505;

int x[MAX];
int treba[MAX*MAX];
int rje[MAX*MAX];
int n;
P poz[MAX];
int ima[MAX];

int check()
{
  int kol[MAX];
  memset(kol, 0, sizeof kol);

  REP(i, n*n) {
    if (rje[i] < 1 || rje[i] > n) return 0;
    kol[rje[i]]++;
    if (kol[rje[i]] == rje[i] && i != x[rje[i]])
      return 0;
  }
  
  FOR(i, 1, n+1)
    if (kol[i] != n)
      return 0;

  return 1;
}
 
int main()
{
  scanf("%d", &n);

  FOR(i, 1, n+1) { 
    scanf("%d", &x[i]);
    x[i]--;
    poz[i] = P(x[i], i);
    treba[x[i]] = i;
  }

  sort(poz + 1, poz + n + 1);

  REP(i, n*n) {
    if (treba[i])
      rje[i] = treba[i];
    else {
      int da = 0;

      FOR(j, 1, n+1) {
	int ind = poz[j].Y;
	if (ima[ind] + 1 < ind) {
	  rje[i] = ind;
	  da = 1;
	  break;
	}
      }
      
      if (!da) {
	FOR(j, 1, n+1) {
	  if (ima[j] >= j && ima[j] < n) {
	    rje[i] = j;
	    break;
	  }
	}
      }
    }

    ima[rje[i]]++;
  }

  if (check()) {
    printf("Yes\n");
    REP(i, n*n)
      printf("%d ", rje[i]);
    printf("\n");
  }
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 4e5+5;

int main(){
	int n , m; cin >> n >> m;
	int sum = 0, a;
	for(int i = 1; i <= m; i++){
		cin >> a;
		sum += a;
	}
	int ans = n - sum;
	if(ans < 0) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 3672
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] NX = ReadLineParseIntArray();
        int N = NX[0];
        int X = NX[1];
        int[] A = ReadLineParseIntArray();
        long sum = 0;
        if(A.Last() > X)
        {
            sum += A.Last() - X;
            A[A.Length - 1] = X;
        }
        for(int i = 1; i < N; i++)
        {
            int n = Max(0, A[i] + A[i - 1] - X);
            A[i] -= n;
            sum += n;
        }
        WriteLine(sum);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 32220
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
F=list(map(int,readline().split()))
#print(N,K)
#print("A:",A)
#print(F)

A.sort()
F.sort(reverse=True)
#print("A:",A)
#print("F:",F)

left=-1
right=N*A[-1]*F[0]
#right=10**3

while left+1<right:
  mid=(left+right)//2
  tmp=0
  for i in range(N):
    tmp+=max(A[i]-mid//F[i],0)
    
  if tmp<=K:
    right=mid
  else:
    left=mid
  #print("mid:",mid,",tmp:",tmp)
#print("left:",left,",mid:",mid,",right:",right)
print(right)

Measured memory_bytes: 83740
#include<bits/stdc++.h>
using namespace std;
int sieve[10005];

int ans[10005];

void precal()
{
	int i,j;
	
	sieve[1]=1;
	
	for(i=2;i*i<=10000;i++)
	{
		if(sieve[i])
		continue;
		
		for (j=2*i;j<=10000;j+=i)
		{
			sieve[j]=1;
		}
	}
	
	vector<int>prime;
	
	
	for (i=1;i<=10000;i++)
	{
		if(!sieve[i])
		prime.push_back(i);
	}
	//cout<<prime.size()<<endl;
	
	for (i=0;i<prime.size();i++)
	{
		int sum=0;
		for (j=i;j<prime.size();j++)
		{
			sum+=prime[j];
			if(sum<=10000)
			ans[sum]++;
		}
	}
	
}

int main()
{
	precal();
	
	int N;
	
	cin>>N;
	
	while(N!=0)
	{
		printf("%d\n",ans[N]);
		cin>>N;
	}
	
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int dir_to_id(char d){
    if(d == 'L') return 0;
    else if(d == 'R') return 1;
    else if(d == 'U') return 2;
    else return 3;
}

int n;
vector<int> pos[4][MAX];
vector<pii> ps[4];
int ans = mod;

void f(vector<pii> &p, vector<pii> &q){
    map<int, vector<int>> mp;
    for(auto [x, y]: p) mp[x+y].push_back(x);
    for(auto &xv: mp) sort(xv.se.begin(), xv.se.end());

    for(auto [x, y]: q)if(mp.find(x+y) != mp.end()){
        auto &v = mp[x+y];
        auto itr = lower_bound(v.begin(), v.end(), x);
        if(itr == v.end()) continue;
        chmin(ans, (*itr - x) * 10);
    }
}

int main(){
    scanf("%d", &n);
    vector<int> x(n), y(n);
    vector<char> dir(n);
    rep(i, n){
        scanf("%d%d %c", &x[i], &y[i], &dir[i]);
        ps[dir_to_id(dir[i])].emplace_back(x[i], y[i]);
        if(dir_to_id(dir[i]) <= 1) pos[dir_to_id(dir[i])][y[i]].push_back(x[i]);
        else pos[dir_to_id(dir[i])][x[i]].push_back(y[i]);
    }

    rep(i, MAX)if(!pos[0][i].empty() && !pos[1][i].empty()){
        sort(pos[0][i].begin(), pos[0][i].end());
        for(auto x: pos[1][i]){
            auto itr = lower_bound(pos[0][i].begin(), pos[0][i].end(), x);
            if(itr == pos[0][i].end()) continue;
            chmin(ans, (*itr - x) * 5);
        }
    }
    rep(i, MAX)if(!pos[2][i].empty() && !pos[3][i].empty()){
        sort(pos[3][i].begin(), pos[3][i].end());
        for(auto x: pos[2][i]){
            auto itr = lower_bound(pos[3][i].begin(), pos[3][i].end(), x);
            if(itr == pos[3][i].end()) continue;
            chmin(ans, (*itr - x) * 5);
        }
    }

    vector<pii> P, Q;
    for(auto p: ps[0]) P.push_back(p);
    for(auto p: ps[3]) Q.push_back(p);
    f(P, Q);

    P.clear(), Q.clear();
    for(auto p: ps[0]) P.emplace_back(p.fi, -p.se);
    for(auto p: ps[2]) Q.emplace_back(p.fi, -p.se);
    f(P, Q);

    P.clear(), Q.clear();
    for(auto p: ps[1]) P.emplace_back(-p.fi, -p.se);
    for(auto p: ps[2]) Q.emplace_back(-p.fi, -p.se);
    f(P, Q);

    P.clear(), Q.clear();
    for(auto p: ps[1]) P.emplace_back(-p.fi, p.se);
    for(auto p: ps[3]) Q.emplace_back(-p.fi, p.se);
    f(P, Q);

    if(ans == mod) puts("SAFE");
    else printf("%d\n", ans);
}

Measured memory_bytes: 46036
#include <stdio.h>

int main(void)
{
	int num;

	scanf("%d", &num);

	if (num % 10 == 3)
	{
		printf("bon\n");
	}
	else if(num % 10 == 0 || num % 10 == 1 || num % 10 == 6 || num % 10 == 8)
	{
		printf("pon\n");
	}
	else
	{
		printf("hon\n");
	}

	return 0;
}

Measured memory_bytes: 1596
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    int ans = inf;
    
    ans = min(ans, abs(a - b) + abs(b - c));
    ans = min(ans, abs(a - c) + abs(c - b));
    ans = min(ans, abs(b - c) + abs(c - a));
    ans = min(ans, abs(b - a) + abs(a - c));
    ans = min(ans, abs(c - a) + abs(a - b));
    ans = min(ans, abs(c - b) + abs(b - a));
    
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
# s = input()
# a,b = map(int,input().split())
# da = list(map(int,input().split()))
# a = [int(input()) for i in range(n)]

ans = 0
a = n//500
ans += a*1000
n-=a*500
ans += n//5*5

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	vector<int> N(4);
	cin >> N[0] >> N[1] >> N[2] >> N[3];
	sort(N.begin(), N.end());
	if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var K = read[1];

            var str = Console.ReadLine();
            char lower = (char)(str[K-1] + 0x20);
            var ret = str.Substring(0, K - 1) + lower + str.Substring(K, N - K);
            Console.WriteLine(ret);

        }
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin >> n >> x;
    vector<long> m(n);
    int i,j;
    int h=1000;
    for(i=0;i<n;i++){
        cin >> m.at(i);
        x-=m.at(i);
        if(m.at(i)<h){
            h=m.at(i);
        }
    }
    cout << n+(x/h) << endl;
    return 0;
}

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

typedef long long ll;

int main() {        
	int n;
	cin >> n;
	map<int,int> m;
	for (int i = 0; i < n; ++i) {
		int y;
		cin >> y;
		m[y]++;
	}
	int cnt = 0;
	for (auto x : m) {
		if (x.second % 2 == 1) {
			cnt++;
		}
	}
	cout << cnt;
}




Measured memory_bytes: 8284
#include <iostream>

using namespace std;

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

  int counter5 = 0;
  int counter7 = 0;

  if (a == 5) counter5 += 1;
  else if (a == 7) counter7 += 1;

  if (b == 5) counter5 += 1;
  else if (b == 7) counter7 += 1;

  if (c == 5) counter5 += 1;
  else if (c == 7) counter7 += 1;

  if (counter5 == 2 && counter7 == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	char x;
	cin>>x;
	if(x>=65 && x<=90)
	cout<<"A"<<"\n";
	else if(x>=97 && x<=122)
	{
		cout<<"a"<<"\n";
	}
}

Measured memory_bytes: 3620
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
#define pb(v,e) v.push_back(e)

string sint(int i){
   stringstream buf;
   buf<<i;
   return buf.str();
}

/*
   ifstream fin("input.txt");
   ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int graph[15][15] = { 
   {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0},
   {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0},
   {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
   {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
   {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
   {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},
   {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
   {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},
   {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
   {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};

int sol[15];

int alias[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

string print(int i,int e){
   if( i == -1)return "";
   if(e)return print(sol[i],0)+sint(alias[i])+"\n";
   return print(sol[i],0)+sint(alias[i])+" ";
}

string do_bfs(int j,int k){
   
   bool vis[15];
   memset(vis,0,sizeof(vis));
   memset(sol,-1,sizeof(sol));

   vis[j] = true;
   sol[j] = -1;

   queue<int> nodes;
   nodes.push(j);

   int stop = j;

   while(!nodes.empty()){
      int nx = nodes.front();
      nodes.pop();
      if( alias[nx] == k){
         stop = nx;
         break;
      }
      rep(i,15){
         if( graph[nx][i] == 1 && !vis[i]){
            sol[i] = nx;
            vis[i] = true;
            nodes.push(i); 
         }
      }
   }
   return print(stop,1);
}

int main(){
   int u;
   scanf("%d",&u);
   rep(a,u){
      string sol = "1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 0 0";
      
      int j,k;
      scanf("%d %d",&j,&k);

      rep(i,15){
         if( alias[i] == j){
            string aux = do_bfs(i,k);
            if( sol.size() > aux.size()) sol = aux;
         }
      }
      printf("%s",sol.c_str());
   }
   return 0;
}

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

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

  int ans = m;
  for(int i = 0; i < n; i++) {
    int x, y; cin >> x >> y;
    if(m < 0) ans = 0;
    if(m >= 0) m += x-y;
    ans = max(ans, m);
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
    int n,k,s;
    while(cin >> n >> k >> s, n){
        vector<int> v(n);
        for(int i = 0 ; i < n ; i++){
            v[i] = i+1;
        }
        int cnt = 0;
        for(int i = 0 ; i < (1<<n) ; i++){
            int sum = 0;
            if(__builtin_popcount(i) != k) continue;
            for(int j = 0 ; j < n ; j++){
                if(i >> j & 1){
                    sum += v[j];
                }
            }
            if(sum == s) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main() {
  string s, t;
  cin >> s;
  
  int i;
  bool flag = true;
  while(1){
    t = s.substr(0, s.size() - 2);
    s = t;
    for(i = 0; i < t.size() / 2; i++){
      if(t.at(i) != t.at(i + (t.size() / 2))){
        flag = false;
        break;
      }
    }
    if(flag){
      cout << t.size() << endl;
      break;
    }
    else flag = true;
  }
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

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

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


// Main Code
int main()
{
	string s;
	cin>>s;
	ll ans = 0;
	int curr = 1;
	rep(i, 0, s.length())
	{
		curr = 1 - curr;
		if(s[i] - '0' != curr) ans++;
 	}
 	curr = 0;
 	ll tans = 0;
 	rep(i, 0, s.length())
 	{
 		curr = 1 - curr;
 		if(s[i]-'0' != curr) tans++;
 	}
 	cout<<min(ans, tans)<<endl;
}


Measured memory_bytes: 512
import queue

H, W = map(int, input().split(' '))
S = []

for h in range(H):
    row = input()
    S.append(row)

INF = 100100100

di = [-1, 0, 1, 0]
dj = [0, 1, 0, -1]

ans = 0

for si in range(H):
    for sj in range(W):
        # start地点を設定する
        s = S[si][sj]
        if s == '#':
            continue

        dist = [[INF] * W for i in range(H)]
        q = queue.Queue()

        def update(i, j, x):
            global dist
            global INF
            global q
            if dist[i][j] != INF:
                return
            dist[i][j] = x
            q.put((i, j))

        update(si, sj, 0)
        while not q.empty():
            p = q.get()
            i = p[0]
            j = p[1]
            for dn in range(4):
                ni = i + di[dn]
                nj = j + dj[dn]
                if ni < 0 or ni >= H or nj < 0 or nj >= W:
                    continue
                if S[ni][nj] == '#':
                    continue
                update(ni, nj, dist[i][j] + 1)

        for i in range(H):
            for j in range(W):
                if dist[i][j] == INF:
                    continue
                ans = max(ans, dist[i][j])

print(ans)


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using lint=long long;
void cmx(double&x,double y){if(x<y)x=y;}
void cmn(double&x,double y){if(x>y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    using complex=std::complex<double>;
    std::vector<complex>data(n);
    for(lint i=0;i<n;i++){
        double x,y;std::cin>>x>>y;
        data.at(i)={x,y};
    }
    auto wt=[&](complex o,complex p,complex q){
        p-=o,q-=o;
        p/=std::abs(p),q/=std::abs(q);
        complex r=q/p;
        return 2*std::real(r)*std::imag(r);
    };
    auto cal=[&,a=std::vector<double>(n)](complex p)mutable{
        std::transform(data.begin(),data.end(),a.begin(),[&](auto&&q){return std::abs(p-q);});
        return *std::max_element(a.begin(),a.end());
    };
    double ans=std::numeric_limits<double>::infinity();
    for(lint i=0;i<n;i++){
        for(lint j=i+1;j<n;j++){
            cmn(ans,cal((data.at(i)+data.at(j))/2.0));
        }
    }
    double eps=1e-10;
    for(lint i=0;i<n;i++){
        for(lint j=i+1;j<n;j++){
            for(lint k=j+1;k<n;k++){
                double I=wt(data.at(i),data.at(j),data.at(k));
                double J=wt(data.at(j),data.at(k),data.at(i));
                double K=wt(data.at(k),data.at(i),data.at(j));
                if(std::abs(I)+std::abs(J)+std::abs(K)<eps)continue;
                cmn(ans,cal((data.at(i)*I+data.at(j)*J+data.at(k)*K)/(I+J+K)));
            }
        }
    }
    std::cout<<ans<<'\n';
}


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

const int DIV = 100000007;
int r, c, ax, ay, bx, by, dp[1001][1001];

int abs(int n){
    return n<0?-n:n;
}

void set(){
    for(int i = 0; i <= 1000; i++) dp[0][i] = 1;
    for(int i = 0; i < 1000; i++){
        dp[i+1][0] = 1;
        for(int j = 0; j < 1000; j++){
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%DIV;
        }
    }
}

int main(){
    set();
    cin >> r >> c >> ax >> ay >> bx >> by;
    int m = 1, x, y;
    int dx = abs(bx-ax), dy = abs(by-ay);
    if( r%2 == 0 && r/2 == dx ) m *= 2;
    if( r/2 >= dx ) x = dx;
    else x = r - dx;
    if( c%2 == 0 && c/2 == dy ) m *= 2;
    if( c/2 >= dy ) y = dy;
    else y = c - dy;
    cout << (m * dp[x][y])%DIV << endl;
    return 0;
}

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,a[200010],b[200010];
    cin>>n;
    rep(i,n)cin>>a[i]>>b[i];
        sort(a,a+n);
        sort(b,b+n);
    if(n%2==1){
        cout<<(b[n/2]-a[n/2]+1)<<endl;
    }
    else{
        cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 1e5 + 10;
bool a[N];
int b[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, m;
    cin >> n >> m;
    for (int i=1; i<=m; i++) {
        int p;
        cin >> p;
        string s;
        cin >> s;
        if (a[p]) continue;
        if (s == "AC") {
            a[p] = 1;
        }
        else {
            b[p]++;
        }
    }
    int x = 0, y = 0;
    for (int i=1; i<=n; i++) {
        if (a[i]) {
            x++;
            y += b[i];
        }
    }
    cout << x << " " << y << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  long long N, M, L, A;
  cin >> N >> M >> L;

  int l = __builtin_ffsll(L);
  while (cin >> A) {
    if (__builtin_ffsll(A) != l) goto NG;
    L = L * A / __gcd(L, A);
    if (L / 2 > M) goto NG;
  }

  cout << (M - L / 2) / L + 1 << "\n";
  return 0;
  NG:
  cout << 0 << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int n;
    cin >> n;
    vs s(n);
    rep(i,n) cin >> s[i];
    int ans = 0;
    rep(k,n){
        bool c = true;
        vs t = s;
        rep(i,n)rep(j,n)t[i][j] = s[(i+k)%n][j];
        rep(i,n)rep(j,n)if(t[i][j]!=t[j][i]) c = false;
        if(c) ans += n;
    }
    cout << ans << endl;
}


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

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

int main(){
  ll N,M;
  cin>>N>>M;

  ll H[N];
  rep(i,N) cin>>H[i];
  ll A[M],B[M];
  rep(i,M) cin>>A[i]>>B[i],A[i]--,B[i]--;

  vector<bool> x(N,true);

  rep(i,M){
    if(H[A[i]] > H[B[i]]){
      x[B[i]]=false;
    }else if(H[A[i]] < H[B[i]]){
      x[A[i]]=false;
    }else{
      x[A[i]]=false;
      x[B[i]]=false;
    }
  }
  ll ans = 0;
  rep(i,N){
    if(x[i]) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 5936
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,i,a[200000],max1=0,max2=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>max1){
            max2=max1;
            max1=a[i];
        }else if(max2<a[i]){
            max2=a[i];
        }
    }
    for(i=0;i<n;i++){
        if(a[i]==max1){
            printf("%d\n",max2);
        }else{
            printf("%d\n",max1);
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
 
using namespace std;
#define sz(x) (int)(x).size()
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=3e5+5;


int main()
{	

		
	int n,x;
	scanf("%d %d",&n,&x);
    	
    	for(int i=-1000000;i<=1000000;i++){
        	if (abs(x-i)<n)
            		printf("%d ",i);
    	}
 	
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!int;
  auto l = new long[](n+1);
  l[0] = 2;
  l[1] = 1;

  foreach (i; 2..n+1)
    l[i] = l[i-1]+l[i-2];

  writeln(l[n]);
}


Measured memory_bytes: 256
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int a[20];
int n;
ll dfs(int i,ll pr)
{
	if(i==n)
	{
		if(pr%2==0)return 1;
		else return 0;
	}
	return dfs(i+1,pr*(a[i]-1))+dfs(i+1,pr*(a[i])) +dfs(i+1,pr*(a[i]+1));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n;
	for(int i=0;i<n;++i)cin>>a[i];
	cout<<dfs(0,1LL)<<'\n';
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	string n;
	cin>>n;
	int ans=9*n.size();
	if(n[0]!='9'){
		ans=9*(n.size()-1)+n[0]-'0';
		rep(i,1,n.size()){ 
			if(n[i]!='9'){
				ans-=1;
				break;
			}
		}
	}
	else rep(i,n.size()){
		if(n[i]!='9') ans=9*n.size()-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256