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

int main() {
  int N; cin >> N;
  int A[N], B[N], C[N-1];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N-1; i++) cin >> C[i];
  int sat = 0, prevDish = -1;
  for (int i = 0; i < N; i++) {
    sat += B[A[i]-1];
    if (prevDish + 1 == A[i]) {
      sat += C[prevDish - 1];
    }
    prevDish = A[i];
  }
  cout << sat << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long a,b,n,r,g=1,ans;
vector <long long> d;
int main()
{
	cin>>a>>b;

	n=__gcd(a,b),r=sqrtl(n);
	for(int i=1;i<=r;i++)
		if(n%i==0)
			d.push_back(i),d.push_back(n/i);
	if(r*r==n) d.pop_back();
	sort(d.begin(),d.end());

	for(auto i:d)
	{
		if(__gcd(g,i)!=1) continue;
		g=g*i;
		ans++;
	}
	cout<<ans;
}

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

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    int m, f, r;
    while(cin >> m >> f >> r)
    {
        if(m == -1 && f == -1 && r == -1)   break;
        if(m == -1 || f == -1)
            cout << "F" << endl;
        else if(m + f >= 80)
            cout << "A" << endl;
        else if(m + f >= 65)
            cout << "B" << endl;
        else if(m + f >= 50 || (m + f >= 30 && r >= 50))
            cout << "C" << endl;
        else if(m + f >= 30)
            cout << "D" << endl;
        else
            cout << "F" << endl;
    }

    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int a,b;
	cin >> a >> b;
	int n;
	if(b <= 9) n = 10 * a + b;
	else if(b == 100) n = 1000 * a + b;
	else n = 100 * a + b;
	for(int i = 1; i <= 333; i++){
		if(i * i == n){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    for k in range(j + 1, n):
      S = [L[i], L[j], L[k]]
      S.sort()
      if S[2] < S[0] + S[1] and (S[0] != S[1] and S[1] != S[2] and S[2] != S[0]):
        ans += 1

print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 2e5 + 5;
int n, a[N], rmq[N][20], logy[N];
int getmin(int l, int r) {
	int tmp = logy[r - l + 1];
	return min(rmq[l][tmp], rmq[r - (1 << tmp) + 1][tmp]);
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) cin >> a[i], rmq[i][0] = a[i];
	fw (j, 1, 20) fw (i, 0, n) if (i + (1 << (j - 1)) < n)
		rmq[i][j] = min(rmq[i][j - 1], rmq[i + (1 << (j - 1))][j - 1]);
	fw (i, 0, N) logy[i] = log2(i);
	int ans = 0;
	fw (i, 0, n) {
		//Count segments [l...r] that a[i] is the minimum.
		int bl, br;
		int l = 0, r = i;
		while (l < r) {
			int m = (l + r) >> 1;
			if (getmin(m, i) >= a[i]) r = m;
			else l = m + 1;
		}
		bl = l;
		l = i, r = n - 1;
		while (l < r) {
			int m = (l + r) >> 1;
			if (getmin(i, m + 1) >= a[i]) l = m + 1;
			else r = m;
		}
		br = l;
		//All segments within [bl...br] is now valid.
		int cnt = (i - bl + 1) * (br - i + 1);
		ans += cnt * a[i];
	}
	cout << ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

ll h,w;
vector<vll> dp(105,vll(105,1e+16));

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
   
  cin >> h >> w;
  vector<string> s(h);
  rep(i,0,h) cin >> s[i];
   
  if(s[0][0]=='#') dp[0][0]=1;
  else dp[0][0]=0;
  
  rep(i,0,h){
   rep(j,0,w){
    if(j+1<w) {
     if(s[i][j+1]=='#'&&s[i][j]=='.') dp[i][j+1]=min(dp[i][j+1], dp[i][j]+1);
     else  dp[i][j+1]=min(dp[i][j+1], dp[i][j]);
    }
    if(i+1<h) {
     if(s[i+1][j]=='#'&&s[i][j]=='.') dp[i+1][j]=min(dp[i+1][j], dp[i][j]+1);
     else  dp[i+1][j]=min(dp[i+1][j], dp[i][j]);
    } 
     
   }
  }
 
  cout << dp[h-1][w-1] << endl;
  
}

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

int main() {
    int n;
    int a[200010];
    int count = 1;
    int ans = 0;
    
    cin >> n;
    rep(i, n) cin >> a[i];
    
    rep(i, n){
        if(count == a[i]){
            count++;
        } else{
            ans++;
        }
    }
    
    if(count == 1) ans = -1;
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
ai = list(map(int,input().split()))

even = []

for i in ai:
    if i%2 == 0:
        even.append(i)

ok = 0
for i in even:
    if i%3==0 or i%5==0:
        ok += 1

if len(even) == ok:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 61780
l = [int(input()) for _ in range(5)]
r = [10 if i % 10 == 0 else i %  10 for i in l]
m = [i  if i % 10 == 0 else i // 10 * 10 + 10 for i in l]
print(sum(m) + min(r) - 10)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string Input;
    cin >> Input;
    int N=0;
    int i;
    for(i=0; i<Input.length(); i++){
        if(Input.at(i)=='0'+i%2){
            N++;
        }
    }
    cout << min(N, i-N);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>n;
    int l;
    cin>l;
    if(l<=0 && 0<=l+n-1){
        dprint("Yay");
        cout<(2*l+n-1)*(n)/2<endl;
    }else if(l>0){
        dprint("Yay2");
        cout<(2*l+n-1)*(n)/2-l<endl;
    }else{
        dprint("Yay3");
        cout<(2*l+n-1)*(n)/2-(l+n-1)<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import heapq
from collections import defaultdict

n=int(input())
a=[int(input()) for _ in range(n)]
minus_a=[-item for item in a]

dd = defaultdict(int)
for key in a:
    dd[key] += 1

heapq.heapify(minus_a)
max1=-heapq.heappop(minus_a)
max2=-heapq.heappop(minus_a)

for item in a:
  if item!=max1:
    print(max1)
  elif dd[max1]==1:
    print(max2)
  else:
    print(max1)



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

#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define ms memset
#define mp make_pair
#define f first
#define s second
#define int long long

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, pair<int, int>> piii;

#define MAXN 1010
#define MAXK 5010


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

	int T;

	cin >> T;

	cout << (T >= 30 ? "Yes": "No") << "\n";
	
	return 0;
}

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

int main( int argc, char *argv[] )
{
    int n, m;
    int k;
    int a[2*100000+1];

    scanf( "%d", &n );

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

    for( int i=1; i<n; i++ ) {
        scanf( "%d", &k );
        a[k-1] ++;
    }

    for( int i=0; i<n; i++ ) printf( "%d\n", a[i] );
}


Measured memory_bytes: 2508
#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 a, b;
    cin >> a >> b;
    if (a % b == 0) {
        cout << -1 << endl;
    }
    else cout << a << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s[0] == 'A'){
        int cnt = 0;
        rep(i, 2, s.size() - 1) if(s[i] == 'C') cnt++;
        int cnt2 = 0;
        rep(i, 0, s.size()) if('a' <= s[i] && s[i] <= 'z') cnt2++;
        if(cnt == 1 && cnt2 == s.size() - 2) cout << "AC" << endl;
        else cout << "WA" << endl;
    }else cout << "WA" << endl;
}

Measured memory_bytes: 256
import copy, sys

class Dice(object):
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, directions):
        if directions == 'E':
            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right
            return

        if directions == 'N':
            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back
            return

        if directions == 'S':
            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front
            return

        if directions == 'W':
            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left
            return

        self.roll(directions[0])
        self.roll(directions[1:])

    def equal(self, dice):
        d = copy.copy(self)

        if(dice.front == d.top):
            d.roll('S')
        elif(dice.front == d.right):
            d.roll('WS')
        elif(dice.front == d.left):
            d.roll('ES')
        elif(dice.front == d.back):
            d.roll('SS')
        elif(dice.front == d.bottom):
            d.roll('N')

        if(dice.top == d.right):
            d.roll('W')
        elif(dice.top == d.left):
            d.roll('E')
        elif(dice.top == d.bottom):
            d.roll('WW')

        return not(dice.top != d.top or dice.front != d.front or dice.right != d.right or dice.left != d.left or dice.back != d.back or dice.bottom != d.bottom)

