akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll N;
  ll sum=0;
  cin>>N;
  ll A;
  for(int i=0; i<N; ++i){
    cin>>A;
    while(A%2==0){
    A=A/2;
    sum++;}
  }
    cout<<sum<<endl;}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int min1(int a, int b, int c)
{
    if(a<=b && a<=c) { return a; }
    else if(b<=a && b<=c) { return b; }
    else if(c<=a && c<=b) { return c; }
    else { return 0; }
}

int min2(int a, int b, int c, int d)
{
    if(a<=b && a<=c && a<=d) { return a; }
    else if(b<=a && b<=c && b<=d) { return b; }
    else if(c<=a && c<=b && c<=d) { return c; }
    else if(d!=0 && d<=a&& d<=b && d<=c) { return d; }
    else { return 0; }
}

void out(int a)
{
    cout << a << endl;
}

int main()
{
    int q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    
    long long min_1=min1(q*4,h*2,s);  //1Lの最安値
    long long min_2=min2(q*8,h*4,s*2,d); //2Lの最安値
   
    if(n==1) {
       cout << min_1 << endl;
    }
    else if(n>=2) {
        if(min_1*2<min_2) {
            cout << min_1*n << endl;
        }
        else if(min_1*2>=min_2) {
            if(n%2==1) {
                long long  cost = min_2*(n/2);
                n%=2;
                cost += min_1;
                cout << cost << endl;
            }
            else { cout << min_2*n/2 << endl; }
        }
        else {}
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100005
#define NIL -1
  
 struct Node{
  int p;
  int l;
  int r;
};
struct Node T[N];

int depth(int);
int child(int);

int main(){
  int i, j;
  int n, b, d, c, m;
  scanf("%d", &n);
    
  for(i = 0; i < n; i++){
   T[i].p = NIL;
   T[i].l = NIL;
   T[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d", &b, &d);
    for(j = 0; j < d; j++){
      scanf("%d", &c); 
      T[c].p = b;
      if(j == 0){
        T[b].l = c;
      } else {
        T[m].r = c;
      }
      m = c;
    }
  }
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].p, depth(i)); 
    if(T[i].p == NIL){
      printf("root, [");
    } else if(T[i].l == NIL){
      printf("leaf, [");
    } else{
    printf("internal node, [");
    }
    child(T[i].l);
    printf("]\n");
  }
  return 0;
}
  
  int depth(int x){
  int a;  
  if(T[x].p == NIL){
    return 0;
  } else{
    a = depth(T[x].p) + 1;
    return a;
  }
}
  
int child(int x){
  if(x==NIL){
    return 0;
  } else {
    if(T[x].r == NIL){
      printf("%d", x);
    } else{
      printf("%d, ", x);
      child(T[x].r);
    }
  }
}

Measured memory_bytes: 1784
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y, r int
	if _, err := fmt.Scan(&w, &h, &x, &y, &r); err != nil {
		panic(err)
	}

	if 0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1124
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size();
    return 0;
}

Measured memory_bytes: 19204
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
aa = 0
if n == 0:
   aa = 1
if aa == 0:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    flg = 0
    dis = []
    while flg == 0:
        if i > 100:
            flg = 1
        if i in p:
            dis.append(5000)
        else:
            dis.append(abs(x-i))
        i += 1
    for i in range(len(dis)):
        if dis[i] == min(dis):
            print(i)
            break
else:
    print(x)

Measured memory_bytes: 9212
def main():
    import sys
    import numpy as np
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(list(input().rstrip()) for i in range(n))
    B = list(list(input().rstrip()) for i in range(m))
    A = np.array(A)
    B = np.array(B)
    
    for i in range(n-m+1):
        for j in range(n-m+1):
            a_b = A[i:i+m,j:j+m]
            if (a_b==B).all():
                print('Yes');exit()
    print('No')
    
if __name__=='__main__':
    main()

Measured memory_bytes: 27124
from math import *;
a, b, h, m = list(map(int, input().split()))
angle = 2 * pi * abs((h + m / 60) / 12 - m / 60)
if angle >= pi:
    angle = 2 * pi - angle
ans = a * a + b * b - 2 * a * b * cos(angle)
print(sqrt(abs(ans)))

Measured memory_bytes: 9372
s = str(input())
ans = 0
temp = 0
l = int(len(s)) // 2

