akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007

int main() {
    ll X; cin >> X;
    int year = 0;
    ll money = 100;
    while (money < X) {
        money *= 1.01;
        year++;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int ans = 0;
  for(int i = 0; i < N; i++){
    int h;
    cin >> h;
    if(h >= K) ans++;
  }

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();

		Node_BT[] nodes = new Node_BT[n];
		for(int i=0; i<n; i++) {
			nodes[i] = new Node_BT();
		}

		for(int i=0; i<n; i++) {
			int id = sc.nextInt();
			int left = sc.nextInt();
			int right = sc.nextInt();
			nodes[id].left = left;
			nodes[id].right = right;

			if(left != -1) {
				nodes[left].parent = id;
				nodes[left].sibling = right;
			}
			if(right != -1) {
				nodes[right].parent = id;
				nodes[right].sibling = left;
			}
		}

		for(int i=0; i<n; i++) {
			if(nodes[i].parent == -1) {
				nodes[i].writeData(nodes, 0);
				break;
			}
		}

		StringBuilder ans = new StringBuilder();
		for(int i=0; i<n; i++) {
			ans.append("node ");
			ans.append(i);
			ans.append(": parent = ");
			ans.append(nodes[i].parent);
			ans.append(", sibling = ");
			ans.append(nodes[i].sibling);
			ans.append(", degree = ");
			ans.append(nodes[i].degree);
			ans.append(", depth = ");
			ans.append(nodes[i].depth);
			ans.append(", height = ");
			ans.append(nodes[i].height);
			ans.append(", ");
			ans.append(nodes[i].type);
			ans.append("\n");
		}
		System.out.print(ans);
	}

	static class Node_BT {
		int left;
		int right;
		int parent = -1;
		int sibling = -1;
		int degree = 0;
		int depth;
		int height;
		String type;

		int writeData(Node_BT[] nodes, int depth) {
			this.depth = depth;

			int h_left = -1;
			int h_right = -1;
			if(left != -1) {
				h_left = nodes[left].writeData(nodes, depth + 1);
				degree++;
			}
			if(right != -1) {
				h_right = nodes[right].writeData(nodes, depth + 1);
				degree++;
			}
			height = Math.max(h_left, h_right) + 1;



			if(parent == -1) {
				type = "root";
			} else if(height == 0) {
				type = "leaf";
			} else {
				type = "internal node";
			}

			return height;
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 24468
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	int cnt = 0;
	rep(i,3){
		char a;
		scanf("%c", &a);
		if(a == '1') cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N2 2500
#define N 50

using namespace std;
typedef long long ll;

ll s[3000][60];
int v[60];

int main()
{
    //freopen("in.in", "r", stdin);
    int n, a;
    cin >> n >> a;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    s[0][0] = 1;
    for(int k = 0; k < n; k++)
    {
        for(int i = N2; i >= v[k]; i--)
        {
            for(int j = 1; j <= n; j++)
            {
                s[i][j] += s[i - v[k]][j - 1];
            }
        }
    }
    ll rez = 0;
    for(int i = 1; i <= n; i++)
        rez += s[a * i][i];
    cout << rez;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n;
int main(){
	n=read();
	printf("%lld",(n-1)*n/2);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <utility>

int main() {
    int x[3];
    scanf("%d %d %d", &x[0], &x[1], &x[2]);
    for(int i=2; i>0; i--) {
        for(int j=0; j<i; j++) {
            if(x[j] > x[j+1]) std::swap(x[j], x[j+1]);
        }
    }
    printf("%d %d %d\n", x[0], x[1], x[2]);
}


Measured memory_bytes: 2724
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b);
int lcm(int a, int b);

void solve_A(){
    int h, a;
    cin >> h >> a;

    cout << (h + a - 1)/a;
}

void solve_B(){
    int h, n, sum = 0;
    cin >> h >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }

    if(sum >= h) cout << "Yes";
    else cout << "No";

}

void solve_C(){
    ll n, k;
    cin >> n >> k;
    ll h[n];
    REP(i,n) cin >> h[i];

    sort(h, h+n);
    
    ll sum = 0;

    REP(i,n-k){
        sum += h[i];
    }

    cout << sum;
}

int main(void){
    
    
    solve_C();
    
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);

    int r = a % b;
    while(r != 0){
        a = b;  b = r;  r = a % b;
    }
    return b;
}

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

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  vll x(5);
  rep(i, 5) {
    cin >> x[i];
  }

  rep(i, 5) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3632
N = int(input())

ans = 0
p = [0]
while p:
    k = p.pop()
    if k > N:
        continue
    if '7' in str(k) and '5' in str(k) and '3' in str(k):
        ans += 1
    p.extend([k*10+3, k*10+5, k*10+7])
print(ans)


Measured memory_bytes: 3060
//Therefore
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    string N;
    cin >> N;
    
    string ans;
    switch (N[N.size()-1])
    {
    case '3':
        /* code */
        ans = "bon";  
        break;
    case '0':
    case '1':
    case '6':
    case '8':
        ans = "pon";
        break;
    default:
        ans = "hon";
        break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int dp[1010][1010];

int main() {
    string s, t; cin >> s >> t;
    int slen = s.length();
    int tlen = t.length();
    for(int i = 0; i <= slen+1; ++i) {
        for(int j = 0; j <= tlen+1; ++j) {
            dp[i][j] = 1e9;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i <= slen; ++i) {
        for(int j = 0; j <= tlen; ++j) {
            chmin(dp[i+1][j], dp[i][j]+1);
            chmin(dp[i][j+1], dp[i][j]+1);
            if(i < slen && j < tlen) {
                if(s[i] != t[j]) chmin(dp[i+1][j+1], dp[i][j]+1);
                else chmin(dp[i+1][j+1], dp[i][j]);
            }
        }
    }
    cout << dp[slen][tlen] << endl;
}


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

int main (int argc, char **argv) {

  // 文字列の入力
  string S, T;
  cin >> S >> T;
  bool match = false;

  int mozisuu = (S.size() - 1);

  for(int i=0;i<=mozisuu;i++){
    if(S==T){
      match = true;
      break;
    }
    S = S[mozisuu] + S;
    S.pop_back();
  }

  if(match == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

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

Measured memory_bytes: 3596
def ed(str1,str2):
    f=[[0 for i in range(len(str2)+1)]for j in range(len(str1)+1)]
    for i in range(len(str1)+1):
        f[i][0]=i;
    for i in range(len(str2)+1):
        f[0][i]=i;
    for i in range(1,len(str1)+1):
        for j in range(1,len(str2)+1):
           if str1[i-1]==str2[j-1]:
              f[i][j]=f[i-1][j-1]
           else:
              f[i][j]=min(f[i-1][j-1]+1,f[i-1][j]+1,f[i][j-1]+1)
    return f[-1][-1]

x=input()
y=input()
print(ed(x,y))



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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 6");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("12345 678901");
            //175897
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();

        long CurrSCnt = wkArr[0];
        long CurrCCnt = wkArr[1];

        //手順1 SとcのペアでSccを作れるだけ作る
        long CanCreateCnt1 = Math.Min(CurrSCnt, CurrCCnt / 2);
        CurrSCnt -= CanCreateCnt1;
        CurrCCnt -= CanCreateCnt1 * 2;

        //手順2 残ったcでSccを作れるだけ作る
        long CanCreateCnt2 = CurrCCnt / 4;

        Console.WriteLine(CanCreateCnt1 + CanCreateCnt2);
    }
}


Measured memory_bytes: 13396
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int h1, h2, m1, m2, k;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	
	int m_dep = 60 * h1 + m1, m_fin = 60 * h2 + m2;
	
	cout << max(m_fin - m_dep - k, 0) << '\n';
	
 	
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    ll A, B; cin >> A >> B;
    
    map<ll, ll> M1;
    map<ll, ll> M2;
    
    for(int i=2; (ll)i*i<=A; i++){
        while(A%i==0){
            M1[i]++;
            A/=i;
        }
    }
    if(A!=1) M1[A]++;
    
    for(int i=2; (ll)i*i<=B; i++){
        while(B%i==0){
            M2[i]++;
            B/=i;
        }
    }
    if(B!=1) M2[B]++;
    
    map<ll, ll> C;
    for(auto m:M1){
        C[m.fs]++;
    }
    for(auto m:M2){
        C[m.fs]++;
    }
    
    ll ans = 0;
    for(auto c:C){
        if(c.sc==2) ans++;
    }
    cout << ans + 1 << endl;
    return 0;
}



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



int main()
{
	int a, b, c, tmp;
	cin >> a >> b >> c;
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	cout << a <<" "<< b <<" "<< c << endl;

	return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }


int main() {
  string s; cin >> s;
  int size=(int)s.size();

  vector<int> v0(26,0),v1,v2;

  for(int i=0;i<size;i++) { v1.push_back(s[i]-'a'); }

  if(size < 26) {
    for(int i=0;i<size;i++) { v0[s[i]-'a'] = 1; }
    for(int i=0;i<26;i++) { if(v0[i] == 0) { v2.push_back(i); } }
    sort(v2.begin(),v2.end());
    v1.push_back(v2[0]);

    for(int i=0;i<(int)v1.size();i++) { printf("%c",v1[i]+'a'); }
    cout << endl;
    return 0;
  } else {
    for(int i=size-1;i>0;i--) {
      //if(i == 0) { cout << "-1\n"; return 0; }

      v2.push_back(v1[i]); v1.pop_back();
      sort(v2.begin(),v2.end());

      for(int j=0;j<(int)v2.size();j++) {
        if(v2[j] > v1[i-1]) {
          v1[i-1] = v2[j];
          for(int i=0;i<(int)v1.size();i++) { printf("%c",v1[i]+'a'); }
          cout << endl;
          return 0;
        }
      }
    }
  }

  cout << "-1\n";
  /*
  for(int i=0;i<(int)v1.size();i++) { printf("%c",v1[i]+'a'); }
  cout << endl;
  */
  return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

if tot > N:
	print(-1)
else:
	print(N-tot)


Measured memory_bytes: 27768
#include<bits/stdc++.h>
using namespace std;
int n,a[300005];
long long sum[300005];
long long Ans=0x3f3f3f3f3f3f3f3f;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i), sum[i]=sum[i-1]+a[i];
	for(int i=2;i<n-1;++i){
		long long S1=sum[i], S2=sum[n]-sum[i];
		int pos1=lower_bound(sum+1,sum+n+1,S1>>1)-sum;
		int pos2=lower_bound(sum+1,sum+n+1,S1+(S2>>1))-sum;
		Ans=min(Ans,max(max(sum[pos1],S1-sum[pos1]),max(sum[pos2]-S1,S2-sum[pos2]+S1))-min(min(sum[pos1],S1-sum[pos1]),min(sum[pos2]-S1,S2-sum[pos2]+S1)));
		if(pos1>1) Ans=min(Ans,max(max(sum[pos1-1],S1-sum[pos1-1]),max(sum[pos2]-S1,S2-sum[pos2]+S1))-min(min(sum[pos1-1],S1-sum[pos1-1]),min(sum[pos2]-S1,S2-sum[pos2]+S1)));
		if(pos2>i+1) Ans=min(Ans,max(max(sum[pos1],S1-sum[pos1]),max(sum[pos2-1]-S1,S2-sum[pos2-1]+S1))-min(min(sum[pos1],S1-sum[pos1]),min(sum[pos2-1]-S1,S2-sum[pos2-1]+S1)));
		if(pos1>1&&pos2>i+1) Ans=min(Ans,max(max(sum[pos1-1],S1-sum[pos1-1]),max(sum[pos2-1]-S1,S2-sum[pos2-1]+S1))-min(min(sum[pos1-1],S1-sum[pos1-1]),min(sum[pos2-1]-S1,S2-sum[pos2-1]+S1)));
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    int n;
    cin>>n;
    while(n>0){
        int x=n%10;
        n/=10;
        if(x==7){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

    
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
struct Edge{ int to; ll cost; };
typedef pair<ll,int> P;
vector<Edge> G[100005];
ll dist[100005];
const ll INF = (1LL<<60);
void dijkstra(int s)
{
  fill( dist, dist+100005, INF );
  priority_queue< P, vector<P>, greater<P> > q;
  q.push({ 0, s });
  dist[s] = 0;
  while( !q.empty() ){
    P p = q.top(); q.pop();
    int v = p.second;
    if( dist[v] < p.first ) continue;
    for( int i=0; i<G[v].size(); i++ ){
      Edge e = G[v][i];
      if( dist[e.to] > dist[v] + e.cost ){
        dist[e.to] = dist[v] + e.cost;
        q.push( P(dist[e.to], e.to) );
      }
    }
  }
}
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int a, b;
  ll c;
  for( int i=0; i<N-1; i++ ){
    cin >> a >> b >> c;
    G[a].push_back( {b, c} );
    G[b].push_back( {a, c} );
  }
  int Q, K;
  cin >> Q >> K;
  dijkstra( K );
  for( int i=0; i<Q; i++ ){
    cin >> a >> b;
    cout << dist[a] + dist[b] << '\n';
  }
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long  ll;
typedef unsigned long long  ull;
typedef long double ld;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define N 100005
const double pi = acos(-1);

ll n,t,m,k;

ll ans;
ll mod = 1e9 +7;
ll mat[105][105],a[10005];



int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("e.txt","r",stdin); 
// freopen("e_out.txt","w",stdout); 
cout.precision(10);



int h,w;
cin>>h>>w>>n;
lp(i,n)cin>>a[i];
int row=0,col=0,dir =1;
lp(i,n){
  lp(j,a[i]){
    mat[row][col]=i+1;
    col+=dir;
    if(col==w){
      row++;
      col=w-1;
      dir=-1;
    }
    else if(col==-1){
      row++;
      col=0;
      dir =1;
    }
  }
}
lp(i,h){
  lp(j,w)cout<<mat[i][j]<<" ";
  cout<<"\n";
}



  
}
  
 



// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

Measured memory_bytes: 3784
#include <iostream>
#include <cstdlib>
#include <cmath>
typedef long long ll;
using namespace std;

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

    ll i;
    for (i = (int)(sqrt(n)); i > 0; i--) {
        if (n % i == 0) {
            cout << int(log10(n / i)) + 1 << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    if(n==1&&m==1){cout<<1<<endl; return 0;}
    if(n==1||m==1){cout<<max(0,n*m-2)<<endl; return 0;}
    cout<<ll(n-2)*(m-2)<<endl;
}


Measured memory_bytes: 256
import collections

n = int(input())
a = [int(_) for _ in input().split()]
aa = collections.Counter(a).most_common()
aa = sorted(aa, reverse=True)
length = []
cnt = 0
for i in aa:
    if i[1] >= 2:
        length.append(i)
        cnt += 1
        if cnt == 2:
            break
    else:
        pass

if cnt == 2 and length[0][1] >= 4:
    print(length[0][0] * length[0][0])
elif cnt == 2:
    print(length[0][0] * length[1][0])
elif cnt == 1 and length[0][1] >= 4:
    print(length[0][0] * length[0][0])
else:
    print(0)

Measured memory_bytes: 21660
#include<stdio.h>
main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if ((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5)||(a==7 && b==5 && c==5)) {
    printf("YES");}
    else{printf("NO");}
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			int z = n * n * n;
			int x = n -1;
			int y = 1;
			int min = z;
			while(x >= y)
			{
				int result = z - x * x * x - y * y * y;
				while(result >= 0)
				{
					if(result < min)
					{
						min = result;
					}
					++y;
					result = z - x * x * x - y * y * y;
				}
				--x;
			}
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 12000
a, b, c, d, e, f = map(int, input().split())
w = []
for i in range(f // 100 + 2):
    for j in range(f // 100 + 2):
          t = 100 * (a * i + b * j)
          if 0 < t <= f:
              w.append(t)
s = []
for i in range(f // c + 2):
    for j in range(f // d + 2):
          t = c * i + d * j
          if t <= f:
              s.append(t)

ans_ws = -1
ans_s = -1
buf = -1

sat = (e * 100) / (100 + e)
for water in w:
    for sugar in s:
          ttl = (water + sugar)
          if ttl > f:
              continue
          concentration = (sugar * 100) / ttl
          if concentration <= sat:
              if buf < concentration:
                  buf = concentration
                  ans_ws = ttl
                  ans_s = sugar
print(ans_ws, ans_s)

Measured memory_bytes: 12440
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e9 + 3;

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int h, n;
	cin >> h >> n;
	vector<long long> dp(h + 1, INF);
	dp[h] = 0;
	for (int i = 0; i < n; ++i){
		int a, b;
		cin >> a >> b;
		for (int j = h; j >= 0; --j){
			dp[j] = min(dp[j], dp[min(j + a, h)] + b);
		}
	}
	cout << dp[0];
	return 0;
}



Measured memory_bytes: 384
a, b = map(int, input().split())

ans = {
    1: 'Positive',
    -1: 'Negative',
    0: 'Zero'
}

res = None
if a > 0:
    res = 1
elif a * b < 0 or a == 0 or b == 0:
    res = 0
else:
    res = (-1) ** ((abs(a - b) + 1) % 2)

print(ans[res])


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

string my_replace(string S, string from, string to){
    auto pos = S.find(from);
    string T;
    T.append(S, 0, pos);
    while (pos != string::npos){
        T.append(to);
        auto prev_pos = pos + from.size();
        pos = S.find(from, prev_pos);
        T.append(S, prev_pos, pos - prev_pos);
    }
    return T;
}

int main() {
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    S = my_replace(S, "dream", "1");
    S = my_replace(S, "ase", "A");
    S = my_replace(S, "er", "E");
    S = my_replace(S, "EA", "3");
    S = my_replace(S, "3r", "4");
    S = my_replace(S, "1E", "2");
    for (auto c : S){
        if (c != '1' and c != '2' and c != '3' and c != '4'){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

using i64=long long;

int main() {
    int N;
    scanf("%d", &N);

    i64 T=1, A=1;
    for (int i=0; i<N; ++i) {
        i64 t, a;
        scanf("%lld %lld", &t, &a);

        i64 h=max((T+t-1)/t, (A+a-1)/a);
        fprintf(stderr, "%lld\n", h);
        T = h * t;
        A = h * a;
    }

    fprintf(stderr, "%lld %lld\n", T, A);

    printf("%lld\n", T+A);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int a[N],b[N],c[N];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n;i++)scanf("%d",&b[i]);
	for(int i=0;i<n;i++)scanf("%d",&c[i]);
	sort(a,a+n);sort(b,b+n);sort(c,c+n);
	int l,mid,r;long long left,right,ans=0;
	for(int i=0;i<n;i++){
		l=0;r=n-1;
		while(l+1<r){
			mid=(l+r)>>1;
			if(a[mid]<b[i])l=mid;
			else r=mid;
		}
		if(a[l]>=b[i])left=0;
		else if(a[r]<b[i])left=n;
		else left=l+1;

		l=0;r=n-1;
		while(l+1<r){
			mid=(l+r)>>1;
			if(c[mid]>b[i])r=mid;
			else l=mid;
		}
		if(c[r]<=b[i])right=0;
		else if(c[l]>b[i])right=n;
		else right=n-r;
		ans+=left*right;
	}
	printf("%lld\n",ans);
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<ll> A(0);
  int num = 0;
  for (int i = 1; i <= N; i++) {
    REP(j, i) num++;
    if (N <= num) {
      A.push_back(i);
      break;
    }
  }
  N -= A[0];
  for (int i = A[0]-1; i > 0; i--) {
    if(i<=N){
      A.push_back(i);
      N -= i;
    }
  }
  sort(A.begin(), A.end());
  REP(i, A.size()) { cout << A[i] << endl; }
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a) for(int i=(a);;++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INPUT \
        FILE *fp; \
        fp=fopen("input.text","r");



int main(int argc, const char *argv[]) {
    
    int N;
    scanf("%d", &N);
    
    int num_seq[N];
    FOR(i, 0, N) scanf("%d", &num_seq[i]);
    FOR(i, 0, N) {
        if (i==(N-1)) printf("%d\n",num_seq[N-1-i]);
        else printf("%d ",num_seq[N-1-i]);
    }
}



Measured memory_bytes: 3212
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin  = open("input.txt","r")
    sys.stdout = open("output.txt","w")
    sys.stderr = open("output.txt","w")

# for _testcases_ in range(int(input())):
n = int(input())
li = get_list()
s = sum(li)/n
l = math.floor(s)
r = math.ceil(s)
if l == r:
    s = l
else:
    if s - l < r - s:
        s = l
    else:
        s = r
print(sum([(s-x)**2 for x in li]))

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  int n;
  cin >> n;
  set<string> s;
  string item;
  for (int i = 0; i < n; ++i) {
    cin >> item;
    s.insert(item);
  }
  cout << s.size() << endl;
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
using namespace std;
long long x;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> x;
    for (long long i = -1000; i <= 1000; i++)
        for (long long j = -1000; j <= 1000; j++)
            if (i*i*i*i*i - j*j*j*j*j == x) {
                cout << i << ' ' << j << '\n';
                return 0;
            }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int sum_r[220000];
Int sum_w[220000];

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,n)
    {
        sum_w[i+1] = sum_w[i] + (s[i] == 'W');
        sum_r[i+1] = sum_r[i] + (s[i] == 'R');
    }
    sum_r[n+1] = sum_r[n];
    sum_w[n+1] = sum_w[n];
    Int ans = LINF;
    for (int i = 0; i <= n; i++)
    {
        ans = min(ans, max(sum_r[n+1] - sum_r[i], sum_w[i]));
    }
    cout << ans << endl;
}

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


double  dp[3000][3000];
double  p[3000],ans;




int main(){
	int n;
	cin>>n;
	for (int i =1;i<=n;i++){
		cin>>p[i];
	}
	dp[0][0]=1;

	for (int i = 1;i<=n;i++){
		for (int j = 0;j<=i;j++){
			dp[i][j] += dp[i-1][j]* (1-p[i]);
			dp[i][j+1] += dp[i-1][j]*p[i];
		}
	}
	for (int i = n;i>n/2;i--)
		ans+=dp[n][i];
	cout<<setprecision(1000000) <<ans;
}

Measured memory_bytes: 72884
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int c[n] , s[n] , f[n];
    for( int i = 0 ; i < n - 1 ; i++ ) cin >> c[i] >> s[i] >> f[i];
    for( int i = 0 ; i < n - 1 ; i++ ){
        ll t = c[i] + s[i];
        for( int j = i + 1 ; j < n - 1 ; j++ ){
            if( t < s[j] ) t = s[j];
            else if( t % f[j] == 0 );
            else t = t + f[j] - t % f[j];
            t += c[j];
        }
        cout << t << endl;
    }
    cout << "0";
}


Measured memory_bytes: 3652
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	if(x>y)
	{
		swap(x,y);
	}
	if(x>z)
	{
		swap(x,z);
	}
	if(y>z)
	{
		swap(y,z);
	}
	printf("%d",x+y);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define H 251

typedef struct{
  int k;
  int l;
  int r;
  int p; 
}N;



N A[H];



int left(int i){return 2*i;}
int right(int i){return 2*i+1;}





int main(){
  int n,i;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i].k);
  }
   for(i=1;i<=n;i++){
     if(i/2>=1)A[i].p=A[i/2].k;
    if(left(i)<=n)A[i].l=A[left(i)].k;
    if(right(i)<=n)A[i].r=A[right(i)].k;
    printf("node %d: key = %d, ",i,A[i].k);

    if(A[i].p)
     printf("parent key = %d, ",A[i].p);
    if(A[i].l)
      printf("left key = %d, ",A[i].l);
    if(A[i].r)
      printf("right key = %d, ",A[i].r);

    printf("\n");
   }
   
  
  return 0;
}



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

using namespace std;


int main(){

    int A, B, M;
    int c[100000];
    int x[100000], y[100000];
    int disc[100000];

    //vector <int> a (100000);
    //vector <int> b (100000);

    cin >> A >> B >> M;

    vector <int> a (A);
    vector <int> b (B);

    for(int i=0; i<A; i++) cin >> a[i];
    for(int i=0; i<B; i++) cin >> b[i];
    
    /*cout << endl;

    for(int i=0; i<A; i++) cout << a[i];
    cout << endl;
    for(int i=0; i<B; i++) cout << b[i];
    cout << endl;*/

    for(int i=0; i<M; i++){
        cin >> x[i] >> y[i] >> c[i];
    }

    //int minx;
    //minx = *std::min_element(x.begin(), x.end());

    for(int i=0; i<M; i++){
        disc[i] = a[x[i]-1] + b[y[i]-1] - c[i];
    }

    //for(int i=0; i<M; i++) cout << disc[i];

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    /*for(int i=0; i<A; i++) cout << a[i];
    cout << endl;
    for(int i=0; i<B; i++) cout << b[i];
    cout << endl;*/


    int dsum = a.at(0) + b.at(0);
    int store = dsum;

    for(int i=0; i<M; i++){
        if(store > disc[i]){
            store = disc[i];
        }
    }

    cout << store << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int isprime(int n)
{
        int i;
	for (i = 2; i*i <= n; i++){
		if (n%i == 0)
			return 0;
	}
	return 1;
}

int main(void)
{
	int i,n;
	int p[10001];
	for (i = 0; i < 10001; i++){
		p[i] = isprime(i);
	}
	while (1){
		scanf("%d", &n);
		if (n == 0)
			break;
		for (i = n; i >1; i--){
			if (p[i] * p[i - 2] == 1)
				break;
		}
		if (n >= 5)
			printf("%d %d\n", i - 2, i);
	}
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

}


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

int main(){
    int N, K, H[100000], DP[100000];
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> H[i];
    DP[0]=0;
    for(int i=1;i<N;i++){
        DP[i] = DP[i-1] + abs(H[i]-H[i-1]);
        for(int k=2;k<=K;k++) if(i-k>=0) DP[i] = min(DP[i], DP[i-k]+abs(H[i]-H[i-k]));
    }
    cout << DP[N-1] << endl;
    return 0;
}

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


int cnt[110];

int main() {
	int n, p;
	scanf("%d%d" , &n, &p);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		cnt[a % 2]++;
	}
	long long ans = 0;
	ans += 1LL << (cnt[0]);
	if (cnt[1] == 0) {
		if (p == 1)ans = 0;
	}
	else {
		ans *= 1LL << (cnt[1] - 1);
	}
	printf("%lld", ans);
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    REP (i, 0, N) cin >> v[i];
    sort(v.rbegin(), v.rend());
    int ab[2] = {0};
    REP (i, 0, N) {
        ab[i % 2] += v[i];
    }
    cout << ab[0] - ab[1] << endl;
    return 0;
}

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

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

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

    int cnt = 0;
    for(int i = 0; i < n - 2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
    }
    cout << cnt << endl;
}




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

using namespace std;

int ch(int a, int b) 
{
    int tmp = a - b;
    return tmp * tmp;
}

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

    int min = *min_element(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());
    int ans = 1 << 30;
    int x = min;

    while (x <= max) {
        int cost = 0;
        for (int i = 0; i < n; ++i) {
            cost += ch(a[i], x);
        }
        if (ans > cost) ans = cost;
        ++x;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    if(N % 10 == 3) cout << "bon" << endl;
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

ll N, M;
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	cout << (N * (N - 1)) / 2 + (M * (M - 1)) / 2;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

string setTwelve(int n1, int n2){
	string str1="000000";
	for(int i=5; n1; i--){
		str1[i] += n1%10;
		n1 /= 10;
	}
	string str2="000000";
	for(int i=5; n2; i--){
		str2[i] += n2%10;
		n2 /= 10;
	}
	return str1+str2;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int, int, string> > c;
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		c.emplace_back(a, b, i, "");
	}
	sort(c.begin(), c.end());
	int p=1, y=1;
	for(int i=0; i<m; i++){
		if(get<0>(c[i])!=p){
			p=get<0>(c[i]);
			y=1;
		}
		get<3>(c[i]) = setTwelve(p,y);
		y++;
	}
	sort(c.begin(), c.end(), [](tuple<int, int, int, string> x, tuple<int, int, int, string> y){
	return get<2>(x)<get<2>(y);
});
	for(int i=0; i<m; i++)
		cout << get<3>(c[i]) << endl;
	return 0;
}

Measured memory_bytes: 8944
#include<stdio.h>
int main()
{
	int A,B;
	scanf("%d %d",&A,&B);
	if(A==B)
	printf("Draw");
	else if(A==1&&B!=1)
	printf("Alice");
	else if(B==1&&A!=1)
	printf("Bob");
	else if(A!=1&&B!=1&&A>B)
	printf("Alice");
	else if(A!=1&&B!=1&&B>A)
	printf("Bob");
	return 0;
}

Measured memory_bytes: 128
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


def func(x, m):
    return x % m


# 処理内容
def main():
    N, X, M = map(int, input().split())

    L = [-1]*M
    route = []
    ans = 0
    a = 0
    l = 0
    r = N
    for i in range(N):
        if i == 0:
            a = X
        else:
            a = func(a**2, M)
        if L[a] >= 0:
            if N:
                pass
            l = L[a]
            r = i
            break
        else:
            L[a] = i
            route.append(a)
    
    ans += sum(route[:l])
    k = (N - l) // (r - l)
    m = (N - l) % (r - l)
    ans += sum(route[l:]) * k
    ans += sum(route[l:l+m])
    
    print(ans)



if __name__ == '__main__':
    main()

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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            long N = long.Parse(Console.ReadLine());
            var H = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);        
            for(var i=0;i<N-1;i++){
                if(H[i]<H[i+1])H[i+1]--;
                if(H[i]>H[i+1]){
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    } 
}

Measured memory_bytes: 25436
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(/ +/);
	// start time
	var t1 = (input[0] - 0) * 60 + (input[1] - 0);
	// end time
	var t2 = (input[2] - 0) * 60 + (input[3] - 0);
	// k
	var k = input[4];
	//出力
	var ret = t2 - t1 - k;
	console.log('%s', ret <= 0 ? 0 : ret);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29632
#include<stdio.h>
int main(void){
int n,i;
scanf("%d",&n);
int hensuu[n];
for(i=0;i<n;i++){
  scanf("%d",&hensuu[i]);
}
for(i=0;i<n;i++){
 printf("%d",hensuu[n-i-1]);
  if(i<n-1)printf(" ");
}
printf("\n");
return 0;
}

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

using namespace std;
#define ll long long int

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

    int price = 700;

    for (int i = 0 ; i<3 ; i++)
    {
        if (s[i] == 'o') price+=100;
    }
     
    cout << price;

    return 0;
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        long[] x = new long[N];
        for (int i = 0 ; i < N; i++) {
            x[i] = scan.nextLong();
        }
        long answer = 0;
        for (int i = 0; i < N-1; i++) {
            answer += Math.min(B, (x[i+1]-x[i])*A);
        }
        System.out.println(answer);
    }
}


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b; a--; b--;
    uf.unite(a, b);
  }
  set<int> p;
  rep(i, n) {
    if (p.find(uf.find(i)) == p.end()) p.insert(uf.find(i));
  }
  cout << p.size() - 1 << endl;
  return 0;
}

Measured memory_bytes: 7672