akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
const int MOD = 1e9 + 7;

struct Node {
    int data;
    Node *pNext, *pPrev;
    Node(int _data = -1){
        data = _data;
        pNext = pPrev = NULL;
    }
};

struct LinkedList {
    Node *pHead, *pTail;
    LinkedList() {
        pHead = pTail = NULL;
    }

    bool empty() {
        return pHead == NULL;
    }

    void insertLast(int x) {
        struct Node *p = new Node(x);
        if (empty()) {
            pHead = pTail = p;
        }
        else {
            p->pPrev = pTail;
            pTail->pNext = p;
            pTail = pTail->pNext;
        }
    }

    void insertFirst(int x) {
        struct Node *p = new Node(x);
        if (empty()) {
            pHead = pTail = p;
        }
        else {
            p->pNext = pHead;
            pHead->pPrev = p;
            pHead = pHead->pPrev;
        }
    }

    bool removeFirst() {
        if (empty()) return false;
        struct Node *p = pHead;
        if (pHead->pNext == NULL) {
            pHead = pTail = NULL;
        }
        else {
            pHead->pNext->pPrev = NULL;
            pHead = pHead->pNext;
        }
        delete(p);
        p = NULL;
    }

    bool removeLast(){
        if (empty()) return false;
        struct Node *p = pTail;
        if (pTail->pPrev == NULL) {
            pTail = pHead = NULL;
        }
        else {
            pTail->pPrev->pNext = NULL;
            pTail = pTail->pPrev;
        }
        delete(p);
        p = NULL;
    }

    bool erase(int x) {
        struct Node *p = pHead;
        while (p && p->data != x) {
            p = p->pNext;
        }
        if (!p) return false;
        if (p == pHead) removeFirst();
        else {
            if (p == pTail) removeLast();
            else {
                p->pPrev->pNext = p->pNext;
                p->pNext->pPrev = p->pPrev;
                delete(p);
                p = NULL;
            }
        }
    }

    void print() {
        if (empty()) return;
        struct Node *p = pHead;
        cout << p->data;
        p = p->pNext;
        while (p) {
            cout << " " << p->data;
            p = p->pNext;
        }
    }
};
void solve() {
    int nTest;
    cin >> nTest;
    LinkedList df;
    while (nTest--) {
        string cmd;
        cin >> cmd;
        if (cmd == "insert") {
            int x;
            cin >> x;
            df.insertFirst(x);
        }
        if (cmd == "delete") {
            int x;
            cin >> x;
            df.erase(x);
        }
        if (cmd == "deleteFirst") df.removeFirst();
        if (cmd == "deleteLast") df.removeLast();
    }
    df.print();
    cout << endl;
}

int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    #ifdef THEMIS
        freopen("solve.inp", "r", stdin);
        freopen("solve.out", "w", stdout);
    #endif // THEMIS
    int T;
    ///cin >> T;
    T = 1;
    while (T--) solve();
}



Measured memory_bytes: 34404
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,k,p,i;
  long m;
  double a;
  cin>>n>>k;
  vector<long> s(n+1);
  m=1;
  for (i=0;i<n;i++) {
    cin>>p;
    s.at(i+1)=s.at(i)+p;
    if (i>=k-1 && s.at(i+1)-s.at(i-k+1)>m) m=s.at(i+1)-s.at(i-k+1);
  }
  a=(m+k)/2.0;
  cout<<setprecision(16)<<a<<endl;
}

Measured memory_bytes: 1920
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过
const int maxn = 100111;
ll h;
int n;
ll a[maxn], b[maxn];

int main() {
	ios::sync_with_stdio(0);
  cin>>n>>h;
  ll amax = -1;
  int ans = 0;
  rep(i,0,n) {
    cin>>a[i]>>b[i];
    amax = max((ll)a[i], amax);
  }
  sort(b, b + n);
  reverse(b, b + n);
  for(int pkatana = 0; pkatana < n; pkatana++) {
    if(b[pkatana] >= amax) {
      h -= b[pkatana];
      ans++;
      if(h <= 0) break;
    }
  }
  if(h > 0) {
    int c = h / amax;
    if(c * amax < h) c++;
    ans += c;
  }
  cout<<ans<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


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

int n;
int a[55];
double ans;

int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    ans = a[0];
    for(int i = 1; i < n; i++)
    {
        ans = (ans + a[i])*1.0/2;
    }
    printf("%lf\n",ans);
}


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