for i in range(l):
    temp = abs(temp)+1
    #print(i,abs(temp)*-1,s[i],s[abs(temp)*-1])
    if s[i] != s[temp*-1]:
        ans += 1

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979;

int main(){
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  long double rad;
  rad = 2*pi * (h/12 + m/60/12 - m/60);
  long double ans = sqrt(a*a + b*b - 2*a*b*cos(rad));
  
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4168
#include <iostream>
#include <cstdio>
#define N 3
using namespace std;

int main()
{
   int c[N][N];
   int a[N], b[N];
   for (int i=0; i<N; i++) {
      for (int j=0; j<N; j++) {
         scanf("%d", &c[i][j]);
      }
   }

   int a0, a1, a2, b0, b1, b2;
   for (a0=0; a0<=100; a0++) {
      b0 = c[0][0] - a0;
      b1 = c[0][1] - a0;
      b2 = c[0][2] - a0;

      a1 = c[1][0] - b0;
      a2 = c[2][0] - b0;

      a[0] = a0; a[1] = a1; a[2] = a2;
      b[0] = b0; b[1] = b1; b[2] = b2;

      int true_num = 0;
      for (int i=1; i<N; i++) {
         for (int j=1; j<N; j++) {
            if (a[i] + b[j] == c[i][j]) true_num += 1;
         }
      }

      if (true_num == 4) {
         printf("Yes\n");
         return 0;
      }

   }

   printf("No\n");


}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;




struct item{
    ll cost;
    ll sum;
};

vector<vector<item>> dp;


item DP(int b, int e, vector<ll>&a){
    if (e-b==1) return {0,a[b]};
    if (dp[b][e].cost != -1) return dp[b][e];
    ll mxcst = 1LL << 60;
    item ret = {mxcst,0};
    for(int i = b+1; i < e; i++){
        item left = DP(b,i,a);
        item right = DP(i,e,a);
        ll cst = left.cost + right.cost + left.sum + right.sum;
        if (ret.cost >  cst){
            
            ret = {cst , left.sum + right.sum};
        }
        
    }
    return dp[b][e] = ret;
}

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    dp.resize(n+1,vector<item>(n+1,{-1,0}));
    
    auto ans = DP(0,n,a);
    cout << ans.cost;
    
    
}


int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}














Measured memory_bytes: 5588
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        s1 += s1;
        if(s1.contains(s2))System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    FOR(i, 1, N-1) {
        ans += ll(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<list>
#include <vector>
#include <stack>
#include<string>
using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int, int> > S2;
  int sum=0,l,a=0;;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='\\') S1.push(i);
    else if(s[i]=='/'&& !S1.empty()){
      l=S1.top();
      S1.pop();
      sum+= i-l;
      a=i-l;
      while(!S2.empty()&&l<S2.top().first){
        a+=S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(l,a));
    }
  }
  if(S2.empty()) cout<<"0\n"<<"0\n";
else{
    vector<int> x;
    while(!S2.empty()){x.push_back(S2.top().second); S2.pop();}
    reverse(x.begin(),x.end());
    cout<<sum<<"\n";
    cout<<x.size()<<" ";
    for(int i=0;i<x.size()-1;i++) cout<<x[i]<<" ";
    cout<<x[x.size()-1]<<"\n";}
    return 0;

}





Measured memory_bytes: 3244
N = gets.to_i
P = gets.split.map &:to_i

RX = P.dup
(N-2).downto(0){|i|
	RX[i] = RX[i+1] if RX[i] < RX[i+1]
}
LX = P.dup
1.upto(N-1){|i|
	LX[i] = LX[i-1] if LX[i] < LX[i-1]
}

LU = lambda{|i, start|
	v = P[i]
	return -1 unless v < (LX[start]||0)
	return  start.downto(0).find{|j|
		v < P[j]
	}||-1
}
RU = lambda{|i, start|
	v = P[i]
	return N unless v < (RX[start]||0)
	return start.upto(N-1).find{|j|
		v < P[j]
	}||N
}

p N.times.map{|i|
	 l,  r = LU[i, i-1], RU[i, i+1]
	ll, rr = LU[i, l-1], RU[i, r+1]
	P[i] * ((rr-r) + (l-ll) + (r!=N ? (i-l-1)*(rr-r) : 0) + (l!=-1 ? (r-i-1)*(l-ll) : 0))
}.inject(&:+)


Measured memory_bytes: 14216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=600005,INF=1<<30;

