akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}


#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define repi(i,a,b) for(int i=(a),_i=(b);i<_i;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

const bool First = true, Second = false;
int main() {
  int in(N); int in(K);

  vi A(N);
  rep(i, N) cin >> A[i];
  all(sort, A);

  vector<bool> win(K+1, Second);

  rep(i, A[0]) win[i] = Second;
  rep(k, A[0], K+1) {
    win[k] = Second;
    rep(i, N) {
      if (k - A[i] >= 0)
        if (win[k-A[i]] == Second)
          win[k] = First;
    }
  }
  if (win[K] == First)
    cout << "First\n";
  else
    cout << "Second\n";


  return 0;
}


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

int main()
{
    array<int, 128> cnt={};
    int n; cin>>n;
    for(string s; n--; ) {
        cin>>s;
        cnt[s[0]]++;
    }
    long res=0;
    for(int i=0; i<(1<<5); ++i) if (__builtin_popcount(i)==3) {
        long c=1;
        for(int j=0; j<5; ++j) if ((i>>j)&1) c*=cnt["MARCH"[j]];
        res+=c;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
M = 0
m = 0
last = A[0]
flag1 = True
count = 1
for i in range(1,N):
    if last == A[i]:
        count += 1
    else:
        if count >= 2 and flag1:
            M = last
            flag1 = False
            if count >= 4:
                m = last
                break
            count = 1
            last = A[i]
            continue
        if count >= 2 and not flag1:
            m = last
            break
        count = 1
        last = A[i]
if count >= 2 and not flag1:
    m = last
print(M*m)

Measured memory_bytes: 62704
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1') {
			ans++;
		}
	}
	return cout << ans << endl, 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 100000
#define INF 1000000000
int n,a,b,ans,p[MAXN+5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		p[a]=i;
	}
	for(int i=1;i<=n;i++)
	printf("%d ",p[i]);
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

ll prime[100010];
ll kaijo[200010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 200000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)%N) + N) % N;
}


int main(void) {
	ll k, a, b, ans = 0, ans1 = 0;
	cin >> k >> a >> b;
	if (k<=a||b-a<=1) {
		cout << k + 1 << endl;
		return 0;
	}
	//ll num1 = k - 1;
	ll num2 = k + 1 - a;
	///ans = (num1 / a)*b + num1%a;
	if (num2 % 2 == 0) {
		ans1 = (num2 / 2)*(b - a) + a;
	}
	else {
		ans1 = (num2 / 2)*(b - a) + a + 1;
	}
	
	cout <<  max(ans, ans1) << endl;
}

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

// ----------- define --------------
#define int long long
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
// ---------------------------------

const int N = 2e6 + 5;
const int mod = 1e9 + 7;

int fac[N];

#define pow abcdef

int pow(int a, int b) {
  if (b == 0) return 1;
  int t = pow(a, b / 2);
  t = (t * t) % mod;
  if (b % 2 == 0) return t;
  else return (a * t) % mod;
}

int mmi(int a) {
  return pow(a, mod - 2);
}

int C(int n, int r) {
  int ret = (fac[n] * mmi(fac[r])) % mod;
  ret = (ret * mmi(fac[n - r])) % mod;
  return ret;
}

void MAIN() {
  fac[0] = 1;
  for (int i = 1; i <= N; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
  }
  int n, m;
  cin >> n >> m;
  int ans = 1;
  for (int i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      int r = 0;
      while (m % i == 0) m /= i, r++;
      (ans *= C(n + r - 1, r)) %= mod;
    }
  }
  if (m > 1) (ans *= n) %= mod;
  cout << ans << '\n';
}

