akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;


int main() {
	ll n, k;
	cin >> n >> k;
	ll a = ((n - 1)*(n - 2)) / 2;
	if (a< k) {
		cout << -1<< endl;
		return 0;
	}
	ll m = a - k + (n-1);
	ll c = 0;
	cout << m << endl;
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			cout << i << " " << j << endl;
			c++;
			if (c == m)return 0;
		}
	}
	return 0;
}




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



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: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool ab = false, ac = false, bc = false;
  
  if (a == b) {
    if (a == c) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else if (b == c) {
    if (a == b) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else if (c == a) {
    if (a == b) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,D = LI()
    ans = 0
    for _ in range(N):
        x,y = LI()
        if x*x + y*y <= D*D:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,H,W;
    cin >> N >> H >> W;

    cout << max(i64(0),(N-H+1))*max(i64(0),(N-W+1)) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

int dp[3005][3005];
void solve(){
	int n;
	string s;
	cin>>n>>s;
	dp[0][1]=1;
	
	rep(i,1,n){
		int r=i+1;
		rep(j,1,r+1){
			dp[i-1][j]+=dp[i-1][j-1];
			dp[i-1][j]%=M;
		}
		rep(j,1,r+1){
			if(s[i-1]=='>'){
				dp[i][j]=(M+dp[i-1][r-1]-dp[i-1][j-1])%M;
				// sigma(j,r-1);
			}
			else{
				dp[i][j]=(M+dp[i-1][j-1]-dp[i-1][0])%M;
				// sigma(1,j-1);
			}
		}
	}
	int ans=0;
	rep(i,0,3002)ans=(ans+dp[n-1][i])%M;
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 68992
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        String s=br.readLine();
        if(s.length()<=n)
        pw.println(s);
        else
        pw.println(s.substring(0,n)+"...");
        pw.flush();
        pw.close();
    }
}

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

int main()
{
    char str[1000+1];
    char command[16];
    char tmp;
    char p[1000+1];
    int q;
    int a, b;
    scanf("%s", str);
    scanf("%d", &q);
    while(q > 0) {
        scanf("%s", command);
        if(strcmp(command, "print") == 0) {
            scanf("%d %d%*c", &a, &b);
            while(a <= b) {
                putchar(str[a]);
                a++;
            }
            putchar('\n');
        } else if(strcmp(command, "reverse") == 0) {
            scanf("%d %d%*c", &a, &b);
            while(a < b) {
                tmp = str[a];
                str[a] = str[b];
                str[b] = tmp;
                a++;
                b--;
            }
        } else if(strcmp(command, "replace") == 0) {
            scanf("%d %d %s", &a, &b, p);
            strncpy(str+a, p, b-a+1);
        }
        q--;
    }
    return 0;
}


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

int main(){
  int n,ans=0;cin>>n;
  REP(i,n){
    int tmp;cin>>tmp;
    if(!(i%2)){
      if(tmp%2) ans++;
    }
  }

  cout<<ans;
}

Measured memory_bytes: 3592
import math
a,b,x=map(int, raw_input().split())

l=float(2*x)/(a*b)
if l<=a:
    print 90-math.degrees( math.atan2(l,b) )
    quit()

c=float(2*x)/(a**2)-b
print math.degrees( math.atan2(b-c,a) )


Measured memory_bytes: 27884
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int A = Integer.parseInt(arr[0]);
        int B = Integer.parseInt(arr[1]);
        int K = Integer.parseInt(arr[2]);
        int limit = Math.min(A, B);
        List<Integer> list = new ArrayList<>();
        for (int i = limit; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                list.add(i);
            }
        }
        out.println(list.get(K - 1));
        out.close();
    }
}


Measured memory_bytes: 23252
using System;
using System.Collections;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(DoubleHelix());
    }

    private static string DoubleHelix()
    {
        Hashtable ht = new Hashtable();
        ht.Add("A", "T");
        ht.Add("C", "G");
        ht.Add("G", "C");
        ht.Add("T", "A");

        string b = string.Empty;

        readData(ref b);

        return (string)ht[b];
    }

    /// <summary>
    /// データを読み込む
    /// </summary>
    private static void readData(ref string b)
    {
        b = Console.ReadLine();
    }
}




Measured memory_bytes: 11092
#include<stdio.h>

int culc(int a,int b,int c){
  int s,t;
  s = a-b;
  if(s < 0)
    s *= -1;
  t = b-c;
  if(t < 0)
    t *= -1;

  return s + t;
}