vector<pair<int,int>> S[MAX];
vector<int> dis(MAX);

void dijkstra(int u){
    dis[u]=0;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> PQ;
    
    PQ.push(make_pair(0,u));
    while(!PQ.empty()){
        int a=PQ.top().first;
        int b=PQ.top().second;
        PQ.pop();
        if(dis[b]<a) continue;
        for(int i=0;i<S[b].size();i++){
            int c=S[b][i].first;
            int d=S[b][i].second;
            if(dis[c]>dis[b]+d){
                dis[c]=dis[b]+d;
                PQ.push(make_pair(dis[c],c));
            }
        }
    }
    return;
}//a,dが長さ

int main(){
  
    int N,M;cin>>N>>M;
    map<pair<int,int>,int> MA;
    
    for(int i=0;i<600005;i++){
        dis[i]=INF;
    }
    
    int now=1;
    for(int i=0;i<M;i++){
        int a,b,c,d,e;cin>>a>>b>>c;
        if(MA[make_pair(a,c)]){
            if(MA[make_pair(b,c)]){
                d=MA[make_pair(a,c)];e=MA[make_pair(b,c)];
            }else{
                d=MA[make_pair(a,c)];e=now;
                MA[make_pair(b,c)]=e;
                now++;
            }
        }else{
            if(MA[make_pair(b,c)]){
                d=now;e=MA[make_pair(b,c)];
                MA[make_pair(a,c)]=d;
                now++;
            }else{
                d=now;now++;
                e=now;now++;
                MA[make_pair(a,c)]=d;MA[make_pair(b,c)]=e;
            }
        }
        S[d].push_back(make_pair(e,0));
        S[e].push_back(make_pair(d,0));
        S[d].push_back(make_pair(500000+a,0));
        S[e].push_back(make_pair(500000+b,0));
        S[500000+a].push_back(make_pair(d,1));
        S[500000+b].push_back(make_pair(e,1));
    }
    
    dijkstra(500001);
    
    if(dis[500000+N]!=INF) cout<<dis[500000+N]<<endl;
    else cout<<-1<<endl;
}



Measured memory_bytes: 60924
/*Bismillahir Rahmanir Raheem*/

#include <bits/stdc++.h>
using namespace std;

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;

// defined for taking input
#define gl(x) getline(cin, x)
#define sf scanf
#define sfi(x) scanf("%d", &x)
#define sfc(x) scanf("%c", &x)
#define sfl(x) scanf("%lld", &x)
#define sflu(x) scanf("%llu", &x)
#define sfii(x, y) scanf("%d %d", &x, &y)
#define sfll(x, y) scanf("%lld %lld", &x, &y)
#define sfiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sflll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)

//defined for printing
#define pf printf
#define pfn pf("\n")
#define pfcas pf("Case %d: ", cas)
#define pfyes pf("YES");
#define pfno pf("NO");
#define pfi(x) pf("%d", x)
#define pfl(x) pf("%lld", x)

//defined for loop

//increament
#define loopi(i, j, k) for (int i = j; i < k; i++)
#define loopl(i, j, k) for (ll i = j; i < k; i++)
#define loopc(i, j, k) for (char i = j; i < k; i++)
#define looplu(i, j, k) for (ull i = j; i < k; i++)
//decreament
#define loopri(i, j, k) for (int i = j; i > k; i--)
#define looprl(i, j, k) for (ll i = j; i > k; i--)
#define looprlu(i, j, k) for (ull i = j; i > k; i--)
#define looprc(i, j, k) for (char i = j; i > k; i--)
#define wa(t) while (t--)

//testcases
#define testc(t) for (char cas = 1; cas <= t; cas++)
#define testi(t) for (int cas = 1; cas <= t; cas++)
#define testl(t) for (ll cas = 1; cas <= t; cas++)

//some cmd
#define pb push_back
#define ppb pop_back
#define mp make_pair

//code start

