akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL N, K;

int ask(int k) {
	cout << k + 1 << endl;
	string S;
	cin >> S;
	if (S == "Yes") {
		return -1;
	}
	if (S == "Near") {
		return 1;
	}
	return 0;
}

int main(void)
{
	cin >> N >> K;
	if (N <= 10) {
		cout << 0 << endl;
		for (int g = 0; g < K; ++g) {
			for (int i = 0; i < N; ++i) {
				if (ask(i) < 0) {
					break;
				}
			}
		}
		return 0;
	}
	int P = N - 9;
	vector<pair<int, int>>vec;//0-indexed
	for (int i = 0; i < 9; ++i) {
		for (int s = 0; s < P; ++s) {
			if (s & (1 << i)) {
				vec.push_back({ s,i + P });
			}
		}
	}
	int M = vec.size();
	cout << M << endl;
	for (int i = 0; i < M; ++i) {
		cout << vec[i].first + 1 << " " << vec[i].second + 1 << endl;
	}
	for (int g = 0; g < K; ++g) {
		bool tok = false;
		int ans = 0;
		for (int i = 0; i < 9; ++i) {
			int res = ask(i + P);
			if (res < 0) {
				tok = true;
				break;
			}
			if(res)ans += (1 << i);
		}
		if (tok)continue;
		int ult = ask(ans);
		assert(ult < 0);
	}
	return 0;
}