int main(){
  int i,j,a,b,c;
  int cost[6];
  int min = 10000;
  scanf("%d %d %d",&a,&b,&c);

  cost[0] = culc(a,b,c);
  cost[1] = culc(a,c,b);
  cost[2] = culc(b,a,c);
  cost[3] = culc(b,c,a);
  cost[4] = culc(c,b,a);
  cost[5] = culc(c,a,b);

  for(i=0;i<6;i++){
    if(cost[i] < min)
      min = cost[i];
  }
  printf("%d\n",min);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
const ll INF=1<<30;
ll h,w;
ll t[50][50]={};
bool inarea(ll x,ll y){
    return x>=0&&y>=0&&x<h&&y<w;
}
ll bfs(){
    vector<vector<ll>> v(h, vector<ll>(w,INF) );
    queue<pair<int, int>> q;
    v[0][0]=0;
    q.push({0,0});
    while(!q.empty()){
        pair<int, int> p = q.front();
        int x = p.first;
        int y = p.second;
        q.pop();
        if(inarea(x+1,y)&&t[x+1][y]&&v[x][y]+1<v[x+1][y]){
            v[x+1][y]=v[x][y]+1;
            q.push({x+1,y});
        }
        if(inarea(x-1,y)&&t[x-1][y]&&v[x][y]+1<v[x-1][y]){
            v[x-1][y]=v[x][y]+1;
            q.push({x-1,y});
        }
        if(inarea(x,y+1)&&t[x][y+1]&&v[x][y]+1<v[x][y+1]){
            v[x][y+1]=v[x][y]+1;
            q.push({x,y+1});
        }
        if(inarea(x,y-1)&&t[x][y-1]&&v[x][y]+1<v[x][y-1]){
            v[x][y-1]=v[x][y]+1;
            q.push({x,y-1});
        }
    }
    return v[h - 1][w - 1];
}


int main()
{ 

cin >>h>>w; 

char maze[51][51];
ll wh=0;

rep(j,h){rep(i,w) {
    cin >> maze[j][i];
    if(maze[j][i]=='.'){t[j][i]=1;wh++;}
    else t[j][i]=0;
}}

ans=bfs();
if(ans==INF)cout << -1 << endl;
else cout << wh-ans-1 << endl;
return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,k;
  cin >> n >> k;
  int count=0;
  vector<int> ans(n);
  rep(i,k){
    int d;
    cin >> d;
    vector<int> v(d);
    rep(j,d){
      cin >> v.at(j);
      ans.at(v.at(j)-1)++;
    }
  }
    rep(i,n){
    if(ans.at(i)==0){
      count++;
    }
  }
  cout << count;
}
  

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

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> x;
  
  for (ll i = 0; i < M; i++) {
    ll a;
    cin >> a;
    x.push_back(a);
  }
  sort(x.begin(), x.end());
  ll D = x[M-1] - x[0];
  
  priority_queue<ll> que;
  for (ll i = 0; i < M-1; i++) {
    que.push(x[i+1]-x[i]);
  }
  
  ll ans = D;
  
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  
  for (ll i = 0; i < N-1; i++) {
    ans -= que.top();
    que.pop();
  }
  cout << ans << endl;
}

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

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 ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll K;

ll f(vector<int> g,bool x){
  ll ans = 1LL;
  if(x){
    for(ll i = 0LL; i < (ll)g.size();i++){
      ans=(ans*(K-i-1LL))%mod;
    }
  }
  if(!x){
    for(ll i = 0; i < (ll)g.size();i++){
      ans=(ans*(K-i-2LL))%mod;
    }
  }
  return ans;
}