typedef struct{
  char c;
  int num;
  int id;
}Card;

Card *B,*S;
int n;

void BubbleSort(){
  int i,j;
  //char ckey;
  Card key;

  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      //printf("i:%d j:%d\n",i,j);
      if(B[j-1].num > B[j].num){
        key=B[j];
        //printf("key:%c%d ",key.c,key.num);
        B[j]=B[j-1];
        B[j-1]=key;
        //printf("B[%d]:%c%d\n",j-1,B[j-1].c,B[j-1].num);
        //turn++;
      }
    }
  }
}

void SelectionSort(){
  int i,j,minj;
  Card key;

  for(i=0; i<n-1; i++){
    minj=i;
    for(j=i; j<=n-1; j++){
      if(S[j].num < S[minj].num){
        minj = j;
      }
    }
    key=S[i];
    S[i]=S[minj];
    S[minj]=key;
    //if(i!=minj)dif++;
  }
}

void judge(Card *T){
  int i,j;
  for(i=1; i<n; i++){
    if((T[i-1].num==T[i].num)&&(T[i-1].id > T[i].id)){
      printf("Not stable\n");
      return;
    }
  }
  printf("Stable\n");
}

void printer(){
  int i;
  for(i=0; i<n; i++){
    printf("%c%d",B[i].c,B[i].num);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  judge(B);
  for(i=0; i<n; i++){
    printf("%c%d",S[i].c,S[i].num);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  judge(S);
}

int main() {
  int i,num;
  char c;

  scanf("%d",&n);
  B = malloc(sizeof(Card) * n);
  S = malloc(sizeof(Card) * n);
  for(i=0; i<n; i++){
    scanf(" %c%d",&c,&num);
    B[i].c = c;
    B[i].num = num;
    B[i].id = i;
    S[i].c = c;
    S[i].num = num;
    S[i].id = i;
    //printf("%c%d",B[i].c,B[i].num);
  }
  //printf("\n");
  BubbleSort();
  SelectionSort();
  printer();

  return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n;
    cin >>n;
    rep1(i, 10){
        if(n%i != 0) continue;
        if(1 <= n/i && n/i <= 9){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout<< "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  int count=0;
  char str[101];
  scanf("%s",str);
  for(int i=0;i<strlen(str);i++){
    if(i<strlen(str)/2){
      if(str[i]!=str[strlen(str)-(i+1)]){
        count++;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

string s, t;

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

    int len = s.size();

    for(int i = 0; i < len; i++)
    {
        bool flag = true;
        for(int j = 0; j < len; j++)
            if(s[(i + j) % len] != t[j])
                flag = false;
        if(flag)
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
#include <bits/stdc++.h>
using namespace std;
double pi = 3.14159265358979323846264338;
string arr[100001];
const int ad = 'A' - 'a';





bool issqt(long long k) {
	if (k <= 3)return true;
	long long s = (long long)sqrt(k);
	//cout<<k<<" "<<s<<endl;
	for (long long i = 2; i <= s; i++)
		if (k % i == 0)return false;
	return true;
}
string s;
bool cmp(string a, string b) {
	int la = a.length();
	int lb = b.length();
	int lnth = min(la, lb);
	for (int i = 0; i < lnth; i++) {
		if (a[i] == b[i])continue;
		int ac, bc;
		for (int j = 0; j < 26; j++) {

			if (a[i] == s[j])ac = j;
			if (a[i] == s[j] + ad)ac = j - ad;
			if (b[i] == s[j])bc = j;
			if (b[i] == s[j] + ad)bc = j - ad;
		}
		return ac < bc;
	}
	if (la < lb)return true;
	return false;
}
long long arr1[200002], arr2[200002];
int main() {
	long long n, m, k;
	cin >> n >> m >> k;
	arr1[0] = 0;
	arr2[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> arr1[i]; arr1[i] += arr1[i - 1];
	}
	for (int i = n + 1; i < 200002; i++){
		arr1[i] = 1000000001; arr1[i] += arr1[i - 1];
	}
	for (int i = 1; i <= m; i++) {
		cin >> arr2[i]; arr2[i] += arr2[i - 1];
	}
	for (int i = m + 1; i < 200002; i++){
		arr2[i] = 1000000001; arr2[i] += arr2[i - 1];
	}
	long long cnt = 0;
	long long cnt2 = m;
	long long x = 1, y = 1;
	for (long long i = 0; i <= n; i++) {
		if (arr1[i] > k)break;
		for (long long j = cnt2 ; j >=0; j--) {
			if (arr1[i] + arr2[j] <= k) {
				cnt2 = j;
				cnt = max(cnt, i + j);
				break;
			}
		}
	}
	cout << cnt<< endl;
	return 0;
}




Measured memory_bytes: 9928
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

using namespace atcoder;
using namespace std;

int main(void){
  ll n, q;
  cin >> n >> q;
  
  dsu d(n);
  for (int i = 0; i < q; i++){
    ll t;
    cin >> t;
    ll u, v;
    cin >> u >> v;
    
    if (!t){
      d.merge(u, v);
    }
    else {
      cout << d.same(u, v) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4008
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
 return 0;   
}

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

using namespace std;

template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

template<class T>
vector<vector<T>> reads(size_t n, size_t m)
{
    vector<vector<T>> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(reads<T>(m));
    });
    return a;
}

int count_paths(const vector<vector<bool>>& graph, size_t index, vector<bool>& visited)
{
    if(visited[index]) return 0;
    
    visited[index] = true;
    
    if(all_of(begin(visited), end(visited), [](auto x){ return x; }))
    {
        visited[index] = false;
        return 1;
    }
    
    int paths = 0;
    for(size_t i = 0; i != graph.size(); ++i)
    {
        if(i != index && graph[index][i])
        {
            paths += count_paths(graph, i, visited);
        }
    }
    
    visited[index] = false;
    return paths;
}

int count_paths(const vector<vector<bool>>& graph)
{
    vector<bool> visited(graph.size(), false);
    return count_paths(graph, 0, visited);
}

int main()
{
    const auto N = read<size_t>();
    const auto M = read<size_t>();
    
    vector<vector<bool>> graph(N, vector<bool>(N, false));
    
    times_do(M, [&](){
        int a,b;
        cin >> a >> b;
        a--;b--;
        graph[a][b] = graph[b][a] = true;
    });
    
    cout << count_paths(graph) << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n; cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ans = 0;
    while (1) {
        sort(a, a + n, greater<int>());
        for (int i = 1; i < n; ++i) {
            if (a[i] != 0 && a[i - 1] != 0) a[i - 1] = a[i - 1] % a[i];
        }
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] != 0) {
                cnt++;
                ans = a[i];
            }
        }
        if (cnt == 1) break;
    }
    /*
    for (int i = 0; i < n; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;*/
    cout << ans << endl;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
	int ans=0;
	string s;
	cin>>s;
	for (int i=0;i<4;i++){
		if (s[i]==s[i+1]){
			ans=1;
			break;
		}
	}
	if (ans==1){
		cout<<"Bad"<<endl;	
	}
	else{
		cout<<"Good"<<endl;
	}
	return 0;
}

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

import itertools

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

class BinaryIndexedTree():
    def __init__(self, seq):
        self.size = len(seq)
        self.depth = self.size.bit_length()
        self.build(seq)
        
    def build(self,seq):
        data = seq
        size = self.size
        for i,x in enumerate(data):
            j = i+(i&(-i))
            if j < size:
                data[j] += data[i]
        self.data = data
        
    def __repr__(self):
        return self.data.__repr__()
        
    def get_sum(self,i):
        data = self.data
        s = 0
        while i:
            s += data[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        data = self.data
        size = self.size
        while i < size:
            data[i] += x
            i += i & -i
    
    def find_kth_element(self,k):
        data = self.data; size = self.size
        x,sx = 0,0
        dx = 1 << (self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= size:
                continue
            y = x + dx
            sy = sx + data[y]
            if sy < k:
                x,sx = y,sy
        return x + 1

def Inversion(seq):
    # seqは、1,2,...,Nの順列
    N = len(seq)
    bit = BinaryIndexedTree([0] * (N+1))
    inv = N*(N-1)//2
    for x in seq:
        inv -= bit.get_sum(x)
        bit.add(x,1)
    return inv

INF = 10 ** 9
answer = INF
for I in itertools.combinations(range(N),(N+1)//2):
    J = [j for j in range(N) if j not in I]
    ODD = [(B[i] if i&1 else A[i],i) for i in I]
    EV = [(A[i] if i&1 else B[i],i) for i in J]
    ODD.sort()
    EV.sort()
    ind = [0] * N
    seq = [0] * N
    for i in range(0,N,2):
        seq[i], ind[i] = ODD[i//2]
    for i in range(1,N,2):
        seq[i], ind[i] = EV[i//2]
    if not all(x<= y for x,y in zip(seq,seq[1:])):
        continue
    ind = [x+1 for x in ind]
    n = Inversion(ind)
    if answer > n:
        answer = n

if answer == INF:
    answer = -1
print(answer)


Measured memory_bytes: 58716
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

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

  int f = N%10;
  if(f == 2 || f == 4 || f == 5 || f == 5 || f == 7 || f == 9)
    cout << "hon" << endl;
  else if(f == 0 || f == 1 || f == 6 || f == 8)
    cout << "pon" << endl;
  else
    cout << "bon" << endl;

  return 0;
}


Measured memory_bytes: 3636
## C - Christmas Eve
N, K = map(int, input().split())
H = sorted([int(input()) for i in range(N)])
rt = 10**9
for i in range(0,N-K+1):
    rt = H[K - 1 + i] - H[i] if rt > H[K - 1 + i] - H[i] else rt
print(rt)

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m, a[125];
  cin>>n>>m;
  int sum=0;
  REP(i, n){
    cin>>a[i];
    sum+=a[i];
  }
  int cnt=0;
  REP(i, n){
    if(a[i]*m*4>=sum){
      ++cnt;
    }
  }
  cout<<(cnt>=m ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
    cout << a << endl;
    exit(0);
}

void Main()
{
    ll n; cin >> n;
    str ans;
    while(n)
    {
        n--;
        ans.pb((char)(n % 26 + 'a'));
        n /= 26;
    }
    reverse(all(ans));
    fin(ans);    
}

//前処理
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10); //高精度少数表示
    Main();
    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>
 
int solve(int, int);
 
int n, A[2000];
 
int main(){
   
  int q, M[2000], i;
   
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &A[i]);
   
  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &M[i]);
 
 
  for(i = 0; i < q; i++){
    if(solve(0, M[i]) == 1)   printf("yes\n");
    else                      printf("no\n");
  }
 
  return 0;
}
 
int solve(int i, int m){
  int res;
 
  if(m == 0)    return 1;
  if(i >= n)    return 0;
   
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  //printf("i + 1 = %d, m = %d res = %d\n", i + 1, m, res);
 
  return res;
}

Measured memory_bytes: 588
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;

const int N = 2e5 + 5;

pii p[N], r[N];

int ans[N];

vector<pii> query;

multiset<int> s;

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, q;
    cin >> n >> q;
    fr(i ,1, n) {
        cin >> p[i].fi >> r[i].fi >> p[i].se;
        r[i].fi--;
        r[i].se = p[i].se;
        p[i].fi -= p[i].se;
        r[i].fi -= r[i].se;
        // cout << p[i].fi << " " << r[i].fi << " " << p[i].se << endl;
    }
    sort(p + 1, p + n + 1);
    sort(r + 1, r + n + 1);
    fr(i, 1, q) {
        int x;
        cin >> x;
        query.pb({x, i});
    }
    sort(all(query));
    int pt1 = 0, pt2 = 0;
    for(pii x : query) {
        int t = x.fi;
        while(pt1 < n && p[pt1 + 1].fi <= t) {
            pt1++;
            s.insert(p[pt1].se);
            // cout << "A " << p[pt1].se << endl;
        }
        while(pt2 < n && r[pt2 + 1].fi < t) {
            pt2++;
            s.erase(s.find(r[pt2].se));
            // cout << "D " << r[pt2].se << endl;
        }
        // cout << "Q" << endl;
        if(s.empty()) ans[x.se] = -1;
        else ans[x.se] = *s.begin();
    }
    fr(i, 1, q) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
	int X,A,B;
	cin >> X;
	cin >> A;
	cin >> B;
	if (abs(A-X) < abs(B-X)) cout << "A" << endl;
	else cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
import math

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))

    left=A[0]

    left_index=0
    right_index=K-1

    for i in range(1,N-K+1):
        left_index+=1
        right_index+=1
        right=A[right_index]
        if left<right:
            print("Yes")
        else:
            print("No")
        left=A[left_index]


if __name__=="__main__":
    main()

Measured memory_bytes: 104536
#include <iostream>
#include <climits>

typedef std::pair<int,int> TV; // Time and Value

void update(TV* A, int s, int t, int index, int l, int r, int time, int val)
{
	if (t<l || r<=s) return; // no intersection
	else if (s<=l && r<=t+1) { // [l,r) is contained in [s,t] 
		A[index].first = time;
		A[index].second = val;
		return;
	}
	else { // at least one end exceeds the range
		int mid = (l+r)/2;
		update(A, s, t, 2*index+1, l, mid, time, val);
		update(A, s, t, 2*index+2, mid, r, time, val);
	}
}

TV find(TV* A, int k, int index, int l, int r)
{
	if (l+1==r) return A[index];
	
	int mid = (l+r)/2;
	TV res;
	if (k<mid) res = find(A, k, 2*index+1, l, mid);
	else res = find(A, k, 2*index+2, mid, r);
	
	return (res.first > A[index].first) ? res : A[index];
}

int main ()
{
	int n, q;
	std::cin >> n >> q;
	
	int a_size = 1;
	for(; a_size<n; a_size<<=1);
	TV* A = new TV[2*a_size-1];
	for (int i=0; i<2*a_size-1; i++) {
		A[i].first = -1;
		A[i].second = INT_MAX;
	}
	
	
	for (int i=0; i<q; i++) {
		int op, s, t, x, k;
		std::cin >> op;
		if (op==0) {
			std::cin >> s >> t >> x;
			update(A, s, t, 0, 0, n, i, x);
		} else {
			std::cin >> k;
			std::cout << find(A, k, 0, 0, n).second << std::endl;
		}
	}
	
	delete[] A;
	
	return 0;
}



Measured memory_bytes: 4956
#include <iostream>
using namespace std;
int main()
{
    int n, k, g, a;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> g;
    }   

    a = ((n - 1) / (k - 1)) + 1;
    if ((n - 1) % (k - 1) == 0)
        a -= 1;
    cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(N);
  i64 sum = 0;
  rep(i,0,N) {
    cin >> A[i];
    sum += A[i];
  }
  sum = (sum + 4 * M - 1) / (4 * M);
  rep(i,0,N) {
    if(sum <= A[i]) {
      M--;
    }
  }
  if(M <= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

#define REP(i,n) for (int (i) = 0;(i) < (n);++(i))
#define FORN(i,a,b) for (int i = (a);i <=(b); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define SORT(list) sort(ALL((list)));
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;

const ll mod=1000000007;
// int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head


int main()   {  
	IOS
	int n;
	scanf("%d",&n);
	int x = ceil(n / 1.08);
	if(floor(x * 1.08) == n) {
		printf("%d\n",x);
	}else {
		printf(":(\n");
	}
}  
  

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 44
int fibonacci(int n){
  int F[MAX],i;
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++)
    F[i]=F[i-2]+F[i-1];
  return F[n];
}

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



Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	int n,k,x,y,sum=0;
	cin>>n>>k>>x>>y;
	if(n-k>=0)sum = k*x + (n-k)*y;
	else sum = n*x;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int a,b;
    cin>>a>>b;
    
    int count=0;
    
    for(int i=a;i<=b;i++){
        if(i/10000==i%10 && (i%10000)/1000==(i%100)/10){
            count++;
        }
        
    }
    
    cout<<count<<endl;
    
    
    return 0;
}








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

struct Node{
  int key;
  struct Node *right, *left ,*parent;
};

struct Node *root, *NIL;

struct Node * find(struct Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z= (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL)root = z;
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else y->right = z;
  }
}

void inorder(struct Node *u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if (u == NIL)return;
  printf(" %d" ,u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n ,i ,x;
  char com[20];

  scanf("%d",&n);
  
  for (i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if (com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}















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


void solve(){

    int k,x;
    cin >> k >> x;
    if(k*500>=x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
  
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	
		int tot = scan.nextInt();
		String s = scan.next();
		int current = 0 , ans = 0;
		for (int i = 0;i < s.length();i ++)
		{
			char ch = s.charAt(i);
			if (ch == 'I')
				current ++;
			else
				current --;
			if (current > ans)
				ans = current;
		}
		System.out.println(ans);
	}
    
}










Measured memory_bytes: 9044
#include <iostream>
using namespace std;
int N, Q;
int root[200005];

int find(int idx){
    if (idx == root[idx])
        return idx;

    int pidx = root[idx];
    root[idx] = find(pidx);
    return root[idx];
}

void join(int u, int v){
    int ru = find(u);
    int rv = find(v);
    root[rv] = ru;
}

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

    for(int i = 0; i <= N; ++i)
        root[i] = i;

    for(int i = 0; i < Q; ++i){
        int t, u ,v;
        scanf("%d%d%d",&t,&u,&v);
        if(t == 0){
            join(u,v);
        }else{
            int ru = find(u);
            int rv = find(v);
            printf("%d\n",(ru==rv)?1:0);
        }
            
    }
}

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


int main()
{
    
    string s;
    ll n;
    cin>>n;
    ll i,j;
    ll no[4];
    memset(no,0,sizeof(no));
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")no[0]++;
        else if(s=="WA")no[1]++;
        else if(s=="TLE")no[2]++;
        else if(s=="RE")no[3]++;
    }
    cout<<"AC x "<<no[0]<<"\n";
    cout<<"WA x "<<no[1]<<"\n";
    cout<<"TLE x "<<no[2]<<"\n";
    cout<<"RE x "<<no[3]<<"\n";
    return 0;
}

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

typedef vector<int> vi;
#define ll long long
#define PI 3.14159265359
//#define x first
//#define y second
#define point pair<int,int>
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
int mod = 1e9 + 7;
int dp[109][100009];
int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int n,k;
    cin>>n>>k;

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



    for(int i = 0; i <= n; i++)
        dp[i][0]= 1;

    for(int i = n - 1; i >= 0; i--){
        int sums[k + 1];
        sums[0] = dp[i + 1][0];
        for(int j = 1; j <= k; j++)
            sums[j] = (sums[j - 1] + dp[i + 1][j])%mod;

        for(int j = 0; j <= k; j++){
            int sum  = sums[j];
            if(j - a[i] - 1 >= 0) sum = (sum - sums[j - a[i] - 1] + mod)%mod;

            dp[i][j] = sum;
            //dp[i][j] = dp[i + 1][j - x : 0 <= x <= a[i]]
        }
    }

    cout<<dp[0][k];
}


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

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

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n / x) * t + (n % x > 0) * t;
}



Measured memory_bytes: 3628
#include <stdio.h>
int main(void)
{
	int i, n;
	char t[4];
	int c[4];
	for (i=0; i<4; ++i) c[i]=0;
	while (scanf("%d,%s", &n, t) != EOF) {
		switch (t[0]) {
			case 'A': if (t[1]=='B') c[2]++; else c[0]++; break;
			case 'B': c[1]++; break;
			case 'O': c[3]++; break;
		}
	}
	if (c[0] == 11) return 1;
	for (i=0; i<4; ++i) printf("%d\n", c[i]);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int a,b,c;
map<int,int> m;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>a>>b>>c;
  m[a]++;
  m[b]++;
  m[c]++;
  if(m[a]==1)cout<<a<<endl;
  else if(m[b]==1)cout<<b<<endl;
  else cout<<c<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    A,B,C,K = mis()
    ans = min(A,K)
    K -= min(A,K)
    if K>0:
        K -= min(B,K)
        if K>0:
            ans -= K
    print(ans)


main()



Measured memory_bytes: 9992
#include <cstdio>

int main()
{
    int time;
    scanf("%d", &time);
    int h, m, s;
    h = time / 3600;
    time %= 3600;
    m = time / 60;
    s = time % 60;
    printf("%d:%d:%d\n", h, m, s);

    return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

int main(int argc, char const* argv[])
{
	uint64_t N{};
	std::vector<uint64_t> v{};
	uint64_t sum{};
	std::cin >> N;
	std::copy(std::istream_iterator<uint64_t> (std::cin),
			  std::istream_iterator<uint64_t>(),
			  std::back_inserter(v));
	v.resize(N+1,0);
	for (uint64_t i = 0; i < N; i++) {
		auto& current = v.at(i);
		auto& next   = v.at(i+1);
		if (current % 2 != 0 && next >= 1) {
			next--;
			current++;
		}
		sum += current / 2;
	}
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
double abso(double a,double b){
  if(a-b<0)
    return b-a;
  else
    return a-b;
}
int main(){
  int n,i;
  scanf("%d",&n);
  double a[n],sum=0,x,y=0,min;
  scanf("%lf",&x);
  for(i=1;i<n;i++){
    scanf("%lf",&a[i]);
    sum+=a[i];
  }
  min=abso(x,sum);
  for(i=1;i<n-1;i++){
    x+=a[i];
    sum-=a[i];
    if(abso(x,sum)<min)
      min=abso(x,sum);
  }
  printf("%.0lf\n",min);
}

Measured memory_bytes: 1664
from sys import stdin, setrecursionlimit


def main():
    s, t = map(str, stdin.readline().split())
    a, b = map(int, stdin.readline().split())
    u = stdin.readline()[:-1]

    if s == u:
        a -= 1
    else:
        b -= 1

    print(a, b)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Measured memory_bytes: 38256
# if true

# include <iostream>


int main()
{

	int c1{}, c2{}, c3{}, c4{};


	for (int i{}; i < 4; ++i)
	{
		int n;
		std::cin >> n;

		if (n == 1) ++c1;
		if (n == 7) ++c2;
		if (n == 9) ++c3;
		if (n == 4) ++c4;
	}


	if (c1 == 1 && c2 == 1 && c3 == 1 && c4 == 1)
		std::cout << "YES";
	else
		std::cout << "NO";


	return 0;
}



# endif

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

ll n, D;
ll a[500010];

bool ans[500010];
ll min_no[500010];

int main()
{
	read(n, D);
	for(int i=1; i<=n; ++i) read(a[i]);
	
	min_no[n+1] = 1;
	for(int i=n; 1<=i; --i){
		int haya = a[i] / 2;
		if(min_no[i+1] <= haya){
			min_no[i] = min_no[i+1];
		} else {
			min_no[i] = min_no[i+1] + a[i];
		}
	}
	
	for(int i=1; i<=n; ++i){
		ans[i] = (D >= min_no[i+1]);
		D = min(D, abs(D - a[i]));
	}
	
	int q;
	read(q);
	for(;q--;){
		int a; read(a);
		puts(ans[a]?"YES":"NO");
	}
	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll C[25];
ll A[25];

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    REP(i, N)
    {
        ll a;
        cin >> a;
        A[a - 1] = i;
    }
    REP(i, N)
    {
        ll b;
        cin >> b;
        ans += b;
    }
    REP(i, N - 1)
    {
        cin >> C[i];
    }
    FOR(i, N, 1)
    {
        if (A[i] == A[i - 1] + 1)
            ans += C[i - 1];
    }
    cout << ans << endl;
    return 0;
}

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

void solve()
{
    int n, W; cin >> n >> W;
    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1));
    for (int i = 1; i <= n; ++i) {
        int w, v; cin >> w >> v;
        for (int j = 0; j <= W; ++j) {
            if (w <= j) {
                dp[i][j] = max(dp[i - 1][j], v + dp[i - 1][j - w]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        } 
    }
    cout << dp[n][W] << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    char a, b;
    cin >> a >> b;

    // 処理
    // 出力
    // HH	H
    // HD	D
    // DH	D
    // DD	H
    cout << (a == b ? "H" : "D") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
map<char,int>a;
char ans;
int main()
{
    string s,st;
    cin>>s;
    for(int i=0; i<s.length(); i++)
     a[s[i]]=1;
    if(s.length()<26)
    {
     for(int i=0; i<26; i++)
     if(a['a'+i]==0)
     { 
         ans='a'+i;
          break;
      }
      cout<<s<<ans;
      return 0;
    }
    else if(s.length()==26)
    {
    	st=s;
        if(!next_permutation(s.begin(),s.end())) {cout<<-1; return 0;} 
        else {
        for(int i=0; i<s.length(); i++)
        {
        cout<<s[i];
        if(s[i]!=st[i]) return 0;
         }
		return 0;}
    }
    else cout<<-1;
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 2000001
//????????????£????????????
struct Node{
  int key;
  struct Node *next,*prev;
};
 
struct Node *nil;
 
struct Node* listSearch(int key){
  struct Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}
 
void init(){
  nil=(struct Node *)malloc(sizeof(struct Node));
  nil->next=nil;
  nil->prev=nil;
}
 
void output(){
  struct Node *cur=nil->next;
  int i=0;
  while(1){
    if(cur==nil) break;
    if(i++>0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
    }
  printf("\n");
}
 
void delNode(struct Node *t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
 
void delF(){
  delNode(nil->next);
}
 
void delL(){
  delNode(nil->prev);
}
 
void delKey(int key){
  delNode(listSearch(key));
}
 
void insert(int key){
  struct Node *a=(struct Node *)malloc(sizeof(struct Node));
  a->key=key;
  a->next=nil->next;
  nil->next->prev=a;
  nil->next=a;
  a->prev=nil;
}
 
int main(){
  int n,key,i,j,npoi=0,ndel=0,size=0;
  char c[12];
 
  scanf("%d",&n);
 
  init();
  for(i=0;i<n;i++){
    scanf("%s %d",c,&key);
 
    if(c[0]=='i'){
      insert(key);
      npoi++;
      size++;
    }
    else if(c[0]=='d'){
if(strlen(c)>6){
      if(c[6]=='F') delF();
      else if(c[6]=='L') delL();
    } else {
        delKey(key);
        ndel++;
      }
        size--;
      }
    }
    output();
  return 0;
}

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

int main()
{
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.size();i++){
		sum+=int(s[i]-'0');
	}
	if(sum%9==0)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3752
#include<stdio.h>
#define MAX 100000

int A[MAX];

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

int main(){
  int i,n,q;

  scanf("%d",&n);

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

  q = partition(0,n-1);

  for(i=0; i<q; i++) printf("%d ",A[i]);
  printf("[%d] ",A[i]);
  for(i=q+1; i<n-1; i++) printf("%d ",A[i]);
  printf("%d\n",A[i]);

  return 0;
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
stack <char> stk;
int mp[3005][3005];
int main()
{
  char a[3005],b[3005];
  a[0]='0',b[0]='0';
  scanf("%s%s",a+1,b+1);
  int m= strlen(a)-1;
	int n= strlen(b)-1;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i]==b[j])
			{
				mp[i][j]=mp[i-1][j-1]+1;
			}
      else
      {
        mp[i][j]=max(mp[i-1][j],mp[i][j-1]);
      }
		}
	}
  // printf("0 ");
  // for (int i=1;i<=n;i++) printf("%2c ",b[i]);
  // printf("\n\n");
  // for (int i=1;i<=m;i++)
  // {
  //   printf("%c ",a[i]);
  //   for(int j=1;j<=n;j++)
  //   {
  //     printf("%2d ",mp[i][j],i,j);
  //   }
  //   printf("\n\n");
  // }
  int i=m,j=n;
  while(i!=0 && j!=0)
  {
    if(a[i]==b[j])
    {
      stk.push(a[i]);
      // printf("Push >> %c (%d,%d)\n",a[i],i,j);
      i--;j--;
      continue;
    }
    if(mp[i][j-1] > mp[i-1][j])
    {
      j--;
    }
    else
    {
      i--;
    }
  }
  while(!stk.empty())
  {
    printf("%c",stk.top());
    stk.pop();
  }
}


Measured memory_bytes: 35456
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
string s[1919];
int n;
signed main() {
	cin >> n;
	rep(i, n)cin >> s[i];
	int ans = 0;
	rep(i, n) {
		if (s[i] == "E869120")ans++;
	}
	cout << ans << endl;
	ggr
}



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

const int LIM = 1e5 + 1;
int N, u, v, a, b, dist[2][LIM], ans;
vector<int> tree[LIM];

void dfs(int i, int node, int parent = -1, int d = 0) {
    dist[i][node] = d;
    for (int child: tree[node]) {
        if (child == parent) continue;
        dfs(i, child, node, d + 1);
    }
}

int main() {
    cin >> N >> u >> v;
    u--; v--;
    rep(i, N-1) {
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    
    dfs(0, u);
    dfs(1, v);
    rep(i, N) {
        if (dist[0][i] < dist[1][i]) ans = max(ans, dist[1][i] - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<PII, int> PPI;
const int INF = 3e18;

int n, gu = 0, ki = 0;
signed main()
{
  cin >> n;
  for(int i = 0; i < n; i++){
    int in;
    cin >> in;
    if(in % 2)
      ki++;
    else
      gu++;
  }

  gu += ki / 2;
  ki %= 2;

  if(gu == 0){
    if(ki == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  else{
    if(ki == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256