Measured memory_bytes: 3308
#include<stdio.h>
int main(){
  int n;
  int sum;
  int b1,b2;
  scanf("%d",&n);
  scanf("%d",&b1);
  sum += b1;
  for(int i = 0;i < n-1;i++){
    b2 = b1;
    scanf("%d",&b1);
    sum += (b1>b2?b2:b1);
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define j1 j1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N; cin>>N;

  int a[N];
  vector<int> b(N);
  int ct=0;
  rep(i,N){
    cin>>a[i];
    b[i]=0;
    while(a[i]%2==0){
      ++ct;
      a[i]/=2;
    }
  }

  cout<< ct <<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#include<stdio.h>

int main(){
   int k,a,b;

   scanf("%d", &k);
   scanf("%d%d", &a,&b);

   int big = (b/k)*k;
   if(a <= big){
      printf("OK\n");
   }else{
      printf("NG\n");
   }
   return 0;
}


Measured memory_bytes: 1588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#define rec(n,i) for(int i=0;i<n;i++)
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	cout << (n-1)*(x-1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 100001;
ll dp[MAX][4] = {};
ll h[MAX][4] = {};

int main() {
    

    ll n;
    cin >> n;
    for (ll i=1;i<=n;i++){
        cin >> h[i][1] >> h[i][2] >> h[i][3];
    }
    for (int i=1;i<=3;i++){
        dp[1][i] = h[1][i];
    }
    ll maxv;
    for (ll i=1;i<=n;i++){
        for (ll j=1;j<=3;j++){
            maxv = 0;
            for (ll k=1;k<=3;k++){
                if(j==k){
                    continue;
                }
                if(maxv < dp[i-1][k]){
                    maxv = dp[i-1][k];
                }
            }
            dp[i][j] = maxv + h[i][j];
        }
    }
    maxv = 0;
    for (int i=1;i<=3;i++){
        if(maxv < dp[n][i]){
            maxv = dp[n][i];
        }
    }
    cout << maxv << endl;

}




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

int main() {
    char b;
    cin >> b;
    switch (b)
    {
    case ('A'):
        cout << 'T';
        break;
    case ('T'):
        cout << 'A';
        break;
    case ('C'):
        cout << 'G';
        break;
    case ('G'):
        cout << 'C';
        break;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null; }
        String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try { tokenizer = new StringTokenizer(reader.readLine()); } 
                catch (IOException e) { throw new RuntimeException(e);} }
            return tokenizer.nextToken(); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    /** CHECKLIST:
     * LIMITS (DOES BRUTE FORCE WORK?)
     * CHECK ALL PARAMETERS
     * INT VS LONG
     */
    public static void main(String[] args) {
        
        String s = r.next();
        String t = r.next();
        int m = s.length();
        int n = t.length();
        int[][] L = new int[m+1][n+1];
        for(int i = 0; i <= m; i++){
            for(int j = 0; j <= n; j++){
                if(i == 0 || j == 0){
                    L[i][j] = 0;
                } else if(s.charAt(i-1) == t.charAt(j-1)){
                    L[i][j] = L[i-1][j-1] + 1;
                } else{
                    L[i][j] = Math.max(L[i][j-1], L[i-1][j]);
                }
            }
        }
        char[] lcs = new char[1 + L[m][n]];
        lcs[L[m][n]] = ' ';
        int i = m;
        int j = n;
        int index = L[m][n];
        while(i > 0 && j > 0){
            if(s.charAt(i-1) == t.charAt(j-1)){
                lcs[index-1] = s.charAt(i-1);
                i--; j--; index--;
            } else if (L[i-1][j] > L[i][j-1]){
                i--; 
            } else {
                j--;
            }
        }
        for(int k = 0; k <= L[m][n]; k++){
            pw.print(lcs[k]);
        }
        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Uneven Numbers
            int N = int.Parse(Console.ReadLine());
            int ans = 0;

            for(int i = 1; i <= N; i++)
            {
                var s = i.ToString();

                if (s.Length % 2 == 1)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define endl "\n"
#define MOD 1000000007

ll recurse(ll i, ll women, vector<vector<ll>>& his, vector<vector<ll>>& dp, ll n) {
    if (women == (1<<n) - 1) {
        // all women done => all men have to be done
        return 1;
    }

    if (i == n) {
        // all men done but not women
        return 0;
    }

    // all women done but men not is not possible

    // no one is done
    if (dp[i][women] != -1) {
        return dp[i][women];
    }

    ll ans = 0;
    for (auto w: his[i]) {
        //  if no women for this man, then ans is 0 from here
        if (!(women & (1<< w))) {
            ans = (ans + recurse(i+1, women | (1<<w), his, dp, n)) % MOD;
        }
    }
    return dp[i][women] = ans;
}



int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll n;
    cin >> n;
    vector<vector<ll>> his (n);
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            ll a;
            cin >> a;
            if (a) {
                his[i].push_back(j);
            }
        }
    }
    vector<vector<ll>> dp (n, vector<ll> (1 << 21 + 1, -1));
    cout << recurse(0, 0, his, dp, n) << endl;

    
    return 0;
}

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

int main(){
  int n;
  int s1,s2,s3,s4;
  cin >> n;
  s1 = n/1000;
  s2 = n/100 - s1*10;
  s3 = n/10 - s1*100 - s2*10;
  s4 = n - s1*1000 - s2*100 - s3*10;
  if (s1 == s2 && s2 == s3 || s2 == s3 && s3 == s4){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>

using namespace std;
vector<long> a;

int main() {

	long n,k = 0;
	cin >> n >> k;
	for (long i = 0; i < n; ++i) {
		long tmp = 0;
		cin >> tmp;
		a.push_back(tmp);
	}

	int tmp1 = n - 1;
	int tmp2 = k - 1;

	double ans = double(tmp1) / double(tmp2);
	if(ans == int(ans)) cout << (n - 1) / (k - 1) << endl;
	else cout << int(ans) + 1 << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; string s; cin >> n >> s;
    int allE = 0, allW = 0;
    rep(i, s.size())
    {
        if (s[i] == 'E')allE++;
        else allW++;
    }

    int ans = MOD;
    int curE = 0, curW = 0;
    rep(i, s.size())
    {
        int E = allE - curE;
        if (s[i] == 'E')
        {
            E--; curE++;
        }
        chmin(ans, curW + E);
        if (s[i] == 'W') curW++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, int> P;
int main() {
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    vector<P> v(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        long long s = A[i] + B[i];
        v[i] = P(s, i);
    }
    sort(v.begin(), v.end(), greater<P>());
    long long tk = 0, ao = 0;
    for (int i = 0; i < N; i++) {
        int x = v[i].second;
        if (i % 2 == 0) {
            tk += A[x];
        } else {
            ao += B[x];
        }
    }
    cout << tk - ao << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

#define YES 1
#define NO 0

void circle_in(int w, int h, int x, int y, int r){
    int flag = YES;
    if (x - r < 0 || x + r > w)
        flag = NO;
    if (y - r < 0 || y + r > h)
        flag = NO;
    if (flag == YES)
        printf("Yes\n");
    else 
        printf("No\n");
    
}

int main(void){
    int w = 0;
    int h = 0;
    int x = 0;
    int y = 0;
    int r = 0;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    circle_in(w, h, x, y, r);

    return 0;
}



Measured memory_bytes: 2104
def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    else:
        p = [int(i) for i in input().split()]

    i = 0
    while True:
        if not x-i in p:
            print(x-i)
            return
        if not x+i in p:
            print(x+i)
            return
        i += 1

resolve()

Measured memory_bytes: 61964
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from heapq import heappush, heappop

def main():
    n, k = map(int, input().split())
    td = [tuple(map(int, input().split())) for _ in range(n)]
    td = list(sorted(td, key=lambda x: -x[1]))
    dsum, kind = 0, 0
    num = [0 for _ in range(n)]
    h = []
    for t, d in td[:k]:
        dsum += d
        if num[t-1] > 0:
            heappush(h, (d, t))
        if num[t-1] == 0:
            kind += 1
        num[t-1] += 1
    
    ans = dsum + kind * kind

    for t, d in td[k:]:
        if len(h) == 0:
            break
        if num[t-1] > 0:
            continue
        else:
            _d, _t = heappop(h)
            num[_t-1] -= 1
            num[t-1] += 1
            kind += 1
            dsum += d-_d
            if dsum + kind * kind > ans:
                ans = dsum + kind * kind
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 main(){
    ll n,a,b; cin>>n>>a>>b;
    ll res=0;
    if(a>b) cout<<0<<endl;
    else if(a==b) cout<<1<<endl;
    else if(n==1 && a<b) cout<<0<<endl;
    else if(n==1) cout<<1<<endl;
    else cout<<max(0ll, (b-a)*(n-2)+1)<<endl;
    return 0;
}

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

using namespace std;

#define ll long long

deque<char> s;
int cnt = 0;
int c;
int a;
char ch;

void solve(){
    cin>>c;
    if(c == 1){
        cnt ++;
    }else{
        cin>>a;
        cin>>ch;
        if(a == 1){
            if(cnt % 2 == 0){
                s.push_front(ch);
            }else{
                s.push_back(ch);
            }
        }else{
            if(cnt % 2 == 0){
                s.push_back(ch);
            }else{
                s.push_front(ch);
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string ss;
    cin>>ss;
    for(int i = 0;i<ss.size();i++){
        s.push_back(ss[i]);
    }
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    if(cnt % 2 == 1){
        for(int i = 0;i<(int)s.size() / 2;i++){
            swap(s[i],s[s.size()-i-1]);
        }
    }
    for(int i = 0;i<s.size();i++){
        cout<<s[i];
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    bool ans = false;
    for(int i=0;i<=n;i++){
        int j = n - 1 - i;
        if(b - a >= c * j - d * i && b - a <= (-1) * c * i + d * j){
            ans = true;
        }
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(void){
    char s[N], t[N];
    scanf("%s\n", s);
    scanf("%s\n", t);

    int u = 0;
    int n1 = strlen(s);

    for(int i = 0; i < n1; i++){
        if(s[i] != t[i]){
            u++;
        }
    }

    printf("%d\n", u);
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

    ll n;cin >> n;
    string str;cin >> str;

    ll up = 0;
    ll right = 0;

    REP(i, n){
        if(str[i] >= 'a' && str[i] <= 'm')right++;
        if(str[i] >= 'n' && str[i] <= 'z')right--;
        if(str[i] >= 'A' && str[i] <= 'M')up++;
        if(str[i] >= 'N' && str[i] <= 'Z')up--;
    }

    string ans = "";
    REP(i, right)ans += 'a';
    REP(i, -right)ans += 'n';
    REP(i, up)ans += 'A';
    REP(i, -up)ans += 'N';
    cout << ans.size() << endl << ans << endl;

	return 0;
}



Measured memory_bytes: 3352
S,H,C,D = 0,1,2,3
table = [[0 for _ in range(14)] for _ in range(4)]

n = int(input())
for _ in range(n):
    a,b = input().split()
    table[eval(a)][int(b)] = 1

for i in ['S','H','C','D']:
    for j in range(1,14):
        if table[eval(i)][j] == 0:
            print(i,j)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    string a,b; 
    cin>>a>>b;
    rep(i,1000)if(stoi(a+b)==i*i) cout<<"Yes\n",exit(0);
    cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
A,B = [int(i) for i in input().split()]

def f(k):
  return k*A - k +1

l = 0
r = 20

while l<r:
  m = (l+r)//2
  if f(m) >= B:
    r = m
  else:
    l = m+1
print(r)
  


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int main() {
    string s, t; cin >> s >> t;
    vector<vector<int>> posS(26);
    rep(i, s.size()) {
        posS[s[i] - 'a'].pb(i);
    }
    rep(i, t.size()) {
        if(posS[t[i] - 'a'].empty()) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = posS[t[0] - 'a'][0] + 1;
    int tmppos = posS[t[0] - 'a'][0];
    rep(i, t.size() - 1) {
        //二分探索してくださいね upper_boundね それが==posS[t[i + 1] - 'a'].size()ならもう一週ですよ
        int key = upper_bound(all(posS[t[i + 1] - 'a']), tmppos) - posS[t[i + 1] - 'a'].begin();
        if(key == posS[t[i + 1] - 'a'].size()) {
            ans += (s.size() - tmppos - 1);
            tmppos = posS[t[i + 1] - 'a'][0];
            ans += (tmppos + 1);
        }else {
            ans += (posS[t[i + 1] - 'a'][key] - tmppos);
            tmppos = posS[t[i + 1] - 'a'][key];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1344
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	ls := make([]int, n)
	for i := 0; i < n; i++ {
		ls[i] = sc.ReadInt()
	}

	counter := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if ls[i] == ls[j] || ls[j] == ls[k] || ls[k] == ls[i] {
					continue
				}

				if ls[i]+ls[j] > ls[k] && ls[j]+ls[k] > ls[i] && ls[k]+ls[i] > ls[j] {
					counter++
				}
			}
		}
	}

	fmt.Println(counter)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

namespace ABC096
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var suf1s = new []
            {
                11, 31, 41, 61, 71, 101, 131, 151, 181, 191,
                211, 241, 251, 271, 281, 311, 331, 401, 421, 431,
                461, 491, 521, 541, 571, 601, 631, 641, 661, 691,
                701, 751, 761, 811, 821, 881, 911, 941, 971, 991,
                1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231,
                1291, 1301, 1321, 1361, 1381,
            };

            Console.WriteLine(string.Join(" ", suf1s.Take(int.Parse(Console.ReadLine()))));
        }
    }
}

Measured memory_bytes: 11220
sa=gets.chomp.chars
sb=gets.chomp.chars
sc=gets.chomp.chars
h = {
    'a' => sa,
    'b' => sb,
    'c' => sc,
}

c = 'a'
loop do
    c = h[c].shift
    if h[c].empty?
        puts c.upcase
        exit 0
    end
end




Measured memory_bytes: 1788
#include <iostream>
#include <cctype>
#include <vector>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(vector<string> s) {
  for (auto &str : s) {
    cout << (char)toupper((unsigned char)str[0]);
  }
  cout << endl;
}

int main() {
  vector<string> s(3);
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
  }
  solve(move(s));
  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define yes() cout << "Yes"<< endl;
#define no() cout << "No"<< endl;

int main() {
	int n;
	cin >> n;
	double res;
	if (n % 2 == 0) {
		res = double(0.5);
	}
	else {
		double nd = double(n);
		res = (nd + 1) / 2 / nd;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
import fractions
lcm=C*D//fractions.gcd(C,D)

c=B // C - (A-1)//C
d=B//D - (A-1)//D
cd=B//lcm - (A-1)//lcm

print(B-A+1 - (c+d-cd))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve(){
    int k,t;cin>>k>>t;
    int ans=0;
    REP(i,t){
        int x;cin>>x;
        ans=max(ans,x);
    }
    cout<<max(2*ans-k-1,0)<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main() {
  int count;
  cin >> count;
  vector<long long> a(count);
  vector<long long> b(count);
  vector<long long> c(count-1);
  long long t = 0;
  long long prv = 0;

  for(int i=0; i<count; i++){
    cin >> a.at(i);
  }
  for(int i=0; i<count; i++){
    cin >> b.at(i);
  }
  for(int i=0; i<count-1; i++){
    cin >> c.at(i);
  }
  
  for(int i=0; i<count; i++){
    
    if(prv == a.at(i) - 1 && prv != 0) {
      t = t + b.at(a.at(i)-1) + c.at(a.at(i) -1 - 1);
    } else {
      t = t + b.at(a.at(i)-1);
    }
    prv = a.at(i);
  }
  
  cout << t << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
#include<vector>
#define pb push_back
#include<algorithm>

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

  ll t=0;
  std::sort(a,a+n);
  if(a[n-1]<=a[0]){
    std::cout << "0" << std::endl;
  }
  else{
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
            if(a[j]>a[i]){
        for(int k=j+1;k<n;k++){
            if(a[j]<a[k] && a[i]+a[j]>a[k]) t++;
        }
      }
   }
 }
std::cout << t << std::endl;
}
 return 0;
}


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

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

    int res = 0;
    for (int i = a; i <= b; i++) {
        if (i/10000 == i % 10 and i/1000 % 10 == i/10 % 10) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

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

	long long sum = 0;
	long long min = 1000000;
	long long max = -1000000;

	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		sum += num;
		if (num < min)
		{
			min = num;
		}
		if (num > max)
		{
			max = num;
		}
	}

	printf("%lld %lld %lld\n", min, max, sum);
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 500

int G[MAXN][MAXN];
string S;
int N,M;

int main(){
	cin>>N>>M;
	for (int i=0;i<N;++i){
		cin>>S;
		for (int j=0;j<M;++j){
			if (S[j] == '#')G[i][j] = 1;
		}
	}
	for (int i=0;i<N;++i){
		for (int j=0;j<M;++j){
			if (G[i][j])cout<<'#';
			else if (i == 0)cout<<'#';
			else if(j%2 && i!=N-1)cout<<'#';
			else cout<<'.';
		}
		cout<<'\n';
	}
	cout<<'\n';
	for (int i=0;i<N;++i){
		for (int j=0;j<M;++j){
			if (G[i][j])cout<<'#';
			else if (i == N-1)cout<<'#';
			else if(j%2==0 && i!=0)cout<<'#';
			else cout<<'.';
		}
		cout<<'\n';
	}
}

Measured memory_bytes: 1664
// 2019/03/26 Tazoe

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

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

	priority_queue< int, vector<int>, greater<int> > q;

	for(int i=0; i<N; i++){
		int M;
		cin >> M;

		int c;
		cin >> c;

		q.push(c);

		for(int j=1; j<M; j++){
			cin >> c;

			if(q.top()<c){
				q.pop();
				q.push(c);
			}
		}

//		cout << q.top() << endl;
	}

	long long sum = 0;

	while(!q.empty()){
		sum += q.top();
		q.pop();
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 4972
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e3+10;


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

	fastio;

	int n,k;
	string s;

	cin >> n >> k >> s;

	rep(i,0,n){
		if(i == k-1) s[i] = tolower(s[i]);
		cout << s[i];
	}

	cout << '\n';

	return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        // TODO 自動生成されたメソッド・スタブ
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int n = 0 , m = 0,l = 0;
        //input
        n = Integer.parseInt(input[0]);
        m = Integer.parseInt(input[1]);
        l = Integer.parseInt(input[2]);
        //InputMatrix
        long[][] matrixA = new long[n][m];
        long[][] matrixB = new long[m][l];
        long[][] ansMatrix = new long[n][l];

        for(int i = 0;i < n;i++){
            String[] line1 = br.readLine().split(" ");
            for(int j = 0;j < m;j++){
                matrixA[i][j] = Integer.parseInt(line1[j]);
            }
        }
        for(int i = 0;i < m;i++){
            String[] line2 = br.readLine().split(" ");
            for(int j = 0;j < l;j++){
                matrixB[i][j] = Integer.parseInt(line2[j]);
            }
        }
        //Calculate
        for(int i = 0;i < n;i++){
            for(int j = 0;j < l;j++){
                for(int k = 0;k < m;k++){
                    ansMatrix[i][j] += matrixA[i][k] * matrixB[k][j];
                }
            }
        }
        //Output
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < n;i++){
            for(int j = 0;j < l;j++){
                sb.append(ansMatrix[i][j]);
                if(j!=l-1)sb.append(" ");
            }
            if(i!=n-1)sb.append("\n");
        }
        System.out.println(sb);

    }

}



Measured memory_bytes: 31852
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]
cnt = 0
for i in range(N) :
    if D[i][0] == D[i][1] :
        cnt += 1
    else :
        cnt = 0
    if cnt == 3 :
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9176
// AOJ Volume 0 Problem 0023

#include <stdio.h>

int main(void)
{
    float v, y;
	float n;
    int m;
	
    while (scanf("%f", &v) != EOF){
        y = v * v / (2 * 9.8);
		n = y / 5 + 1;
		
		m = n;
		
		if (m < n){
			m++;
		}
        
        printf("%d\n", m);
    }
    
    return (0);
}

Measured memory_bytes: 0
N,C=map(int,input().split())
f=[[0]*int(1e5) for _ in range(C)]

for i in range(N):
	s,t,c=map(int,input().split())
	f[c-1][s-1:t]=[1]*(t-s+1)

print(max(map(sum,zip(*f))))


Measured memory_bytes: 69592
N = int(input())
s= {}
max_keep=0
for i in range(N):
    key=input()
    s.setdefault(key,0)
    s[key]+=1
    if s[key]>max_keep:
        max_keep=s[key]

max_list=[]
for value in s.values():
  if value==max_keep:
    max_list.append(s)

keys = [k for k, v in s.items() if v==max_keep]
keys.sort()

string = "\n".join(keys)
print(string)


Measured memory_bytes: 35676
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
const ll mod=1e9+7;
const ll inf=1e16;
using namespace std;

int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll k;
  cin>>k;
  if(k%2==0){
  	cout<<"-1"<<endl;
  }
  
  else{
  	ll pos=0;
  	ll num=0;
  	ll i;
  	for(i=1;i<=k;i++){
  		num=(num*10+7)%k;
  		if(num==0){
  			cout<<i<<endl;
  			break;
		  }
	
	}
	
	if(i>k){
		cout<<"-1"<<endl;
	}
  	 	
 }
  
  
  return 0;
}

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

vector<int> to[200005];
vector<int> ans;

void dfs (int v, int p=-1) { // デフォルト変数？明示的に書かなければ-1が入る

    for (int u : to[v]) {
        if (u == p) continue; // 双方向に行けるときは親へ戻らないためにこの処理が必要
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main () {

    int N, Q;
    scanf("%d %d", &N, &Q);

    for (int i = 0; i < N-1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    ans.resize(N);
    for (int i = 0; i < Q; i++) {
        int p, x;
        scanf("%d %d", &p, &x);
        p--;

        ans[p] += x;
    }

    dfs(0);

    for (int i = 0; i < N; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;
int n;
vector<int> v[N],a(N),ans(N);

void dfs(int node,int p)
{
    //cout<<node<<endl;
    a[node]=1;
    for(auto i:v[node])
    {
        if(i!=p)
        {
            dfs(i,node);
            a[node]*=(a[i]+1);
            if(a[node]>=mod)
            a[node]%=mod;
        }
    }
}

void dfs2(int node,int p,int ways)
{
    ans[node]=((ways+1)*a[node])%mod;
//    cout<<a[node]<<" "<<node<<" "<<p<<" "<<ways<<endl;

    int n1=v[node].size();
    int pre[n1+1],suf[n1+1];
    for(int i=0;i<n1;i++)
    {
        if(v[node][i]==p)
            pre[i]=1;
        else
            pre[i]=a[v[node][i]]+1;
        if(i>0)
        pre[i]=(pre[i-1]*pre[i])%mod;
    }

    for(int i=n1-1;i>=0;i--)
    {
        if(v[node][i]==p)
            suf[i]=1;
        else
            suf[i]=a[v[node][i]]+1;
        if(i<(n1-1))
            suf[i]=(suf[i+1]*suf[i])%mod;
    }
    int j=0;
    for(auto i:v[node])
    {
        int y=1;
        if(j>0)
            y=pre[j-1];
        if(j+1<n1)
            y=(y*suf[j+1])%mod;
        //cout<<node<<":"<<y<<endl;
        int nways=y;
        nways=((ways+1)*nways)%mod;
        if(i!=p)
        dfs2(i,node,nways);
        j++;
    }
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 int x,y;
 cin>>n>>mod;
 for(int i=1;i<n;i++)
 {
    cin>>x>>y;
    v[x].push_back(y);
    v[y].push_back(x);
 }

 dfs(1,-1);
 dfs2(1,-1,0);
 for(int i=1;i<=n;i++)
    cout<<ans[i]<<endl;


}

Measured memory_bytes: 26544
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

char c;


int main(){
	
	cin>>c;
	
	if( c=='a' || c=='i' || c=='u' || c=='e' || c=='o' ) puts("vowel");
	else{	puts("consonant");}
	
	return 0;

}

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

int main() {
  int n,Y;
  cin>>n>>Y;
  Y=Y/1000;
  int x=-1,y=-1,z=-1;
  for (int i=0;i<=n;i++) {
    for (int j=0;j<=n-i;j++){
      if (i*10+j*5+n-i-j==Y) {
        x=i;
        y=j;
        z=n-i-j;
      }
    }
  }
  cout<<x<<' '<<y<<' '<<z<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, k; // 長さはk未満
    cin >> n >> k;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i), i--;
    map<int, int> m;
    vector<int> S(n+1);
    for (int i = 0; i < n; ++i) {
        S[i+1] = (S[i]+v[i])%k;
    }
    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        if(m.count(S[i])) ans += m[S[i]];
        m[S[i]]++;
        if(i >= k-1){  // 長さはk未満
            m[S[i-k+1]]--;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{

    int N,K;

    cin>>N>>K;
    char S[50];
    cin>>S;

    S[K-1]+=32;
    cout<<S;

}

Measured memory_bytes: 256
#include <iostream>
int main(int argc, char *argv[]) {
  char S;
  bool A = false, B = false;
  while (std::cin >> S) {
    if (S == 'A')
      A = true;
    if (S == 'B')
      B = true;
    if (A && B) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char a[20];
  int i;
  int num;
  scanf("%s",a);
  num = strlen(a);

  for (i = num-1;i >= 0;i--) {
    printf("%c",a[i]);
  }

    printf("\n");

  return 0;
}

Measured memory_bytes: 524
#include <iostream>
using namespace std;
int main()
{
	int n, m, h[100], i, j, r, f;
	char s[100][9], t[9];
	while (cin >> n >> m, n)
	{
		for (i = r = 0; i < n; i++) cin >> s[i] >> h[i];
		for (; m > 0; m--)
		{
			cin >> t;
			for (i = 0; i < n; i++)
			{
				f = 1;
				for (j = 7; j >= 0 && f; j--)
				{
					if (s[i][j] == '*') break;
					if (s[i][j] != t[j]) f = 0;
				}
				if (f) r += h[i];
			}
		}
		cout << r << endl;
	}
}

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

template<typename T>
T gcd(T a, T b){
  if(b == 0) return a;
  return gcd(b, a%b);
}


int main(){
  ll A,B;
  cin >> A >> B;
  ll g;
  if(A > B) g = gcd(A, B);
  else g = gcd(B, A);

  ll i = 2;
  ll cnt = 0;
  int tmp = g;
  for(ll p = 2; p * p <= g; ++p){
    if(g % p != 0) continue;
    while(g % p == 0) g /= p;
    cnt++;
  }
  if(g != 1) cnt++;

  cout << cnt + 1 << endl;
  
}


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

ll x,y;
cin>>x>>y;
if(x<y)
    cout<<x<<endl;
else{

    if(x%y==0)
        cout<<-1<<endl;
    else cout<<x<<endl;

}

return 0;}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int num,count;
    while (1) {
        scanf("%d",&num);
        if (num==0) break;
        count=0;
        while (num!=1) {
            if (num%2==0) {
                num/=2;
            } else {
                num=num*3+1;
            }
            count++;
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 600
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;


int main()
{
	int n;
	cin >> n;
	string s;
	int ans = 0;
	int a = 0;
	int b = 0;
	int ab = 0;
	for (int i = 0; i < n; i++) {
		cin >> s;

		if (s[0] == 'B') {
			if (s[s.size() - 1] == 'A') {
				ab++;
			}
			else {
				b++;
			}
		}else if (s[s.size() - 1] == 'A') {
			a++;
		}

		for (int j = 0; j < s.size() - 1; j++) {
			if (s[j] == 'A' && s[j + 1] == 'B') {
				ans++;
			}
		}
	}

	ans = ans + min(a, b) + ab;
	if (a == 0 && b == 0) {
		ans = ans - 1;
	}

	if (a == 0 && b == 0 && ab == 0) {
		ans++;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 4e2 + 10;
const ll mod = 1e9 + 7;


int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);

  int l, r; cin >> l >> r;

  if (r - l + 1 >= 2019) cout << 0;
  else {
    ll ans = 2019;

    for (ll i = l; i <= r; ++i)
      for (ll j = i + 1; j <= r; ++j)
        ans = min(ans, (i * j) % 2019);

    cout << ans;
  }

  return 0;
}



Measured memory_bytes: 3596
import sys
readline = sys.stdin.readline
from math import floor, ceil
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def round(f, r=0):
    return Decimal(str(f)).quantize(Decimal(str(r)), rounding=ROUND_HALF_UP)

def main():
    H, W = map(int, readline().rstrip().split())
    ans = H * W
    if H >= 3:
        y1 = int(round(H/3))
        y2 = (H-y1) // 2
        y3 = H - y1 - y2
        ans = min(ans, max(W*y1, W*y2, W*y3)-min(W*y1, W*y2, W*y3))
    if W >= 3:
        x1 = int(round(W/3))
        x2 = (W-x1) // 2
        x3 = W - x1 - x2
        ans = min(ans, max(x1*H, x2*H, x3*H)-min(x1*H, x2*H, x3*H))
    
    # 縦にスライス + 残りに横にスライス
    x1_cand = [floor(W/3), ceil(W/3)]
    # x1_cand = [i for i in range(1, W)]
    y1 = H
    for x1 in x1_cand:
        x2 = W - x1
        x3 = x2
        y2 = H // 2
        y3 = H - y2
        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))

    # 横にスライス + 残りに縦にスライス
    y1_cand = [floor(H/3), ceil(H/3)]
    # y1_cand = [i for i in range(1, H)]
    x1 = W
    for y1 in y1_cand:
        y2 = H - y1
        y3 = y2
        x2 = W // 2
        x3 = W - x2
        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int N=S.size();
  bool b=true;
  for (int i=0; i<N; i++){
    for (int j=i+1; j<N; j++){
      if(S[i]==S[j]){
        b=false;
        break;
      }
    }
  }
  if(b)puts("yes");
  else puts("no");
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		int ans = (T / A) * B;
		System.out.println(ans);
	}

}


Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 
def update(k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x,True,x,i), (t-x,False,x,i)]
    qs = []
    for _ in range(Q):
        qs.append(int(input()))
    xs.sort(key=lambda x:x[0])
    j = 0
    for x in xs:
        while Q-j and qs[j] < x[0]:
            print(segl[0] if segl[0]!= mx else -1)
            j += 1
        update(x[3], x[2] if x[1] else mx)
    while Q-j:
        print(-1)
        j+=1


Measured memory_bytes: 124128
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(s==u)
		a--;
	else
		b--;
	cout<<a<<" "<<b<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin() (a).end()
void solve()
{
	ll n , k;
	cin >> n >> k;
	cout<<(ll)ceil((ld)n/k)<<"\n";
return ;
}
int main()
{
	solve();
return 0;
}


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

int main() {
    int N;
    while (cin >> N, N) {
        string str;
        cin >> str;

        int sum = 0;
        vector<int> count(N);
        for (int i = 0; i < str.size(); i++) {
            if (str[i] == 'M') count[i % N]++;
            if (str[i] == 'L') count[i % N]+= sum+1, sum = 0;
            if (str[i] == 'S') sum += count[i%N]+1, count[i%N]=0;
        }

        sort(count.begin(), count.end());
        for (auto i : count) cout << i << " ";
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3188
public class Main {

	
	public static void main(String[] args) {
		
		
		for(int x = 1; x < 10; x++) {
			for(int y = 1; y < 10; y++) {
				System.out.printf("%dx%d=%d\n", x, y, x * y);
			}
		}
	}
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string N, M;
    cin >> N >> M;
    rep(i, N.size())
    {
        if (N[i] != M[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3600