int main()
{
    // freopen("/root/Programming/input.txt", "r", stdin);
    // freopen("/root/Programming/output.txt", "w", stdout);
    int a,b;
    sfii(a,b);
    int lm=(b+1)*10 +1 ;
    int strt=b*10;
    loopi(i,strt,lm){
        if(floor(i*0.08)==a and floor(i*0.10)==b){
            return pfi(i),pfn,0;
        }
    }
    return pfi(-1),pfn,0;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

inline int readin(){
	int x=0,c;
	for (;(c=getchar())<'0'||c>'9';);
	for (;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+c-48;
	return x;
}

int main(){
	int x=readin(),y=readin();
	if (x%2==0) return puts("No"),0;else if (y%2==0) return puts("No"),0;else return puts("Yes"),0;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        System.out.println(new Main().solve());
    }
    
    // パラメタ渡しもちゃんとクラス作るのも面倒なので手抜き
    // 必要な値はここで全部取ってしまう
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    {sc.nextLine();}
    int[] a = IntStream.range(0, n).map(i -> Integer.parseInt(sc.next())).toArray();
    // List<Integer> a = IntStream.range(0, n).map(i -> Integer.parseInt(sc.next())).boxed().collect(Collectors.toList());
    int solve() {
        int count = 1;
        O:
        for(int i = 1; i < n; i++) {
            for(int j = 0; j < i; j++) {
                if(a[i] < a[j]) {
                    continue O;
                }
            }
            count++;
        }
        
        return count;
    }
}


Measured memory_bytes: 28368
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <set>
#include <map>
#define sf scanf
#define pf printf
#define show(x) cout<<"x:"<<x<<endl;
using namespace std;
typedef long long ll;
const int maxn=1e3+5;
const int inf=1e9;
stack<int>s1;
stack<pair<int,int> >s2;
int main()
{
    char ch;
    ll sum=0;
    for(int i=0;cin>>ch;i++)
    {
        if(ch=='\\')
            s1.push(i);
        else if(ch=='/'&&!s1.empty())
        {
            int j=s1.top();
            int a=i-j;
            s1.pop();
            sum+=a;
            while(!s2.empty()&&s2.top().first>j)
            {
                a+=s2.top().second,s2.pop();
            }
            s2.push(make_pair(j,a));
        }

    }
    vector<int>ans;
    while(s2.size()>0){ans.push_back(s2.top().second),s2.pop();}
    reverse(ans.begin(),ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0;i<ans.size();i++)
    {
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;

    return 0;
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

bool Solve() {
  int n;
  cin >> n;
  int a = 0, b = 0, c = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 4 == 0) a++;
    else if (x % 4 == 2) b++;
    else c++;
  }

  if (c == 0) return true;

  if (b == 0) {
    return a >= 1 && a >= c - 1;
  } else {
    return a >= c;
  }
}

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

  cout << (Solve() ? "Yes" : "No") << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    string a, b;
    cin >> a >> b;
    string ans;
    if (a.size() > b.size()) {
        ans = "GREATER";
    } else if (a.size() < b.size()) {
        ans = "LESS";
    } else {
        if (a > b) {
            ans = "GREATER";
        } else if (a == b) {
            ans = "EQUAL";
        } else {
            ans = "LESS";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define mod 1000000007
using namespace std;


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

int n;
cin>>n;

//string A = "ABC";
//
//A+= to_string(n);
//cout<<A;

int ans;
int mx=1;
for(int i=1;i<=n;i++)
{

    if( (i & (i-1) )== 0 )
    {
        ans=i;
    }


//    int c=0;
//    int j=i;
// while(j)
//{
//    if(j%2 ==0)
//        {c++;
//        j/=2;
//
//        }
//    else
//        break;
//
//}
//    if(c>=mx)
//    {
//        mx = c;
//        ans = j;
//
//    }
}

cout<<ans;
return 0;
}


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

int main(void){

    int n;
    cin >> n;
    
    vector<int> b(n);
    for(int i=0; i<n; i++) cin >> b[i];
    
    unsigned long long result = 0;
    for(int i=0; i<n-1; i++) {
        if(i==0) {
            result += b[0];
        }
        else {
            result += min(b[i], b[i-1]);
        }
    }
    
    result += b[n-2];
    
    cout << result << endl;


    return 0;
}


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

namespace ConsoleApp15
{
    class Class285
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(x=>x=="1").ToArray();
            var ans = new bool[N];
            for(int i = N - 1; i >= 0; i--)
            {
                var num = a[i];
                int index = i + 1;
                for(int j = 2; index * j - 1 < N; j++)
                {
                    if (ans[index * j - 1]) num = !num;
                }

                if (num) ans[i] = true;
            }
            
            Console.WriteLine(ans.Count(y=>y==true) );
            for(int i = 0;i<N;i++)
                if (ans[i]) Console.WriteLine(i+1);
        }
    }
}