if __name__ == '__main__':
    nums1 = [int(i) for i in input().split()]
    nums2 = [int(i) for i in input().split()]
    if set(nums1) != set(nums2):
        print('No')
        sys.exit()

    d1 = Dice(nums1)
    d2 = Dice(nums2)
    if d1.equal(d2):
        print('Yes')
    else:
        print("No")

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

int main(){
    string S, T;
    int A, B;
    string U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (U==S) {
        A -= 1;
    }
    else {
        B -= 1;
    }
    
    std::cout << A << " " << B << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from math import ceil, floor, gcd, sqrt
from collections import defaultdict as dd, deque, Counter as C
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
dp = dd(int)
i = 2
while i * i <= n:
    while n % i == 0:
        dp[i] += 1
        n //= i
    i += 1
if n > 1:
    dp[n] = 1
answer = 0
for i in dp.keys():
    temp = floor((-1 + sqrt(8 * dp[i] + 1)) / 2)
    answer += temp
out(answer)


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

int main()
{
    int a[33];
    a[1]=1;
    a[2]=1;
    a[3]=1;
    a[4]=2;
    a[5]=1;
    a[6]=2;
    a[7]=1;
    a[8]=5;
    a[9]=2;
    a[10]=2;
    a[11]=1;
    a[12]=5;
    a[13]=1;
    a[14]=2;
    a[15]=1;
    a[16]=14;
    a[17]=1;
    a[18]=5;
    a[19]=1;
    a[20]=5;
    a[21]=2;
    a[22]=2;
    a[23]=1;
    a[24]=15;
    a[25]=2;
    a[26]=2;
    a[27]=5;
    a[28]=4;
    a[29]=1;
    a[30]=4;
    a[31]=1;
    a[32]=51;
    int n;
    cin>>n;
    cout<<a[n];
    return 0;
}

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

vector<int> elements;
vector<vector<int> > records;

int play(int total){
   
    for(int stones = 0; stones <= total; stones++){
        for(int player = 0; player < 2; player++){
            int win = false;
            int competiter = player ^ 1;
            for(int i = 0; i < (int)elements.size(); i++){
                if(stones < elements[i])
                    continue;

                if(records[stones-elements[i]][competiter] == 0)
                    win = true;
            }

            if(win)
                records[stones][player] = 1;

            //cout << "stones=" << stones << " player=" << player << " result=" << records[stones][player] << "\n";

        }
    }

    return records[total][0];
}

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

    elements = vector<int>(n);
    records = vector<vector<int> >(k+1, vector<int>(2, 0));

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

    int result = play(k);

    if(result == 1)
        cout << "First";
    else
        cout << "Second";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int x;
	std::cin >> x;
	std::cout << (!x) << std::endl;
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int maxx(vector<int> even){
  int emax = (max_element(even.begin(), even.end()) - even.begin()); //最頻値の値
  int emaxnum = even[emax]; //最頻値の級数
  return emax;
}
int maxnum(vector<int> even){
  int emax = (max_element(even.begin(), even.end()) - even.begin()); //最頻値の値
  int emaxnum = even[emax]; //最頻値の級数
  return emaxnum;
}
  
int main(){
  int nn;
  cin >> nn;
  int n = nn / 2;
  vector<int> even(100001);
  vector<int> odd(100001);
  for(int i = 0;i < n;i++){
    int e,o;
    cin >> e >> o;
    even[e]++;
    odd[o]++;
  }
  int emax = maxx(even);
  int emaxnum = maxnum(even);
  int omax = maxx(odd);
  int omaxnum = maxnum(odd);
  
  if(emax == omax){ //値が同じなら級数が小さいほうを変える
    if(emaxnum < omaxnum){
      even[emax] = 0;
      emax = maxx(even);
      emaxnum = maxnum(even); //二番目に最頻値の級数
    }else if(emaxnum > omaxnum){
      odd[omax] = 0;
      omax = maxx(odd);
      omaxnum = maxnum(odd);
    }else{
      odd[omax] = 0;
      even[emax] = 0;
      int e2maxnum = maxnum(even);
      int o2maxnum = maxnum(odd);
      emaxnum = max(e2maxnum,o2maxnum);  
    }
  }
  cout << nn - emaxnum - omaxnum << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
int main(void)
{
    string s;
    int even_0_count = 0, odd_0_count = 0, l; 
    
    cin >> s;
    l = s.size();
    rep (i, l)
    {
        if (s[i] == '0')
        {
            if (i % 2 == 0)
            {
                odd_0_count++;
            }
            else
            {
                even_0_count++;
            }
        }
    }

    if (odd_0_count < ceil(double(l) / 2 ) - odd_0_count )
    {
        cout << odd_0_count +  floor(double(l) / 2 ) - even_0_count << endl;
    }
    else if (odd_0_count == ceil(double(l) / 2 ) - odd_0_count)
    {
        cout << odd_0_count +  min(even_0_count, int(floor(double(l) / 2 ) - even_0_count)) << endl;
    }
    else
    {
        cout << ceil(double(l) / 2 ) - odd_0_count + even_0_count << endl;
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

struct Combination{
    vector<long long> fac, finv, inv;
    Combination(int n=1001001):fac(n+1), finv(n+1), inv(n+1) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long operator()(int n, int k) const {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

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

    Combination C;
    mint ans = 0;
    for (int i = 1; i <= S / 3; ++i) {
        int N = S - 3 * i;
        ans += C(N+i-1, i-1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
#define int long long
using namespace std;
bool ok(char c){
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}
void solve(){
    string s;
    cin >> s;
    int ans = 0, tmp = 0;
    for(int i = 0; i < s.length(); i++){
        if(ok(s[i])){
            tmp++;
        }
        else tmp = 0;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}
main(){
    ios_base::sync_with_stdio(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
import math
n = int(input())

def fact(n, x, ans):
    if x > n:
        return ans
    else:
        ans +=  math.floor(n//(2*x))
        return fact(n, x*5, ans)

if n%2:
    print(0)
else:
    print(fact(n, 5, 0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int,int> &fir,pair<int,int> &las){
	if(fir.first<las.first)return true;
	else if(fir.first ==  las.first){
		if(fir.second < las.second)return true;
		else return false;
	}
	else return false;
}
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>> mv;
	
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		mv.push_back(make_pair(b,a));
	}
	sort(mv.begin(),mv.end(),cmp);
	int time=0;
	int sucflag=1;
	for(int i=0;i<n;i++){
		time+=mv[i].second;
		if(time>mv[i].first){
			sucflag=0;
			break;
		}
	}
	if(sucflag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 2420
def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else:
            print(nums[i])
def selectionSort(A,N):
    count=0
    for i in range(N):
        minj = i
        for j in range(i+1,N):
            if A[j] < A[minj]:
                minj = j
        if A[i]>A[minj]:
            A[i],A[minj]=A[minj],A[i]
            count+=1
    show(A)
    print(count)
N = int(input())
A = list(map(int,input().split()))
selectionSort(A,N)


Measured memory_bytes: 5612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>

typedef long long ll;

int max(int a,int b){
    if(a>b) return a;
    else return b;
}

int min(int a,int b){
    if(a<b) return a;
    else return b;
}

/*qsort(array,num_of_index,sizeof(int),compare_int); */
 int compare_int(const void *a,const void *b){
     return *(int*) a - *(int *) b; 
 } 
 
int b_search(int* array,int left,int right,int key){
    int mid = left - (right - left)/2;
     if( right - left == 1){
         if(array[mid]==key)
             return mid;
          else
               return -1;
     }
     if(array[mid]==key)
         return mid;
     else if(array[mid]>key)
         b_search(array,left,mid,key);
     else if(array[mid]<key)
         b_search(array,mid,right,key);
}

/*lower_bound(key以上のイテレータを返す)*/
 /*例えば,2,2,5,5,9でkey=2なら(2),2,5,5,9を返す*/
 int lower_bound(int  *array,int left,int right,int key){
     if(right-left==1)
         return left;
     int mid = left + (right - left)/2;
     if(array[mid]<key)
         return lower_bound(array,mid,right,key);
     else
         return lower_bound(array,left,mid,key);
 }

int main(){
    char X,Y;
    scanf("%c %c",&X,&Y);
    if(X>Y) printf(">");
    else if(X<Y) printf("<");
    else printf("=");
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl;})
#define modadd(a,b) (a + b) % (1000000007)
#define modmul(a,b) (a * b) % (1000000007)

int main(){
	cin.sync_with_stdio(0);
	
	vl in;
	ll n;
	cin >> n;
	ll l;
	FOR(i,0,n){
		cin >> l;
		in.pb(l);
	}

	ll tailsum = 0;
	ll sum = 0;

	FORD(i,0,n-1){
		tailsum = modadd(tailsum,in[i+1]);
		sum = modadd(sum,modmul(in[i], tailsum));
	}

	cout << sum << endl;
}


Measured memory_bytes: 5340
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define C(a,b) (((a)+(b)-1)/(b))

void solve(){
  long a,b,c,d;
  cin>>a>>b>>c>>d;

  // 文字のチャンクの最大長
  long L = C(max(a,b), min(a,b)+1);

  // 前半の長さ
  long l=0, r=a+b+1;
  while(r-l>1){
    long m = (l+r)/2;
    long na1 = (m/(L+1))*L + m%(L+1);
    long nb1 = m/(L+1);
    long na2 = a - na1;
    long nb2 = b - nb1;

    if((na2+1)*L > nb2) l = m;
    else r = m;

    // long sa = na1+na2;
    // long sb = nb1+nb2;
    // if(sa < a || sb > b) l = m;
    // else if(sa > a || sb < b) r = m;
    // else {
    //   assert(sa==a && sb==b);
    //   l = m;
    // }
  }
// dbg(a,b,l);
  c--;
  for(long i=c; i<min(l,d); i++){
    if(i%(L+1)==L) printf("B");
    else printf("A");
  }
  for(long i=max(l,c); i<d; i++){
    if((a+b-i)%(L+1)==0) printf("A");
    else printf("B");
  }
  printf("\n");
}

int main(){
  int q;
  cin>>q;
  rep(i,q) solve();

  return 0;
}


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

const int INF = 99999999;

int h, w;
int V;

int d[900];
bool used[900];
int cost[900][900];

void dijkstra(int s){
  fill(d, d+V, INF);
  fill(used, used + V, false);

  d[s] = 0;
  while(true){
    int v = -1;
    for(int u = 0; u < V; u++){
      if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }

    if(v == -1) break;

    used[v] = true;

    for(int u = 0; u < V; u++){
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}
 
int tov( int i, int j)
{
  return (i*w+j);
}

int main()
{ 
  while(cin>>w>>h,w!=0 && h!=0)
    {
      V = h * w;
      for(int i = 0; i < V; i++)
	for(int j = 0; j < V; j++)
	  cost[i][j] = INF;

      for(int i = 0; i < V; i++)
          cost[i][i] = 0;
      
      for(int i=0;i<2*h-1;i++)
	{
	  if(i%2==0)
	    {
	    for(int j=0;j<w-1;j++)
	      {
		int wall; 
		cin>> wall; 
		cost[tov(i/2,j)][tov(i/2,j+1)]=	cost[tov(i/2,j+1)][tov(i/2,j)]=wall?INF:1;
		
	      }
	    }
	  else

	    {
	      for(int j=0;j<w;j++)
		{
		  int wall; 
		  cin>>wall;
		  cost[tov(i/2,j)][tov(i/2+1,j)]= cost[tov(i/2+1,j)][tov(i/2,j)]=wall?INF:1;
		}

	    }
	}
      dijkstra(0);
      int len = d[tov(h-1, w-1)];
      if(len==INF) 
	len=-1;
      cout<<len+1<<"\n";
    }



  return 0; 
}

Measured memory_bytes: 4328
import java.util.*;

public class Main {
   public static void main(String[] args) {
           Scanner sc = new Scanner(System.in);
       
           int N = sc.nextInt();
           int T = sc.nextInt();
       
           int A[] = new int[N];
           
           for(int i = 0;i < N;i++){
               A[i] = sc.nextInt();
           }
           
           int max = 0;
		int maxCnt = 0;
		int min = Integer.MAX_VALUE;

		for (int i=0;i<N;i++) {
			min = Math.min(min, A[i]);
			int gain = A[i] - min;
			if (gain > max) {
				max = gain;
				maxCnt = 1;
			} else if (gain == max) {
				maxCnt++;
			}
		}

	    System.out.println(maxCnt);                                 
   
   }    
}

Measured memory_bytes: 50968
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

// [問題設定]
// それぞれ1からNまでの番号が付いたN個の頂点が、N-1本の無向辺によって繋がれたグラフが与えられる。
// 各頂点について、その頂点からスタートしてすべての頂点を訪れるための最短のステップ数を出力せよ。
//
// [解法]
// 各頂点からの最遠頂点までの距離を辺の数の2倍から引く
// 全方位木DPで解く

using T = ll; // データ型
int n; // 頂点
vector<vector<int>> tree;
vector<T> dist; // 根付き木中の i の
vector<T> ans;

void dfs1(int v, int p = -1) {
    T res = 0;
    for (auto &u : tree[v]) {
        if (u == p) continue;
        dfs1(u, v);
        res = max(res, dist[u] + 1);
    }
    dist[v] = res;
}

void dfs2(int v, T d_par, int p = -1) {
    // v における答えの計算
    ans[v] = max(d_par + 1, dist[v]);

    // 左右からの累積演算を用いて子に送る d_par の計算
    // lf[i] : [:i-1]の演算結果
    // ri[i] : [i+1:]の演算結果
    auto f = [](T a, T b) { return max(a, b); }; // 演算
    int e = -1; // 演算の単位元
    vector<T> lf(tree[v].size(), e), ri(tree[v].size(), e); // 累積配列
    for (int i = 1; i < tree[v].size(); i++) {
        if (tree[v][i - 1] == p) lf[i] = f(d_par, lf[i - 1]);
        else lf[i] = f(dist[tree[v][i - 1]], lf[i - 1]);
    }
    for (int i = tree[v].size() - 2; i >= 0; i--) {
        if (tree[v][i + 1] == p) ri[i] = f(d_par, ri[i + 1]);
        else ri[i] = f(dist[tree[v][i + 1]], ri[i + 1]);
    }
    for (int i = 0; i < tree[v].size(); i++) {
        if (tree[v][i] == p) continue;
        dfs2(tree[v][i], f(lf[i], ri[i]) + 1, v);
    }
}

int main() {
    cin >> n;
    tree.resize(n);
    dist.resize(n);
    ans.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    dfs1(0);
    dfs2(0, 0);
    for (int i = 0; i < n; i++) {
        cout << 2 * (n - 1) - ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 23800
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B,T;
    cin >> A >> B >> T;
    cout << B * (T/A)<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

int main(void)
{

	int n, d, x;
	cin >> n >> d >> x;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;

		x += (d - 1) / a + 1;

	}

	cout << x << endl;

	return 0;
}


Measured memory_bytes: 256
<?php

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $a, $b);
echo $a * $b, PHP_EOL;



Measured memory_bytes: 16028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  int A;
  A = 0;
  for ( int i = 0 ; i < S.size() ; i++ ) {
    if ( S.at(i) != T.at(i) ) {
      A = A + 1;
    }
    else {
    }
  }
  if ( A == 0 ) {
    cout << "Yes" << endl;
  }
  else { 
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
while True:
    card_num = int(input())
    if(card_num == 0):
        break
    a = 0
    b = 0
    for i in range(card_num):
        comp = input()
        if(int(comp[0]) == int(comp[2])):
            a += int(comp[0])
            b += int(comp[0])
        elif(int(comp[0]) > int(comp[2])):
            a += int(comp[0]) + int(comp[2])
        elif(int(comp[0]) < int(comp[2])):
            b += int(comp[0]) + int(comp[2])
    print(str(a)+' '+ str(b))

Measured memory_bytes: 7548
x = int(input())

if 400<=x<=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
elif 1800<=x<=1999:
    print(1)

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

using namespace std;

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

    vector<vector<long long>> a(N, vector<long long>(N));
    for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
        cin>>a[i][j];

    long long M = 1000000007LL;

    auto mul = [&](vector<vector<long long>> a, vector<vector<long long>> b)
    {
        vector<vector<long long>> c(N, vector<long long>(N));
        for (int i=0; i<N; i++)
        for (int j=0; j<N; j++)
            for (int k=0; k<N; k++)
                c[i][j] += a[i][k] * b[k][j],
                c[i][j] %= M;
        return c;
    };

    vector<vector<long long>> b(N, vector<long long>(N));
    for (int i=0; i<N; i++)
        b[i][i] = 1;

    for (; K>0; K/=2)
    {
        if (K%2!=0)
            b = mul(b, a);
        a = mul(a, a);
    }

    long long ans = 0;
    for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
        ans += b[i][j],
        ans %= M;

    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<string> cand = {"maerd", "remaerd", "esare", "resare"};
    for(ll i = 0; i < s.size(); ){
        bool a = false;
        for(ll j = 0; j < 4; j++){
            string t = s.substr(i,cand[j].size());
            if(t == cand[j]){
                i += cand[j].size();
                a = true;
                continue;
            }
        }
        if(!a){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main(){
    string t, h;
    int n, i, a, b;
    a = b = 0;
    
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> t >> h;
        if(t == h){
            a = a + 1;
            b = b + 1;
        }
        else if(t < h) b = b + 3;
        else if(t > h) a = a + 3;
    }
    
    cout << a << " " << b << endl;
}



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


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

    ll n;
    cin>>n;
    if(n==1){
        cout << 0 << endl;
        return 0;
    }
    ll x[n],y[n];
    ll pma=0,pmi=0;
    ll ma=0,mi=1e18;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        if(x[i] > y[i]) swap(x[i],y[i]);
        if(ma < max(x[i],y[i])){
            ma = max(x[i],y[i]);
            pma = i;
        }
        if(mi > min(x[i],y[i])){
            mi = min(x[i],y[i]);
            pmi = i;
        }
        if(ma == max(x[i],y[i]) && pmi==pma){
            pma = i;
        }
        if(mi == min(x[i],y[i]) && pmi == pma){
            pmi = i;
        }
    }
    ll ans = 1e18;
    ll l=1e18,r=0;
    for(int i=0;i<n;i++){
        if(i==pmi && i==pma);
        else if(i==pma) r = max(r,min(x[i],y[i]));
        else if(i==pmi) l = min(l,max(x[i],y[i]));
        else {
            r = max(r, min(x[i],y[i]));
            l = min(l, max(x[i],y[i]));
        }
    }
    ans = (ma - l) * (r - mi);
    if(pmi != pma){
        ll dif = ma - mi;
        array<ll,2> a[n];
        multiset<ll> st;
        for(int i=0;i<n;i++){
            a[i] = {x[i],i};
            st.insert(x[i]);
        }
        sort(a,a+n);
        st.insert(y[a[0][1]]);
        auto itr = st.begin();
        auto h = itr;
        h++;
        st.erase(itr,h);
        itr =  st.end();
        itr--;
        ma = *itr;
        ans = min(ans, dif * (ma - *st.begin()));
        for(int i=1;i<n;i++){
            auto t = st.lower_bound(a[i][0]);
            auto k = t;
            k++;
            st.erase(t,k);
            st.insert(y[a[i][1]]);
            itr = st.end();
            itr--;
            ans = min(ans, dif * (*itr - *st.begin()));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

const i64 MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  i64 size = s.size();
  vector<vector<i64>> dp(size + 1, vector<i64>(13));
  bool plus = (size + 2) / 3 % 2;
  dp[0][0] = 1;
  i64 p[3] = {1, 10, 100};
  for (i64 i = 0; i < size; i++)
  {
    if (s[i] == '?')
    {
      for (i64 j = 0; j < 13; j++)
        for (i64 now = 0; now <= 9; now++)
        {
          i64 tmp = (j + ((plus ? 1 : -1) * now * p[(size - i - 1 + 3) % 3]) + 1300) % 13;
          dp[i + 1][tmp] += dp[i][j];
          dp[i + 1][tmp] %= MOD;
        }
    }
    else
    {
      i64 now = s[i] - '0';
      for (i64 j = 0; j < 13; j++)
      {
        i64 tmp = (j + ((plus ? 1 : -1) * now * p[(size - i - 1 + 3) % 3]) + 1300) % 13;
        dp[i + 1][tmp] += dp[i][j];
        dp[i + 1][tmp] %= MOD;
      }
    }
    if ((size - i - 1) % 3 == 0)
      plus = !plus;
  }
  cout << dp[size][5] % MOD << endl;
  return 0;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

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

	string ss = "ABC";
	int ct=0;
	for(int i=0; i<=n-3; i++){

		if(s[i] ==ss[0] && s[i+1] == ss[1] && s[i+2] ==ss[2]){
			ct++;
		}
	}
	writeln(ct);

}




Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<String>();
    let b=read::<String>();
    println!("{}",if a==b{"H"}else{"D"})
}

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

int main() {
    string s;
    cin >> s;
    int num = -1;
    if (s.length() == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 0; i < s.length() - 1; ++i) {
        if (s[i] != s[i + 1]) {
            int currentK = max((int)s.length() - i - 1, i + 1);
            num = num < 0 ? currentK : min(currentK, num);
        }
    }
    if (num < 0) {
        num = s.length();
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    string s[H];
    rep(i, H) cin >> s[i];
    vector<int> vec;
    rep(i, H){
        rep(j, W){
            if(s[i][j] == '#'){
                vec.push_back(i);
                break;
            }
        }
    }
    int n = vec.size();
    vec.push_back(H);
    int cnt = 1, a[H][W];
    rep(i, n){
        int x = vec[i], y = vec[i+1], p;
        rep(j, W){
            if(s[x][j] == '.') a[x][j] = cnt;
            else{
                a[x][j] = cnt;
                p = j;
                break;
            }
        }
        rep2(j, p+1, W){
            if(s[x][j] == '.') a[x][j] = cnt;
            else{
                cnt++;
                a[x][j] = cnt;
            }
        }
        cnt++;
        rep2(k, x+1, y){
            rep(j, W) a[k][j] = a[x][j];
        }
    }
    rep(i, vec[0]){
        rep(j, W) a[i][j] = a[vec[0]][j];
    }
    rep(i, H){
        rep(j, W-1) cout << a[i][j] << ' ';
        cout << a[i][W-1] << endl;
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
int a,b,c,ma=0;
cin>>a; ma=max(ma,a);
cin>>b; ma=max(ma,b);
cin>>c; ma=max(ma,c);
cout<<a+b+c-ma+ma*10<<endl;
return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    REP(i, n){
        cin >> x[i];
    }

    int ans = 1000000000;
    IFOR(i, 1, 100){
        int accum = 0;
        REP(j, n){
            accum += (i-x[j])*(i-x[j]);
        }
        ans = min(ans, accum);
    }

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

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] num = sc.nextLine().split(" ");
			int n = Integer.parseInt(num[0]);
			int x = Integer.parseInt(num[1]);
			// ????????????
			if (n == 0 && x == 0)
				break;
			int cnt = 0;
			// 5 9
			for (int i = 1; i <= n - 2; i++) {
                for (int j = i + 1; j <= n - 1; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if ((i + j + k) == x)
                            cnt++;
                    }
				}
			}
			System.out.println(cnt);

		}

	}
}

Measured memory_bytes: 27136
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

// Code Credit https://www.geeksforgeeks.org/calculate-xor-1-n/
ll computeXOR(ll n) 
{ 
    // Modulus operator are expensive on most of the  
    // computers. n & 3 will be equivalent to n % 4.    
  
    switch(n & 3) // n % 4  
    { 
    case 0: return n;     // if n is multiple of 4 
    case 1: return 1;     // If n % 4 gives remainder 1   
    case 2: return n + 1; // If n % 4 gives remainder 2     
    case 3: return 0;     // If n % 4 gives remainder 3   
    } 
} 
void solve(){
    ll A,B;
    cin>>A>>B;

    if(A>B) swap(A,B);
    ll ans = computeXOR(B)^computeXOR(A-1);
    cout<<ans<<endl;
}

signed main(){

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    FastRead;

    int t;
    t = 1;
    // cin>>t;
    
    while(t--) solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
string divide[4] = {"dream", "dreamer", "erase", "eraser"};
 
int main() {
    string S;
    cin >> S;
 
    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());
 
    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i,d.size()) == d){
              can2 = true;
              i += d.size();
            }
        }
      if(!can2){
        can = false;
        break;
      }
    }
  
  if(can) cout << "YES" << endl;
  else    cout << "NO"  << endl;
}

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

using namespace std;

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

    vector<vector<int>> vec(m);
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> vec[i][j];
            --vec[i][j];
        }
    } 

    vector<int> p(m);
    for (int i = 0; i < m; i++) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool ok = true;
        for (int j = 0; j < m; j++) {
            int c = 0;
            for (int id : vec[j]) {
                if ((i >> id) & 1) {
                    c++;
                }
            }
            c %= 2;
            if (c != p[j]) ok = false;
        }
        if (ok) ans++;
    }

    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    string s;
    cin >> s;
    int count_0 = 0;
    int count_1 = 0;
    rep(i, s.size()) s[i] == '0' ? count_0++ : count_1++;
    cout << 2 * min(count_0, count_1) << endl;;
}

Measured memory_bytes: 3720