akhauriyash/Code-Regression huggingface dataset:
from heapq import *
n, k = map(int, input().split())
d = list(map(int, input().split()))

res = 0
num = min(k, n)
for a in range(num + 1):
    for b in range(num + 1 - a):
        l = min(k - (a + b), a + b)
        s = d[:a] + d[-b:] if b != 0 else d[:a]
        heapify(s)
        for _ in range(l):
            tmp = heappop(s)
            if tmp > 0:
                heappush(s, tmp)
                break
        res = max(res, sum(s))
print(res)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		String s;
		String sl[];

		s = r.readLine();
		sl = s.split(" ");
		int n = Integer.parseInt(sl[0]);
        int k = Integer.parseInt(sl[1]);
      	s = r.readLine();
		sl = s.split(" ");
      	int a[] = new int[50];
      	for(int i = 0; i < n; i++)
        {
          a[i] = Integer.parseInt(sl[i]);
        }
      	
        int vmax = 0;
      	int minkn = Math.min(k, n);
        for(int i = 1; i <= minkn; i++)
        {
          int js[] = new int[i];
          for(int j = 0; j <= i; j++)
          {
            int v = 0;
            for(int l = 0; l < j; l++)
            {
              js[l] = a[l];
            }
            for(int l = 0; l < i - j; l++)
            {
              js[i - 1 - l] = a[n - 1 - l];
            }
            Arrays.sort(js);
            int kii = Math.min(k - i, i);
            int z = 0;
            for(z = 0; z < kii; z++)
            {
              if(js[z] >= 0) break;
            }
            for(; z < i; z++)
            {
              v += js[z];
            }
            vmax = Math.max(v, vmax);
          }
        }
        System.out.println(vmax);
	}
}


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