Measured memory_bytes: 28760
/*
   Author : BabaYaga42,
   BITS Pilani, Hyderabad.
   Don't give up ;)
   */  
#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define int long long
 
int32_t main()
{
	IOS;	
	int cnt = 0;
	string a,b;
	cin >> a >> b;
	for(int i = 0; i < 3; i++)
		if(a[i] == b[i])cnt++;
	cout << cnt <<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
vector<vector<int>> G;
vector<int> K;
int main() {
	int N, M, t;
	cin >> N >> M;
	vector<int> dp(N + 1, 0);
	rep(i, 0, M)cin >> t, dp[t] = -1;
	dp[0] = 1;
	rep(i, 1, N + 1) {
		if (i - 2 >= 0 && dp[i] != -1 && dp[i - 2] > 0)dp[i] += dp[i - 2];
		if (i - 1 >= 0 && dp[i] != -1 && dp[i - 1] > 0)dp[i] += dp[i - 1];
		dp[i] %= mod;
		//printf("i:%d dp:%d\n", i, dp[i]);
	}
	printf("%d\n", dp[N]);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

#define ll long long

using namespace std;

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

	ll n;
	cin >> n;
	vector<ll> a(n);

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


	ll sum = 0;
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			if (a[i] < a[i - 1]) {
				sum += a[i - 1] - a[i];
				a[i] += a[i - 1] - a[i];
				
			}
		}
	}

	cout << sum;
	

	return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> multi_vector(size_t a){return vector<T>(a);}template<class T, class... Ts>auto multi_vector(size_t a, Ts... ts){return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}

/* ここからコード開始 */
vector<ll> l;
ll N, A, B, C;

ll saiki(ll sum, ll num, ll a, ll b, ll c){
  // cout << num << sp << a << sp << b << sp << c << rt;
  if(sum == -1){
    if(a != A && b != B && c != C) return abs(a) + abs(b) + abs(c) + num;
    else return MOD;
  }
  ll i = saiki(sum-1, num+10, a-l[sum], b, c);
  ll j = saiki(sum-1, num+10, a, b-l[sum], c);
  ll k = saiki(sum-1, num+10, a, b, c-l[sum]);
  ll l = saiki(sum-1, num, a, b, c);
  return min({i, j, k, l});
}

int main(){
  kyopro;
  
  cin >> N >> A >> B >> C;
  l.assign(N, 0);
  for(auto&& i : l){
    cin >> i;
  }
  cout << saiki(N-1, 0, A, B, C)-30 << rt;
}

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

int main() {

	int a, b;
	string ans;
	cin >> a >> b;
	if (a > b) {
		ans = "a > b";
	} else if (a < b) {
		ans = "a < b";
	} else {
		ans = "a == b";
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1192
n,k=map(int,input().split())
lists=list(map(int,input().split()))
ans=10**9
for i in range(n-k+1):
    if lists[i]<0 and lists[i+k-1]<0:
        ans=min(ans,-lists[i])
        
    elif lists[i]<0 and lists[i+k-1]>=0:
        ans=min(ans,lists[i+k-1]-lists[i]+min(lists[i+k-1],-lists[i]))
        
    elif lists[i]>=0 and lists[i+k-1]>=0:
        ans=min(ans,lists[i+k-1])
print(ans)

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

int n,last,ans,h,maxh,minh;

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> h;
		if(h >= maxh) maxh = h;
			else{
				ans += maxh - minh;
				minh = h;
				maxh = minh;
			}
	}
	if(maxh > minh) ans += maxh - minh;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int value = N;
		int sum=0;
		while(value != 0) {
			sum +=  (value % 10);
			value /= 10;
		}
		if(N%sum == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22612
S = input()
T = input()
L = 0
A = S[0] 
B = S[1]
C = S[2]
D = T[0]
E = T[1]
F = T[2]
if A == D:
    L += 1
if B == E:
    L += 1
if C == F:
    L += 1
print(L)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
  char past[3];
  char present[3];
  int i,count=0;
  for(i=0;i<3;i++)
  {
    cin>>past[i];
  }
  for(i=0;i<3;i++)
  {
    cin>>present[i];
  }
    for(i=0;i<3;i++)
    {
      if(past[i]==present[i])
        count++;
    }
  cout<<count;
}

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

int get_index(int x,int y,int w){
  return x + y * w;
}

void add_edge(vector<vector<int>> &maze,int x1,int y1,int x2,int y2,int w){
  const int a = get_index(x1,y1,w);
  const int b = get_index(x2,y2,w);
  maze[a].emplace_back(b);
  maze[b].emplace_back(a);
}

int bfs(int s,int g,vector<vector<int>> &maze){
  const int n = maze.size();
  vector<int> d(n,-1);
  d[s] = 1;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    const int now = q.front(); q.pop();

    // can get to goal
    if(now == g) return d[now];

    for(const auto &to : maze[now]){
      if(d[to] == -1){
        d[to] = d[now] + 1;
        q.push(to);
      }
    }
  }
  // fail to get to goal
  return -1;
}

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

  int w,h;
  while(cin>>w>>h&&w){
    vector<vector<int>> maze(w*h);

    for(int i=0;i<h;++i){
      // vertical wall
      for(int j=0;j<w-1;++j){
        int wall; cin>>wall;
        if(!wall)
          add_edge(maze,j,i,j+1,i,w); // connect to right node
      }
      if(i==h-1) break;
      // horizontal wall
      for(int j=0;j<w;++j){
        int wall; cin>>wall;
        if(!wall){
          add_edge(maze,j,i,j,i+1,w); // connect to below node
        }
      }
    }

    const int ans = bfs(get_index(0,0,w),get_index(w-1,h-1,w),maze);
    ans == -1 ? cout<<0<<endl : cout<<ans<<endl;
  }

  return EXIT_SUCCESS; 
}

