akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c; cin >> a >> b >> c;
    Yn(a<=c && c<=b);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s,t;
int sl,tl;
int main(){
	//注意对于sl的长度特殊判断！ 
	cin>>s>>t;
	sl = s.length();
	tl = t.length();
	int ans = 1946081700;
	for(int i=0;i+tl<=sl;i++){
		int tm = 0;
		for(int j = 0;j<tl;j++){
			if(s[i+j]!=t[j]) tm++;
		}
		ans = min(tm,ans);
	}
	cout<<ans;
} 

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

int main() {
  long long N,K;
  cin >> N >> K;
  long long ans;
  
  if (K % 2 == 1){
    ans = (N/K)*(N/K)*(N/K);
  }
  else {
    ans = (N/K)*(N/K)*(N/K);
    long long count = 0;
    for (int i = 1; i <= N; i++) {
      if (i % K == K / 2){
        count++;
      }
    }
    ans += count*count*count;
  }
  cout << ans << endl;
}
    
  

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

const int p=1000000007;
int n,m,f[3010][3010][2],g[3010][6010][2],ans;

int main()
{
    scanf("%d%d",&n,&m);
    repu(i,0,n)
        g[0][i][!i]=1;
    repu(i,1,m)
    {
        repu(j,0,n)
            repu(k,0,1)
            {
                if (j)
                    (f[i][j][k || j==1]+=g[i-1][j][k])%=p;
                if (j<n)
                    (f[i][j+1][k]+=g[i-1][j][k])%=p;
            }
        repu(j,1,n)
            repu(k,0,1)
            {
                if (j)
                    (g[i][j-1][k || j==1]+=f[i][j][k])%=p;
                (g[i][j][k]+=f[i][j][k])%=p;
            }
    }
    repu(i,0,n)
        (ans+=g[m][i][1])%=p;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 211200
n, m = map(int, input().split())
ab_array = [[int(x) for x in input().split()] for y in range(m)]
graph = [[] for x in range(n + 1)]


def dfs(graph, now, a, b):
    visited[now] = True
    for next in graph[now]:
        if (now == a and next == b) or (now == b and next == a):
            continue
        if not visited[next]:
            dfs(graph, next, a, b)
    return visited.count(False) == 1


for a, b in ab_array:
    graph[a].append(b)
    graph[b].append(a)
ans = 0
for a, b in ab_array:
    start = a
    end = b
    visited = [False for x in range(n + 1)]
    if dfs(graph, 1, a, b):
        ans += 1
print(m - ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    int n;
    while(cin>>n, n){
        vector<pair<int,int> > p(n);
        for(int i=0; i<n; i++){
            int x, y;
            scanf("%d %d", &x,&y);
            p[i] = make_pair(x,y);
        }

        int m; cin>>m;
        vector<pair<int,int> > q(m);
        for(int i=0; i<m; i++){
            int x, y;
            scanf("%d %d", &x,&y);
            q[i] = make_pair(x,y);
        }

        sort(q.begin(), q.end());

        int ansx=-1, ansy=-1;
        for(int i=0; i<m; i++){
            int dx = - q[i].first + p[0].first;
            int dy = - q[i].second + p[0].second;
            bool ok = true;
            for(int j=0; j<n; j++){
                pair<int,int> after = make_pair(p[j].first - dx, p[j].second - dy);
                if(binary_search(q.begin(), q.end(), after)) continue;
                else ok = false;
            }
            if(ok) {
                ansx = dx;
                ansy = dy;
                break;
            }
        }

        cout << -ansx << " " << -ansy << endl;
    }
}

Measured memory_bytes: 1252
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
a = LIST()

# for i in range(n-1):
#     for j in range(i+1, n):
#         if a[i] == a[j]:
#             print("NO")
#             exit()
# print("YES")
if len(set(a)) != len(a):
    print("NO")
else:
    print("YES")



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

int main()
{
  set<int> a = {1, 3, 5, 7, 8, 10, 12};
  set<int> b = {2};
  set<int> c = {4, 6, 9, 11};
  
  int x, y;
  cin >> x >> y;
  
  if(a.count(x) and a.count(y))
  {
    cout << "Yes" << endl;
    return 0;
  }
  if(b.count(x) and b.count(y))
  {
    cout << "Yes" << endl;
    return 0;
  }
  if(c.count(x) and c.count(y))
  {
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for(int i=0;i<N;i++) {
    cin >> vec.at(i) ;
  }
  
  int j=0;
  int i=0;
  for(;i<N;i++) {
    j=vec.at(j)-1;
    if(j==1) {
      break;
    }
  }
  
  if(j==1) {
    cout << i+1 << endl;
  }
  else {
    cout << -1 << endl;
  }
}

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


vector<int> pieces;
int main(){
	int h, w, n;
	cin >> h >> w >> n;
	int ans = h;
	pieces.resize(h+1, w);
	pieces[h] = 0;

	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		x--; y--;
		pieces[x] = min(pieces[x], y);
	}

	int cur = 0;
	for(int i = 1; i <= h; i++){
		if(pieces[i] <= cur){
			cout << i << '\n';
			return 0;
		} else if(pieces[i] == cur + 1){
			cur = cur;
		} else {
			cur = cur + 1;
		}
	}
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    int N;
    vector<int> h;
    cin >> N;
    h = fetch_vec<int>(N);
    vector<int> dp(N,0);
    dp[1] = dp[0]+abs(h[1]-h[0]);
    for (int i = 2; i < N; i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;
    

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int a = 0,b = 0,x;
    char s;
    while(1){
    scanf("%d %c %d",&a,&s,&b);
    
    if(s == 43){
        x = a + b;
    }else if(s == 45){
        x = a - b;
    }else if(s == 47){
        x = a / b;
    }else if(s == 42){
        x = a * b;
    }else{
        break;
    }
    printf("%d\n",x);
    }
return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int N, any = 0, AA = 0,
         re[9] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
  bool ans[9] = {};
  cin >> N;
  int a[N];
  rep(i, N) {
    cin >> a[i];
    rep(j, 9) {
      if (a[i] < re[j]) {
        ans[j] = 1;
        break;
      }
      if (j == 8)
        any++;
    }
  }
  rep(i, 8) if (ans[i]) AA++;
  if (AA == 0)
    cout << 1 << ' ' << any << endl;
  else
    cout << AA << ' ' << AA + any << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=60;
int n,m,x,y,eg,u[MAXN],v[MAXN],hd[MAXN],ver[2*MAXN],nx[2*MAXN],f[MAXN];
bitset <51> q[21],t[1<<20];
ll ans;
ll qpow (ll a,ll b) {
	ll res=1;
	while (b) {
		if (b&1) {res*=a;}
		a*=a,b>>=1;
	}
	return res;
}
void add_edge (int x,int y) {
	ver[++eg]=y;
	nx[eg]=hd[x];
	hd[x]=eg;
	return;
}
void dfs (int x,int fa) {
	f[x]=fa;
	for (int i=hd[x];i;i=nx[i]) {
		if (ver[i]==fa) {continue;}
		dfs(ver[i],x);
	}
	return;
}
void mk (int x,int y,int p) {
	for (int i=x;i!=1;i=f[i]) {q[p].set(i,1);}
	int cur=y;
	for (;cur!=1&&!q[p][cur];cur=f[cur]) {q[p].set(cur,1);}
	for (;cur!=1;cur=f[cur]) {q[p].set(cur,0);}
	return;
}
int main () {
	eg=1;
	scanf("%d",&n);
	for (int i=1;i<=n-1;i++) {
		scanf("%d%d",&x,&y);
		add_edge(x,y),add_edge(y,x);
	}
	dfs(1,0);
	scanf("%d",&m);
	for (int i=1;i<=m;i++) {
		scanf("%d%d",&u[i],&v[i]);
		mk(u[i],v[i],i);
	}
	for (int i=0;i<(1<<m);i++) {
		int cnt=0,cur=0;
		for (int j=0;j<m;j++) {
			if (i&(1<<j)) {cnt++,cur=j+1;}
		}
		if (cnt) {t[i]=t[i^(1<<(cur-1))]|q[cur];}
		if (cnt&1) {
			ans-=qpow(2,n-1-t[i].count());
		} else {
			ans+=qpow(2,n-1-t[i].count());
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8448
N, K = map(int, input().split())
X = list(map(int, input().split()))

min_cost = 10 ** 20

if N == K:
    print(X[N-1] - X[0] + min(abs(X[N-1]), abs(X[0])))
else:
    for i in range(N-K+1):
        min_cost = min(min_cost, X[i + K - 1] - X[i] + min(abs(X[i + K - 1]), abs(X[i])))
    print(min_cost)

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  cout << min(n *  a, b) << endl;
}

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

int main() {
	int a, b, c, k; cin >> a >> b >> c >> k;
	vector<int> s = { a,b,c };
	sort(s.begin(), s.end());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		s[2] *= 2;
	}
	ans = s[0] + s[1] + s[2];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
#include<utility>
#include<climits>
#include<algorithm>
using namespace std;

#define BLACK '#'
#define WHITE '.'

int main(void)
{
	int H, W;
	cin >> H >> W;

	vector<string> s(H+2, string(W+2, BLACK));
	for(int i=1; i<=H; i++)
		for(int j=1; j<=W; j++)
			cin >> s[i][j];

	const int dx[4] = {0, 1, 0, -1};
	const int dy[4] = {1, 0, -1, 0};
	vector<vector<int>> stage(H+2, vector<int>(W+2, INT_MAX));
	queue<pair<int, int>> task;
	
	task.emplace(1, 1);
	stage[1][1] = 1;
	while(task.empty() != true){
		auto p = task.front();
		task.pop();

		int x = p.first;
		int y = p.second;

		for(int i=0; i<4; i++){
			int xx = x + dx[i];
			int yy = y + dy[i];

			if(s[yy][xx] == BLACK)
				continue;
			if(stage[yy][xx] != INT_MAX)
				continue;

			stage[yy][xx] = stage[y][x] + 1;
			task.emplace(xx, yy);
		}
	}

	if(stage[H][W] == INT_MAX){
		cout << -1 << endl;
		return 0;
	}

	int cnt = 0;
	for(int i=1; i<=H; i++)
		cnt += count(s[i].begin(), s[i].end(), WHITE);
	
	cout << cnt - stage[H][W] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int tower_h[100000];
  int tower_good[100000];
  int n,m,count=0;
  int i,a,b;
  
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&tower_h[i]);
    tower_good[i]=1;
  }
  
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    if(tower_h[a-1]<tower_h[b-1]){
      tower_good[a-1]=0;
    } else if(tower_h[b-1]<tower_h[a-1]){
      tower_good[b-1]=0;
    } else {
      tower_good[a-1]=tower_good[b-1]=0;
    }
  }
  
  for(i=0;i<n;i++){
    if(tower_good[i]==1){
      count++;
    }
  }
  printf("%d",count);
}


Measured memory_bytes: 2492
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

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

signed main(){
    ll n,m; cin >> n >> m;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    vector<ll> cnt(n_max), mod(m), mod_odd(m);
    rep(i,n){
        cnt[x[i]]++;
        mod[x[i] % m]++;
    }
    rep(i,n_max){
        if(cnt[i] & 1)mod_odd[i % m]++;
    }
    
    // print(mod);
    // print(mod_odd);

    ll ans = 0;
    rep(i,m){
        if(i > m-i)continue;
        
        if(i == m-i || i == 0){
            ans += (mod[i]) / 2;
            // debug(i);debug(ans);
            continue;
        }
        ll t = max(mod_odd[i], mod_odd[m-i]);
        chmin(t, mod[i]);chmin(t, mod[m-i]);
        ans += t;
        if(mod_odd[i] < t){
            mod[i] -= t;
        }
        else{
            mod[i] -= mod_odd[i];
        }
        if(mod_odd[m-i] < t){
            mod[m-i] -= t;
        }
        else{
            mod[m-i] -= mod_odd[m-i];
        }
        ans += (mod[i] / 2) + (mod[m-i] / 2);
        // debug(i);debug(t);debug(ans);
    }
    // print(mod);
    cout << ans << endl;
}

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

int main(void) {
  string S, T;
  cin >> S >> T;
  int index = -1;
  for (int i = 0; i < S.length() - T.length() + 1; i++) {
    bool flag = true;
    for (int j = 0; j < T.length(); j++) {
      if (S[i + j] != '?' && S[i + j] != T[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      index = i;
    }
  }

  if (index == -1) {
    cout << "UNRESTORABLE" << endl;
  } else {
    for (int i = 0; i < T.length(); i++) {
      S[index + i] = T[i];
    }
    for (int i = 0; i < S.length(); i++) {
      S[i] = S[i] == '?' ? 'a' : S[i];
    }
    cout << S << endl;
  }

  return 0;
}

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

int main(void)
{
	int r, g, b;
	cin >> r >> g >> b;

	int num = 10 * g + b;
	if (num % 4 == 0)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
ans = [0]*N

for i in range(1,N+1):
  for j in range(i+1,N+1):
    d = min(j-i,abs(i-X)+abs(j-Y)+1)
    #print(i,j,d)
    ans[d]+=1

print(*ans[1:], sep='\n')


Measured memory_bytes: 46044
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        String s=sc.next();
        String t=sc.next();
        long lcm=(long)n/(long)gcd(n,m)*(long)m;
        HashMap<Long,Character> mapS=new HashMap<>();
        HashMap<Long,Character> mapT=new HashMap<>();
        long tempn=lcm/n;
        int k=0;
        for (long i = 0; i < n; i++) {
            mapS.put(i*tempn+1l,s.charAt(k));
            ++k;
        }
        long tempm=lcm/m;
        k=0;
        for (long i = 0; i < m; i++) {
            mapT.put(i*tempm+1l,t.charAt(k));
            ++k;
        }
        for (long i:mapS.keySet()) {
            if(mapS.get(i)!=null&&mapT.get(i)!=null&&mapS.get(i)!=mapT.get(i)){
                out.println(-1);
                exit(0);
            }
        }
        out.println(lcm);
    }
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 54768
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cstdint>
#include <stack> 
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

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

const int MAX = 1000005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	int x, y;
	cin >> x >> y;

	int sum = x + y;
	if (sum % 3) {
		cout << 0;
		return 0;
	}
	int n = sum / 3;
	x -= n; y -= n;

	// 前処理
	COMinit();

	// 計算例
	cout << COM(n, x) << endl;

	return 0;
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <


// CODE STARTS HERE

void solve(){
	int n;
	cin >> n;

	vector<int> A(n);
	for(auto& i: A) cin >> i;
	A.erase(unique(A.begin(), A.end()), A.end());
	n = A.size();

	vector<int> extrema;
	if(A[0] < A[1]) extrema.PB(A.front());
	for(int i = 1; i < n - 1; ++i)
		if((A[i - 1] < A[i] and A[i] > A[i + 1]) or
		   (A[i - 1] > A[i] and A[i] < A[i + 1]))
			extrema.PB(A[i]);
	if(A[n - 2] < A[n - 1]) extrema.PB(A.back());

	ll money = 1000;

	for(int i = 0; i < (int)extrema.size() - 1; i += 2){
		ll stocks = money / extrema[i];
		money += stocks * (extrema[i + 1] - extrema[i]);
	}

	cout << money << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3644
def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    min_value = sum(A)/(4*M)
    A2 = [a for a in A if a >= min_value]
    if len(A2) >= M:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
N, K = map(int,input().split())
MOD = 10 ** 9 + 7

ans = 0

for i in range(K, N + 2):
    i_sum_min = i * (i - 1) // 2
    i_sum_max = N * i - i_sum_min
    ans += (i_sum_max - i_sum_min) + 1
    ans %= MOD

print(ans)


Measured memory_bytes: 9200
#include<stdio.h>

int main(void){
    char b[1];
    scanf("%c",&b[0]);
    if(b[0] =='A') printf("T\n");
    if(b[0] =='C') printf("G\n");
    if(b[0] =='G') printf("C\n");
    if(b[0] =='T') printf("A\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cctype>	// ??§??????????°??????????????????????????????¨??????
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

int main() {
	//char b;
	//vector<char> a;
	//a.resize(120);
	//// ??\????????????
	//int i = 0;
	//do{
	//	b = getchar();
	//	if (islower(b))			a[i] = toupper(b);
	//	else if (isupper(b))	a[i] = tolower(b);
	//	else					a[i] = b;
	//	i++;
	//} while (b != '\n');

	//// ??????
	//for (int i = 0; i < a.size(); i++)
	//{
	//	cout << a[i];
	//}
	//cout << endl;
	string s;
	getline(cin, s);
	char t;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (islower(s[i])) t =  toupper(s[i]);
		else if (isupper(s[i])) t = tolower(s[i]);
		else t = s[i];
		cout << t;
	}
	cout << endl;

	return 0;
}

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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int p=0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        vector<int> a={i,j,k};
        int b=0;
        for(int l=0;l<n;l++){
          if(ctoi(s.at(l))==a.at(b)){
            b++;
          }
          if(b==3){
            p++;
            break;
          }
        }
      }
    }
  }
  cout<<p<<endl;
}

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

signed main() {
  int N;
  cin >> N;
  
  if( N == 0 ){
    cout << 2 << endl;
    return 0;
  }else if( N == 1 ){
    cout << 1 << endl;
    return 0;
  }
  
  int L0 = 2;
  int L1 = 1;
  int ans;
  for( int i = 2; i <= N; i++ ){
    ans = L0 + L1;
    L0 = L1;
    L1 = ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Tree
{
    class Reconstruction_of_a_Tree
    {
        struct Node
        {
            public int id;
            public int parent;
            public int left, right;
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var preorder = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var inorder = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var nodes = new Node[n + 1];

            var root = Reconstruct(nodes, preorder, inorder);
            Postorder(nodes, root, root);
            Console.WriteLine();

        }

        static int Reconstruct(Node[] nodes, List<int> preoder, List<int> inorder)
        {
            var root = preoder[0];
            nodes[root].id = root;
            preoder.Remove(root);
            var index = inorder.IndexOf(root);

            if (index == 0)
                nodes[root].left = -1;
            else
            {
                var left = Reconstruct(nodes, preoder, inorder.GetRange(0, index));
                nodes[root].left = left;
                nodes[left].parent = root;
            }

            if (index == inorder.Count - 1)
                nodes[root].right = -1;
            else
            {
                var right = Reconstruct(nodes, preoder, inorder.GetRange(index + 1, inorder.Count - index - 1));
                nodes[root].right = right;
                nodes[right].parent = root;
            }
            return root;
        }

        static void Postorder(Node[] nodes, int id, int root)
        {
            if (id == -1) return;
            Postorder(nodes, nodes[id].left, root);
            Postorder(nodes, nodes[id].right, root);
            if (id == root) Console.Write(nodes[id].id);
            else Console.Write(nodes[id].id+" ");
        }
    }
}

Measured memory_bytes: 10096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int main(){
	ll n;
	string s;
	read(n);
	cin>>s;
	if(n%2==1)
	{
		cout<<"No"<<endl;
		return 0;
	}
	n/=2;
	if(s.substr(0,n)==s.substr(n,n)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m;
    cin >> n >> m;
    VLL a(n);
    map<int,int> ma;
    set<int> se;
    int p;
    string s;
    REP(i,0,m) {
        cin >> p >> s;
        if (se.count(p) > 0) continue;
        if (s == "AC") {
            se.insert(p);
        } else {
            ma[p]++;
        }
    }
    int ans = 0;
    for (const auto &p: se) ans += ma[p];
    cout << se.size() << " " << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 10368
N = int(input())
A = [0]*(N)
B = list(map(int, input().split()))
ans = int(0)

A[0]=B[0]
A[N-1]=B[N-2]

for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])

ans = sum(A)

print(ans)


Measured memory_bytes: 3060
#pragma once

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
long long int X,result,mytime;


int main() {
	
	cin >> X;
	
	for (long long int i = 1; i < 1000000000; i++)
	{
		if (mytime >= X) {
			break;
		}
		result++;
		mytime += i;
	}

	cout << result<< endl;

	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int c=0;
    char s[100001];
    int ans[100001];
    
    for(int i=0;i<=100001;i++){
        s[i]='Z';
    }
    
    scanf("%s",s);
    
    for(int i=0;i<=99999;i++){
        if(s[i]-'R'==0){
            if(s[i+1]-'R'==0){
                ans[i]=0;
                c=c+1;
            }
            if(s[i+1]-'L'==0){
                ans[i]=c+1;
                c=0;
            }
        }
    }
    
    for(int i=100000;i>=1;i--){
        if(s[i]-'L'==0){
            if(s[i-1]-'L'==0){
                ans[i]=0;
                c=c+1;
            }
            if(s[i-1]-'R'==0){
                ans[i]=c+1;
                c=0;
            }
        }
    }
    
    int d=0;
    
    for(int i=0;i<=99999;i++){
        if(ans[i]>0){
            d=d+1;
            if(d%2==1){
                if((ans[i]+ans[i+1])%2==1){
                    if(ans[i]%2==0){
                        int s=ans[i];
                        int t=ans[i+1];
                        ans[i+1]=(s+t+1)/2;
                        ans[i]=(s+t-1)/2;
                    }else{
                        int s=ans[i];
                        int t=ans[i+1];
                        ans[i+1]=(s+t-1)/2;
                        ans[i]=(s+t+1)/2;
                    }
                }else{
                    int s=ans[i];
                    int t=ans[i+1];
                    ans[i]=(s+t)/2;
                    ans[i+1]=(s+t)/2;
                }
            }
        }
    }
    
    int a=0;
    
    for(int i=0;i>=0;i++){
        if(s[i]!='Z'){
            a=a+1;
        }else{
            break;
        }
    }
    
    for(int i=0;i<=a-2;i++){
        printf("%d ",ans[i]);
    }
    
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,x,j;
    cin>>k>>x;
    for(j=(x-k+1) ;j<=(x+k-1) ;j++)
    {
        printf("%d ",j);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}
 
void solve(){
	int n;
	cin >> n;
	pii a[n];
	rep(i, n) {
		cin >> a[i].F;
		a[i].S = i + 1;
	}
	sort(a, a + n);
	if (a[0].F != 1) {
		cout << -1;
		return;
	}
	int cur = 1, temp = 0;
	for(int i = 0; i < n; i++) {
		if (cur == a[i].F && temp < a[i].S) {
			cur++;
			temp = a[i].S;
		}
	}
	cout << n - cur + 1;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

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

int main(){
  
  int n; 
  cin>>n;
  int a[n][3];
  int dp[n+1][3];
  
  for(int i = 0; i<n; i++){
    for(int j =0; j<3; j++){
      cin>>a[i][j];
      dp[i][j] = 0;
    }
}
  
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][1];
  dp[0][2] = a[0][2];
  
  for(int i =1; i<n; i++){
    for(int j = 0; j<3; j++){
      if(j == 0)
        dp[i][j] = a[i][j] + max(dp[i-1][1], dp[i-1][2]);
      if(j == 1)
        dp[i][j] = a[i][j] + max(dp[i-1][0], dp[i-1][2]);
      if(j == 2)
        dp[i][j] = a[i][j] + max(dp[i-1][0], dp[i-1][1]);
    }
  }
  int ans = max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]));
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 2560
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        q: usize,
        lr: [(usize, usize);m],
        pq: [(usize, usize);q],
    }
    let mut table = vec![vec![0; n + 1]; n + 1];
    for (l, r) in lr {
        table[l][r] += 1;
    }
    // for i in 0..n + 1 {
    //     eprintln!("{:?}", table[i]);
    // }
    // eprintln!();
    for i in 1..n + 1 {
        for j in 1..n + 1 {
            table[i][j] += table[i][j - 1];
        }
    }
    for i in 1..n + 1 {
        for j in 1..n + 1 {
            table[i][j] += table[i - 1][j];
        }
    }
    // for i in 0..n + 1 {
    //     eprintln!("{:?}", table[i]);
    // }
    // eprintln!();
    for (p, q) in pq {
        let result = table[q][q] + table[p - 1][p - 1] - table[p - 1][q] - table[q][p - 1];
        println!("{}", result);
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string A,B,C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B>>C;
	int ret=0;
	FOR(i,N) {
		if(A[i]==B[i]&&B[i]==C[i]) continue;
		if(A[i]==B[i]||B[i]==C[i]||A[i]==C[i]) ret++;
		else ret+=2;
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

typedef long long lli;

struct Tree {
    vector<int> par;
    vector<int> mark;
    Tree(int n) : par(n, -1), mark(n, 0) { }

    void unmark(int k) {
        mark[k]--;
    }

    int query(int k) {
        if(mark[k]) return k;
        return par[k] = query(par[k]);
    }
};

int main() {
    for(int N, Q; cin >> N >> Q, N + Q > 0; ) {
        Tree tree(N);
        tree.mark[0]++;
        for(int i = 0; i < N - 1; i++) {
            int p; cin >> p; p--;
            tree.par[i + 1] = p;
        }
        vector<int> type;
        vector<int> node;
        for(int i = 0; i < Q; i++) {
            char t; int n; cin >> t >> n; n--;
            type.push_back(t == 'Q');
            node.push_back(n);
            if(t == 'M') tree.mark[n]++;
        }
        reverse(type.begin(), type.end());
        reverse(node.begin(), node.end());
        lli res = 0;
        for(int i = 0; i < Q; i++) {
            if(type[i]) {
                res += tree.query(node[i]) + 1;
            }
            else {
                tree.unmark(node[i]);
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3172
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;


int B[100001];

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> B[i];
    }
    set<int> memo;
    int cur = 1;
    memo.insert(cur);
    int ans = 0;
    while (true) {
        cur = B[cur];
        ++ans;
        if (cur == 2) {
            cout << ans << endl;
            return 0;
        }
        if (memo.count(cur)) {
            cout << "-1" << endl;
            return 0;
        }
        memo.insert(cur);
    }
}


Measured memory_bytes: 5376
a, b, k = list(map(int, input().split()))

if b - a >= 2 * k:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)
else:
    for i in range(a, b+1):
        print(i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,j) for(I i{};i<j;i++)
using I=int;I d[100001][13];void f(I i, I j, I k){(d[i+1][k%13]+=d[i][j])%=1000000007;}main(){std::string s;std::cin>>s;d[0][0]=1;rep(i,s.size())rep(j,13){if(s[i]>57)rep(k,10)f(i,j,j*10+k);else f(i,j,j*10+s[i]-48);}std::cout<<d[s.size()][5];}

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

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

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/08  Problem: codefestival2017_qual A  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;

ll ans = 0LL;

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

	string s;
	
	cin >> s;
	string p;
	FOR(i, 0,int(s.size()) - 8) {
		p += s[i];
	}

	cout << p << endl;

	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  char a = 'a';
  for(int i=0; i<26; i++) {
    bool flg = false;
    for(int j=0; j<n; j++) {
      if(s.at(j) == a) {
        flg = true;
      }
    }
    if(flg) {
      a++;
    } else {
      cout << a << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int arr[105];
int main(void){
	int n,a,b; scanf("%d %d %d",&n,&a,&b);
	for(int i=0;i<n;i++) scanf("%d",&arr[i]);
	//sort(arr,arr+n);
	int x=0,y=0,z=0;
	for(int i=0;i<n;i++){
		if(arr[i]<=a) x++;
		else if(arr[i]>=b+1) z++;
		else y++;
	}
	printf("%d",min(min(x,y),z));
	return 0;
}

Measured memory_bytes: 256
n = int(input())
csf = [tuple(map(int, input().split())) for _ in range(n - 1)]

for i in range(n - 1):
    c, s, f = csf[i]
    a = s + c
    now = i
    for j in range(i + 1, n - 1):
        nc, ns, nf = csf[j]
        # next = ns + nf * x
        if a <= ns:
            a = ns
        else:
            x = (a - ns + nf - 1) // nf
            a = ns + nf * x
        a += nc

    print(a)
print(0)


Measured memory_bytes: 9152
from bisect import *
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
Ap = []
Am = []
for a in A:
    if a >= 0:
        Ap.append(a)
    elif a < 0:
        Am.append(a)
p = len(Ap)
m = len(Am)
Ap.sort()
Am.sort(reverse=True)
U = 10 ** 18
L = - 10 ** 18
while U - L > 1:
    mid = (U+L)//2
    cnt = 0
    if mid >= 0:
        cnt += p*m
        i = p
        t = 0
        for a in Ap:
            while i and Ap[i-1] * a > mid:
                i -= 1
            t += i
            if a*a <= mid:
                t -= 1
        cnt += t//2
        i = m
        t = 0
        for a in Am:
            while i and Am[i-1] * a > mid:
                i -= 1
            t += i
            if a*a <= mid:
                t -= 1
        cnt += t//2
    else:
        i = m
        for a in Ap:
            while i and Am[i-1] * a <= mid:
                i -= 1
            cnt += m - i   
    if cnt < K:
        L = mid
    else:
        U = mid
print(U)

Measured memory_bytes: 97492
n,m = map(int, input().split())
a = [int(input()) for i in range(m)]
N = [1]+[0]*(n)
mod = 10 ** 9 + 7
out = [0] * n
for i in a:
  out[i-1] = 1
for key in range(n-1):
  now = N[key]
  if out[key] == 0:
    N[key+1] += now 
    N[key+1] %= mod
  if out[key+1] == 0:
    N[key+2] += now 
    N[key+2] %= mod
ans = (N[-1] + N[-2]) % mod
print(ans)


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

R = S.count('R')
G = S.count('G')
B = N - R - G

ans = R * G * B

for i in range(0, N-2):
  for j in range(i+1,N-1):
    k = 2 * j - i
    if k >= N:
      break
    else:
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        ans -= 1

print(ans)

Measured memory_bytes: 9212
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class UnionFind:
    """
    sizeによる実装
    """

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size[px] < self.size[py]:
            self.parent[px] = py
            self.size[py] += self.size[px]
        else:
            self.parent[py] = px
            self.size[px] += self.size[py]

    def same(self, x, y):
        return self.find(x) == self.find(y)


N = int(input())
A = list(map(int, input().split()))

Un = UnionFind(N+1)
pos = [-1]*(N+1)
for i, a in enumerate(A):
    pos[a] = i

ans = 0
for i in reversed(range(1, N+1)):
    ind = pos[i]
    left = 0
    right = 0
    if ind > 0 and A[ind] < A[ind-1]:
        left = Un.size[Un.find(ind-1)]
        Un.union(ind, ind-1)
    if ind+1 < N and A[ind+1] > A[ind]:
        right = Un.size[Un.find(ind+1)]
        Un.union(ind, ind+1)
    ans += (left+1)*(right+1)*A[ind]

print(ans)


Measured memory_bytes: 29000