signed main() {
  // ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 19216
#include <iostream>

using namespace std;

int a, b, c;

int calc() {
    for (int t = 0; t <= a + b; t++) {
        int x = (60 * t + c) % (a + b);
        if (0 <= x && x <= a) {
            return 60 * t + c;
        }
    }
    return -1;
}

int main() {
    cin >> a >> b >> c;
    cout << calc() << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
    map<ll, ll> m;
    ll n, a, i, sum = 0;

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

    for(auto x : m){
        sum += x.second - 1;
    }

    if(sum % 2 == 1){
        sum++;
    }

    cout << n - sum << endl;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, a, cnt = LINF;
    cin >> n;
    rep(i, 0, 5)
    {
        cin >> a;
        chmin(cnt, a);
    }
    //cout << cnt << '\n';

    cout << (n + cnt - 1) / cnt + 4 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char S[100005];
int ANS[100005],n;
void DO(int s,int e) {
	for(int i=e+1; i<=n&&S[i]=='L'; i++) {
		if((i-e)&1)ANS[s]++;
		else ANS[e]++;
	}
	for(int i=s-1; i&&S[i]=='R'; i--) {
		if((s-i)&1)ANS[e]++;
		else ANS[s]++;
	}
}
int main() {
	scanf("%s",S+1);
	n=strlen(S+1);
	for(int i=1; i<=n; i++)
		if(S[i]=='R'&&S[i+1]=='L') DO(i,i+1),ANS[i]++,ANS[i+1]++;
	for(int i=1; i<=n; i++)printf("%d ",ANS[i]);
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    bool jdg = true;
    for(int i = 0; i < S.length(); i++){
        if(i % 2 == 0){
            if(S[i] == 'L')jdg = false;
        }else{
            if(S[i] == 'R')jdg = false;
        }
    }
    cout << ((jdg) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(int i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;

 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    cout << (string)t+s << endl;
    cout << endl;
    return 0;
}

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

int A, B, C, D, E, F;
int water[3005], sugar[3005];
int main(){
	cin>>A>>B>>C>>D>>E>>F;
	water[0] = sugar[0] = 1;
	for(int i = 1; i <= F; i ++){
		if(i >= 100*A)water[i] = water[i - 100*A];
		if(i >= 100*B)water[i] = (water[i] | water[i - 100*B]);
		if(i >= C)sugar[i] = sugar[i - C];
		if(i >= D)sugar[i] = (sugar[i] | sugar[i - D]);
	}
	int ansx = 100*A;
	int ansy = 0;
	for(int x = 1; x <= F; x ++){
		if(water[x] == 1){
			for(int y = 0; y <= F-x; y ++)if(sugar[y] == 1){
				double s = y*1.0 / x;
				double t = E*1.0 / 100;
				double u = ansy*1.0 / ansx;
				if(s <= t && s > u){
					ansx = x;
					ansy = y;
				}	
			}
		}
	}
	cout<<ansx+ansy<<" "<<ansy<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[505][505];
int main(){
    int n,m,q;
    cin >> n >> m >> q;
    int L,R;
    for(int i=0;i<m;i++){
        cin >> L >> R;
        c[L][R]++;
    }
    for(int j=1;j<n+1;j++){
        for(int i=j;i>1;i--){
            c[i-1][j]+=c[i][j];
        }
    }
    for(int j=n;j>=1;j--){
        for(int i=j;i<n+1;i++){
            c[j][i+1]+=c[j][i];
        }
    }
    for(int i=0;i<q;i++){
        cin >> L >> R;
        cout << c[L][R] << endl;
    }
}

Measured memory_bytes: 1920
# Dice I
# 2018/11/17

class Dice:
    def __init__(self, *num):
        if len(num) != 6:
            raise ValueError("6!")
        self.numbers = num

    def east(self):
        index = (3, 1, 0, 5, 4, 2)
        self.numbers = tuple((self.numbers[i] for i in index))

    def west(self):
        index = (2, 1, 5, 0, 4, 3)
        self.numbers = tuple((self.numbers[i] for i in index))

    def south(self):
        index = (4, 0, 2, 3, 5, 1)
        self.numbers = tuple((self.numbers[i] for i in index))

    def north(self):
        index = (1, 5, 2, 3, 0, 4)
        self.numbers = tuple((self.numbers[i] for i in index))

    @property
    def top(self):
        return self.numbers[0]

    def __repr__(self):
        return "Dice(" + ", ".join([str(i) for i in self.numbers]) + ")"


def main():
    num = [int(i) for i in input().rstrip().split()]
    dice = Dice(*num)
    for i in input().rstrip():
        if i == "E":
            dice.east()
        elif i == "W":
            dice.west()
        elif i == "S":
            dice.south()
        elif i == "N":
            dice.north()
    print(dice.top)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5632
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

int a[N];
ll suff[N];

pll solve(int n, int min_sum);

int main() {
	fast_cin();
	int n; ll m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	for (int i = n; i >= 1; --i) {
		suff[i] = suff[i + 1] + a[i];
	}
	int lo = 1, hi = 2 * a[n];
	ll ans = 0;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		pll temp = solve(n, mid);
		if (temp.first >= m) {
			ans = temp.second - mid * (temp.first - m);
			lo = mid + 1;
		} else {
			hi = mid - 1;
		}
	}
	cout << ans << '\n';
}

pll solve(int n, int min_sum) {
	ll cnt = 0, sum = 0;
	int p = 1;
	for (int i = n; i >= 1; --i) {
		while (p <= n and a[i] + a[p] < min_sum) {
			++p;
		}
		cnt += (n - p + 1);
		sum += ll(n - p + 1) * a[i] + suff[p];
	}
	return {cnt, sum};
}

Measured memory_bytes: 1408
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
dp =[[0,0,0]]
for i in range(1,n+1):
        a = s[i-1][0] + max(dp[i-1][1],dp[i-1][2])
        b = s[i-1][1] + max(dp[i-1][0],dp[i-1][2])
        c = s[i-1][2] + max(dp[i-1][1],dp[i-1][0])
        dp.append([a,b,c])
print(max(dp[-1]))

Measured memory_bytes: 75864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final long[] arrayForSort = new long[n];
        final long[] nativeArray = new long[n];

        for (int i = 0; i < n; i++) {
            final long tmp = scanner.nextLong();
            arrayForSort[i] = tmp - (i + 1);
            nativeArray[i] = tmp;
        }

        Arrays.sort(arrayForSort);

        if (n % 2 == 0) {
            final long mid1 = arrayForSort[n / 2];
            final long mid2 = arrayForSort[n / 2 - 1];

            long answer1 = 0;
            long answer2 = 0;

            for (int i = 0; i < n; i++) {
                answer1 += Math.abs(nativeArray[i] - (mid1 + i + 1));
                answer2 += Math.abs(nativeArray[i] - (mid2 + i + 1));
            }

            System.out.println(Math.min(answer1,answer2));
        } else {
            final long mid = arrayForSort[(n - 1) / 2];

            long answer = 0;

            for (int i = 0; i < n; i++) {
                answer += Math.abs(nativeArray[i] - (mid + i+1));
            }

            System.out.println(answer);
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 52632
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    string s;
    cin>>s;
    int cnt=0;
    ll res=0;
    rep(i,s.size()-1){
        if(s[i]=='A')cnt++;
        else {
            if(s[i]=='B'&&s[i+1]=='C'){
            res+=cnt;
            i++;
            }
            else {cnt=0;}
        }
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============
constexpr int SIZE = 26;
using ALPHA = int;

vector<ALPHA> parse_bits(const string& s) {
    const int len = s.size();
    vector<ALPHA> res(len + 1, 0);
    rep(i, len) {
        int idx = s[i] - 'a';
        ALPHA buf(1 << idx);
        res[i + 1] = res[i] ^ buf;
    }
    return res;
}

map<ALPHA, set<int>> compress(const vector<ALPHA>& bits) {
    map<ALPHA, set<int>> mp;
    rep(i, bits.size())mp[bits[i]].insert(i);
    return mp;
}

set<ALPHA> make_nexts(ALPHA bit) {
    set<ALPHA> st;
    // st.insert(bit);
    rep(i, SIZE) {
        ALPHA buf(1 << i);
        bit ^= buf;
        st.insert(bit);
        bit ^= buf;
    }
    return st;
}

int solve(string s) {
    auto bits = parse_bits(s);
    auto mp = compress(bits);

    const int len = s.size();
    vector<int> dp(len + 1, INF);
    dp[0] = 0;
    rep(i, len) {
        [&]() {
            // same processing
            auto itr = mp[bits[i]].upper_bound(i);
            if (itr != mp[bits[i]].end()) {
                int idx = *itr;
                dp[idx] = min(dp[idx], dp[i] + 0);
            }
        }();
        [&]() {
            // different processing
            auto nexts = make_nexts(bits[i]);
            for (auto next : nexts) {
                if (mp.find(next) == mp.end())continue;
                auto itr = mp[next].lower_bound(i);
                if (itr != mp[next].end()) {
                    int idx = *itr;
                    dp[idx] = min(dp[idx], dp[i] + 1);
                }
            }
        }();
    }
    int res = dp.back();
    return res == 0 ? 1 : res;
}

int main()
{
    string s;
    cin >> s;
    cout << solve(s) << endl;
    //int res1 = solve(s);
    //reverse(s.begin(), s.end());
    //int res2 = solve(s);
    //cout << min(res1, res2) << endl;
    return 0;
}


Measured memory_bytes: 33332
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  ifstream cin("input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif

  ll a, b, k;
  cin >> a >> b >> k;
  a -= k;
  if(a < 0) {
    b += a;
    a = 0;
  }
  if(b < 0) b = 0;
  cout << a << " " << b;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--) 
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    ll N;
    cin >> N;
    vector<int> d(N);
    rep(i,0,N){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    cout << d[N/2]-d[N/2-1] <<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(a+x<b) prin("dangerous");
  else if(a<b&&b<=a+x) prin("safe");
  else prin("delicious");

  return 0;
}


Measured memory_bytes: 256
def main():
    m = list(input())
    q = int(input())
    A = []
    for _ in range(q):
        A.append(input().split())

    for x in range(q):
        if A[x][0] == "print":
            A[x][1] = int(A[x][1])
            A[x][2] = int(A[x][2])
            for y in range(A[x][1], A[x][2] + 1):
                if y != A[x][2]:
                    print(m[y], end = "")
                else:
                    print(m[y])
        elif A[x][0] == "reverse":
            A[x][1] = int(A[x][1])
            A[x][2] = int(A[x][2])
            hoge = []
            for y in range(A[x][1], A[x][2] + 1):
                hoge.append(m[y])
            hoge = hoge[::-1]
            i = 0
            for y in range(A[x][1], A[x][2] + 1): 
                m[y] = hoge[i]
                i += 1
        elif A[x][0] == "replace":
            A[x][1] = int(A[x][1])
            A[x][2] = int(A[x][2])
            fuga = list(A[x][3])
            j = 0
            for y in range(A[x][1], A[x][2] + 1):
                m[y] = fuga[j]
                j += 1


if __name__ == "__main__":
    main()

Measured memory_bytes: 9140
<?php
define("MOD", 10**9+7);
$str = str_split(str());
$n = count($str);
for($j = 0; $j < 13; $j++){
  $dp[$n-1][$j] = 0;
}
if($str[$n-1] == "?"){
  for($i = 0; $i < 10; $i++){
    $dp[$n-1][$i] = 1;
  }
}else{
  $dp[$n-1][$str[$n-1]] = 1;
}
$c = 0;
$m = 1;
for($i = $n-2; $i>=0; --$i){
  $m*=10;
  $m%=13;
  for($j = 0; $j < 13; ++$j){
    $dp[$i][$j] = 0;
  }
  $dpi = &$dp[$i];
  $dpip = $dp[$i+1];
  if($str[$i] != "?"){
    $diff = $m*intval($str[$i])%13;
    for($j = 0; $j < 13; ++$j){
      $dpi[($j+$diff)%13] = $dpip[$j];
    }
  }else{
    for($k = 0; $k < 10; ++$k){
      $diff = $m*$k%13;
      for($j = 0; $j < 13; ++$j){
        $dpi[($j+$diff)%13] += $dpip[$j];
        $c+=$dpip[$j];
      }
    }
  }
  for($j = 0; $j < 13; $j++){
    $dp[$i][$j] = $dp[$i][$j] % MOD;
  }
}
echo $dp[0][5];


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}


Measured memory_bytes: 86904
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	int n;
	cin>>n;
	for(int i=n;i<1000;i++){
		if(i%111 == 0){
			cout<<i<<endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 764
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+1;
vector<P> ps[L];
int cs[L];
int m=0;
void f(int r,int p,int c){
	m=max(m,c);
	int k=1;
	for(auto n:ps[r]){
		if(n.first==p)continue;
		if(k==c){
			k++;
		}
		cs[n.second]=k;
		f(n.first,r,k);
		k++;
	}
}
int main() {
	int N;
	cin >> N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		ps[a].push_back(P(b,i));
		ps[b].push_back(P(a,i));
	}
	f(1,0,0);
	cout << m << endl;
	for(int i=0;i<N-1;i++){
		cout << cs[i] << endl;
	}


	return 0;
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  int xmax = -100;
  rep(i,n){
    int X;
    cin >> X;
    xmax = max(X,xmax);
  }
  int ymin = 100;
  rep(i,m){
    int Y;
    cin >> Y;
    ymin = min(Y,ymin);
  }
  string ans;
  if(x + 1 <= y && xmax + 1 <= ymin && max(x,xmax) < min(y,ymin)) ans = "No War";
  else ans = "War";
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n, m;
    cin >> n >> m;
    int t = 1900 * m + 100 * (n - m);
    // double p = pow(1.0 / 2, m);
    // double ans = 0.0;
    // rep(i, (int)1e5) {
    //     ans += (i + 1) * t * pow(1 - p, i) * p;
    // }
    // cout << (int)(ans + 0.001) << endl;
    int e = 1;
    rep(i, m) {
        e *= 2;
    }
    cout << t * e << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define asort(x) sort((x).begin(), (x).end())
#define rsort(x) sort((x).rbegin(), (x).rend())
using namespace std;
//ll dp[1005][100005]={-1};
ll knap(ll wt[], ll val[], ll w, ll n)
{
    ll dp[n+1][w+1];
//    memset(dp, -1, sizeof dp);
  //  if(n==0 || w==0)
   // return 0;
   for(int i=0;i<=n;i++)
   for(int j=0;j<=w;j++)
   {
       if(i==0 || j==0)
       dp[i][j]=0;
   }
  /*  if(dp[n][w]!=-1)
    return dp[n][w];
    if(w >= wt[n-1])
    {
        dp[n][w] = max(val[n-1] + knap(wt, val, w-wt[n-1],n-1) , knap(wt, val, w, n-1));
    }
    else
    {
        dp[n][w] = knap(wt, val, w, n-1);
    }
    return dp[n][w];*/
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j>=wt[i-1])
            dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]], dp[i-1][j]);
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            
        }
    }
    return dp[n][w];
}
int main()
{
    ll n,w;
    cin>>n>>w;
    ll wt[n],val[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    ll ans=knap(wt,val,w,n);
    cout<<ans<<"\n";

}

Measured memory_bytes: 82392
h,w=map(int,input().split())
n=int(input())
A=list(map(int,input().split()))
q=[]
for i in range(n):
  q+=[i+1]*A[i]
c=[[0]*w for _ in range(h)]
for i in range(h):
  if i%2==0:
    for j in range(w):
      c[i][j]=q.pop(0)
  else:
    for j in range(w-1,-1,-1):
      c[i][j]=q.pop(0)

for i in c:
  print(' '.join(map(str, i)))

Measured memory_bytes: 9444
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(ll arg_weight,ll arg_value){
		weight = arg_weight;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{
		return weight < arg.weight;
	}
	ll weight,value;
};

int N;
ll A,B;
vector<Info> V[5],G[2];

int main(){

	scanf("%d %lld %lld",&N,&A,&B);

	int type;
	ll x,y;

	for(int i = 0; i < 5; i++)V[i].push_back(Info(0,0)); //装備なし

	for(int loop = 0; loop < N; loop++){
		scanf("%d %lld %lld",&type,&x,&y);
		type--;
		V[type].push_back(Info(x,y));
	}

	for(int i = 0; i < V[0].size(); i++){
		for(int k = 0; k < V[1].size(); k++){
			G[0].push_back(Info(V[0][i].weight+V[1][k].weight,V[0][i].value+V[1][k].value));
		}
	}

	for(int a = 0; a < V[2].size(); a++){
		for(int b = 0; b < V[3].size(); b++){
			for(int c = 0; c < V[4].size(); c++){
				G[1].push_back(Info(V[2][a].weight+V[3][b].weight+V[4][c].weight,V[2][a].value+V[3][b].value+V[4][c].value));
			}
		}
	}

	sort(G[0].begin(),G[0].end());
	sort(G[1].begin(),G[1].end());

	int add_index = G[1].size()-1,del_index = G[1].size()-1;

	map<ll,int> count;
	set<ll> SET;

	for(int i = 0; i < G[0].size(); i++){

		while(add_index >= 0 && G[0][i].weight+G[1][add_index].weight >= A){
			SET.insert(G[1][add_index].value);
			count[G[1][add_index].value]++;
			add_index--;
		}

		while(del_index > add_index && G[0][i].weight+G[1][del_index].weight > B){
			count[G[1][del_index].value]--;
			if(count[G[1][del_index].value] == 0)SET.erase(G[1][del_index].value);
			del_index--;
		}

		if(SET.lower_bound(A-G[0][i].value) != SET.upper_bound(B-G[0][i].value)){
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;
}



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

int main()
{
  int a, b; cin >> a >> b;
  if (a == b) {
    cout << "Draw" << endl;
  } else if (a == 1) {
    cout << "Alice" << endl;
  } else if (b == 1) {
    cout << "Bob" << endl;
  } else if (a > b) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
using namespace std;
int n, w;
typedef vector<int64_t> vi;
typedef vector<vi> vii;
#define rep(i, k, n) for (int64_t i = k; i < (int)(n); i++)
int main()
{
    cin >> n >> w;
    vii wv(n + 1, vi(2));
    rep(i, 1, n + 1)
    {
        cin >> wv[i][0] >> wv[i][1];
    }

    vii dp(n + 1, vi(w + 1, 0));
    rep(N, 1, n + 1)
    {
        rep(W, 1, w + 1)
        {
            dp[N][W] = (W < wv[N][0]) ? dp[N - 1][W] : max(dp[N - 1][W], dp[N - 1][W - wv[N][0]] + wv[N][1]);
        }
    }
    cout
        << dp[n][w] << endl;
}

Measured memory_bytes: 83076
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

typedef long long ll;

string N;
int K;
ll dp[100 + 10][2][4];

int main() {
	cin >> N >> K;
	dp[0][1][0] = 1;
	for (int i = 0; i < N.size(); i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k <= K; k++) {
				for (int d = 0; d <= (j ? N[i] - '0' : 9); d++) {
					if(d == 0)
						dp[i + 1][(!j) ? 0 : ((d == (N[i] - '0')) ? 1 : 0)][k] += dp[i][j][k];
					else if(k != K)
						dp[i + 1][(!j) ? 0 : ((d == (N[i] - '0')) ? 1 : 0)][k + 1] += dp[i][j][k];
				}
			}
		}
	}
	cout << dp[N.size()][0][K] + dp[N.size()][1][K] << endl;
	return 0;
}

Measured memory_bytes: 256
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  int n ,k;
  cin >> n >> k;
  vector<long long> H(n);
  rep(i, 0, n){
    cin >> H[i];
  }
  rep(i, 0, n){
    
  }
  sort(H.begin(), H.end());
  rep(i, 0, k){
    if(!H.empty())H.pop_back();
  }
  H.push_back(0);
  cout << accumulate(H.begin(), H.end(), 0LL);

}

Measured memory_bytes: 6380
/*input
869121
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

const ll MX = 1000005;

ll dp[MX][2][2];

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll n; cin >> n;
	dp[0][1][1] = true;
	for(ll i = 1; i <= n; i++) {
		for(ll j = 0; j < 2; j++) {
			for(ll k = 0; k < 2; k++) {
				dp[i][j][k] = (8 * dp[i - 1][j][k]) % MOD;
				dp[i][j][k] = (dp[i][j][k] + dp[i - 1][1][k]) % MOD;
				dp[i][j][k] = (dp[i][j][k] + dp[i - 1][j][1]) % MOD;
			}
		}
	}
	cout << dp[n][0][0] << endl;
	return 0;
}




















Measured memory_bytes: 34744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

void Warshall_Floyd (vector<vector<ll>>& distance){
    ll n = distance.size();
    for(ll i = 0; i < n; i++) distance[i][i] = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < n; j++){
            for(ll k = 0; k < n; k++){
                distance[j][k] = min(distance[j][i]+distance[i][k],distance[j][k]);
            }
        }
    }
}

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<ll>> d(10,vector<ll>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> d[i][j]; 
        }
    }
    Warshall_Floyd(d);
    int a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    ll ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == -1) continue;
            else ans += d[a[i][j]][1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

int main(){
	string s[3];
	rep(i,3) cin>>s[i];
	cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;

	return 0;
}


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

int main(){

	int A, B, C, X;
	int count=0;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	for(int i = 0; i <= A; i++){
		for(int j = 0; j <= B; j++){
			for(int k = 0; k <= C; k++){
				if( X == (i*500 + j*100 + k*50)){
					count++;
				}
			}
		}
	}

	cout << count << '\n';
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
using namespace std;
bool binarysearch(long int x,long int* D,long int n){
    int B=0;
    int T=n-1;

    while(B<=T){
      int mid=(B+T)/2;
      if(D[mid]==x){return true;}
      else if(D[mid]<x){B=mid+1;}
      else T=mid-1;
    }
    return false;
}

int main(){
  long int n;
  cin>>n;
  long int S[n];
  for(int i=0;i<n;i++)cin>>S[i];
  long int q;
  cin>>q;
  long int T[q];
  for(int i=0;i<q;i++)cin>>T[i];
  int cnt=0;
  for(int i=0;i<q;i++){
    if(binarysearch(T[i],S,n))cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

vi h;
vvi to;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    h.resize(n);
    rep(i, n) {
        cin >> h[i];
    }
    to.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    int cnt = 0;
    rep(v, n) {
        bool flag = true;
        for (int nv : to[v]) {
            if (h[nv] >= h[v]) {
                flag = false;
                break;
            }
        }
        if (flag) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define DV(K,L,N,M) vector<vector<L>> K(N, vector<L>(M));
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main() {
  lli A,B,C,D,E,F=1,N,M,K,sum=0,num=0,ans=0;
  cin >> N >> M;
  DV(P,char,N,M);
  rep(i,0,N)rep(j,0,M)cin >> P[i][j];
  rep(i,0,N)rep(j,0,M){
    num=0;sum=0;
    if(P[i][j]=='.')continue;
    if(i!=0){
      sum++;
      if(P[i-1][j]=='.')num++;
    }
    if(i!=N-1){
      sum++;
      if(P[i+1][j]=='.')num++;
    }
    if(j!=0){
      sum++;
      if(P[i][j-1]=='.')num++;
    }
    if(j!=N-1){
      sum++;
      if(P[i][j+1]=='.')num++;
    }
    if(sum==num){
      F=0;
      break;
    }
  }
  if(F)Out("Yes");
  else Out("No");
}

Measured memory_bytes: 256
N, M, *rest = $stdin.read.split.map(&:to_i)
to1 = Array.new(N+1)
toN = Array.new(N+1)
rest.each_slice(2) do |a, b|
  a, b = *[a, b].sort
  if a == 1
    if toN[b]
      puts "POSSIBLE"; exit
    end
    to1[b] = true
  end
  if b == N
    if to1[a]
      puts "POSSIBLE"; exit
    end
    toN[a] = true
  end
end
puts "IMPOSSIBLE"


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

using namespace std;

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int day_x = min(K, N);
  int day_y = N - day_x;
  cout << X * day_x + Y * day_y;
  return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn = 100009;
long long n, A, B, h[maxn];
long long l = 0, r = 9e18, mid;

bool check(long long x)
{
    long long res = 0;
    for (long long i=1; i<=n; i++)
        if (h[i] > B*x)
            res+= (int)ceil(h[i]-B*x+A-B-1)/(A-B);
    return res <= x;
}

int main()
{
    scanf("%lld%lld%lld", &n, &A, &B);
    for (long long i=1; i<=n; i++) scanf("%lld", &h[i]);
    while (l < r)
    {
        mid = (l+r) >> 1;
        if (check(mid)) r = mid;
        else l = mid + 1;
    }
    printf("%lld\n", l);
    return 0;
}



Measured memory_bytes: 896
n = input()
n = int(n)

d = []
for i in range(n):
    d.append(input().split())
active = False
count = 0
for x in d:
    if x[0] == x[1]:
        active = True
        count += 1
    else:
        count = 0
        active = False
    if count >2:
        break

if count > 2:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		long x, y;
		x = a * b;
		y = c * d;
		System.out.println(Math.max(x, y));
	}
}

Measured memory_bytes: 21844
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

#define fr first
#define sc second
#define mk make_pair

using namespace std;

long long n, ar[1000001], k, u[1000001];
vector<int> vec;

int main()
{
    cin >> n >> k;
    for(long long i = 1; i <= n; i++)
        cin >> ar[i];

    if( (n >= 5000 && k < 5000 && k > 4000 ) || (n <= 400 && k > 400))
    {
        for(long long i = 1; i <= n; i++)
        {
            long long r = 1, sum = 0;
            for(int j = 1; j <= i; j++)
                sum += ar[j];
            r = i + 1;

            for(long long j = 1; j <= i; j++)
            {
                if(r < j)
                {
                    r = j;
                    sum = 0;
                }
                while((r <= n && sum < k))
                {
                    sum += ar[r];
                    r++;
                }

                if(sum >= k)
                {
                    if(sum - ar[i] < k)
                    {
                        u[i] = 1;
                        break;
                    }
                }else
                {
                    break;
                }
                //cout << j << " " << r << endl;
                sum -= ar[j];
            }
        }
        long long ans = 0;
        for(long long i = 1; i <= n; i++)
            ans += u[i];

        cout << n - ans;
    }else
    {
        for(long long i = 1; i <= n; i++)
        {
            long long r = 1, sum = 0;
            for(long long j = 1; j <= n; j++)
            {
                if(r < j)
                {
                    r = j;
                    sum = 0;
                }
                while((r < j) || (r <= n && sum < k))
                {
                    sum += ar[r];
                    r++;
                }

                if(i >= j && j < r && sum >= k)
                    if(sum - ar[i] < k)
                        u[i] = 1;
                //cout << j << " " << r << endl;
                sum -= ar[j];
            }
        }

        for(long long i = 1; i <= n; i++)
        {
            long long r = n, sum = 0;
            for(long long j = n; j > 0; j--)
            {
                if(r > j)
                {
                    r = j;
                    sum = 0;
                }
                while((r > j) || (r > 0 && sum < k))
                {
                    sum += ar[r];
                    r--;
                }

                if(i <= j && j > r && sum >= k)
                    if(sum - ar[i] < k)
                        u[i] = 1;
                //cout << j << " " << r << endl;
                sum -= ar[j];
            }
        }

        long long ans = 0;
        for(long long i = 1; i <= n; i++)
            ans += u[i];

        cout << n - ans;
    }
    return 0;//
}


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

using namespace std;

typedef long long int lli;

lli i,j,k,l,m,n,t,a,b,c,d,x,y,p,q,sum=0,total=0;

#define read(in) freopen("Input.txt","r",stdin)
#define write(out) freopen("Ouput.txt","w",stdout)

int main()
{
  cin>>n>>m;
  sum=0;
  while(m--)
  {
    cin>>x;
    sum+=x;
  }
  if(sum<=n)	cout<<n-sum<<"\n";
  else if(sum>n)	cout<<"-1\n";
}

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

int main() {
  int a;
  cin >> a;
  int c100 = a / 100;
  int c10 = a / 10 % 10;
  int c1 = a % 2;
  cout << c100 + c10 + c1 << endl;
}



Measured memory_bytes: 256