int main() {
    const int numPrimes = 1000000;
	bool primes[numPrimes];
    for (int i = 0; i != numPrimes; ++i) {
        primes[i] = true;
    }

    for (int i = 2; i != sqrt(numPrimes); ++i) {
        for (int j = 2; i * j < numPrimes; ++j) {
            primes[i*j] = false;
        }
    }

    int n;
    while (cin >> n) {
        int count = 0;
        for (int i = 2; i <= n; ++i) {
            if (primes[i]) { ++count; }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 2136
//agc040_a.cpp
//Sun Dec  1 11:17:55 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll n[s.length()+1];
	ll incaccum = 0;
	ll decaccum = 0;
	ll sum = 0;
	ll num = 0;
	for (int i=0;i<s.length();i++){
		if (s[i]=='<'){
			i++;
			incaccum++;
			sum+=incaccum;
			while (s[i]=='<'){
				incaccum++;
				sum+=incaccum;
				i++;
			}
			i--;
//			sum -= min(num,incaccum);
			num = incaccum;
			incaccum = 0;
		}else {
			i++;
			decaccum++;
			sum+=decaccum;
			while (s[i]=='>'){
				decaccum++;
				sum+=decaccum;
				i++;
			}
			i--;
			sum -= min(num,decaccum);
			num = decaccum;
			decaccum = 0;
		}
	}

	cout << sum << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 900
package main
import . "fmt"
import . "strings"
import . "os"
func main() {
  var s string
  Scan(&s)
  if Count(s,"A") != 1 || Count(s,"C") != 1 {
    Println("WA")
  } else if s[0:1] == "A" && Contains(s[2:len(s)-1],"C") {
    if Contains(s,"B") {
      Println("WA")
    } else {
      for i:=68;i<91;i++ {
        if Contains(s,string(i)) {
          Println("WA")
          Exit(0)
        }
      }
      Println("AC")
    }
  } else {
    Println("WA")
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int k,s;
    int ans=0;
    cin >>k>>s;
    for(int a=0;a<=k;a++){
        for(int b=0;b<=k;b++){
            if(s-a-b >=0 and s-a-b <=k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//prototype
int main(void);

int main(void){
  //variable definition
  unsigned int Room_Array[4][3][10] = {0};
  int building;
  int floor;
  int number;
  int tenant;
  int roop_count = 0;
  int n, i, j, k;

  scanf("%d", &n);

  while(1){
    //exit condition
    if(roop_count == n){
      break;
    }

    scanf("%d %d %d %d", &building, &floor, &number, &tenant);

    Room_Array[building - 1][floor - 1][number - 1] += tenant;   //movement Room_Array

    roop_count ++;    //increment　count
  }


    //Room_Array output
    for (i = 0; i <= 3; i++) {
      for (j = 0; j <= 2; j++) {
        for (k = 0; k <= 9; k++) {
          printf(" %d", Room_Array[i][j][k]);
        }
        printf("\n");
      }
      if(i != 3){
        printf("####################\n");
      }
    }

  return 0;
}



Measured memory_bytes: 2044
n, t = map(int, input().split())
A = list(map(int, input().split()))
d = {}
min_ = 10**18
for a in A:
    p = a-min_
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
    if a <= min_:
        min_ = a
M = max(d.keys())
print(d[M])


Measured memory_bytes: 99204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  int a=S.size(), z=-1;
  rep(i, S.size()) {
    if(S[i] == 'A') a = min(a, i);
    if(S[i] == 'Z') z = max(z, i);
  }
  cout << z - a + 1 << endl;
  return 0;
}



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

using namespace std;

int main(){
    int n,m;
    while(cin >> n >> m){
        if((n|m) == 0) break;

        int p[n+1];
        for(int i=0;i<n;i++){
            cin >> p[i];
        }
        p[n] = 0;
        vector<int> d;
        for(int i=0;i<n+1;i++){
            for(int j=i;j<n+1;j++){
                d.push_back(p[i]+p[j]);
            }
        }
        sort(d.begin(),d.end());

        int ret=0;
        for(int i=0;i<d.size();i++){
            if(d[i] > m) continue;
            ret = max(ret, d[i] + *(upper_bound(d.begin(), d.end(), m-d[i])-1));
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 3000
import itertools
import sys
n, m, x = map(int, input() .split())
ca = [list(map(int, input() .split())) for _ in range(n)]


max_acheive = [0 for _ in range(m)]
for i in range(n):
    for j in range(m):
        max_acheive[j] += ca[i][j+1]

for j in range(m):
    if max_acheive[j] < x:
        print(-1)
        sys.exit()

cost = []
all_flag = []
for i in range(1,n+1):
    options = list(itertools.combinations(range(n), i))
    for j,option in enumerate(options):
        acheive = [0 for _ in range(m)]
        cost.append(0)
        for k,book in enumerate(option):
            for ability in range(m):
                acheive[ability] += ca[book][ability+1]
            cost[-1] += ca[book][0]
        flag = 0
        for pp in range(m):
            if acheive[pp] >= x:
                flag+=1
        if flag != m:
            all_flag.append(0)
        else:
            all_flag.append(1)
min_cost = 10e+10
for i in range(len(cost)):
    if all_flag[i] == 1 and min_cost>cost[i]:
        min_cost = cost[i]
print(min_cost)

Measured memory_bytes: 9468
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int min(int *a, int b);

int main(void){
	int N;
	int *s;
	int sum = 0;
	scanf("%d", &N);
	s = (int *)malloc(sizeof(int) * N);
	for(int i = 0; i < N; i++) scanf("%d", s + i);

	for(int i = 0; i < N; i++) sum += s[i];
	if(sum%10) printf("%d\n", sum);
	else{
		int ret = 120;
		for(int i = 0; i < N; i++) if(s[i]%10 && s[i] < ret) ret = s[i];
		if(ret == 120) printf("0\n");
		else printf("%d\n", sum - ret);
	}
}

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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if ((b-a+1)<(k*2)) {
        for (ll i=a; i<=b; i++) {
            cout << i << endl;
        }
        return 0;
    }
    for (ll i=a; i<a+k; i++) {
        cout << i << endl;
    }
    for (ll i=b-k+1; i<=b; i++) {
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
using System;

namespace AOJ0059
{
    class Program
    {
        public void Proc()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                string[] num = input.Split(' ');

                Point A1 = new Point(num[0], num[1]);
                Point A2 = new Point(num[2], num[3]);
                Point B1 = new Point(num[4], num[5]);
                Point B2 = new Point(num[6], num[7]);

                bool res = checkInterSection(A1, A2, B1, B2);
                if (res)
                {
                    Console.WriteLine("YES");
                } else
                {
                    Console.WriteLine("NO");
                }

            }
        }

        static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }

        public static bool checkInterSection (Point a1, Point a2, Point b1, Point b2)
        {
            if (a1.X > b2.X || a2.X < b1.X)
            {
                return false;
            } else
            {
                if (a1.Y > b2.Y || a2.Y < b1.Y)
                {
                    return false;
                } else
                {
                    return true;
                }
            }
        }
    }

    public struct Point
    {
        public decimal X, Y;

        public Point(string a, string b)
        {
            this.X = decimal.Parse(a);
            this.Y = decimal.Parse(b);
        }
    }
}

Measured memory_bytes: 9092
#include <iostream>
using namespace std;
int main(){
  int  n;
  cin >>n;
  int mo[n];
  int a=0;
  for(int i=0;i<n;i++){
    cin >> mo[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(mo[i]==-1) continue;
      if(mo[i]==mo[j]) mo[j]=-1;
    }
  }
  for(int i=0;i<n;i++){
    if(mo[i]!=-1) a++;
  }
  cout << a << endl;
}


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

const int maxN = 8005;
bool dp[2][maxN * 2], ok[2];
int tx, ty, N, q[maxN];
char s[maxN];
int main() {
	scanf("%s", s); scanf("%d%d", &tx, &ty);
	int cnt = 0, ed = 0; int len = strlen(s);
	for(int i = 0; i < len; ++i) {
		if(s[i] == 'T') {
			q[++ed] = cnt; cnt = 0;
		} else cnt++;
	}
	if(cnt) q[++ed] = cnt;
	dp[0][q[1] + 8000] = 1; int nw = 0;
	//cout << ed << endl;
	for(int i = 3; i <= ed; i += 2) {
		for(int j = 0; j <= 16000; ++j) {
			if(!dp[nw][j]) continue;
			if(!q[i]) {
				dp[nw ^ 1][j] = 1; dp[nw][j] = 0; continue;
			}
			for(int k = -q[i]; k <= q[i]; k += 2 * q[i]) {
				if(k + j < 0 || k + j > 16000) continue;
				dp[nw ^ 1][k + j] = 1;
			}
			dp[nw][j] = 0;
		}
		nw ^= 1;
	}
	ok[0] = dp[nw][tx + 8000];
	for(int i = 0; i < 2; ++i)
	for(int j = 0; j <= 16000; ++j) dp[i][j] = 0;
	dp[0][8000] = 1; nw = 0;
	for(int i = 2; i <= ed; i += 2) {
		for(int j = 0; j <= 16000; ++j) {
			if(!dp[nw][j]) continue;
			//cout << i << ' ' << j << endl;
			if(!q[i]) {
				dp[nw ^ 1][j] = 1; dp[nw][j] = 0; continue;
			}
			for(int k = -q[i]; k <= q[i]; k += 2 * q[i]) {
				if(k + j < 0 || k + j > 16000) continue;
				dp[nw ^ 1][k + j] = 1;
			}
			dp[nw][j] = 0;
		}
		nw ^= 1;
	}
	ok[1] = dp[nw][ty + 8000];
	if(ok[0] && ok[1]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

// between-two-integers.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2017 Seong Yong-ju

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  cout << (a <= c && c <= b ? "Yes" : "No") << endl;
}


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

int cx[12] = {0, 0, 0, 0, 0, 0, -3, -2, -1, 1, 2, 3};
int cy[12] = {-3, -2, -1, 1, 2, 3, 0, 0, 0, 0, 0, 0};

int field[8][8];

void bomb(int X, int Y) {
    field[Y][X] = 0;
    for (int i=0; i<12; ++i) {
        int nx = X + cx[i];
        int ny = Y + cy[i];
        if (0 <= nx && nx < 8 && 0 <= ny && ny < 8 && field[ny][nx] == 1) {
            bomb(nx, ny);
        }
    }
}

int main() {
    int n, X, Y;
    cin >> n;
    for (int k=1; k<=n; ++k) {
        char c;
        for (int i=0; i<8; ++i) {
            for (int j=0; j<8; ++j) {
                cin >> c;
                field[i][j] = c - '0';
            }
        }
        cin >> X >> Y;
        --X; --Y;
        bomb(X, Y);
        cout << "Data " << k << ":" << endl;
        for (int i=0; i<8; ++i) {
            for (int j=0; j<8; ++j) {
                cout << field[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::collections::HashMap;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();

    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", n * 2);
    }
}



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

void solve() {
	ll x;
	cin >> x;
	ll l = 0, r = 2 * x;
	while (r - l > 1) {
		ll mid = l + (r - l) / 2;
		if (mid * (mid + 1) / 2 >= x) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	cout << r;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

class pqComp
{
public:
    bool operator()(pair<int, int> &a, pair<int, int> &b)
    {
        return a.second < b.second;
    }
};

bool sorting(pair<int, int> a, pair<int, int> b)
{
    return a.second < b.second;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie();
    cout.tie();
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n);
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x - 1].push_back(y - 1);
        v[y - 1].push_back(x - 1);
    }
    vector<bool> visited(n, false);
    vector<int> rez(n);
    queue<int> q;
    q.push(0);
    int cnt = n;
    while (!q.empty())
    {
        int curr = q.front();
        q.pop();
        for (int i = 0; i < v[curr].size(); i++)
        {
            if (visited[v[curr][i]])
            {
                continue;
            }
            visited[v[curr][i]] = true;
            rez[v[curr][i]] = curr;
            cnt--;
            q.push(v[curr][i]);
        }
    }
    if (cnt != 0)
    {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for (int i = 1; i < n; i++)
    {
        cout << rez[i] + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 9656
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 0;

    for (int i = 0; i < s.length()/2; i++) {

      char k = s.charAt(i);
      char g = s.charAt(s.length()-i-1);
      if (k != g) {
        count++;
      }

    }

    System.out.println(count);

  }

}


Measured memory_bytes: 23124
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

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

    int even_cnt = 0;
    int num_type = 0;
    for (int i = 0; i <= 100000; ++i) {
        if (cnt[i] > 0)
            ++num_type;

        if (cnt[i] > 0 && cnt[i] % 2 == 0)
            ++even_cnt;
    }

    if (even_cnt % 2 == 0)
        cout << num_type << endl;
    else
        cout << num_type - 1 << endl;
    return 0;
}

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

#define INF 1120000000

long solve(){
  long n,d;
  cin>>n>>d;
  vector<long> t(n),f(n);
  rep(i,n) cin>>t[i]>>f[i], f[i]--;

  long p=0; // ????????????
  long pt = 0; // ???????????????
  long pf=0; // ????????????
  long ans=0;
  rep(i,n){
    if(f[i]+pf <= t[i]-pt){
      ans += pf*p;
      p=1;
    }
    else {//dbg(i);
      if(t[i]-pt < abs(f[i]-pf)) return -1;
      ans += abs(t[i]-pt)*p;
      p++;
      if(p>d) return -1;
    }
    pt = t[i];
    pf = f[i];//dbg(p,pt,pf);
  }

  ans += pf*p;

  return ans;
}

int main(){
  cout << solve() << endl;

  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmax(T &u, const T z)
{
    if (u < z)
    {
        u = z;
        return true;
    }
    else
        return false;
}
template <typename T>
bool chmin(T &u, const T z)
{
    if (u > z)
    {
        u = z;
        return true;
    }
    else
        return false;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main()
{
    string a[] = {"maerd", "remaerd", "esare", "resare"};
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    bool hantei = false;
    rep(i, n)
    {
        hantei = false;
        rep(j, 4)
        {
            int k = a[j].size();
            string t = s.substr(i, k);
            //cout << a[j] << " " << t << endl;
            if (a[j] == t)
            {
                hantei = true;
                i += k - 1;
                break;
            }
        }
        if (hantei == false)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll mod=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    string s;cin>>s;
    ll ans=0;
    for(ll i=0;i<=n-3;i++){
        if(s.substr(i,3)=="ABC")ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int main() {
    String s;
    cin >> s;
    if (s == "SUN") puts("7");
    else if (s == "MON") puts("6");
    else if (s == "TUE") puts("5");
    else if (s == "WED") puts("4");
    else if (s == "THU") puts("3");
    else if (s == "FRI") puts("2");
    else if (s == "SAT") puts("1");
    return 0;
}

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

int main() {
	int h, n;
	cin >> h >> n;
	int sum = 0;
	for(int i  = 0;i < n; i++){
		int val;
		cin >> val;
		sum += val;
	}
	if(sum >= h){
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
map<P,int>dp;
map<P,bool>ex;
vector<int>edge[200005];
int n;
bool ok[200005];
void dfs(int v,int u){
	if(u!=-1){
		dp[mp(u,v)] = 1;
		ex[mp(u,v)] = ok[v];
	}
	rep(i,edge[v].size()){
		if(edge[v][i]==u) continue;
		dfs(edge[v][i],v);
		if(u!=-1){
			dp[mp(u,v)] = max(dp[mp(u,v)],dp[mp(v,edge[v][i])]+1);
			ex[mp(u,v)] |= ex[mp(v,edge[v][i])];
		}
	}
}
void dfs2(int v,int u,int mx,bool EX){
	EX |= ok[v];
	priority_queue<int,vector<int>,greater<int> >S;
	int cnt = 0;
	rep(i,edge[v].size()){
		if(edge[v][i]==u) continue;
		S.push(dp[mp(v,edge[v][i])]);
		if(S.size() == 3) S.pop();
		cnt += ex[mp(v,edge[v][i])];
	}
	if(S.size() < 1) return;
	S.push(0);
	if(S.size() == 3) S.pop();
	int a = S.top(); S.pop();
	int b = S.top(); S.pop();
	rep(i,edge[v].size()){
		if(edge[v][i]==u) continue;
		if(dp[mp(v,edge[v][i])] == b) dp[mp(edge[v][i],v)] = 1+max(mx,a);
		else dp[mp(edge[v][i],v)] = 1+max(mx,b);
		if(EX || cnt-ex[mp(v,edge[v][i])] >= 1){
			ex[mp(edge[v][i],v)] = 1;
		}
		else{
			ex[mp(edge[v][i],v)] = 0;
		}
		dfs2(edge[v][i],v,dp[mp(edge[v][i],v)],ex[mp(edge[v][i],v)]);
	}
}
int main(){
	scanf("%d",&n);
	rep(i,n-1){
		int a,b; scanf("%d%d",&a,&b);
		a--; b--;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	string s; cin>>s;
	rep(i,n) if(s[i]=='1') ok[i]=true;
	dfs(0,-1);
	dfs2(0,-1,0,false);
	ll ret = 0;
	rep(i,n){
		priority_queue<int,vector<int>,greater<int> >S;
		for(int j=0;j<edge[i].size();j++){
			S.push(dp[mp(i,edge[i][j])]);
			if(S.size() == 3) S.pop();
		}
		int ub = 0;
		if(S.size() == 2){
			ub = max(ub,S.top());
		}
		int lb = INF;
		if(ok[i]) lb = 0;
		for(int j=0;j<edge[i].size();j++){
			if(!ex[mp(i,edge[i][j])]) continue;
			lb = min(lb,dp[mp(i,edge[i][j])]);
		}
		if(lb <= ub){
			ret += (ub-lb+1);
		}
	}
	rep(i,n){
		rep(j,edge[i].size()){
			int u = i,v = edge[i][j];
			if(u > v) continue;
			bool flag = 0;
			if(dp[mp(v,u)] <= dp[mp(u,v)]){
				flag |= ex[mp(v,u)];
			}
			if(dp[mp(v,u)] >= dp[mp(u,v)]){
				flag |= ex[mp(u,v)];
			}
			if(flag) ret++;
		}
	}
	cout << ret << endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  int k; cin >> k;
  vll a(n);
  REP(i, n) {
    cin >> a[i];
  }

  FOR(i, k, n) {
    cout << (a[i] > a[i-k] ? "Yes" : "No") << endl;
  }

}








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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+5; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,ans=0;
	cin>>n;
	string s;
	map<string,ll> m;
	while(n--){
		cin>>s;
		if(m[s]==0){ans++;m[s]++;}
	}
	cout<<ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 19216
# -*- coding: utf-8 -*-

import bisect

n, m = map(int, input().split())
py = [list(map(int, input().split())) for _ in range(m)]

dct = {}
for i in range(m):
    if py[i][0] in dct.keys():
        dct[py[i][0]].append(py[i][1])
    else:
        dct[py[i][0]] = [py[i][1]]

for key in dct.keys():
    dct[key].sort()

for i in range(m):
    print("{:06}{:06}".format(py[i][0], bisect.bisect(dct[py[i][0]], py[i][1])))


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

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> mat(h);
    for(int i = 0; i < h; ++i)
    {
        vector<int> tv(w);
        for(int j = 0; j < w; ++j)
        {
            char c;
            cin >> c;
            if(c == '.')
            {
                tv[j] = 0;
            }
            else
            {
                tv[j] = -1;
            }
        }
        mat[i] = tv;
    }

    int ans = 0;
    vector<vector<int>> scoresH(h);
    vector<vector<int>> scoresW(h);
    for(int i = 0; i < h; ++i)
    {
        scoresH[i] = vector<int>(w);
        scoresW[i] = vector<int>(w);
    }

    for(int i = 0; i < h; ++i)
    {
        for(int j = 0; j < w; ++j)
        {
            if(mat[i][j] == -1)
            {
                continue;
            }
            if(scoresH[i][j] == 0)
            {
                vector<int> sameScores;
                int tsc = 0;
                int tp = i;
                while(tp < h
                && mat[tp][j] != -1)
                {
                    sameScores.push_back(tp);
                    ++tsc;
                    ++tp;
                }
                for(int k : sameScores)
                {
                    scoresH[k][j] = tsc;
                }
            }
            if(scoresW[i][j] == 0)
            {
                vector<int> sameScores;
                int tsc = 0;
                int tp = j;
                while(tp < w
                && mat[i][tp] != -1)
                {
                    sameScores.push_back(tp);
                    ++tsc;
                    ++tp;
                }
                for(int k : sameScores)
                {
                    scoresW[i][k] = tsc;
                }
            }
            ans = max(ans,scoresH[i][j]+scoresW[i][j]-1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 47360
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;

const ll N = 1e6 + 10;

ll n;

int main() {
	cin >> n;

	ll res = 0;
	for (ll i = 1; i <= n; i++) {
		ll j = n / i;
		while (j) {
			if (i * j == n) {
				j--;
				continue;
			}
			res++;
			j--;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=1;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll a[1002];
//int sosu[]={2,3,5,7,11,13,17,23,29,31,37};
int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<1<<endl;return 0;
    }
    
    for(int i=2;i<=n;i++){
        ll s=i;
        ll t=2;
        while(s!=1){
            while(s%t==0){
            a[t]++;
            s/=t;
            }
            t++;
        }
    }
    ll ans=1;
    rep(i,1002){
        ans=ans*(a[i]+1)%(ll)1000000007;
    }
    
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int h,n;
  cin>>h>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  int sum=0;
  string ans="No";
  for(int i=0;i<n;i++){
    sum+=a[i];
    if(h<=sum) ans="Yes";
  }
  
  
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chadd(x, y) x = (x + y) % mod

int n;
vector<int> graph[100005];
// dp[node][color] := ノード node を、色 color で塗ったとき、それ以下のノードの色の塗り方
vector<vector<ll>> dp(100005, vector<ll>(2, -1));

ll memo_rec(int node, int color, int parent = -1){
    if(dp[node][color] != -1)   return dp[node][color];
    
    ll res = 1;
    for(int v : graph[node]){
        if(v == parent) continue;
        
        ll tmp = 0;
        // v を白で塗るのはいつでも可能
        tmp = (tmp + memo_rec(v, 0, node)) % mod;
        // node が白で塗られていれば、v は黒で塗ってもよい
        if(color == 0)  tmp = (tmp + memo_rec(v, 1, node)) % mod;

        res = res * tmp % mod;
    }

    return dp[node][color] = res;
}

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

    cin >> n;
    for(int i = 0; i < n-1; ++i){
        int x, y;
        cin >> x >> y;
        --x, --y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    ll res = (memo_rec(0, 0) + memo_rec(0, 1)) % mod;
    cout << res << endl;
}

Measured memory_bytes: 19584
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<iomanip>
#include<string>
#include<math.h>
#define MOD 1000000007

bool graph[8][8];
using namespace std; 
int main(){
    int ans=0;
    int path[8];
    int n,m;
    int a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        graph[a][b]=true;
        graph[b][a]=true;
    }
    for(int i=0;i<n;i++){
        path[i]=i;
    }
    do{
        bool flag=true;
        for(int i=0;i<n-1;i++){
            if(!graph[path[i]][path[i+1]])flag=false;
        }
        if(flag)ans++;
    }while(next_permutation(path+1,path+n));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
cnt=0
for b in range(k+1,n+1):
    if n%b>=k:
        if k==0:
            cnt+=(b-k)*(n//b)+(n%b-k)
        else:
            cnt+=(b-k)*(n//b)+(n%b-k+1)
    else:
        cnt+=(b-k)*(n//b)

print(cnt)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int len = s.length();
	for(int i = 0;i < len;i++){
		if(s[i] == ',') printf(" ");
		else printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

int h,n,i;
cin>>h>>n;
int sum=0;
for(i=0;i<n;i++)
{
	int t;
    cin>>t;
    sum += t;
}
  if(sum>=h)
    cout<<"Yes";
  else
    cout<<"No";

  
  
}


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

int main(){
	int n, m;
	cin >> n >> m;
	int a, b;
	string s;
	for(int i = 0; i < n; ++i){
		getchar();
		for(int j = 0; j < m; ++j){
			cin >> s;
			if(s == "snuke"){
				a = i;
				b = j;
			}
		}
	}
	printf("%c%d\n", 'A'+b, a+1);
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


void solve_init(long long N, long long A, long long B){
    if(A==0){
        cout << 0 << endl;
        return;
    }
    ll cnt=N/(A+B);
    ll sum=cnt*A;
    if(N%(A+B)>0){
        ll res=N%(A+B);
        if(res>=A){
            sum+=A;
        }else{
            sum+=res;
        }
    }
    cout << sum << endl;
}

void solve(long long N, long long A, long long B){
    ll cnt=N/(A+B);
    ll sum=cnt*A+min(N%(A+B),A);
    cout << sum << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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


signed main() {
  double n; cin >>n;
  vector<pair<double, double>> vec(n);
  for(int i = 0; i < n;i++){cin >> vec[i].first >> vec[i].second;}
  double tum_paths = 0.0;
  for(int i = 0; i < vec.size(); i++) {
    for(int j = i+1;  j <vec.size(); j++) {
      tum_paths += sqrt((vec[j].first-vec[i].first)*(vec[j].first-vec[i].first) + (vec[j].second-vec[i].second)*(vec[j].second-vec[i].second));
    }
  }
  double ust = 2.0*tum_paths;
  for(double i = 1; i < n; i++) ust *=i;
  double bolen = 1.0;
  for(double i = 1; i <= n;i++) bolen *= i;

  cout <<setprecision(10) << ust/bolen << endl;

}


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

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

  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int A,B;
  cin>>A>>B;
  REP(i,0,10101){
    if(8*i/100==A && i/10 == B){
      cout<<i<<endl;
      return 0;
    }
  }
      cout<<-1<<endl;

  return 0;
}


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

using namespace std;

const double PI = 3.14159265358979;

struct Item
{
	int value;
	int weight;
};

int dp[101][10001];

int main() {

	int N; cin >> N;

	int A[100001];

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

	int length = 0;
	int L[100001];
	L[length++] = A[0];
	for (int i = 1; i < N; i++)	{

		if (L[length - 1] < A[i]) {

			L[length++] = A[i];
		}
		else {		//L[length] >= A[i]
			int* p = lower_bound(L, L + length, A[i]);
			*p = A[i];
		}
	}

	cout << length << endl;
	return 0;
}



Measured memory_bytes: 3876
# 20200610_yorukatsu_e.py
H,W = map(int,input().split())
glid = [list(input()) for _ in range(H)]

row = [False]*H
col = [False]*W
for i in range(H):
    for j in range(W):
        if glid[i][j] == "#":
            row[i] = True
            col[j] = True
for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(glid[i][j],end="")

        print()

Measured memory_bytes: 4596
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int n = sc.nextInt();
    int p[] = new int[n];
    int s[] = new int[n];
    if(n==0){
      System.out.println(x);
      return;
    }
    for(int i = 0 ; i < n ; ++i){
      p[i] = sc.nextInt();      
    }
    
    Arrays.sort(p);
    
    int ue_s = 0;
    int st_s = 0;
    int ue_ans = 0;
    int st_ans = 0;
    

    //うえ
    for(int i = x ; i <= 101 ; ++i){
      int count=0;
      for(int j = 0 ; j < n ; ++j){   
        if(p[j] != i){
          count++; 
        }else if(p[j] == i){
          break;
        }
      }if(count == p.length){
        ue_ans = i;
        break;
      }
    }

    //した
    for(int i = x ; i >= 0 ; --i){
      int count=0;
      for(int j = 0 ; j < n ; ++j){
        if(p[j] != i){
          count++; 
        }else if(p[j] == i){
          break;
        }
      }if(count == p.length){
        st_ans = i;
        break;
      }
    }
    ue_s = Math.abs(x-ue_ans);
    st_s = Math.abs(x-st_ans);
    if(ue_s<st_s) System.out.println(ue_ans);
    else System.out.println(st_ans);
    
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int n;
vector<int> v;

bool check(int left,int tar,int right){
  if(left>right)swap(left,right);
  if(left<tar&&tar<right)return true;
  return false;
}

int main(){
  cin>>n;
  REP(i,n){
    int temp;
    cin>>temp;
    v.push_back(temp);
  }
  int count=0;
  REP(i,n-2){
    if(check(v[i],v[i+1],v[i+2]))count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
n1,n2 = gets.chomp.split(" ").map(&:to_i)
high = Array.new(n1, 0)
for i in 0..n1 - 1
  high[i] = gets.to_i
end
high = high.sort
ans = 10**10
for i in 0..n1 - n2
  if ans > high[i + n2 - 1] - high[i]
    ans = high[i + n2 - 1] - high[i]
  end
end
puts ans


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


int main(){
    int k;
    cin >> k;
    vector<ll> a;
    for (int i = 1; i < 10 ;i++) a.push_back(i);
    while (1){
        vector<ll> old;
        swap(old,a);
        for (ll x: old ){
            k--;
            if (k==0){
                cout << x << endl;
                return 0;
            }
            for (int i = -1; i < 2; i++){
                int d = x%10+i;
                if (d < 0 || d > 9) continue;
                a.push_back(x*10+d);
            }
        }
    }

}


Measured memory_bytes: 2764
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let vs: Vec<u32> = s.trim().split_whitespace().map(|token| token.parse().ok().unwrap()).collect();
    let n = vs[0];
    let k = vs[1];
    if (n + 1) / 2 >= k {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/7
Update on 2019/3/
Solved on 2019/3/  
@author: shinjisu
"""


# Educational Dynamic Programming
# import math
#import numpy as np
#import sys
#sys.setrecursionlimit(10**6)


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)


def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)


def getIntLines(n): return [int(input()) for i in range(n)]
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data


def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    mat = zeros((n, m))
    #dmp(mat)
    for i in range(n):
        mat[i] = getIntList()
    return mat


def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_H_v1():  # Grid 1    AC 10  TLE 6
    H, W = getIntList()
    dmp((H, W), 'H, W')
    a = []
    for i in range(H):
        a.append(input())
    dmp(a)
    WALL = '#'
    BLANK = '.'
    dp = zeros((H+1, W+1))
    dp[1, 1] = 1
    dmp(dp, 'dp initial')
    for i in range(H):
        for j in range(W):
            if a[i][j] == BLANK and (i > 0 or j > 0):
                dp[i+1, j+1] = (dp[i, j+1] + dp[i+1, j]) % N1097

    dmp(dp, 'dp')
    return dp[H, W]


def prob_H_v2():  # Grid 1  AC 11  TLE 5
    H, W = getIntList()
    dmp((H, W), 'H, W')
    a = []
    for i in range(H):
        a.append(input())
    dmp(a)
    WALL = '#'
    BLANK = '.'
    dp = zeros((H+1, W+1))
    dp[1, 1] = 1
    dmp(dp, 'dp initial')
    for i in range(1, H):
        if a[i][0] == BLANK:
            dp[i+1, 1] = dp[i, 1]
    for j in range(1, W):
        if a[0][j] == BLANK:
            dp[1, j+1] = dp[1, j]
    for i in range(1, H):
        for j in range(1, W):
            if a[i][j] == BLANK:
                dp[i+1, j+1] = (dp[i, j+1] + dp[i+1, j]) % N1097

    dmp(dp, 'dp')
    return dp[H, W]




def prob_H():  # Grid 1    AC 11  TLE 5
    H, W = getIntList()
    dmp((H, W), 'H, W')
    a = []
    for i in range(H):
        a.append(input())
    dmp(a)
    WALL = '#'
    BLANK = '.'
    dp = zeros2(H+1, W+1)
    dp[0][1] = 1  # [1,1]ではないことがポイント
    dmp(dp, 'dp initial')
    for i in range(H):
        for j in range(W):
            if a[i][j] == WALL:
                continue
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][ j]) % N1097

    dmp(dp, 'dp')
    return dp[H][ W]


debug = False  # True False
ans = prob_H()
print(ans)
#for row in ans:
#    print(row)



Measured memory_bytes: 43764