akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;

int main()
{
    int N;
    int M;
    int ans = 0;
    cin >> N >> M;
    vector<int> H(N);
    rep(i,N){
        cin >> H[i];
    }
    vector<int> A(M);
    vector<int> B(M);
    vector<int> have(N,0);
    vector<int> yoi(N,0);
    rep(i,M){
        cin >> A[i] >> B[i];
        have[A[i] - 1] += 1;
        have[B[i] - 1] += 1;
        if(H[A[i] - 1] > H[B[i] - 1]){
            yoi[A[i] - 1] += 1;
            yoi[B[i] - 1] += -20^5;
        }else if(H[A[i] - 1] < H[B[i] - 1]){
            yoi[A[i] - 1] += -20^5;
            yoi[B[i] - 1] += 1;
        }else if(H[A[i] - 1] == H[B[i] - 1]){
            yoi[A[i] - 1] += -20^5;
            yoi[B[i] - 1] += -20^5;
        }
    }
    rep(i,N){
        if(have[i] == 0){
            ans += 1;   //橋がない展望台の個数を追加
            //cout << "no bridge :"<< i << endl;
        }
        if(yoi[i] >= 1){
            ans += 1;
            //cout  << "highest :"<< i << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define FOR(i, x, n) for(int i=x; i<=n; ++i)
#define ROF(i, x, n) for(int i=x; i>=n; --i)
#define MOD 1000000007
#define F first
#define S second

int main() {

    string s;
    cin>>s;

    cout<<s;

    if(s[(int) s.size() - 1] == 's') {
        printf("es\n");
    }
    else {
        printf("s\n");
    }
}




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

using namespace std;

int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	pair<int, int> maxdensity(0, a*100);
	set<int> waterset;
	for (int i = 0; i <= f/(100*a); i++)
		for (int j = 0; j <= f/(100*b); j++)
		{
			waterset.insert((100*a*i + 100*b*j)*e);
		}
	for (int i = 0; i <= f*e/((100+e)*c); i++)
		for (int j = 0; j <= f*e/((100+e)*d); j++)
		{
			int sugar = c*i + d*j;
			auto it = waterset.lower_bound(100.0f*sugar);
			if (it != waterset.end())
			{
				auto sugarwater = *it/e + sugar;
				if (sugarwater > f) continue;
				if (maxdensity.first * sugarwater < maxdensity.second * sugar)
					maxdensity = pair<int, int>(sugar, sugarwater);
			}
		}
	cout << maxdensity.second << " " << maxdensity.first << endl;
	return 0;
}


Measured memory_bytes: 256
import math

alphabets = [chr(i) for i in range(97, 97+26)]

N = int(input())

def run(n):
    a = 0
    for i in range(1, 12):
        if math.pow(26, i) >= n:
            break
        n -= int(math.pow(26, i))

    ans = ''
    for j in range(i-1):
        b = n // int(math.pow(26, i-j-1))
        amari = n % int(math.pow(26, i-j-1))
        if amari == 0:
            b -= 1
        ans += alphabets[b]
        n = n % int(math.pow(26, i-j-1))
    ans += alphabets[n-1]
    return ans
    
print(run(N))

Measured memory_bytes: 9480
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int h, w, n, a;
int g[100][100];
int main() {
	cin >> h >> w >> n;
	int i = 0 , j = 0;
	int flag = 0;
	for (int _ = 0; _ < n; _++) {
		cin >> a;
		for (int k = 0; k < a; k++) {
			g[i][j] = _ + 1;
			if (flag == 0) {
				j++;
				if (j >= w) {
					i++;
					j = w - 1;
					flag = 1;
				}
			}
			else {
				j--;
				if (j <= -1) {
					i++;
					j = 0;
					flag = 0;
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << g[i][j];
			if (j != w - 1) {
				cout << ' ';
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long L = s[0];
            long R = s[1];

            long ans = long.MaxValue;
            if (Abs(L - R) >= 2019)
            {
                ans = 0;
            }
            else {
                for (long i = L; i <= R; i++)
                {
                    for (long j = i; j <= R; j++)
                    {
                        if (i < j)
                        {
                            long tmp = (i * j) % 2019;
                            if (ans > tmp)
                            {
                                ans = tmp;
                            }
                        }
                    }
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<math.h>
int main(){
	int i,j,k,l,a[10]={0};
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	
	for(k=9;k>6;k--){
		for(i=0;i<k;i++){
			if(a[i]>a[i+1]){
				j=a[i];
				a[i]=a[i+1];
				a[i+1]=j;
			}
		}
	}
	printf("%d\n%d\n%d\n",a[9],a[8],a[7]);
	return 0;
}

Measured memory_bytes: 1028
N = int(input())
A = [0]
input_A = list(map(int, input().split()))
A.extend(input_A)
A.append(0)

distances = []

for i in range(N+1):
    distance = abs(A[i+1] - A[i])
    distances.append(distance)

S = sum(distances)

for i in range(1, N+1):
    ans = S - (distances[i-1] + distances[i]) + abs(A[i+1]-A[i-1])
    print(ans)


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

int main(void) {
    long n, k, q;
    cin >> n >> k >> q;
    map<long,long> c;

    for(long i=0; i<q; i++) {
        long a;
        cin >> a;
        a--;
        c[a]++;
    }
    for(long i=0; i<n; i++)
        cout << (k-q+c[i] <= 0 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 6912
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

long long gcd(long long x, long long y){
	if (x > y)swap(x, y);
	if (x == 0)return y;
	else if (y%x == 0)return x;
	else return gcd(y%x, x);
}

int main(){
	char a[N + 1];
	char b[N + 1];
	f(i, N + 1){
		a[i] = 0;
		b[i] = 0;
	}
	long long n, m, k;
	long long x, y, nx, ny;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	scanf("%lld", &m);
	k = gcd(n, m);
	scanf("%s", a);
	scanf("%s", b);
	x = n / k;
	y = m / k;
	nx = 0;
	ny = 0;
	f(i, k){
		if (a[nx] != b[ny])v = false;
		nx += x;
		ny += y;
	}

	if (v)printf("%lld\n", x*m);
	else printf("-1\n");


	return 0;
}

Measured memory_bytes: 640
S = input()
ans = [0] * len(S)
mark = [0] * len(S)

tmp = 0
flag = False
for i in range(len(S)-1):
    if flag:
        flag = False
    elif S[i] == 'R':
        if S[i + 1] == 'L':
            mark[i] = 0
            mark[i+1] = 0
            tmp = 0
            flag = True
    else:
        # i == L
        tmp -= 1
        mark[i] = tmp
if S[-2] == 'L':
    mark[-1] = mark[-2] - 1

flag = False
tmp = 0
for i in reversed(range(1, len(S))):
    if flag:
        flag = False
    elif S[i] == 'L':
        if S[i-1] == 'R':
            mark[i] = 0
            mark[i-1] = 0
            tmp = 0
            flag = True
    else:
        tmp += 1
        mark[i] = tmp
if S[1] == 'R':
    mark[0] = mark[1] + 1


for i in range(len(S)):
    if mark[i] == 0:
        ans[i] += 1
    elif mark[i] > 0:
        if mark[i] % 2 == 0:
            ans[i+mark[i]] += 1
        else:
            ans[i+mark[i]+1] += 1
    else:
        #mark[i] < 0
        if abs(mark[i]) % 2 == 0:
            ans[i + mark[i]] += 1
        else:
            ans[i + mark[i] - 1] += 1
for i in ans:
    print(i, end = " ")

print("")

Measured memory_bytes: 53976
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  string str = in<string>();
  foreach(i,str){
    if(i=='?')i='D';
  }
  cout << str << endl;
  return 0;
}


Measured memory_bytes: 3752
//copy from https://www.cnblogs.com/AKMer/p/10043220.html
#include <deque>
#include <cstdio>
using namespace std;
typedef long long ll;

int m,num;
deque<int> s1,s2;
deque<int>::iterator it;

ll read() {
    ll x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return x*f;
}

int main() {
    ll n=read()+1;//以为空串也是好串，所以这里要加一
    for(ll i=1;i<=n;i<<=1)m++;
    for(int i=m-2;~i;i--) {//初始有一个空串是好串，m-2是n的第二高的二进制位
        s1.push_back(++num),s2.push_back(num);
        if((n>>i)&1)s1.push_front(++num),s2.push_back(num);
    }
    printf("%d\n",(int)(s1.size()+s2.size()));
    for(it=s1.begin();it!=s1.end();it++)
        printf("%d ",(*it));
    for(it=s2.begin();it!=s2.end();it++)
        printf("%d ",(*it));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const int MAXN = 1e5;

int main()
{
	int n;
	cin >> n;
	bool flag = true;
	map<string,int> m;
	char a = 'a';
	for(int i = 0; i < n; i++){
		string w;
		cin >> w;
		m[w]++;
		if(m[w] > 1) flag = false;
		if(i != 0 && a != w[0]) flag = false;
		a = w[w.size()-1];
	}

	cout << (flag?"Yes":"No") << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin>>tt; while(tt--)
#define mp make_pair
#define pb push_back
#define lchild (2*node+1)
#define rchild (2*node+2)
#define f first
#define s second
#define br cout<<endl
#define MOD (1000000007LL)

using namespace std;

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

ll gcd(ll a, ll b){
    if(b==0)return a;
    else gcd(b, a%b);
}

ull pwr(ull base, ull p, ull mod=MOD){
    ull ans = 1;
    while(p){
        if(p&1)ans=((ans%mod) * (base%mod))%mod;
        base=((base%mod) * (base%mod))%mod;
        p/=2;
    }
    return ans;
}

const int N = (int) 1e5;

ll fact(ll x){
    ll temp=1;
    for(ll i=1; i<=x; ++i){
        temp = ((temp%MOD) * (i%MOD))%MOD;
    }
    return temp%MOD;
}

int main(){
    FIO
        ll n, m; cin >> n >> m;
        if(abs(n-m)>=2){
            cout << 0 << endl;
        }
        else{
            if(n!=m){
                ll res = (fact(n)%MOD * fact(m)%MOD)%MOD;
                cout << res << "\n";
            }
            else{
                ll res = (2 * (fact(n)%MOD *fact(m)%MOD)%MOD)%MOD;
                cout << res << "\n";
            }
        }




return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
 
int main (){
	int n ;
  	cin >> n ;
  	double k = 0.5 ;
  	if(n%2){
    	cout << fixed << setprecision(10) << double((n/2)+1)/n ;
    }else cout << fixed << setprecision(10) << k ;
}

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	bool ok = true;
	rep(i, n){
		int a; cin >> a;
		if(a % 2 != 0) continue;
		else{
			if(a % 3 == 0 || a % 5 == 0) ok = true;
			else{
				ok = false;
				break;
			}
		}
	}
	if(ok) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

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

int main() {
  string s;
  map<string, int> word;

  while(cin >> s) {
    if(word.find(s) == word.end()) {
      word.insert(make_pair(s, 1));
    } else {
      word[s]++;
    }
  }

  string longs, manys;
  int longn = 0, manyn = 0;

  map<string, int>::iterator it = word.begin();
  while(it != word.end()) {
    if(it->first.length() > longn) {
      longn = it->first.length();
      longs = it->first;
    }
    if(it->second > manyn) {
      manyn = it->second;
      manys = it->first;
    }
    it++;
  }
  cout << manys << ' ' << longs << endl;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
int n, in[26], out[26], G[26][26];
bool visited[26];
bool check() {
	rep(i, 26)
		if (in[i] != out[i])
			return false;
	return true;
}
void dfs(int u) {
	visited[u] = true;
	rep(v, 26)
		if (!visited[v] && G[u][v])
			dfs(v);
}
int getNComponent() {
	int nc = 0;
	rep(i, 26)
	{
		if (in[i] == 0 && out[i] == 0)
			continue;
		if (!visited[i]) {
			nc++;
			dfs(i);
		}
	}
	return nc;
}
int main() {
	while (cin >> n && n) {
		rep(i, 26)
		{
			in[i] = out[i] = 0;
			visited[i] = false;
			rep(j, 26)
				G[i][j] = 0;
		}
		string str;
		rep(i, n)
		{
			cin >> str;
			in[str[0] - 'a']++;
			out[str[str.size() - 1] - 'a']++;
			G[str[0] - 'a'][str[str.size() - 1] - 'a'] = 1;
			G[str[str.size() - 1] - 'a'][str[0] - 'a'] = 1;
		}
		cout << ((check() && getNComponent() == 1) ? "OK" : "NG") << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 int main() {
   ll N, A, B;
   cin >> N >> A >> B;
   vector<ll> X(N);
   rep(i, 0, N) cin >> X.at(i);

   ll ans = 0;
   rep(i, 0, N - 1) {
     ans += min(B, A * (X.at(i + 1) - X.at(i)));
   }

   cout << ans << endl;
 }


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>

#define pb push_back
#define pf push_front

using namespace std;	
typedef long long int lli;

lli n,k,l,m,t,a,b,r,c,temp1,temp2,x,y,temp,q,d,mod=1e9+7,w;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a;
    if(a>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#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 REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int>>
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long>>
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int A[SIZE],B[SIZE],C[SIZE];
int main(){
    DRI(N);
    REP(i,N)RI(A[i]);
    REP(i,N)RI(B[i]);
    REP(i,N)RI(C[i]);
    sort(A,A+N);
    sort(B,B+N);
    sort(C,C+N);
    LL an=0;
    REP(i,N){
        int it1=lower_bound(A,A+N,B[i])-A;
        int it3=upper_bound(C,C+N,B[i])-C;
        an+=(N-it3)*(LL)it1;
    }
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 8832
from enum import Enum
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


line = input()
num_query = int(input())

for loop in range(num_query):

    input_str = list(input().split())

    if input_str[0] == 'replace':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + input_str[3] + line[right:]

    elif input_str[0] == 'reverse':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + line[left:right][::-1] + line[right:]

    else: #print
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        for i in range(left,right):
            print(line[i],end = "")
        print()



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

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
    string s;
    cin>>s;
    int x=s.size();
    rep(i,x) cout<<'x';
    cout<<endl;
    
}

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

void myquicksort(vector<tuple<int, int, char>> &, int, int);

void myswap(tuple<int, int, char> &, tuple<int, int, char> &);

int mypartition(vector<tuple<int, int, char>> &, int, int);

int main(int argc, char const *argv[])
{
    int n = 0;
    cin >> n;

    int num_card = 0;
    char char_card = '0';

    vector<tuple<int, int, char>> a;
    for (int i = 0; i < n; i++)
    {
        cin >> char_card >> num_card;
        a.push_back(make_tuple(num_card, i, char_card));
    }

    // for (int i = 0; i < n; i++)
    // {
    //     cout << get<2>(a[i]) << ", " << get<0>(a[i]) << ", " << get<1>(a[i]) << endl;
    // }

    myquicksort(a, 0, n - 1);

    bool unstable_flag = false;
    for (int i = 1; i < n; i++)
    {
        if (a[i] < a[i - 1])
        {
            unstable_flag = true;
            break;
        }
    }

    cout << ((unstable_flag) ? "Not stable" : "Stable") << endl;
    for (int i = 0; i < n; i++)
    {
        cout << get<2>(a[i]) << " " << get<0>(a[i]) << endl;
    }

    return 0;
}

void myquicksort(vector<tuple<int, int, char>> &a, int p, int r)
{
    if (p < r)
    {
        int q = mypartition(a, p, r);
        myquicksort(a, p, q - 1);
        myquicksort(a, q + 1, r);
    }
}

void myswap(tuple<int, int, char> &a, tuple<int, int, char> &b)
{
    tuple<int, int, char> c = a;
    a = b;
    b = c;
}

int mypartition(vector<tuple<int, int, char>> &a, int p, int r)
{
    int i = p - 1;
    int j = p;

    while (j < r)
    {
        if (get<0>(a[j]) > get<0>(a[r]))
        {
            j++;
        }
        else
        {
            i++;
            myswap(a[i], a[j]);
            j++;
        }
    }

    myswap(a[i + 1], a[r]);

    return (i + 1);
}


Measured memory_bytes: 4544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int[] x=new int[s.length()];
		int sum = 0;
		int a = 0,b = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				a = i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				b = i;
				break;
			}
		}
		sum = Math.abs(b-a+1);
		System.out.print(sum);
	}
}

Measured memory_bytes: 27696
k, s = map(int, input().split())
ans = 0
if s <= k:
    ans = (s+2)*(s+1) / 2
elif k < s <= 2*k:
    for i in range(k+1):
        j = s-k+i
        if j <= k:
            ans += j+1
        else:
            ans += j+1-2*(j-k)
elif 2*k < s < 3*k:
    ans = 3
else:
    ans =  1
print(int(ans))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    cout << a[a.size()-1]-*a.begin() << endl;
}


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

int main() {
  ll l,r; 
  cin >> l >> r;
  
  int m = 2018;
  
  r = min(r, l+4038);
  for (ll i=l; i<r; i++){
    for (ll j=i+1;j<=r;j++){
      int x = i*j%2019;
      m = min(m, x);
    }
  }
  cout << m << endl;
}


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/

signed main()
{
    showoff;
    int n,k;
    cin >> n >> k;
    if(k > ((n-1)*(n-2))/2){
        cout << -1;
        return 0;
    }    
    int rem = ((n-1)*(n-2))/2-k;
    vector<pii>ans;
    FOR(i,2,n+1)ans.pb({1,i});
    int u = 2,v = 3;
    while(rem){
        ans.pb({u,v});
        v++;
        if(v > n){
            u++;
            v = u+1;
        }
        rem--;
    }
    cout << sz(ans) << "\n";
    for(auto &x:ans)cout << x.f << " " << x.se << "\n";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

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

int dp[51][4];
int rec( int mul, int idx){
  if(mul < 0) return 0;
  if(idx == 4) return mul == 0;
  if(~dp[mul][idx]) return dp[mul][idx];

  int ret = 0;
  for(int i = 0 ; i < 10 ; i++ ){
    ret += rec( mul - i, idx + 1);
  }
  return dp[mul][idx] = ret;
}
int main(){
  int n;
  fill_n( *dp, 51 * 4, -1);
  while(cin >> n){
    cout << rec( n, 0) << endl;
  }
}

Measured memory_bytes: 1160
#include <cmath>
#include <cstdlib>
#include <complex>
#include <iostream>
#include <limits>
#include <vector>


int
main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n, m;
  std::cin >> n >> m;

  std::vector<std::pair<int, int>> froms(n);
  for (auto&& e : froms) {
    std::cin >> e.first >> e.second;
  }
  std::vector<std::pair<int, int>> tos(m);
  for (auto&& e : tos) {
    std::cin >> e.first >> e.second;
  }

  std::vector<int> checkPoints;
  checkPoints.reserve(n);
  for (const auto& e : froms) {
    auto min = std::numeric_limits<int>::max();
    auto checkPoint = 0;
    for (decltype(tos)::size_type i = 0; i < tos.size(); i++) {
      auto d = std::abs(e.first - tos[i].first) + std::abs(e.second - tos[i].second);
      if (d < min) {
        min = d;
        checkPoint = static_cast<int>(i);
      }
    }
    checkPoints.push_back(checkPoint + 1);
  }

  for (const auto& e : checkPoints) {
    std::cout << e << std::endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
const ll n = 100004;
vector<ll> dp(n,-1);

ll i,j;

int fun(ll a[],ll n)
{
    if(n==1)
    {
        dp[1]=0;
        return dp[1];
    }
    else if(n==2)
    {
        dp[2]=abs(a[2]-a[1]);
        return dp[2];
    }
    else 
    {
        if(dp[n]!=-1)
        {
        return dp[n];
        }

    }

    dp[n]=min((abs(a[n]-a[n-1])+fun(a,n-1)),(abs(a[n]-a[n-2])+fun(a,n-2)));
    return dp[n];

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    ll a[n+1];

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }

    cout<<fun(a,n);

    return 0;

}


Measured memory_bytes: 7836
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <list>

using namespace std;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	map<int,int> cnt;
	for(int i = 0; i < n;i++) {
		int x;
		cin >> x;
		cnt[x] ++;
	}
	int t;
	cin >> t;
	map<int,int> need;
	for(int i = 0; i < t; i++) {
		int x;
		cin >> x;
		need[x]++;
	}
	for(auto x : need) {
		if(x.second > cnt[x.first]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 19072
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int64_t> as(n), bs(n), cs(m), ds(m);

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

    for (int i = 0; i < m; i++)
    {
        cin >> cs[i] >> ds[i];
    }

    auto distance = [&](int pi, int ci) {
        const auto dx = abs(as[pi] - cs[ci]);
        const auto dy = abs(bs[pi] - ds[ci]);
        return dx + dy;
    };

    vector<int> select(n);
    for (int i = 0; i < n; i++)
    {
        int64_t min_dist = numeric_limits<int64_t>::max();
        for (int j = 0; j < m; j++)
        {
            if (min_dist > distance(i, j))
            {
                select[i] = j;
                min_dist = distance(i, j);
            }
        }
    }
    for (auto i : select)
    {
        cout << (i + 1) << endl;
    }
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

vector<vector<char>> field(10, vector<char>(10));

//oと上下左右で隣接しているところは全てxに変える 
//全てのマスをxに変えるまで何回dfsを行ったかがoの連結数

//現在地(x,y)
void dfs(int x, int y) {
  //今いるところをxに変える

  field[x][y] = 'x';

  //移動する四方向をループ
  for (int i = 0; i < 4; i++) {

    //移動先をnx,nyとする
    int nx = x + dx[i], ny = y + dy[i];

    //nxとnyが地図の範囲内であるかどうかと移動先field[nx][ny]が陸地かどうかを判定
    if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10 && field[nx][ny] == 'o') dfs(nx,ny);

  }
  return;
}

int main(){
	int n;
  	cin >> n;
	vector<int> p(n);
	rep(i,n){
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1;i < n - 1; i++) {
		vector<int> v = {p[i-1], p[i], p[i+1]};
		sort(v.begin(), v.end());
      
		if(v[1] == p[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
  int a,b;
  cin>>a>>b;
  //////
  int ans=0;
  ans+=a-1;
  if(a<=b) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
while line = gets do
a,b,c,d,e,f=line.split.map(&:to_f)
y=(a*f-c*d)/(a*e-b*d)
x=(c-b*((a*f-c*d)/(a*e-b*d)))/a
puts sprintf("%.3f %.3f",x,y)
end

Measured memory_bytes: 6136
#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll mod = 1e9+7;

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp)%mod;
    else
        return (((x*temp)%mod)*temp)%mod;
}


/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;

void Sieve(int n)
{
    vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 1e6 + 6;

ll n,k;
ll arr[Nmax];

bool check(ll mid)
{
    ll o = 0;
    for(int i=0;i<n;i++)
    {
        ll c = arr[i]/mid;
        if(c==0)
            continue;
        long double v = (1.0*arr[i])/(1.0*c);
        if(v > mid)
            c++;
        o += c-1;
        if(o>k)
            return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i=0;i<n;i++)
        cin >> arr[i];
    ll low = 1;
    ll high = 1e12;
    while(low<=high)
    {
        ll mid = (low+high)/2;
        if(check(mid))
            high = mid-1;
        else
            low = mid+1;
    }
    cout << low;
}


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

int main() {
      int a,b,c,d,count;
      count = 0;
      int num[100];
      int max;
      int n;
      
      for (int v=0;v<100;v++) {
      	num[v] = 100;
      	cin >> num[v];
      	if (!(0<=num[v]&&num[v]<=50)){
      		max = v-1;
      		break;
      	}
      }
      for (int w=0;w<=max;w++){
      	n=num[w];
      	count = 0;
      	for (int i=0;i<=9;i++) {
            a=i;
            if (n-a<0) {

            	break;
            }
            for (int j=0;j<=n-a&&j<=9;j++) {
            	b=j;
            	if (n-a-b < 0) {
            		break;
            	}
            	for (int k=0;k<=n-a-b&&k<=9;k++) {
            		c=k;
            		if (n-a-b-c < 0) {
            			break;
            		}
            		
            		for (int l=0;l<=n-a-b-c&&l<=9;l++) {
            			d=l;
            			if (n==a+b+c+d) {
            				//cout << a << b << c << d <<(a+b+c+d)<<endl;
            				count++;
            			}
            			if (n-a-b-c-d < 0) {
            			break;
            		}
            		}
            	}
            }
      }
      
      cout << count <<endl;
      }
      return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=2e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,bit[nmax];
ll k,x,s;
pair<ll,int>p[nmax];
void upd(int x)
{
	for(;x<=n+1;x+=x&(-x))bit[x]++;
}
int qry(int x)
{
	int ans=0;
	for(;x;x-=x&(-x))ans+=bit[x];
	return ans;
}
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>k;
    for(i=1;i<=n;i++)
	{
		cin>>x;
		s+=x;
		p[i]={s-k*i,i+1};
	}
	p[0]={0,1};
	sort(p,p+n+1);
	for(i=s=0;i<=n;i++)
	{
		s+=qry(p[i].sc);
		upd(p[i].sc);
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 4224
N = int(input())
S = input()
cnt = 0
for i in S[1:]:
    if i == 'E':
        cnt += 1
min_cnt = cnt
for i in range(N-1):
    if S[i] == 'E' and S[i + 1] == 'E':
        cnt -= 1
    elif S[i] == 'W' and S[i + 1] == 'W':
        cnt += 1
    if cnt < min_cnt:
        min_cnt = cnt
print(min_cnt)


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

int main() {
  string S; cin >> S;
  int N = S.size();
  vector<int> R(N), L(N), C(N);
  int cntR = 0;
  for (int i = 0; i < N-1; i++) {
    if (S.at(i) == 'R') cntR++;
    if (S.at(i) == 'R' && S.at(i+1) == 'L') {
      R.at(i) = cntR;
      cntR = 0;
    }
  }
  int cntL = 0;
  for (int i = N-1; i > 0; i--) {
    if (S.at(i) == 'L') cntL++;
    if (S.at(i) == 'L' && S.at(i-1) == 'R') {
      L.at(i) = cntL;
      cntL = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (R.at(i) != 0) {
      C.at(i) = (R.at(i) + 1) / 2 + L.at(i+1) / 2;
      C.at(i+1) = R.at(i) / 2 + (L.at(i+1) + 1) / 2;
    }
  }
  for (int i = 0; i < N-1; i++) {
    cout << C.at(i) << " ";
  }
  cout << C.at(N-1) << endl;
}

Measured memory_bytes: 1792
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 100001
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int n,m,ans,s[N],t[N],c[N];
bool use[31][N];
int main()
{
	re(n),re(m);
	for(int i=1;i<=n;++i)
	{
		re(s[i]),re(t[i]),re(c[i]);
		for(int j=s[i]-1;j<t[i];++j)
			use[c[i]][j]=1;
	}
	for(int i=1;i<N;++i)
	{
		int now=0;
		for(int j=1;j<=m;++j)now+=use[j][i];
		ans=max(ans,now);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll n,m; cin >> n >> m;
  cout << abs(n*m-n*2-m*2+4) << endl;
}


Measured memory_bytes: 256
s = list(input())
i = 0
ans = []
while i < len(s):
    count = 0
    while s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T" :
        count += 1
        i += 1
        if i >= len(s):
            break
    ans.append(count)
    i += 1
print(max(ans))

Measured memory_bytes: 38256
#include <iostream>
#include <vector>

using namespace std;

const int maxN = 1e5 + 5;

vector<int> farr(maxN, 0);

int main()
{
    int n, num, q, b, c;
    long long int ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> num;
        farr[num]++;
        ans += num;
    }
    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> b >> c;
        ans += (1LL * farr[b] * (c - b));
        farr[c] += farr[b];
        farr[b] = 0;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, t;
	cin >> n >> t;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll ans = t;
	for (int i = 0; i < n - 1; i++) {
		ans += min(t, a[i + 1] - a[i]);
	}

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

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

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

// author: Seong Yong-ju ( @sei40kr )

using namespace std;

template<typename T>
T gcd(T m, T n) {
  while (m % n != 0) {
    return gcd(n, m % n);
  }

  return n;
}

template<typename T>
T lcm(T m, T n) {
  return m / gcd(m, n) * n;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  long ts[n];
  REP(i, n) {
    cin >> ts[i];
  }

  long ans = accumulate(ts, ts + n, (long) 1, [](long x, long t) {
    return lcm(x, t);
  });
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

def kai(x):
    a = 1
    for i in range(1, x + 1):
        a *= i
    return a

al= list(range(1,n+1))
j = n-1
a = 0
for i in p:
    a += al.index(i) * kai(j)
    j -= 1
    al.remove(i)

al = list(range(1, n+1))
j = n-1
b = 0
for i in q:
    b += al.index(i) * kai(j)
    j -= 1
    al.remove(i)

print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> d, t;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    d[tmp]++;
  }
  int m;
  cin >> m;
  rep(i, m) {
    int tmp;
    cin >> tmp;
    t[tmp]++;
  }
  for (auto e : t) {
    if (d[e.first] < e.second) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

const ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> flag_lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
        flag_lazy.resize(2 * n - 1, false);
    }

    void update(int i, int l, int r) {
        if (!flag_lazy[i]) return;
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
            flag_lazy[2 * i + 1] = true;
            flag_lazy[2 * i + 2] = true;
        }
        flag_lazy[i] = false;
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            flag_lazy[k] = true;
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

    void disp() {
        for (int i : node) {
            cout << i << " ";
        }
        cout << "\n";
    }

};

int main() {
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(N + 1);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            st.add(min(l, N + 1), min(r, N + 1), x);
        }
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

Measured memory_bytes: 11456
package main

import "fmt"

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for 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
	}
}

const (
	MOD = 1000000007
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

type Po struct {
	i       int
	cnt     int
	counter int
}

func main() {
	var S string
	fmt.Scan(&S)
	last := ""
	ok := true
	for _, rs := range []rune(S) {
		if string(rs) == last {
			ok = false
			break
		}
		last = string(rs)
	}
	if ok {
		fmt.Println("Good")

	} else {
		fmt.Println("Bad")

	}
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 12416
n,a,b = map(int,input().split())
s = input()
c_a = 0
c_b = 0

for v in s:
    if v == 'a' and c_a < a+b:
        c_a += 1
        print('Yes')
    elif v == 'b' and c_a < a+b and c_b < b:
        c_a += 1
        c_b += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9204
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt();
		int[] a=  new int[n], b = new int[n];
		long freeA = 0, needB = 0;
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = in.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			if (a[i] <= b[i]) {
				freeA += (b[i] - a[i]) / 2;
			} else {
				needB += a[i] - b[i];
			}
		}
		if (needB <= freeA) {
			out.println("Yes");
		} else {
			out.println("No");
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 27732
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

int main()
{
	int N;
	cin >> N;
	if(N<1200){
		cout << "ABC" << endl;
	}else{
		cout << "ARC" << endl;
	}
    return 0;
}

Measured memory_bytes: 764