akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  vi ans(n);
  rep(sv,n) {
    vi dist(n,INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      if (dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(sv, 0);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      int d = dist[v];
      if (v-1 >= 0) push(v-1, d+1);
      if (v+1 < n) push(v+1, d+1);
      if (v == x) push(y, d+1);
      if (v == y) push(x, d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }
  rep(i,n) ans[i] /= 2;
  rrep(i,n-1) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;



int main(){

  string s;
  int k;

  cin >> s >> k;

  map<string, int> mp;
  if(s.length() < 50){
    for(int i = 0; i < s.length(); ++i){
      for(int j = i; j < s.length(); ++j){
        mp[s.substr(i,j-i+1)] = 1;
      }  
    }

    int cnt = 1;
    REPI(itr,mp){
      if(cnt == k){
        cout << itr->first << endl;
        return 0;
      }
      cnt++;
    }
    return 0;
  }

  for(int i = 0; i < 26; ++i){
    for(int j = 0; j < s.length(); ++j){
      if(s[j] == 'a' + i){
        for(int k = 1; k <= 5; ++k){
          mp[s.substr(j,k)] = 1;
        }
      }
    }
      if(mp.size() >= 5){
        vector<string> ans;
        int cnt = 1;
        REPI(itr,mp){
          if(cnt == k){
            cout << itr->first << endl;
            return 0;
          }
          cnt++;
        }
      }
  }
  int cnt = 1;
  REPI(itr,mp){
    if(cnt == k){
      cout << itr->first << endl;
      break;
    }
  }
  return 0;
}



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

using namespace std;

typedef long long ll;

int main () {
	double a,b,h,m;
	double deg;
	double sl=((double)360)/((double)60);
	double ss=((double)360)/((double)720);
	ll i, j;
	double ret;
	
	cin >> a>>b>>h>>m;
	
	deg = abs(ss*h*60+ss*m-sl*m);
	if (deg>180) {
		deg = 360-deg;
	}
	ret =sqrtl(static_cast<long double>(a*a + b*b - 2*a*b*cos(deg*M_PI/180.0)));
	cout << fixed << setprecision(20) << ret << endl;

	return 0;
}

Measured memory_bytes: 4220
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
//#define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

ll gcd(ll N, ll M){

if(N%M == 0)return M;

else return gcd(M, N%M);

}

ll F(ll N, ll M){
return (N*M)/gcd(N, M);
}

int main() {
ll A, B, C, D;cin >> A >> B >> C >> D;
ll N = B/C - (A - 1)/C + B/D - (A - 1)/D - B/F(C, D) + (A - 1)/F(C, D);
cout << B - A - N + 1;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<int>vec={a,b,c};
  sort(vec.begin(),vec.end());
  
 if(a-c>=-d&&a-c<=d){
   cout<<"Yes"<<endl;
 }
  else if((vec.at(1)==b)&&((a-b>=-d&&a-b<=d)&&(b-c>=-d)&&(b-c<=d))){
    cout<<"Yes"<<endl;
  }
          else{
            cout<<"No"<<endl;
          }
          }
          
          


Measured memory_bytes: 256
import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    if('AC' in L):
        idx=L.index('AC')
    else:
        idx=-1
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))

Measured memory_bytes: 40424
n = int(input())
w = [int(i) for i in input().split()]
sum_w = sum(w)
sum_left_w = 0
diff = sum_w
for w_i in w:
    sum_left_w += w_i
    diff_tmp = abs(sum_w - 2 * sum_left_w)
    if diff_tmp < diff:
        diff = diff_tmp

print(diff)


Measured memory_bytes: 3060
// Problem : B - Contest with Drinks Easy
// Contest : AtCoder Beginner Contest 050
// URL : https://atcoder.jp/contests/abc050/tasks/abc050_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T, size_t N> ostream& operator << (ostream &os, const array<T, N> &a) {os << "("; for (int i=0; i<(int)N; i++) {if (i) os << ", "; os << a[i];} return os << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int t[100];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> t[i];
    
    int m;
    cin >> m;
    for (int i=0; i<m; i++) {
        int p, x;
        cin >> p >> x;
        
        int ret = 0;
        for (int j=0; j<n; j++) {
            if (j == p - 1)
                ret += x;
            else
                ret += t[j];
        }
        
        cout << ret << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    long long* a;
    cin >> n;
    a = new long long[n];
    long long wa = 0;;

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

    long long result = 0;
    for (int i = 1; i < n; i++) {
        wa -= a[i];
        while (wa < 0) {
            wa += 1000000007;
        }
        result += a[i] * wa;
        result %= 1000000007;
    }

    cout << result << endl;

    delete[] a;
    return 0;
}

Measured memory_bytes: 4772
function main(input){
  const N = input.split("\n")[0];
  var arr =[];
  
  var retsu=input.split("\n");
  
  for(var i=0; i<N; i++){
    var temp=[]
    temp.push(retsu[i+1].split(" ")[0]);
    temp.push(parseInt(retsu[i+1].split(" ")[1], 10));
    temp.push(i+1);
    arr.push(temp)
  }

  arr.sort(function(a,b){
    if(a[0]>b[0]) return 1;
    if(a[0]<b[0]) return -1;
    if(a[1]>b[1]) return -1;
    if(a[1]<b[1]) return 1;
  });
  for(var i=0; i<N; i++){
    console.log(arr[i][2]);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7628
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
      os << *i;
  }
  return os;
}

ll W;
ll c[10],d[10];

void init(ll B[100]){
  rep(i,W-1){
    if(B[i]==1){
      c[i]++;
    }
  }
  rep(i,W){
    if(i==0){
      if(B[i]==0){
        d[i]++;
      }
    }
    else if(i==W-1){
      if(B[i-1]==0){
        d[i]++;
      }
    }
    else{
      if(B[i]==0 && B[i-1]==0){
        d[i]++;
      }
    }
  }
}

void dfs(ll i,ll B[100]){
  if(i>=W-1){
    init(B);
    return;
  }
  else{
    dfs(i+1,B);
    B[i]=1;
    dfs(i+2,B);
    B[i]=0;
  }
}

ll dp[1007][10];

int main(){
  ll H,K,B[100];
  rep(i,99){
    B[i]=0;
  }
  cin >> H >> W >> K;
  dfs(0LL,B);
  dp[0][0]=1;
  Rep(i,1,H+1){
    rep(j,W){
      dp[i][j]=(j>0 ? dp[i-1][j-1]*c[j-1] : 0)
                     +dp[i-1][j]*d[j]         
           +(j<W-1 ?  dp[i-1][j+1]*c[j] : 0);
      dp[i][j]%=MOD;
    }
  }
  cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  while (q--) {
    int u, v; cin >> u >> v, --u, --v;
    if (n == 1) {
      cout << min(u, v) + 1 << '\n';
    } else {
      set<int> se;
      while (true) {
        se.insert(u);
        if (!u) break;
        u = (u - 1) / n;
      }
      while (true) {
        if (se.count(v)) {
          cout << v + 1 << '\n';
          break;
        }
        v = (v - 1) / n;
      }
    }
  }
}

Measured memory_bytes: 1280
MOD = 998244353
n,k = gets.chomp.split(" ").map(&:to_i)
l,r = k.times.map{gets.split.map(&:to_i)}.transpose
dp = Array.new(n+1,0)
dp[n] = 1
arr = Array.new(n+1,0)
arr[n] = 1
arr[n-1] = -1
n.downto(1) do |i|
  if i+1 <= n
    arr[i] += arr[i+1]
    arr[i] %= MOD
  end
  k.times do |j|
    arr[i-l[j]] += arr[i] if i-l[j] > 0
    arr[i-r[j]-1] -= arr[i] if i-r[j]-1 > 0
  end
end
puts arr[1]

Measured memory_bytes: 17468
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        long count = 0;

        long firstHP = long.Parse(Console.ReadLine());
        var HPs = new SortedDictionary<long, long>(); // (hp, count)
        HPs.Add(firstHP, 1);
        while( true )
        {
            if ( !HPs.Keys.Any(n => n != 1) )
            {
                break;
            }

            long maxHP = HPs.Keys.Max();
            HPs.Add(maxHP / 2, HPs[maxHP] * 2);
            count += HPs[maxHP];
            HPs.Remove(maxHP);
        }
        count += HPs[1];
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13652
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
long n,q,idx;
long long val,lazy[1000005],st_max[1000005],st_sum[1000005];
void update(long id,long l,long r,long i,long j,long long x){
	if(lazy[id]!=0){
		st_max[id]=lazy[id];
		st_sum[id]=(r-l+1)*lazy[id];
		if(l<r){
		    lazy[2*id]=lazy[id];
		    lazy[2*id+1]=lazy[id];
		}
		lazy[id]=0;
	}
	if(l>j||r<i||i>j){
		return;
	}
	if(l>=i&&r<=j){
		st_max[id]=x;
		st_sum[id]=(r-l+1)*x;
		if(l<r){
		    lazy[2*id]=x;
		    lazy[2*id+1]=x;
		}    
		return;
	}
	long mid=(l+r)/2;
	update(2*id,l,mid,i,j,x);
	update(2*id+1,mid+1,r,i,j,x);
	st_max[id]=max(st_max[2*id],st_max[2*id+1]);
	st_sum[id]=st_sum[2*id]+st_sum[2*id+1];
}
long long get_max(long id,long l,long r,long i,long j){
	if(lazy[id]!=0){
		st_max[id]=lazy[id];
		st_sum[id]=(r-l+1)*lazy[id];
		if(l<r){
		    lazy[2*id]=lazy[id];
		    lazy[2*id+1]=lazy[id];
		}
		lazy[id]=0;
	}
	if(l>j||r<i||i>j){
		return -1e18;
	}
	if(l>=i&&r<=j){
		return st_max[id];
	}
	long mid=(l+r)/2;
	return max(get_max(2*id,l,mid,i,j),get_max(2*id+1,mid+1,r,i,j));
}
long long get_sum(long id,long l,long r,long i,long j){
	if(lazy[id]!=0){
		st_max[id]=lazy[id];
		st_sum[id]=(r-l+1)*lazy[id];
		if(l<r){
		    lazy[2*id]=lazy[id];
		    lazy[2*id+1]=lazy[id];
		}
		lazy[id]=0;
	}
	if(l>j||r<i||i>j){
		return 0;
	}
	if(l>=i&&r<=j){
		return st_sum[id];
	}
	long mid=(l+r)/2;
	return get_sum(2*id,l,mid,i,j)+get_sum(2*id+1,mid+1,r,i,j);
}
long search(long l,long r,long i,long long val){
	while(l<r){
		long mid=(l+r)/2;
		if((get_max(1,1,n,mid,i)*(i-mid+1)-get_sum(1,1,n,mid,i))<=val){
			r=mid;
		}else{
			l=mid+1;
		}
	}
	return l;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>q;
	for(int vl=1;vl<=q;vl++){
		cin>>idx>>val;
		long pos=search(1,idx,idx,val);
		long long dm=get_max(1,1,n,pos,idx);
		long long dm3=idx-pos+1;
		val-=dm*dm3-get_sum(1,1,n,pos,idx);
		update(1,1,n,pos,idx,dm);
		long long dm1=val/dm3;
		long long dm2=val%dm3;
		update(1,1,n,pos,idx,dm+dm1);
		update(1,1,n,pos,pos+dm2-1,dm+dm1+1);
	}
	for(int i=1;i<=n;i++){
		cout<<get_max(1,1,n,i,i)<<endl;
	}
}


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

bool isAllEven(int *A, int N){
  for(int i=0;i<N;i++){
    if(A[i] % 2 != 0){
      return false;
    }
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int counter = 0;
  while(isAllEven(A, N)){
    counter ++;
    for(int i=0;i<N;i++){
      A[i] = A[i]/2;
    }
  }
  cout << counter;
}



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[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		solve(N, A);
	}
	
	public static void solve(int N, int[] A) {
		for (int j = 0; j < N; j++) {
			int key = A[j];
			int i = j - 1;
			while(i >= 0 && A[i] > key) {
				A[i+1] = A[i];
				i--;
			}
			A[i+1] = key;
			
			System.out.print(A[0]);
			for(int k = 1; k < N; k++) {
				System.out.print(" ");
				System.out.print(A[k]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 25904
#include <stdio.h>
 
int main()
{
    int n;
    scanf("%d", &n);
    int ans[10001] = {0};
    for (int i = 1; i <= 100; i++)
	{
        for (int j = 1; j <= 100; j++)
		{
            for (int k = 1; k <= 100; k++)
			{
                int temp = i*i + j*j + k*k + i*j + j*k + i*k;
                if (temp <= 10000)
				{
                    ans[temp]++;
                }
            }
        }
    }
 
    for (int i = 1; i <= n; i++){
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll inf=(ll)1e18;
const ll maxs = (ll)3000+5;
const ll mod = (ll)1e9+7;
const ll oo = (ll) 1e18;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll n;
string s;
ll dp[maxs][maxs];
bitset<3005> b;
ll go(ll pos,ll below ,ll above)
{
    if(below<0||above<0)
        return 0;
    if(pos==n)return 1;    
    if(dp[pos][below]!=-1)
        return dp[pos][below];
    ll op = s[pos-1];
    ll ans=0;
    if(op=='<')
    {
        ans += go(pos+1,below,above-1);
        ans += go(pos,below+1,above-1);
        ans %= mod;
    }
    else
    {
        ans += go(pos+1,below-1,above);
        ans += go(pos,below-1,above+1);
        ans %= mod;
    }
    return dp[pos][below]=ans;
    
}

void solve()
{
    ll ans=0;
    memset(dp,-1,sizeof dp);
    for(ll i=1;i<=n;i++)
    {
        ll below = i-1;
        ll above = n-i;
        ans = ( ans + go(1,below,above) )%mod;
    }    
    cout<<ans;    
}

int main() {
    fastio();
	cin>>n>>s;
	solve();
	return 0;
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll K;
    cin >> K;
    ll ans = 0;
    rep1(a,K+1)rep1(b,K+1)rep1(c,K+1){
        ans += gcd(a,gcd(b, c));
    }
    cout << ans << endl;
}

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

#define A first
#define B second

vector<string> a;
string g = "AKIHABARA";

void ins(string s, int k) {
	if (k >= s.length()) {
		a.push_back(s);
		return;
	}

	a.push_back(s);
	if (s[k] == 'A') {
		string t = "";
		for (int i = 0; i < s.length(); ++i)
			if (i != k)
				t += s[i];
		ins(t, k);
	}

	ins(s, k+1);
}

int main() {
	ins(g, 0);
	string s;
	cin >> s;

	for (int i = 0; i < a.size(); ++i) {
		if (a[i] == s) {
			cout << "YES\n";
			return 0;
		}
	}

	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
# 各日について満足度の一番高いコンテストを選択する貪欲
def main():
    import sys
    import numpy as np
    D=int(sys.stdin.readline())
    S=np.zeros((D,26))
    C=np.array(map(int,sys.stdin.readline().split()))
    for i in range(D):
        S[i]=list(map(int,sys.stdin.readline().split()))
    
    for i in range(D):
        print(np.argmax(S[i])+1)

main()

Measured memory_bytes: 27256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   int N, M; cin >> N >> M;
   rep(i, 0, M) {
     int A; cin >> A;
     N -= A;
   }

   if (N < 0) cout << -1 << endl;
   else cout << N << endl;
 }


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll X, y;
    cin >> X >> y;
    ll a, b, c;
    cin >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for(auto& x:p)
        cin >> x;
    for(auto &x : q)
        cin >> x;
    for(auto &x : r)
        cin >> x;
    priority_queue<ll, vector<ll>, greater<>> red, green;
    for(auto &x : p){
        red.push(x);
        if(red.size() == X + 1) red.pop();
    }
    for(auto &x : q) {
        green.push(x);
        if(green.size() == y + 1) green.pop();
    }
    for(auto& x:r){
        if(red.top()<green.top()){
            if(red.top()<x){
            red.pop();
            red.push(x);
            }
        }else {
            if(green.top() > x) continue;
            green.pop();
            green.push(x);
        }
    }
    ll ret = 0;
    while(!red.empty()){
        ret += red.top();
        red.pop();
    }
    while(!green.empty()) {
        ret += green.top();
        green.pop();
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4852
import itertools
def Warshall_Floyd(edges,N):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])
  return edges
n,m,r = map(int,input().split())
a = list(map(int,input().split()))
b = [list(map(int,input().split())) for l in range(m)]
d = [[float("inf")]*n for i in range(n)]
for i in range(m):
  d[b[i][0]-1][b[i][1]-1] = min(b[i][2],d[b[i][0]-1][b[i][1]-1])
  d[b[i][1]-1][b[i][0]-1] = min(b[i][2],d[b[i][1]-1][b[i][0]-1])
d = Warshall_Floyd(d,n)
kumi = list(itertools.permutations(a, r))
kota = float("inf")
for i in kumi:
  ans = 0
  for j in range(1,r):
    ans += d[i[j-1]-1][i[j]-1]
  kota = min(ans,kota)
print(kota)

Measured memory_bytes: 65752
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int[] arr = {in.nextInt(), in.nextInt()};

        while (!(arr[0] == 0 && arr[1] == 0)) {
            Arrays.sort(arr);
            System.out.println(arr[0] + " " + arr[1]);

            arr[0] = in.nextInt();
            arr[1] = in.nextInt();
        }

        System.exit(0);
    }
}



Measured memory_bytes: 36188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

ll N, P;
string S;

ll pow_mod(ll n, ll k, ll mod) {
    if (k == 0) return 1;
    else if (k % 2 == 1) {
        return pow_mod(n, k-1, mod) * n % mod;
    }
    else {
        ll tmp = pow_mod(n, k/2, mod);
        return tmp * tmp % mod;
    }
}

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

    if (P == 2 || P == 5) {
        ll ans = 0;
        for (int i = N-1; i >= 0; i--) {
            if ((S[i] - '0') % P == 0) {
                ans += (i+1);
            }
        }
        cout << ans << endl;
    }
    else {
        ll dp[N+1];
        dp[0] = 0;
        dp[1] = (S[N-1] - '0') % P;
        for (ll i = 2; i <= N; i++) {
            dp[i] = (dp[i-1] + pow_mod(10, i-1, P) * (S[N-i] - '0') % P) % P;
        }

        map<ll, ll> mp;
        for (int i = 0; i <= N; i++) {
            mp[dp[i]]++;
        }

        ll ans = 0;
        for (auto itr = mp.begin(); itr != mp.end(); itr++) {
            ll val = itr->second;
            ans += val * (val-1) / 2;
        }

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


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

using namespace std;

long long solve(long long h) {
	if (h == 1) return 1;
	return (2 * solve(h / 2) + 1);
}

int main() {
	long long h; cin >> h;
	cout << solve(h) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_in 2000
int n,A[MAX_in];

int Solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  res=Solve(i+1,m)||Solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(Solve(0,m)==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define test(a) cout << "*" << a << endl
int main(){
  int a,b;
  int kAns;
  int k=0;
  int i;
  int aBig,aSmall;
  int maxYakusuu;
  
  cin >> a >> b >> kAns;
  
  if(a>=b){
    aBig = a;
    aSmall = b;
  }
  else{
    aBig = b;
    aSmall = a;
  }
  
  for(i=aSmall;i>0;i--){
    if(aBig%i==0 && aSmall%i==0){
      maxYakusuu = i;
      break;/*ちゅうい*/
    }
  }
  //test(maxYakusuu);
  for(i=maxYakusuu;i>0;i--){
    if(maxYakusuu%i==0)
      k++;
    if(k==kAns){
      cout << i << endl;
      break;
    }
  }

}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int s[100];
int main ()
{
	string s;
	cin>>s;
	int a=0,b=0;
	for (int i=0;i<s.length();++i)
	   {
	   	 if (s[i]=='0') a++;
	   	 if (s[i]=='1') b++;
	   }
	if (a==0||b==0) printf ("0");
	else
	   {
	   	 if (a>=b)
	   	   printf ("%d",2*b);
	   	 else printf ("%d",2*a);
	   }
   return 0;
 } 

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

	ll n,k;
  cin>>n>>k;
  
  if(k==1) cout << 0 << endl;
  
  else cout << (n-k) << endl;

  return 0;

}


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

long long n,m,c,x,y,a,b,t, hasil=0, tag, j, dist;
int stick[200001];
bool mulai[200001];
bool sel[200001];
bool valid = true;

int main() {
   cin >> n;
   for (int i = 1; i <= n; i++){
       cin >> stick[i];
   }
   sort(stick+1,stick+1+n);
   for(int i = n; i>= 1; i--){
       if (stick[i] == stick[i-1]){
           a = stick[i];
           j= i-1;
           break;
       }
   }
   for (int i = j-1; i>= 1; i--){
       if (stick[i] == stick[i-1]){
           b = stick[i];
           break;
       }
   }
    cout << a*b << endl;
           
 }
    
    
    
    

    
   


Measured memory_bytes: 3988
<?php

function primeFactor($N) {
    $res = array();
    for ($d = 2; $d*$d <= $N; $d++) {
        while ($N % $d == 0) {
            $res[''.$d] = $res[''.$d]+1;
            $N /= $d;
        }
    } 
    if ($N != 1) {
       $res[''.$N] = $res[''.$N]+1;
    }
    return $res;
}

$input = explode(' ', trim(fgets(STDIN)));
$N = (int)$input[0];
$P = (int)$input[1];
$max = 1;
foreach (primeFactor($P) as $key => &$value) {
    $divisor = (int)$key;
    $count = $value;
//    echo $divisor." ".$count." ".$N."\n";
    while ($count >= $N) {
        $max *= $divisor;
        $count -= $N;
    }
}
echo $max;


Measured memory_bytes: 4728
#include<stdio.h>
int main(){
  char n[3];
  scanf("%s",n);
  if(n[0]=='A' && n[1]=='B' && n[2]=='C')
    printf("ARC");
  else if(n[0]=='A' && n[1]=='R' && n[2]=='C')
    printf("ABC");
  return 0;
}


Measured memory_bytes: 1676
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

res = 1
coin = [1]
i = 1
while res < 10**5:
    coin.append(6**i)
    i += 1
    res *= 6
    
res = 1
i = 1
while res < 10**5:
    coin.append(9**i)
    i += 1
    res *= 9
    
coin.sort()
    
dp = [10**5]*(n+1)
dp[0] = 0

for i in range(1,n+1):
    for c in coin:
        if i-c >= 0:
            dp[i] = min(dp[i], dp[i-c]+1)
            
print(dp[n])

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

int h,n;
long long f[20001];

int main()
{
	int x,y;
	for(int i=1;i<=20000;i++)
		f[i]=1e18;
	
	f[0]=0;
	cin>>h>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		for(int j=0;j<h;j++)
			f[j+x]=min(f[j+x],f[j]+y);
	}
	
	long long minn=1e18;
	
	for(int i=h;i<=20000;i++)
		minn=min(f[i],minn);
	
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

const int MOD = 1e9+7;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

vector<pair<long long, long long> > prime_factorizer(long long N){
    vector< pair<long long, long long> > res;

    for(long long i = 2; i * i <= N; ++i){
        if( N %i != 0 ) continue;
        long long ex = 0;

        while(N%i == 0){
            ex++;
            N /= i;
        }
        res.push_back({ i, ex });
    }
    
    if(N != 1) res.push_back({N, 1});

    return res;
}

using mint = Fp<MOD>;

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

    mint dp[K+1];
    for(int i=1; i<K+1; ++i){
        dp[i] =modpow(mint(K/i), N);
    }

    for(int i=K+1; i>0; --i){
        for(int j=2*i; j<K+1; j= j+i){
            dp[i] -= dp[j];
        }
    }

    mint ans = 0;
    for(int i=1; i<K+1; ++i){
        ans += (dp[i] * i);
    }

    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> t(n);
  rep(i, n) {
    string s;
    cin >> s;
    int a;
    cin >> a;
    t.at(i) = make_tuple(s, 100-a, i);
  }
  sort(t.begin(), t.end());
  rep(i, n) {
    int b;
    tie(ignore, ignore, b) = t.at(i);
    cout << b+1 << endl;
  }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	ll p = a * x + b * y;
	
	ll q = 2 * c * max(x, y);
	
	ll t = x > y ? a : b;
	ll r = 2 * c * min(x, y) + t * abs(x - y);

	ll ans = min(p, min(q, r));
	out(ans);

	return 0;
}

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

int a[100001];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int ql=1;
	for(int i=1;i<=n;i++)
		if(a[i])ql=0;
	if(ql){
		printf("Yes\n");
		return 0;
	}
	if(n%3){
		printf("No\n");
		return 0;
	}
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++)
		if(i!=n/3+1&&i!=n/3*2+1&&a[i]!=a[i-1]){
			printf("No\n");
			return 0;
		}
	if(a[1]^a[n/3+1]^a[n/3*2+1]){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
}

Measured memory_bytes: 2052
n=int(input())
flag=0
ans=[]
cnt=0
if n%2==0:flag=1
for i in range(1,n):
    for j in range(i+1,n+1):
        if i+j!=n+flag:
            cnt+=1
            ans.append([i,j])
print(cnt)
for i in ans:
    print(*i)

Measured memory_bytes: 4124
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#define INF 10e10

using namespace std;

//  #define y cout << "yes"<< endl
  #define Y cout << "YES" << endl
  #define y cout << "Yes" << endl
//  #define n cout << "no"<< endl
  #define N cout << "NO" << endl
  #define n cout << "No" << endl
  #define pu(q) cout << q ;
  #define put(q) cout << q << " ";
  #define puts(q) cout << q << endl;
  
  
	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h,ans,res;
//	string a,b,c,d,e,f,g,h,ans,res;
//	double a,b,c,d,e,f,g,h,ans,res;
	
void take(int x);
  
int main(void){
	take(3);//数
	d=a-b;
	puts(max(c-d,0));
	
	/*if(){
		
		
	//	y;	//Yes
	//	Y;	//YES
	//	n;	//No
	//	N;	//NO
	}
	
	else if(){
		
		
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}
	else if(){
		
		
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}
	else if(){
		
		
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}
	
	else{
		
		
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}*/
//	cout << ans << endl;
	
	return 0;
}
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}

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

int main(void)
{
 int N,i;
 char S[100];
 int count=0;

  scanf("%d",&N);
  scanf("%s",S);
 for(i=0;i<=N-3;i++){
  if(((S[i]=='A')&&(S[i+1]=='B'))&&(S[i+2]=='C')){
    count++;
  }
 }
 printf("%d\n",count);

 return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  cout << (s=="abc"?"Yes":"No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define LL long long
#define P pair<int,int>
#define LP pair<LL,LL>
string A, B, C;
int main(){
    int N;
    cin >> N;
    cin >> A >> B >> C;
    int res = 0;
    for(int i = 0; i < A.size(); i++){
        char a = A[i], b = B[i], c = C[i];
        if(a == b && b == c) res;
        else if(a == b && a != c) res++;
        else if(b == c && a != b) res++;
        else if(a == c && a != b) res++;
        else res += 2;
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    bool f = false;

    while (N > 0){
        int dig = N % 10;
        if (dig == 9){
            f = true;
        }
        N = N / 10;
    }
    
    if (f == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 300;

int edge[1 + MAXN][1 + MAXN];
pair<int, pair<int, int> > v[1 + MAXN * MAXN];

bool Check(int n) {
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (i != j && i != k && k != j && edge[i][k] + edge[k][j] < edge[i][j])
                    return false;
    return true;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n;
    long long sum = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) {
            scanf("%d", &edge[i][j]);
            sum += edge[i][j];
        }
    sum /= 2;
    if (!Check(n)) {
        printf("-1\n");
        return 0;
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            v[(i - 1) * n + j] = make_pair(edge[i][j], make_pair(i, j));
    sort(v + 1, v + n * n + 1);
    for (int i = n * n; i >= 1; i--) {
        int a = v[i].second.first, b = v[i].second.second;
        if (a >= b)
            continue;
        for (int j = 1; j <= n; j++)
            if (a != j  && b != j && edge[a][j] + edge[j][b] == edge[a][b]) {
                sum -= edge[a][b];
                break;
            }
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 1536
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

int main(int argc, char const *argv[]) {
  ll n,m; std::cin >> n >> m;
  std::vector<ll> a(n,0); REP(i,n) std::cin >> a[i];
  ll _gcd, LeastCommonMultipule=1;
  // init
  REP(i,n) LeastCommonMultipule=lcm(LeastCommonMultipule,a[i]);

  // if (m < LeastCommonMultipule/2) {
  //   std::cout << 0 << '\n';
  //   return 0;
  // }
  for (int i = 0; i < n; i++) {
    if ((LeastCommonMultipule / a[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans;
  ans = m/LeastCommonMultipule;
  ll sa = m - ans*LeastCommonMultipule;
  if (sa < LeastCommonMultipule/2) std::cout << ans << '\n';
  else std::cout << ans+1 << '\n';
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABCA130
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,A, X;
            var word = Console.ReadLine().Split();
            A =int.Parse(word[0]);
            X = int.Parse(word[1]);
            
            if (X <= A)
                a = 10;

            else 
                a = 0;
            Console.WriteLine(a);
            Console.ReadKey();

                
        }
    }
}

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



auto lcs(const std::string& a, const std::string& b, std::vector<std::vector<int> >*tp) {
	auto tab = *tp;

	for (auto&e : tab) {
		std::fill(std::begin(e),std::end(e),0);
	}

	for (decltype(a.size()) ai{1}; ai <= a.size();++ai) {
		for (decltype(ai) bi{1}; bi<=b.size(); ++bi) {
			if (a[ai-1] == b[bi-1])
				tab[ai][bi] = tab[ai - 1][bi - 1] + 1;
			else
				tab[ai][bi] = std::max(tab[ai - 1][bi], tab[ai][bi - 1]);
		}
	}
	return tab[a.size()][b.size()];
}

int main() {
	int q;
	std::cin >> q;

	std::vector<std::vector<int>> buf{};
	buf.resize(1005);
	for (auto&e : buf)
		e.resize(1005);

	for (int i{}; i < q; ++i) {
		std::string x, y;
		std::cin >> x >> y;
		std::cout << lcs(x, y, &buf)<<"\n";
	}

	return 0;
}


Measured memory_bytes: 10884
#include<stdio.h>
#include<algorithm>
#include<vector>
#define fst first
#define snd second

using namespace std;

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

char three[3][4] = {
    "xx.",
    "..y",
    "..y"
};

char four[4][5] = {
    "aacd",
    "bbcd",
    "cdaa",
    "cdbb"
};

char five[5][6] = {
    "aabbc",
    "dx..c",
    "dx..b",
    "a.yyb",
    "accdd"
};

char six[6][7] = {
    "aacd..",
    "bbcd..",
    "..aacd",
    "..bbcd",
    "cd..aa",
    "cd..bb"
};

char seven[7][8] = {
    "aabbcc.",
    "xx.xx.a",
    "..y..ya",
    "..y..yb",
    "xx.xx.b",
    "..y..yc",
    "..y..yc"
};

char ans[1000][1000 + 1];

int main() {
    int n;
    scanf("%d", &n);
    if (n == 2) return !puts("-1");
    if (n == 3) {
        for(int i = 0; i < 3; i++)
            puts(three[i]);
    }
    else {
        for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans[i][j] = '.';

        for(int st = 0; st < n;) {
            if (n - st == 5) {
                for (int i = 0; i < 5; i++) for (int j =0; j < 5; j++) {
                    ans[st + i][st + j] = five[i][j];
                }
                st += 5;
            }
            else if (n - st == 6) {
                for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) {
                    ans[st + i][st + j] = six[i][j];
                }
                st += 6;
            }
            else if (n - st == 7) {
                for (int i = 0; i < 7; i++) for (int j = 0; j < 7; j++) {
                    ans[st + i][st + j] = seven[i][j];
                }
                st += 7;
            }
            else {
                for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) {
                    ans[st + i][st + j] = four[i][j];
                }
                st += 4;
            }
        }
        
        for (int i = 0; i < n; i++)
            puts(ans[i]);
    }
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

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

int main(void) {
    int s,m;
    cin>>s>>m;

    if(m >= s) {
        cout<<"unsafe"<<endl;
    } else {
        cout<<"safe"<<endl;
    }

    return 0;
}




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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;

  ll div = N / (A + B);
  ll ans = div * A;
  ll amari = N - div * (A + B);
  ans += min(A, amari);

  cout << ans << endl;


}


Measured memory_bytes: 256