Measured memory_bytes: 1272
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int flag = 0;

		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				if (N == i * j) {
					flag = 1;
				}
			}
		}
		if (flag == 1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		scan.close();

	}
}


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

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

  int K, N;
  cin >> K >> N;
  vector<int> A(N), dist(N);
  int sum = 0;
  for(int i = 0; i < N; ++i) {
    cin >> A.at(i);
  }

  for(int i = 0; i < N; ++i) {
    if(i == N - 1) {
      dist.at(i) = K - A.at(i) + A.at(0);
    }
    else {
      dist.at(i) = A.at(i + 1) - A.at(i);
    }
    sum += dist.at(i);
  }

  cout << sum - *max_element(dist.begin(), dist.end()) << endl;
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	auto a=0,z=0;
	for(int i=0;i<s.length();++i){
		if(a==0 and s[i]=='A') a=i+1;
		if(s[i]=='Z') z=i+1;
	}
	
	if(a!=0 and z!=0) cout << z-a+1 << endl;
	else cout << 0 << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

struct para
{
    ll a, b, nr;
};

bool porownanie(para a, para b)
{
    if (a.b > b.b)
        return true;
    if (a.b < b.b)
        return false;
    if (a.nr < b.nr)
        return true;
    return false;
}

ll Ile(vector<para>& a, ll x)
{
    ll odp = 0;
    ll max_a = 0;
    for (int i = 0; i < a.size(); ++i)
        max_a = max(max_a, a[i].a);
    ll s = 0;
    for (int i = 0; i < min((int) a.size(), (int) x); ++i)
    {
        s += a[i].b;
        ll r = 0;
        if (x - (i + 1) > 0)
            r = x - (i + 1);
        odp = max(odp, s + r * max_a);
    }
    odp = max(odp, x * max_a);
    return odp;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, h;
    cin >> n >> h;
    vector<para> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i].a >> a[i].b;
        a[i].nr = i;
    }
    sort(a.begin(), a.end(), porownanie);
    ll l = 1, p = 1000000000, s, r = -1;
    while (l <= p)
    {
        s = (l + p) / 2;
        if (Ile(a, s) >= h)
        {
            r = s;
            p = s - 1;
        }
        else
            l = s + 1;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n;
		cin>>n;
		string s;
		ll a,d;
		ll cnt[3][50][40];
		memset(cnt,0,sizeof(cnt));
		ll ans=0;
		FOR(i,0,n)
		{
			cin>>s;
			a=0;
			d=0;
			FOR(j,0,s.size())
			{
				if(s[j]=='.')
				{
					d=s.size()-j-1;
					continue;
				}
				a*=10;
				a+=(s[j]-'0');
			}
			while((a%10)==0)
			{
				a/=10;
				d--;
			}
			if((a%2)==0)
			{
				int  c=0;
				while((a%2)==0)
				{
					a/=2;
					c++;
				}
				FOR(j,0,40)
				{
					FOR(k,0,50)
					{
						if((j-20+d)<=0)
						ans+=cnt[0][k][j]+cnt[2][k][j];
						if((j-20+d-min(c,k))<=0)
						ans+=cnt[1][k][j];
					}
				}
				cnt[0][c][20+d]++;
			}
			else if((a%5)==0)
			{
				int c=0;
				while((a%5)==0)
				{
					a/=5;
					c++;
				}
				FOR(j,0,40)
				{
					FOR(k,0,50)
					{
						if((j-20+d)<=0)
						ans+=cnt[1][k][j]+cnt[2][k][j];
						if((j-20+d-min(c,k))<=0)
						ans+=cnt[0][k][j];
					}
				}
				cnt[1][c][20+d]++;
			}
			else
			{
				
				FOR(j,0,40)
				{
					FOR(k,0,50)
					{
						if((j-20+d)<=0)
						ans+=cnt[0][k][j]+cnt[2][k][j]+cnt[1][k][j];
					}
				}
				cnt[2][0][20+d]++;
			}
		}
		cout<<ans;
	}
	return 0;
}

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

