akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

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

    int sum = 0;
    for(int i = 0;i < s.length();i++){
        int tmp = s[i] - '0';
        //cout << tmp << endl;
        sum += tmp;
    }

    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll fact(int N){
    if (N==0) return 1;
    return N*fact(N-1);
}
int main() {
    int N; cin >> N;
    vector<pint> xy(N);
    for (int i=0;i<N;i++) cin >> xy[i].first >> xy[i].second;
    vector<vector<double>> dist(N,vector<double>(N));
    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            dist[i][j] = sqrt(pow((xy[i].first - xy[j].first),2)+pow((xy[i].second - xy[j].second),2)); 
        }
    }
    vector<int> order(N);
    for (int i=0;i<N;i++) order[i] = i;
    double sum_dist = 0;
    do{
        for (int i=1;i<N;i++) {
            sum_dist += dist[order[i-1]][order[i]];
        }
    } while (next_permutation(order.begin(),order.end()));
    double res = sum_dist / fact(N);
    printf("%.8f\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int n, m;
double calc(vector<int> &cnt){
	double res = 0;
	for (double x : cnt){
		if(x) res -= x / n*log(x / n);
	}
	return res;
}

tuple<int, int, int> bf(vector<int> &v){
	double opt = 1e9;
	auto ans = MT(-1, -1, -1);
	rep(s, 16) rep(a, 16) rep(c, 16){
		vector<int> cnt(256);
		int r = s;
		rep(i, v.size()){
			r = (a*r + c) % m;
			++cnt[(v[i] + r) % m];
		}
		double tmp = calc(cnt);
		if (tmp + 1e-9 < opt){
			ans = MT(s, a, c);
			opt = tmp;
		}
	}
	return ans;
}

int main(){
	m = 256;
	while (cin >> n, n){
		vector<int> v(n);
		rep(i, n) cin >> v[i];
		int s, a, c;
		tie(s, a, c) = bf(v);
		cout << s << ' ' << a << ' ' << c << '\n';
	}

	return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF INT_MAX //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

vector<int>memo;

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

   int N,M;
   cin>>N>>M;
   vector<int>A(N);
   for(int i=0;i<N;i++)cin>>A[i];
   for(int i=0;i<N;i++)A[i]%=M;

   vector<int>sum(N+1,0);
   for(int i=1;i<=N;i++){
      sum[i]=A[i-1];
   }
   for(int i=1;i<=N;i++){
      sum[i]+=sum[i-1]%M;
   }
   for(int i=0;i<=N;i++){
      sum[i]%=M;
   }

   ll ans=0;
   map<int,int>memo;
   for(int i=0;i<=N;i++){
      ans+=memo[sum[i]];
      memo[sum[i]]++;
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  
  ch a,b;
  	ci(a>>b);
  if(a-b==0) co("H")
    else co("D")
    }

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

int main()
{
	// 読み込み(\0)分も考慮する
	char searchStr[101];
	// scanf_s("%s\n", searchStr, 101);
	scanf("%s\n", searchStr);

	char patternStr[101];
	// scanf_s("%s\n", patternStr, 101);
	scanf("%s\n", patternStr);

	// 繰り返し用アレイ作成
	char dupStr[202];
	// strcpy_s(dupStr, 202, searchStr);
	strcpy(dupStr, searchStr);
	// 下の引数が別々のアレイになるように
	// strcat_s(dupStr, 202, searchStr);
	strcat(dupStr, searchStr);

	// デバッグ用
	// printf("%s\n", dupStr);
	// printf("%s\n", patternStr);

	if (strstr(dupStr, patternStr) == NULL)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}


Measured memory_bytes: 2756
# https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b

k, t = gets.split.map(&:to_i)
cakes = gets.split.map(&:to_i)

max_cake = cakes.max

sum_cake = k - max_cake

puts [max_cake - sum_cake - 1, 0].max


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;



int main(){
double R;
    cin >> R;
 cout << fixed << setprecision(10);
 cout<<2*R*3.141592653589793<<endl;
return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<numeric>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	vector<ll> a(3*n);
	for(int i=0;i<3*n;i++){
		cin >> a[i];
	}

	ll S=accumulate(a.begin(),a.begin()+n,0LL);
	vector<ll> S1(n+5);
	S1[0]=S;
	priority_queue<ll,vector<ll>,greater<ll>> que1(a.begin(),a.begin()+n);
	for(int i=n;i<2*n;i++){
		que1.push(a[i]);
		ll val=que1.top();que1.pop();
		S+=(a[i]-val);
		S1[i-n+1]=S;
	}

	S=accumulate(a.begin()+2*n,a.end(),0LL);
	vector<ll> S2(n+5);
	S2[0]=S;
	priority_queue<ll> que2(a.begin()+2*n,a.end());
	for(int i=1;i<=n;i++){
		que2.push(a[2*n-i]);
		ll val=que2.top();que2.pop();
		S+=(a[2*n-i]-val);
		S2[i]=S;
	}

	ll ans=-1e18;
	for(int i=0;i<=n;i++){
		ans=max(ans,S1[i]-S2[n-i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6516
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>

using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> a(3 * N);
    for(int i = 0; i < 3 * N; ++i){
        cin >> a[i];
    }
    
    sort(a.begin(), a.end(), greater<int>());
    
    ll ans = 0;
    
    for(int i = 1; i < 2 * N; i += 2){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
N = int(input())
S =[input() for _ in range(N)]
M= int(input())
T =[input() for _ in range(M)]

counts = []
for si in S:
    count = 0
    for s in S:
        if s == si:
            count+=1
    for t in T:
        if t == si:
            count -=1
    counts.append(count)

max_count = max(counts)
if max_count < 0:
    print(0)
else:
    print(max_count)



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

int main () {
    string r,g,b;
    cin >> r >> g >> b;
    string ns = "";
    ns += r;
    ns += g;
    ns += b;
    int n = atoi(ns.c_str());
    if (n%4 == 0) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}


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

using namespace std;

int main(void)
{
	string s; cin>>s;
	char ans[20];
	int w = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != 'B'){
			ans[w] = s[i];
			w++;
		}
		else if(w > 0) w--;
	}
	for(int i = 0; i <w; i++){
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>

int main() {
	int A, B;
	int C = 0;

	std::cin >> A;
	std::cin >> B;

	for (int i = 0; i < 2; i++) {
		if (A >= B) {
			C += A;
			A--;
		}
		else {
			C += B;
			B--;
		}
	}

	std::cout << C << std::endl;

}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

vector<ll> make_groups(ll N, vector<ll> A)
{
    vector<ll> ret;
    for(ll i=0;i<N;i++)
    {
        ll add = 0;
        for(ll& j=i;j<N;j++)
        {
            if(A[j]==0)
            {
                break;
            }
            add += A[j];
        }
        ret.push_back(add);
    }
    return ret;
}

ll Ans(vector<ll> groups)
{
    ll ret = 0;
    for(auto x : groups)
    {
        ret += x/2;
    }
    return ret;
}

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

    vector<ll> A(N);
    ALLIN1_NUMBER(A);

    OUT0(Ans(make_groups(N,A)));

    return 0;
}

Measured memory_bytes: 5880
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int n;cin >> n;
    REP(i,n){
        string s,t;cin >> s >> t;
        int slen=s.length();int tlen=t.length();
        vector<vector<int>> lcm(slen+1,vector<int>(tlen+1,0));
        REP(i,s.length())REP(j,t.length()){
            if(s[i]==t[j]){
                lcm[i+1][j+1]=max({lcm[i][j+1],lcm[i+1][j],lcm[i][j]+1});
            }
            lcm[i+1][j+1]=max({lcm[i+1][j+1],lcm[i+1][j],lcm[i][j+1]});
        }
        cout << lcm[slen][tlen] << endl;
    }

}


Measured memory_bytes: 6864
#include <stdio.h>


int main () {
    int N;  
	scanf("%d", &N);
    char str[N + 1];
    scanf("%s", str);
    if (N % 2 == 1) {
        printf("No");
    }
    else {
        int flag = 1;
        for (int i = 0; i < N / 2; i++){
            if (str[i] != str[i + N / 2]){
                flag = 0;
            }
        }
        if (flag){
            printf("Yes");
        }
        else {
            printf("No");
        }
    }
    return 0;
}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX/2 + 2], R[MAX/2 + 2];

llong merge(int A[], int left, int mid, int right)
{
    int i, j, k;
    llong cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid ;
    for (i = 0; i < n1; i++) L[i] = A[left + i];
    for (i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i  = j = 0;
    for (k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

llong mergeSort(int A[], int left, int right)
{
    int mid;
    llong v1, v2, v3;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, left, mid);
        v2 = mergeSort(A, mid, right);
        v3 = merge(A, left, mid, right);
        return v1 + v2 + v3;
    } else {
        return 0;
    }
}


int main(int argc, char const *argv[])
{
    int A[MAX], n, i;

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

    llong ans = mergeSort(A, 0, n);
    cout << ans << endl;

    return 0;
}




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


int main(){
    int64_t N,M,K,maxbook,sumAB=0,countA=0,countB=0;
    bool limitA=false,limitB=false;
    cin>>N>>M>>K;
    vector<int64_t> A(N),B(M);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        if(!limitA&&sumAB<=K-A.at(i)){
            countA++;
            sumAB+=A.at(i);
        }
        else{
            limitA=true;
        }
    }
    for(int i=0;i<M;i++){
        cin>>B.at(i);
        if(!limitB&&sumAB<=K-B.at(i)){
            countB++;
            sumAB+=B.at(i);
        }
        else{
            limitB=true;
        }
    }
    maxbook=countA+countB;
    while(countA>0&&countB<M){
        countA--;
        sumAB-=A.at(countA);
        while(countB<M&&K-sumAB>=B.at(countB)){
            sumAB+=B.at(countB);
            countB++;
        }
        maxbook=max(maxbook,countA+countB);
    }
    cout<<maxbook<<endl;
}


Measured memory_bytes: 6380
A,B,C=map(int,input().split())
K = int(input())

count = 0

for i in range(7):
    if A >= B:
        B = B*2
        count = count +1
    else:
        break

for j in range(7):
    if B >= C:
        C =C*2
        count = count+1
    else:
        break

#print(A,B,C)
#print(count)

if K >= count:
    print("Yes")
else:
    print("No")

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

int main() {
  int X, y = 0, z = 0, ans = 0;
  cin >> X;
  
  if (X/500 > 0) {
    y = X/500;
    ans += y*1000;
  }
  z = X - y*500;
  if (z/5 > 0) {
    z = z/5;
    ans += z*5;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9 + 7;
int main()
{
    string S; cin >> S;
    int x = 0;
    for (char c : S) {
        if (x == 0 && c == 'C') x = 1;
        if (x == 1 && c == 'F') x = 2;
    }
    cout << (x == 2 ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N,W,H,ans = 1,dp[HMAX][WMAX];
string S;
vector<char > v;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (int i = 0; i < S.size(); ++i)
	{
		if(find(v.begin(), v.end(),S[i]) != v.end()){
			ans = 0;
			return;
		}else{
			v.push_back(S[i]);
		}
	}
}

void debug(){

}

void answer(){
	if (ans)
	{
		cout << "yes\n";
	}else{
		cout << "no\n";
	}
}

int main(){
	cin >> S;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, a;
    cin >> n >> a;

    cout << n * n - a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#define pi 3.14159265358979

using namespace std;

int main(void) {
	double a,b,c,h,C;
	cin >> a >> b >> C;
	c = sqrt(a*a+b*b-2*a*b*cos(pi*C/180));
	h = b*sin(pi*(180-C)/180);
	cout << setprecision(20) << fixed << a*h/2 << endl;
	cout << setprecision(20) << fixed << a+b+c << endl;
	cout << setprecision(20) << fixed << h << endl;
	return 0;
}



Measured memory_bytes: 3636
from sys import exit, setrecursionlimit, stdin, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *
import operator
import math
from fractions import gcd
from random import randint

setrecursionlimit(10**8)

def input():
  return stdin.readline().strip()

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

S = read()
if S == 10**18:
  print(0, 0, 10**9, 0, 0, 10**9)
  exit()
  
y = (-S) % 10**9
z = 1
x = 10**9
assert (S + y) % 10**9 == 0
w = (S + y) // 10**9

print(0, 0, x, y, z, w)


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

signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int ans = 1;
    int mode = 0;
    for (int i = 0; i < N - 1; i++) {
        if (mode == 0) {
            if (A[i] < A[i + 1]) {
                mode = 1;
            } else if (A[i] > A[i + 1]) {
                mode = 2;
            }
        } else if (mode == 1) {
            if (A[i] > A[i + 1]) {
                mode = 0;
                ++ans;
            }
        } else if (mode == 2) {
            if (A[i] < A[i + 1]) {
                mode = 0;
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a=0;
	string s;
	cin>>s;
	if(s=="RRR")
	cout<<"3";
	else if(s=="RRS"||s=="SRR")
	cout<<"2";
	else if(s=="SSS")
	cout<<"0";
	else
	cout<<"1";
	return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedHashMap;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		Integer N = sc.nextInt(); // 参加者の数
		Integer K = sc.nextInt(); // 初期ポイント
		Integer Q = sc.nextInt(); // 正解した数
		LinkedHashMap<Integer, Integer> score = new LinkedHashMap<Integer, Integer>();
		// 初期の点数をセット
		for (int i = 0; i < N; i++) {
			score.put(i, K);
		}
		for (int i = 0; i < Q; i++) {
			Integer winner = sc.nextInt() - 1;
			score.put(winner, score.get(winner) + 1);
		}
		for (int i : score.values()) {
			pw.println(i <= Q ? "No" : "Yes");
		}
		pw.flush();
	}

}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 34872
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;

int main() {
	int card[100005];
	int  n;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> card[i];

	sort(card, card + n);
	int k=0;
	for (int i = 0;i < n - 1;i++) {
		if (card[i] == card[i + 1])k++;
	}
	k = (k + 1) / 2;
	k *= 2;
	cout << n - k << endl;
	return 0;
}

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

int main(){

    int A;
    int B;
    int C;
    int K;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&K);

    int res,minus=0;
    
    int a,b,c;
    if(K>A){
        a = A;
    }else{
    	a = K;
    }

    K = K-A;
    res = 1*a;
    
    if(K>0){
       K = K-B;
       res = res + 0*K;
       

    }
    if(K>0){
    	
    	minus = K*-1;
    }
    

    res = res + minus;

    	
   	printf("%d\n",res);

    return 0;

}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve(long long N, std::vector<long long> L){
    ll cnt=0;
    SORT(L);
    for (ll i = 0; i < N; i++) {
        for (ll j = i + 1; j < N; j++) {
            for (ll k = j + 1; k < N; k++) {
                if ((L[i] < L[j] + L[k]) && (L[j] < L[k] + L[i]) && (L[k] < L[i] + L[j])){
                    cnt++;
                }else{break;}
            }
        }
    }
    cout << cnt << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define rep1(i,n) for(int i=1;i<=((int)n);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=1000005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;

		b>>=1;
	}
	return res;
}


int main()
{
	//IOS;
    int x,y,z,k;
    while(cin>>x>>y>>z>>k)
    {
        priority_queue<ll> p;
        vector<ll> a(x),b(y),c(z);
        rep(i,x) cin>>a[i]; sort(ALL(a),greater<ll>());
        rep(i,y) cin>>b[i]; sort(ALL(b),greater<ll>());
        rep(i,z) cin>>c[i]; sort(ALL(c),greater<ll>());
        rep(i,x)
        {
            rep(j,y)
            {
                if((i+1)*(j+1)>k) break;
                rep(q,z)
                {
                    if((i+1)*(j+1)*(q+1)>k) break;
                    p.push(a[i]+b[j]+c[q]);
                }
            }
        }
        while(k--)
        {
            cout<<p.top()<<"\n";
            p.pop();
        }
    }
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

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

        int i=1;
        int arg=X;
        while(1){
                if(arg%360==0) break;
                arg += X;
                i++;
        }
        cout << i << endl;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long H = sc.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];
		long amax = -1;
		for(int i=0; i<N; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
			amax = Math.max(amax, a[i]);
		}
		Arrays.sort(b);
		long ans = 0;
		for(int i=N-1; i>=0; i--) {
			if(amax<b[i]) {
				H -= b[i]; ans++;
			} else {
				H -= amax; ans++;
			}
			if(H<=0) {
				System.out.println(ans);
				return;
			}
		}
		if(H%amax==0) {
			System.out.println(ans+H/amax);
		} else {
			System.out.println(ans+H/amax+1);
		}
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 78312
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0; i<(n); ++i)
typedef long long ll;
using namespace std;

int main(){

  int n;
  cin >> n;
  string s;
  cin >> s;

  ll r, g, b;
  r = g = b = 0;

  rep(i,n){
    if(s[i] == 'R') ++r;
    if(s[i] == 'G') ++g;
    if(s[i] == 'B') ++b;
  }

  ll ans = r*g*b;

  for(int wide=1; 2*wide < n; ++wide){
    for(int i=0; i + 2*wide < n; ++i){
      if(s[i] != s[i + wide] 
	 && s[i + wide] != s[i + 2*wide] 
	 && s[i + 2*wide] != s[i]){
	--ans;
      } 
    }
  }

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


Measured memory_bytes: 3612
def read_input():
    n = int(input())
    tlist = []
    for i in range(n):
        tlist.append(int(input()))

    return n, tlist


def mygcd(a, b):
    if b == 0:
        return a
    return mygcd(b, a % b)


def mylcm(a, b):
    g = mygcd(a, b)
    return a * b // g


def submit():
    n, tlist = read_input()

    acc = 1
    for t in tlist:
        acc = mylcm(acc, t)

    print(acc)


if __name__ == '__main__':
    submit()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
//12月30日のM時から次の年になるまでは何時間か、求めてください。
//1 ≦ M ≦ 23

//年明けは1/1 0:00
//12/30 16:00 なら　24-16 + 24 = 32
//12/30 21:00 なら　24-21 + 24 = 27

int main() {
  int M;
  cin >> M ;  //入力を受け取る
  cout << (24 - M) + 24 << endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans_t = T

for i in range(1, N):
    if t[i] <= t[i - 1] + T:
        ans_t = ans_t - t[i - 1] + t[i]
    else:
        ans_t += T

print(ans_t)

Measured memory_bytes: 85328
N = int(input())
A = [0]
A += [int(input()) for _ in range(N)]

p = A[1]
count = 1
while True:
    if count == N+1:
        print('-1')
        break
    if p == 2:
        print(count)
        break
    p = A[p]
    count += 1

Measured memory_bytes: 7852
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        int n;
        cin>>n;
        cout<<n*(n+1)/2;
    }
    RETURN;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FIntervalRunning {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        vc<lint> T(2), A(2), B(2), L(2);
        REP(i, 2) in>>T[i];
        REP(i, 2) in>>A[i];
        REP(i, 2) in>>B[i];
        L[0] = T[0] * A[0] + T[1] * A[1];
        L[1] = T[0] * B[0] + T[1] * B[1];
        if(L[0]==L[1]){
            out<<"infinity\n";
            return;
        }
        if(L[0]<L[1]){
            swap(A[0], B[0]);
            swap(A[1], B[1]);
            swap(L[0], L[1]);
        }
        if(A[0]>=B[0]){
            out<<"0\n";
            return;
        }
        lint left = T[0] * (B[0]-A[0]) / (L[0]-L[1]);
        lint ans = 2 * left + 1, dif = left * (L[0]-L[1]);
        if(dif==T[0]*(B[0]-A[0])) --ans;
        out<<ans<<'\n';
    }
};


int main() {
	FIntervalRunning solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	if (n == 22) cout << "Christmas Eve Eve Eve" << endl;
	else if (n == 23) cout << "Christmas Eve Eve" << endl;
	else if (n == 24) cout << "Christmas Eve" << endl;
	else if (n == 25) cout << "Christmas" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	long long n,a[200];
	while(~scanf("%lld",&n)){
		a[0]=2;
		a[1]=1;
		for(int i=2;i<=n;i++){
			a[i]=a[i-1]+a[i-2];
		}
		printf("%lld\n",a[n]);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N,K;
  cin>>N>>K;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  sort(H.begin(),H.end());
  int64_t sum=0;
  for(int i=0;i<N-K;i++){
    sum+=H[i];
  }
  cout<<sum<<endl;
  return 0;
}

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

int main(){
string s; cin >> s;
int llen=s.length();
int len=s.length()/2;
int ans=0;
rep(i,len){
    if(s[i] != s[llen-i-1]) ans++;
}
cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

int main()
{
	int N = 0, ans = 0;
	std::cin >> N;

	std::vector<int> A(N), B(N + 1);

	for (int i = 0; i < N - 1; i++)
	{
		int a = 0;
		std::cin >> a;
		B[i + 1] = a;
 	}
	B[0] = B[1];
	B[N] = B[N-1];

	
	for (int i = 0; i < N; i++)
	{
		//std::cout << B[i] <<", "<< B[i-1] << std::endl;
		A[i] = (B[i] <= B[i+1])? B[i]: B[i+1];
	}

	for (int i = 0; i < N; i++){
		//std::cout << A[i] << std::endl;
		ans += A[i];
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S1, S2;
	cin >> S1 >> S2;

	reverse(S2.begin(), S2.end());

	if (S1 == S2)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
bool pl(char a[]){
	for(int i=0;i<strlen(a);i++)if(a[i]!=a[strlen(a)-i-1])return false;
	return true;
}
int main(){
	char a[10050];
	scanf("%s",a);
	char p1[5030],p2[5030];
	int q=(strlen(a)-1)/2;
	for(int i=0;i<q;i++)p1[i]=a[i];
	for(int i=q+1;i<strlen(a);i++)p2[i-q-1]=a[i];
	if(pl(a)&&pl(p1)&&pl(p2))cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long num = 1, HP = N, ans = 0;
  while(HP != 1){
    ans += num;
    if(HP % 2 == 0){
      HP = (HP / 2);
    } else {
      HP = (HP - 1) / 2;
    }
    num *= 2;
  }
  cout << ans + num << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(998244353)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
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;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (s.size() % 2 == 0) {
		Yes(s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size() / 2));
	}
	else cout << "No" << endl;
	return 0;
}

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;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll h,w,m;
	cin >> h >> w >> m;
	vector<ll> mpw(w);
	vector<ll> mph(h);
	map<pair<int,int>,int> mp;
	rep(i,m){
		ll a,b;
		cin >> a >> b;
		a--;
		b--;
		mph[a]++;
		mpw[b]++;
		mp[make_pair(a,b)]++;
	}
	ll ans = 0;
	vector<int> idh;
	rep(i,h) {
		if(ans <= mph[i]){
			ans = max(ans, mph[i]);
			idh.push_back(i);
		}
	}
	vector<int> idh2;
	rep(i,idh.size()){
		if(mph[idh[i]] == ans){
			idh2.push_back(idh[i]);
		}
	}
	ll ans2 = 0;
	vector<int> idw;
	rep(i,w) {
		if(ans2 <= mpw[i]){
			ans2 = max(ans2, mpw[i]);
			idw.push_back(i);
		}
	}
	vector<int> idw2;
	rep(i,idw.size()){
		if(mpw[idw[i]] == ans2){
			idw2.push_back(idw[i]);
		}
	}
	ans += ans2;
	bool flag = false;
	rep(i,idh2.size()){
		rep(j, idw2.size()){
			if(mp[make_pair(idh2[i], idw2[j])] == 0) {
				flag = true;
				break;
			}
		}
	}
	if(!flag) ans--;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 50144
#include<stdio.h>
#include<bits/stdc++.h>
#define f(a,b,c) for(register int a=(b);a<=(c);++a)
#define ff(a,b,c) for(register int a=(b);a>=(c);--a)
#define ll long long
char pbuf[1<<20],*pp1=pbuf;
inline void push(char c){*pp1=c;pp1=(pp1-pbuf==(1<<20)-1)?(fwrite(pbuf,1,1<<20,stdout),pbuf):(pp1+1);}
#define pc push
//#define pc putchar
#define pe pc('\n')
#define ps pc(' ')
#define wer rd()
char *p1,*p2,buf[1<<20];
#define GC (p1==p2&&(p1=buf,p2=buf+fread(buf,1,1<<20,stdin),p1==p2)?0:(*(p1++)))
//#define GC getchar()
using namespace std;
inline ll wer{
	ll ans;char t,k;
	while(((t=GC)!='-')&&(t>'9'||t<'0'));
	k=(t=='-');
	ans=k?0:(t-'0');
	while((t=GC)>='0'&&t<='9')ans=ans*10+t-'0';
	return k?-ans:ans;
}
inline void wt(ll k)
{
	if(k<0)pc('-'),wt(-k);
	else
	{
		if(k<10)pc('0'+k);
		else wt(k/10),pc('0'+k%10);
	}
	return;
}
pair<int,int>a[200001];
priority_queue<int>q;
int n,m;
vector<int>v;
int main()
{
	scanf("%d%d",&n,&m);
	f(i,1,n)scanf("%d%d",&a[i].first,&a[i].second);
	sort(a+1,a+n+1,[&](pair<int,int>a,pair<int,int>b)
	{
		if(a.first==b.first)return a.second>b.second;
		return a.first<b.first;
	});
	int le=1,ri=m;
	f(i,1,n)
	{
		if(le>a[i].first)
		{
			if(q.size()&&q.top()<a[i].second)
			{
				int t=q.top();
				q.pop();
				v.push_back(t);
			}
			else v.push_back(a[i].second);
		}
		else le++;
	}
	int Ans=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int a:v)
	{
		if(ri<a||le>ri)Ans++;
		else ri--;
	}
	cout<<Ans;
}

Measured memory_bytes: 2936
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      string s[3];
      rep(i,3)cin >> s[i];
      rep(i,3) cout << s[i][i];
      cout << endl;
      return 0;}

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

int main() {
	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else  cout << "ABC" << endl;
	return 0;
}


Measured memory_bytes: 3572
N, M = map(int, input().split())
XY = [list(map(int, input().split())) for i in range(M)]

redded = [False] * (N+1)
redded[1] = True
boll_num = [1] * (N+1)

for x, y in XY:
    if redded[x]:
        redded[y] = True
    boll_num[y] += 1
    boll_num[x] -= 1
    if boll_num[x] == 0:
        redded[x] = False

ans = 0
for r, b in zip(redded, boll_num):
    if r and b:
        ans += 1
print(ans)


Measured memory_bytes: 28964
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 1e18;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, q;
  cin >> a >> b >> q;
  vector<int> s(a + 2), t(b + 2), x(q);

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

  for (int i = 1; i <= b; i++) {
    int x;
    cin >> x;
    t[i] = x;
  }
  s[0] = t[0] = -1 * inf;
  s[a + 1] = t[b + 1] = inf;
  for (auto &&w : x) {
    cin >> w;
  }
  //   sort(s.begin(), s.end());
  //   sort(t.begin(), t.end());

  for (auto &&w : x) {
    int res = inf;
    int ls = lower_bound(s.begin(), s.end(), w) - s.begin();
    int lt = lower_bound(t.begin(), t.end(), w) - t.begin();
    for (int is : {ls - 1, ls})
      for (int it : {lt - 1, lt}) {
        res = min(res, abs(w - s[is]) + abs(s[is] - t[it]));
        res = min(res, abs(w - t[it]) + abs(s[is] - t[it]));
      }
    cout << res << endl;
  }
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

map< int, int > prime_factor(int n) {
	map< int, int > ret;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}


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

	// long long?
	ll N;
	cin >> N;

	int cnt = 0;
	rep(i, N+1) {
		if (i % 2 == 0) continue;

		map<int, int> mDec = prime_factor(i);
		int num = 1;
		for(map<int, int>::iterator it = mDec.begin(); it != mDec.end(); ++it) {
			num *= (it->second+1);
		}

		if (num == 8) {
			cnt++;
		}

	}


	cout << cnt<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int b[10];
 
bool good(int n){
	while(n){
		if(b[n%10])	return false;
		n/=10;
	}
	return true;
}
 
int main(){
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=k;i++){
		int val;
		cin >> val;
		b[val]=1;
	}
	while(!good(n))	n++;
	cout << n << endl;
	return 0;
}

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

int main() {
    vector<int> x(5);
    rep(i,5){
        cin >> x.at(i);
        if(x.at(i)==0) cout << i+1 << endl;
    }
}


Measured memory_bytes: 3624