int main() {
  ll N;
  cin>>N>>K;
  vector<vector<int>> g(N);
  for(int i = 0; i < N-1; i++) {
    int x,y;
    cin>>x>>y;
    g[x-1].push_back(y-1);
    g[y-1].push_back(x-1);
  }
  queue<int> q;
  vector<bool> seen(N,false);
  q.push(0);
  seen[0]=true;
  vector<int>parent(N,-1),dep(N,0);
  vector<vector<int>> child(N);
  int d = 0;
  while(!q.empty()){
    d++;
    int t= q.front();
    q.pop();
    for(auto nx:g[t]){
      if(seen[nx]) continue;
      seen[nx]=true;
      q.push(nx);
      child[t].push_back(nx);
      parent[nx]=t;
      dep[nx]=d;
    }
  }
  queue<int> bfs;
  ll ans = K;
  bfs.push(0);
  while(!bfs.empty()){
    int t = bfs.front();
    bfs.pop();
    ans=(ans*f(child[t],(dep[t]<1)))%mod;
    for(auto x:child[t]){
      bfs.push(x);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12032
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    vector<ll>b(n);
    rep(i,n){
        b[a[i]]++;
    }
    ll ans = 0;
    rep(i,n){
        ans += b[i]*(b[i]-1) / 2;
    }
    rep(i,n){
        int k = a[i];
        ans -= b[k]*(b[k]-1)/2;
        b[k]--;
        ans += b[k]*(b[k]-1)/2;
        cout << ans << "\n";
        ans -= b[k]*(b[k]-1)/2;
        b[k]++;
        ans += b[k]*(b[k]-1)/2;
        
    }
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;


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

    int ans = 1;
    REP(i, N){
        if(ans*2 < ans+K){
            ans *= 2;
        }else{
            ans += K;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

struct Pair {
  unsigned x, y;
  Pair(unsigned x, unsigned y) : x(x), y(y) {}
};

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::vector<long long> a(N);
  N_TIMES(n, N) std::cin >> a[n];
  
  auto max_itr = std::max_element(a.begin(), a.end());
  auto min_itr = std::min_element(a.begin(), a.end());
  
  std::list<Pair> list;
  if (std::abs(*max_itr) >= std::abs(*min_itr)) {
    unsigned max_index = std::distance(a.begin(), max_itr);
    
    for (unsigned n = 0; n < N; ++n) {
      //if (a[n] < 0) {
        list.emplace_back(max_index, n);
      //}
    }
    
    for (unsigned n = 1; n < N; ++n) {
      //if (a[n - 1] <= a[n]) continue;
      
      list.emplace_back(n - 1, n);
    }
  } else {
    unsigned min_index = std::distance(a.begin(), min_itr);
    
    for (unsigned n = 0; n < N; ++n) {
      //if (a[n] >= 0) {
        list.emplace_back(min_index, n);
      //}
    }
    
    for (unsigned n = N - 1; n > 0; --n) {
      //if (a[n - 1] <= a[n]) continue;
      
      list.emplace_back(n, n - 1);
    }
  }
  
  std::cout << list.size() << std::endl;
  for (const Pair &p : list) {
    std::cout << (p.x + 1) << ' ' << (p.y + 1) << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
let pr x = print_endline @@ string_of_int x

let max (a : int) (b : int) =
  if a > b then a else b

let min (a : int) (b : int) =
  if a < b then a else b

let fold (f : int * char * int -> char -> int * char * int) init s =
  let rec iter i res =
    if i < 0 then res else iter (i - 1) (f res s.[i]) in
  iter (String.length s - 1) init

let solve seq =
  let len = String.length seq in
  let (_,_,res) = fold
                    (fun (cnt,pre,mv) x ->
                      if x != pre then
                        (cnt+1,x,min mv (max cnt (len - cnt)))
                      else (cnt+1,x,mv))
                    (0,seq.[0],len) seq in res

let () = input_line stdin
         |> solve
         |> pr

Measured memory_bytes: 4864
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a;
    map<int, int> s;
    int x;
    rep(i, n) {
        cin >> x;
        if (s[x] >= 1) {
            s[x]++;
        }
        else {
            a.push_back(x);
            s[x] = 1;
        }
    }
    sort(a.begin(), a.end());
    int m = a.size();
    int res = 0;
    for (int i = 0; i < m - 2; i++) {
        for (int j = i + 1; j < m - 1; j++) {
            for (int k = j + 1; k < m; k++) {
                if (a[i] + a[j] > a[k])
                    res += s[a[i]] * s[a[j]]* s[a[k]];
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;



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

        ll n; cin >> n;
        vector<ll> a(n);
        ll x = 0;
        rep(i,n){
                cin >> a[i];
                x ^= a[i];
        }

        rep(i,n){
                ll tmp = x ^ a[i]; 
                cout << tmp << " ";
        }
        cout << endl;
        
        

        return 0;
}


Measured memory_bytes: 4788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int s[210][210],f1[210][210][210],f2[210][210][210],n,m;
char a[210][210];
bool chk(int x1,int y1,int x2,int y2){
	int tmp=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
	return tmp==0||tmp==(x2-x1+1)*(y2-y1+1);
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i]+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(a[i][j]=='.');
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			for(int k=m;k;k--){
				if(k<m&&chk(i,k,j,f1[i][j][k+1])) f1[i][j][k]=f1[i][j][k+1];
				else if(chk(i,k,j,k)) f1[i][j][k]=k;
			}
	for(int i=1;i<=m;i++)
		for(int j=i;j<=m;j++)
			for(int k=n;k;k--)
				if(k<n&&chk(k,i,f2[i][j][k+1],j)) f2[i][j][k]=f2[i][j][k+1];
				else if(chk(k,i,k,j)) f2[i][j][k]=k;
	if(f1[1][n][1]==m){
		puts("0");
		return 0;
	}
	int ans=1;
	while(1){
		for(int i=1;i<=n;i++)
			for(int j=i;j<=n;j++)
				for(int k=1;k<=m;k++)
					if(f1[i][j][f1[i][j][k]+1]>0) 
						f1[i][j][k]=f1[i][j][f1[i][j][k]+1];
		for(int i=1;i<=m;i++)
			for(int j=i;j<=m;j++)
				for(int k=1;k<=n;k++)
					if(f2[i][j][f2[i][j][k]+1]) f2[i][j][k]=f2[i][j][f2[i][j][k]+1];
		for(int x=1;x<=n;x++)
			for(int y=1;y<=m;y++){
				int now=m;
				for(int i=x;i<=n;i++){
					while(now&&f2[y][now][x]<i) now--;
					f1[x][i][y]=max(f1[x][i][y],now);
				}
				now=n;
				for(int i=y;i<=m;i++){
					while(now&&f1[x][now][y]<i) now--;
					f2[y][i][x]=max(f2[y][i][x],now);
				}
			}
		if(f1[1][n][1]==m){
			cout<<ans<<'\n';
			return 0;
		}
		ans++;
	}
	return 0;
}


Measured memory_bytes: 67584
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var r = nextInt()
	var d = nextInt()
	var base = nextInt()

	for i := 0; i < 10; i++ {
		base = base*r - d
		fmt.Println(base)
	}

}


Measured memory_bytes: 640
import sys

def LI():
  return [int(s) for s in input().split()]

ROWS = 3
COLS = 3

A = []
A.append(LI())
A.append(LI())
A.append(LI())

BINGO = []
BINGO.append([0]*3)
BINGO.append([0]*3)
BINGO.append([0]*3)

N = int(input())

for n in range(N):
  b = int(input())
  for i in range(ROWS):
    for j in range(COLS):
      if A[i][j] == b:
        BINGO[i][j] = 1
      
if BINGO[0][0] == 1 and BINGO[0][1] == 1 and BINGO[0][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[1][0] == 1 and BINGO[1][1] == 1 and BINGO[1][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[2][0] == 1 and BINGO[2][1] == 1 and BINGO[2][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][0] == 1 and BINGO[1][0] == 1 and BINGO[2][0] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][1] == 1 and BINGO[1][1] == 1 and BINGO[2][1] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][2] == 1 and BINGO[1][2] == 1 and BINGO[2][2] == 1:
  print('Yes')
  sys.exit()
      
if BINGO[0][0] == 1 and BINGO[1][1] == 1 and BINGO[2][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][2] == 1 and BINGO[1][1] == 1 and BINGO[2][0] == 1:
  print('Yes')
  sys.exit() 
      
print('No')      

Measured memory_bytes: 3192
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t;
	cin >> s >> t;
	int ct = 0;
	for(int i = 0; i < 3; i++)
		if(s[i] ^ t[i]) ++ct;
	cout << 3-ct;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

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

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n;
	cin >> n;
	cout << (111*((n-1)/111+1)) << endl;
	return 0;
}


Measured memory_bytes: 256
// A - ABC/ARC

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string ans;

	if (x < 1200) ans = "ABC";
	else ans = "ARC";

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = 1000000;

int dp[41][401][401];

int main()
{
    int n, ma, mb;
    cin >> n >> ma >> mb;

    int a[n], b[n], c[n];

    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    rep(i, n + 1) rep(j, 401) rep(k, 401) dp[i][j][k] = inf;

    dp[0][0][0] = 0;

    rep(i, n)
    {
        rep(j, 401)
        {
            rep(k, 401)
            {
                dp[i + 1][j][k] = dp[i][j][k];
                if (j - a[i] >= 0 && k - b[i] >= 0)
                    dp[i + 1][j][k] = min(dp[i][j - a[i]][k - b[i]] + c[i], dp[i][j][k]);
            }
        }
    }
    int ans = 1e7;

    rep(j, 401)
    {
        rep(k, 401)
        {
            if (j * k == 0)
                continue;
            if (j * mb == k * ma)
                ans = min(ans, dp[n][j][k]);
        }
    }

    OP((ans == inf ? -1 : ans));

    return 0;
}

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

using namespace std;

int N, M;

struct BC {
    int B, C;
};

bool operator<(const BC& left, const BC& right) {
    return left.C > right.C;
}

int main() {

    while (cin >> N >> M) {
        int l_max = 1, r_min = N;
        vector<int> a_v;
        for (int i = 0; i < N; i++) {
            int a;
            cin >> a;
            a_v.push_back(a);
        }
        sort(a_v.begin(), a_v.end());

        vector<BC> bc_v;
        for (int i = 0; i < M; i++) {
            BC bc;
            cin >> bc.B >> bc.C;
            bc_v.push_back(bc);
        }
        sort(bc_v.begin(), bc_v.end());

        for (int i = 0, a_i = 0; i < M; i++) {
            BC bc = bc_v.at(i);
            for (int j = 0; j < bc.B && a_i < a_v.size(); j++, a_i++) {
                if (a_v.at(a_i) < bc.C) {
                    a_v.erase(a_v.begin() + a_i);
                    a_v.insert(a_v.begin() + a_i, bc.C);
                }
            }
        }
        long int ret = 0;
        for (int i = 0; i < N; i++) {
            ret += a_v.at(i);
        }
        cout << ret << endl;
    }

    return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int n_max = 0, n_min = 1e9;
    int a[100];
    rep(i, n){
        cin >> a[i];
        n_max = max(n_max, a[i]);
        n_min = min(n_min, a[i]);
    }
    cout <<  n_max - n_min << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut it = line.split_whitespace();
    let a = it.next().unwrap().parse::<usize>().unwrap();
    let b = it.next().unwrap().parse::<usize>().unwrap();

    if (a * b) % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}


Measured memory_bytes: 4352
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int n;
long long int a[3000];
long long int result[3010][3010][2];
static const long long int INIT = (long long int)mod * 3000;

long long int solve(int l, int r, int nowPlayer) {
	if (l == r) return 0;
	if (result[l][r][nowPlayer] != INIT) return result[l][r][nowPlayer];
	if (nowPlayer == 0) {
		long long int res1 = a[l] + solve(l + 1, r, 1);
		long long int res2 = a[r - 1] + solve(l, r - 1, 1);
		return result[l][r][nowPlayer] = max(res1, res2);
	} else {
		long long int res1 = -a[l] + solve(l + 1, r, 0);
		long long int res2 = -a[r - 1] + solve(l, r - 1, 0);
		return result[l][r][nowPlayer] = min(res1, res2);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			result[i][j][0] = result[i][j][1] = INIT;
		}
	}
	cout << solve(0, n, 0) << endl;
}

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

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

const int N = 1e5 + 10;
struct Edge { int v, next;} edge[N * 4];
bool vis[N];
int n, m, cnt, head[N];
inline void add(int u, int v) {
    edge[++cnt].v = v; edge[cnt].next = head[u]; head[u] = cnt++;
    edge[++cnt].v = u; edge[cnt].next = head[v]; head[v] = cnt++;
}
void dfs(int u) {
    vis[u] = 1;
    for (int i = head[u]; i; i = edge[i].next) {
        int v = edge[i].v;
        if (!vis[v]) dfs(v);
    }
}

int main() {
    n = read(), m = read();
    for (int i = 0; i < m; i++) {
        int a = read(), b = read(); int c = read();
        add(a, b);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            ans++;
            dfs(i);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 5376
# include <bits/stdc++.h>
# define rr
# define int long long
const int N=100010,INF=0x3f3f3f3f;
double X;

inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
signed main(void){
	X=read();
	for(rr double i=-1000;i<=1000;i+=1.0){
		for(rr double j=-1000;j<=1000;j+=1.0){
			if(i*i*i*i*i-j*j*j*j*j==X){
				printf("%.0lf %.0lf",i,j);
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s,t;
  cin >> s;
  t = "";
  rep(i,0,50000) t += "10";
  int count = 0;
  int sizes = s.size();
  rep(i,0,sizes) if(s[i]==t[i]) count++;
  cout << min(count, sizes-count) << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
	int n,m,i,c=0,s=0;
	float d;
	cin>>n>>m;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s=s+a[i];
	}
	d=(float)s/(4*m);
	for(i=0;i<n;i++)
	{
		if(c==m)
		{
			break;
		}
		if(a[i]<d)
		{
			continue;
		}
		else if(a[i]>=d)
		{
			c++;
		}
	}
	if(c==m)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
int INF = 1e9+7;
int L[4][4];

int main() {
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            L[i][j] = 0;
        }
    }
    for (int i = 0; i < 3; i++) {
        int a,b;
        cin >> a >> b;
        L[a-1][b-1] = 1;
        L[b-1][a-1] = 1;
    }

    int ans = 0;
    for (int i = 0; i < 4; i++) {
        int sum = 0;
        for (int j = 0; j < 4; j++) {
            if (L[i][j] == 1)
                sum++;
        }
        if (sum == 3) {
            ans = 1;
            break;
        }
    }

    if (ans == 0) {
        cout << "YES" << endl;
    }
    else
        cout  << "NO" << endl;

}


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

int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	for (int n = 0; n < N; ++n) {
		cin >> H[n];
	}
	int ans = 0;
	int now = 0;
	for (int n = 0; n < N - 1; ++n) {
		if (H[n] >= H[n + 1]) {
			++now;
			ans = max(ans, now);
		}
		else {
			now = 0;
		}
	}
	cout << ans <<endl;
	return 0;
}


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

int gethappy(int n, vector<int> a, vector<int> b, vector<int> c){
    int dpa[n];
    int dpb[n];
    int dpc[n];

    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];

    for(int i=1;i<n;i++){
        dpa[i] = a[i] + max(dpb[i-1],dpc[i-1]);
        dpb[i] = b[i] + max(dpc[i-1],dpa[i-1]);
        dpc[i] = c[i] + max(dpa[i-1],dpb[i-1]);
    }

    return max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
}

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

    int n;
    cin>>n;

    vector<int> a(n),b(n),c(n);

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

    cout<<gethappy(n,a,b,c)<<endl;


    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll getMax(vector<ll> &bit, int index) {
    ll maxm = 0;
    while (index > 0) {
        maxm = max (maxm, bit[index]);
        index -= (index & (-index));
    }
    return maxm;
}
void update(vector<ll> &bit, int n, int index, ll val) {
    while (index <= n) {
        bit[index] = max (bit[index], val);
        index += (index & (-index));
    }
}
int main() {
    int n;
    cin>>n;
    vector<int> h(n), a(n);
    for (int i = 0; i < n; i++)
        cin>>h[i];
    for (int i = 0; i < n; i++)
        cin>>a[i];
    vector<ll> bit(n+1, 0);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll maxm = getMax(bit, h[i]-1);
        update(bit, n, h[i], maxm + a[i]);
        ans = max (ans, maxm + a[i]);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6412
#include<iostream>
#include<stdio.h>
using namespace std;
struct dice {
	int up, down, left, right, front, behind;
};

int main(void) {
	dice a;
	int temp;
	char  c;
	cin >> a.up >> a.front >> a.right >> a.left >> a.behind >> a.down;
	while (getchar() != '\n')
		continue;
	while ((c = getchar()) != '\n') {
		if (c == 'E') {
			temp = a.down;
			a.down = a.right;
			a.right = a.up;
			a.up = a.left;
			a.left = temp;
		}
		else if (c == 'S') {
			temp = a.front;
			a.front = a.up;
			a.up = a.behind;
			a.behind = a.down;
			a.down = temp;
		}
		else if (c == 'N') {
			temp = a.down;
			a.down = a.behind;
			a.behind = a.up;
			a.up = a.front;
			a.front = temp;
		}
		else if (c == 'W') {
			temp = a.up;
			a.up = a.right;
			a.right = a.down;
			a.down = a.left;
			a.left = temp;
		}
	}
	cout << a.up<<endl;
}


Measured memory_bytes: 3136
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU

-- 解説読後
-- http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf

import qualified Data.Array as A
import qualified Data.Map as M

main = print . solve . map read . words =<< getContents

solve (n:a:xs) = ans where
    x  = maximum (a:xs)
    nx = n * x
    ys = A.listArray (1, n) $ map (+ (-a)) xs
    dp j t m =
        case M.lookup (j, t) m of
        Just c  -> (c, m)
        Nothing ->
            case True of
                _ | j == 0 && t == nx -> (1, m)
                _ | j >= 1 && (ty <  0 || ty >  2 * nx) -> ans where
                    (a1, m1) = dp j1 t m
                    ans = (a1, M.insert (j, t) a m1)
                _ | j >= 1 && (ty >= 0 && ty <= 2 * nx) -> ans where
                    (a1, m1) = dp j1 t m
                    (a2, m2) = dp j1 ty m1
                    ans = (a1 + a2, M.insert (j, t) (a1 + a2) m2)
                _ -> (0, m)
            where
                j1 = j - 1
                ty = t - (ys A.! j)
    ans = fst (dp n nx M.empty) - 1

Measured memory_bytes: 7164
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int Y;
  cin>>Y;
  int m=Y/10000;
  int d[m+1];
  for(int i=0;i<=m;i++)d[i]=Y-i*10000;
  for(int i=0;i<=m;i++){
    int k=d[i]/5000;
    for(int j=0;j<=k;j++){
      int t=d[i]-j*5000;
      if(t==(N-i-j)*1000){
        printf("%d %d %d",i,j,N-i-j);
        return 0;
      }
    }
  }
  printf("%d %d %d",-1,-1,-1);
  return 0;
}

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

int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=5)cout<<0<<endl;
	else if(a>=13)cout<<b<<endl;
	else cout<<b/2<<endl;
	return 0;
}

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

const int mn=1005;
const int co=(mn*(mn-1))/2;
vector<int> idtree[co];
int dp[co];
bool calculated[co];
bool visited[co];

int dfs(int no){
    if(visited[no]){
        if(!calculated[no]){
          return -1;
        }
        return dp[no];
    }
    visited[no]=true;
    dp[no]=1;
    rep(i,idtree[no].size()){
        int re=dfs(idtree[no][i]);
        if(re==-1) return -1;
        dp[no]=max(dp[no],re+1);
    }
    calculated[no]=true;
    return dp[no];
}

int main(){
    int n; cin >> n;
    vector<vector<int> > le(n);
    vector<vector<int> > id(n,vector<int>(n));
    rep(i,n){
        rep(j,n-1){
            int a; cin >> a;
            a--;
            le[i].push_back(a);
        }
    }
    int asid=0;
    rep(i,n)rep(j,n){
        if(i<j) id[i][j]=asid++; 
    }
    
    rep(i,n)rep(j,n-1){
        int ti=i;
        if(ti>le[i][j]) swap(ti,le[i][j]);
        le[i][j]=id[ti][le[i][j]];
    }
    rep(i,n){
        for(int j=n-2; j>=1; j--){
            idtree[le[i][j-1]].push_back(le[i][j]);
        }
    }
    rep(i,(n*(n-1))/2){
        visited[i]=false;
        calculated[i]=false;
    }
    
    int ans=0;
    rep(i,(n*(n-1))/2){
      int t=dfs(i);
      if(t==-1){
        ans=-1;
        break;
      }
      ans=max(ans,t);
    }
    cout << ans << endl;
return 0;
}


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


int main(){
  int n,sw=0;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  for(int i=0;i<n-1;i++){
    int minj=i;
    for(int j=i+1;j<n;j++){
      if(A[minj]>A[j]){
        minj=j;
      }
    }
    if(minj!=i){
      swap(A[minj],A[i]);
      sw++;
    }
  }
  for(int i=0;i<n;i++){
    if(i){cout << " ";}
    cout << A[i];
  }
  cout << endl<<sw<<endl;
}


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

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, cnt=0;
    char s[51];
    
    scanf("%d%s", &n, s);
    
    rep(i, n-2){
        if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
            cnt++;
        }
    }
    
    printf("%d", cnt);
    
    return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

const int MOD = 1000000007;

int main() {
  ll N, P; cin >> N >> P;
  auto p = prime_factor(P);
  ll ans = 1;
  for(auto x : p) {
    ll tmp = x.second / N;
    ans *= pow(x.first , tmp);
  }
  cout << ans << endl;
}

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

int main()
{
    int x,y;
    
    while(1)
    {
        cin >> x >> y;
        if(x == 0 && y == 0)
            break;
        else if(x <= y)
            cout << x << " " << y << endl;
        else
            cout << y << " " << x << endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pl = pair<ll, ll>;
using Tl = tuple<ll, ll, ll>;

const ll INF = 1e15;
const ld eps = 1e-6;

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  vector<vector<ll> > dp(N+1, vector<ll>(3));
  for(int i=0;i<N;i++){
    vector<ll> today(3);
    cin >> today[0] >> today[1] >> today[2];
    for(int yes=0;yes<3;yes++)
      for(int tod=0;tod<3;tod++){
	if(tod == yes)
	  continue;
	dp[i+1][tod] = max(dp[i+1][tod], dp[i][yes] + today[tod]);
	ans = max(ans, dp[i+1][tod]);
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
import fractions

a,b,c,d = map(int,input().split())
def lcm(x,y):
  return x*y//fractions.gcd(x,y)
def func(n,x,y):
  return n - (n//x + n//y - n//lcm(x,y))
ans = func(b,c,d) - func(a-1,c,d)
print(ans)

Measured memory_bytes: 5048
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	cout << (a + b) * c / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split(' '))
 
def divisor(n):
  ass = []
  for i in range(1,int(n**0.5)+1):
    if n%i == 0:
      ass.append(i)
      ass.append(n//i)
  return ass #sortされていない
 
a_div = divisor(a)
b_div = divisor(b)

k = []
for val in a_div:
  if val != 1 and val in b_div:
    k.append(val)
k.sort()

ans = 0
if len(k) == 0:
  ans = 1
elif len(k) == 1:
  ans = 2
else:
  ans = 2
  for i in range(1, len(k)):
    tmp = k[i]
    for j in range(0, i):
      if (tmp % k[j]) == 0:
        break
    else:
      ans += 1
 
print(ans)

Measured memory_bytes: 40176
#include<stdio.h>
int main(void){
    int time[4];
    scanf("%d%d%d%d",&time[0],&time[1],&time[2],&time[3]);
    printf("%d\n%d\n",(time[0]+time[1]+time[2]+time[3])/60,(time[0]+time[1]+time[2]+time[3])%60);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
using namespace std;

int main() {
    nl // 	

    string s, temp;
    cin >> s;
    for(int i=0; i<s.size(); i++) {
        if(s[i] == '1') temp.push_back('9');
        else temp.push_back('1');
    }
    cout << temp;
}	


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
using namespace std;
typedef long long ll;

ll a,A,B;

int main(){
  cin >> a;
  stringstream ss;
  ss << a;
  string s = ss.str();

  int ans = 0;
  ll k = 10;
  for(int i=0;i<s.size();i++){
    A = a/k;
    B = a%k;
    if(s[s.size()-1-i]!='0' && (A+B)%2==0 && B>=(A+B)/2){
      ans++;
    }
    k*=10;
  }

  cout << ans << endl;
}
    
    

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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e6+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);


signed main(){
    fast_io();
    int X, Y;
    cin >> X >> Y;
    int cnt = 0;
    while(X <= Y) cnt++, X *= 2;
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
const int N = 2e5 + 5;
const int Mod = 998244353;

struct LCA
{
	vector<vector<int>> Dp;
	vector<int> Euler, Bit, F, H;
	void DFS(int u, int p, vector<vector<int>>& G)
	{
		H[u] = H[p] + 1;
		F[u] = Euler.size();
		Euler.push_back(u);
		for (auto v : G[u])
		{
			if (v == p)
				continue;
			DFS(v, u, G);
			Euler.push_back(u);
		}
	}
	int MIN(int& a, int& b)
	{
		if (a == 0)
			return b;
		if (b == 0)
			return a;
		return H[a] > H[b] ? b : a;
	}
	void Build(vector<vector<int>>& G, int root)
	{
		H = F = vector<int>(G.size(), 0);
		DFS(root, 0, G);
		int n = Euler.size();
		Dp = vector<vector<int>>(n, vector<int>(20, 0));
		for (int i = 0; i < n; i++)
			Dp[i][0] = Euler[i];
		Bit = vector<int>(1 << 20, 0);
		for (int i = 1; i < (1 << 20); i++)
			for (int j = 0; j < 20; j++)
				if (i & 1 << j)
					Bit[i] = j;
		for (int j = 1; j < 20; j++)
			for (int i = 0; i < n; i++)
			{
				if (i + (1 << j) >= n)
					break;
				Dp[i][j] = MIN(Dp[i][j - 1], Dp[i + (1 << j - 1)][j - 1]);
			}
	}
	int FindLCA(int u, int v)
	{
		if (F[v] < F[u])
			swap(u, v);
		int f1 = F[u];
		int f2 = F[v];
		int b = Bit[f2 - f1 + 1];
		return MIN(Dp[f1][b], Dp[f2 - (1 << b) + 1][b]);
	}
	LCA() {}
	LCA(vector<int> G[], int n, int root = 1)
	{
		vector<vector<int>> GG;
		for (int i = 0; i <= n; i++)
			GG.push_back(G[i]);
		Build(GG, root);
	}
	LCA(vector<vector<int>>& G, int root = 1)
	{
		Build(G, root);
	}
};

struct Edge
{
	int to;
	int c;
	int d;
	Edge(int to = 0,int c = 0,int d = 0):to(to),c(c),d(d){}
};

struct query
{
	int idx;
	int c;
	int d;
	query(int idx = 0,int c = 0,int d = 0):idx(idx),c(c),d(d){}
};

int n, m;
vector<Edge> G[N];
vector<query> Q[N];
ll dis[N], cnt[N];
ll ans[4 * N];

void DFS(int u, int p = -1, ll cur = 0)
{
	for (query q : Q[u])
		ans[q.idx] = cur - dis[q.c] + q.d * cnt[q.c];
	for(Edge e : G[u])
		if (e.to != p)
		{
			dis[e.c] += e.d;
			cnt[e.c]++;
			DFS(e.to, u, cur + e.d);
			dis[e.c] -= e.d;
			cnt[e.c]--;
		}
}

vec T[N];

int main()
{
	GO;
	cin >> n >> m;
	for (int i = 1; i < n; i++)
	{
		int u, v, c, d;
		cin >> u >> v >> c >> d;
		G[u].push_back(Edge(v, c, d));
		G[v].push_back(Edge(u, c, d));
		T[u].push_back(v);
		T[v].push_back(u);
	}
	
	LCA lc(T, n);
	for (int i = 0; i < m; i++)
	{
		int u, v, c, d;
		cin >> c >> d >> u >> v;
		int w = lc.FindLCA(u, v);
		Q[u].push_back(query(3 * i, c, d));
		Q[v].push_back(query(3 * i + 1, c, d));
		Q[w].push_back(query(3 * i + 2, c, d));
	}
	DFS(1);
	for (int i = 0; i < m; i++)
		cout << ans[3 * i] + ans[3 * i + 1] - 2 * ans[3 * i + 2] << '\n';
	return 0;
}

Measured memory_bytes: 68876