ll min(ll a, ll b){
	if (a>b){return b;}
	else {return a;}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m, x;
	cin >> n >> m >> x;
	vector<ll> a(m);
	REP(i, m){cin >> a[i];}
	ll l = 0;
	while (a[l]<x){
		l++;
	}
	cout << min(l, m-l) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
    int A, B, K=0 , ans = 0;
    cin >> A >> B;
    int Temp = 1;
    while (Temp < B)
    {
        Temp += A - 1;
        ans += 1;
    }

    cout << ans << endl;
}




Measured memory_bytes: 256
import re
while 1:
    s=input()
    if s==".":break
    s=s.replace(" ","").replace(".","")
    st=re.sub("[a-zA-Z]","",s)
    a1,a2,b1,b2=0,0,0,0
    while 1:
        if "()" in st or "[]" in st:st=st.replace("()","").replace("[]","")
        else:break
    print(["no","yes"][st==""])


Measured memory_bytes: 6520
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    int maxa = 0;
    int maxids;
    rep(i, n) {
        cin >> a[i] >> b[i];
        if (a[i] > maxa) {
            maxa = a[i];
            maxids = i;
        }
    }

    vector<int> ids(n);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) {return b[i] > b[j];});

    int res = 0;
    
    for (int i = 0; i < n; ++i) {
        if (h <= 0) break;
        if (b[ids[i]] > maxa) {
            h -= b[ids[i]];
            ++res;
        }
        else break;
    }
    
    if (h > 0) {
        if (h % maxa == 0) res += h / maxa;
        else res += h / maxa + 1;
    }

    cout << res << endl;
    return 0;
}

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

#define fs first
#define sc second

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
const int m=1000000000;

int main(){
	int n,c=0;
    string s;
    cin>>n>>s;
    s+="PPPPPPPPPPPPPP";
    FOR(i,0,n){
        int j=i+1;
        int k=j+1;
        if(s[i]=='A'&&s[j]=='B'&&s[k]=='C'){
c++;
        }
    }
    cout<<c;

}


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<lli, lli>
#define ps pair<double, string>
#define pib pair<pi, bool>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 50
#define MAXL 10001
#define mod 1000000007

signed main()
{
  int n;
  cin >> n;
  int at = n % 10;
  if (at == 2 || at == 4 || at == 5 || at == 7 || at == 9)
    cout << "hon";
  else if (at == 0 || at == 1 || at == 6 || at == 8)
    cout << "pon";
  else
    cout << "bon";
  n = n / 10;
  cout << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>

using namespace std;

struct Card{
    char suit, value;
};

void bubbleSort(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j >= i+1; j--){
            if(A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selectionSort(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[minj].value > A[j].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

bool judgeStable(struct Card A[], struct Card B[], int N){
    for(int i = 0; i < N; i++) if(A[i].suit != B[i].suit) return false;
    return true;
}

void printData(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        if(i != 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

int main(){
    struct Card C1[100], C2[100];
    int N;
    
    cin >> N;

    for(int i = 0; i < N; i++) cin >> C1[i].suit >> C1[i].value;

    for(int i = 0; i < N; i++) C2[i] = C1[i];

    bubbleSort(C1, N);
    selectionSort(C2, N);

    printData(C1, N);
    cout << "Stable" << endl;

    printData(C2, N);
    if(judgeStable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }


    return 0;
}





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

using namespace std;

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

	int N, K;

	cin >> N >> K;

	cout << (N + K - 3) / (K - 1) << '\n';

	return 0;
}


Measured memory_bytes: 256
def main():
    x, y, a, b, c = map(int, input().split())
    al = sorted(list(map(int, input().split())), reverse=True)[:x]
    bl = sorted(list(map(int, input().split())), reverse=True)[:y]
    cl = sorted(list(map(int, input().split())), reverse=True)
    ans = 0
    xi, yi = 0, 0
    for i in cl:
        if al:
            ai = al[-1]
        else:
            ai = 10000000000
        if bl:
            bi = bl[-1]
        else:
            bi = 10000000000
        if ai < bi:
            if al:
                m = al.pop()
            else:
                m = 0
        else:
            if bl:
                m = bl.pop()
            else:
                m = 0
                
        if m < i:
            ans += i
        else:
            ans += m
            break
    ans += sum(al)+sum(bl)
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    int A, B;
    cin >> A >> B;
    int counter = 0;
    for(int i = A; i <= B; i++){
        int tmp = i;
        int a[5];
        a[0] = tmp % 10; tmp /= 10;
        a[1] = tmp % 10; tmp /= 10;
        a[2] = tmp % 10; tmp /= 10;
        a[3] = tmp % 10; tmp /= 10;
        a[4] = tmp % 10;
        
        if (a[0] == a[4] && a[1] == a[3]){
            counter++;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll d,w;
  while(cin>>d>>w,d+w){
    ll e[d+1][w+1];
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
	cin>>e[i][j];
      }
    }
    ll ans=0;
    for(int lx=0;lx<d-2;lx++){
      for(int ly=0;ly<w-2;ly++){
	for(int rx=lx+2;rx<d;rx++){
	  for(int ry=ly+2;ry<w;ry++){
	    ll mi=llINF;
	    for(int i=lx;i<=rx;i++){
	      mi=min({mi,e[i][ly],e[i][ry]});
	    }
	    for(int i=ly;i<=ry;i++){
	      mi=min({mi,e[lx][i],e[rx][i]});
	    }
	    bool fl=true;
	    ll sum=0;
	    for(int i=lx+1;i<rx;i++){
	      for(int j=ly+1;j<ry;j++){
		if(mi<=e[i][j])fl=false;
		sum+=mi-e[i][j];
	      }
	    }
	    if(fl){ans=max(ans,sum);}
	  }
	}
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define REG register
#define LL long long
#define MAXN 55
using namespace std;
inline int read(){
	REG int x(0);
	static char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=(x*10)+(c^48),c=getchar();
	return x;
}

int n,p;
int a[MAXN];
LL dp[MAXN][2];

inline void Work(){
	n=read(),p=read();
	for(REG int i=1;i<=n;++i) a[i]=read()&1;
	dp[1][0]=1+(!a[1]),dp[1][1]=a[1];
	for(REG int i=2;i<=n;++i)
		dp[i][0]=dp[i-1][0]+(a[i]?dp[i-1][1]:dp[i-1][0]),
		dp[i][1]=dp[i-1][1]+(a[i]?dp[i-1][0]:dp[i-1][1]);
	printf("%lld\n",dp[n][p]);
}

int main(){Work();}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    ll n,x,t;
    cin>>n>>x>>t;
    ll k=ceil((n*1.0)/x*1.0)*t;
    cout<<k<<endl;


}
//Alhamdulillah





















Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	string s;
	cin >> s;

	int res = 0;
	int cur = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			cur++;
			res = max(res, cur);
		} else {
			cur = 0;
		}
	}
	cout << res << endl;
}


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

int main(){
  int t,n,d;
  cin>>t;
  for(int i=0;i<t;i++){
    cin>>n>>d;
    if(n%2==0)d^=127;
    cout<<(n-1)*127+d<<endl;
  }
  return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define PP std::pair<int,int>
#define LL long long
int c[4][4];
int main() {
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			std::cin >> c[i][j];
		}
	}
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= 2; j++) {
			if (c[i][j] - c[i][j + 1] != c[i + 1][j] - c[i + 1][j + 1]) {
				std::cout << "No" << std::endl;
				return 0;
			}
			if (c[i][j] - c[i + 1][j] != c[i][j + 1] - c[i + 1][j + 1]) {
				std::cout << "No" << std::endl;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 256