akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	if 0 < A {
		fmt.Println("Positive")
	} else if (A < 0 && 0 < B) || A == 0 || B == 0 {
		fmt.Println("Zero")
	} else if B < 0 {
		if (B-A)%2 == 0 {
			fmt.Println("Negative")
		} else {
			fmt.Println("Positive")
		}
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<map>
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> v(n+2);
	v[0] = 0;
	for(int i=0;i<n;++i){
		cin >> v[i+1];
	}
	v[n+1] = 0;
	
	int origin = 0;
	for(int i=1;i<n+2;++i){
		origin += abs(v[i]-v[i-1]);
	}
//	origin += abs(previous-v[n-1]);
	
	for(int i=1;i<n+1;++i){
		int tmp = abs(v[i]-v[i-1]) + abs(v[i] -v[i+1]);
		cout << origin - tmp + abs(v[i-1] - v[i+1]) << endl;;
	}
	
	
	
	return 0;
	
}



Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(void)
{
	int N;
	cin >> N;
	if (N % 1000 == 0)
		cout << 0 << endl;
	else
	{
		int change = 1000 - N % 1000;
		cout << change << endl;
	}
	return 0;
}

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

long long int c(long long int n){
    long long int ans = 0;
    /*
    for(int i=1;powl(5,i)<=n;i++){
        ans += n / powl(5,i);
    }
    */
    if(n % 2 == 0){
        for(int i=1;powl(5,i)<=n;i++){
        ans += (n / (long long)powl(5,i)) / 2 ;
        }
    }else{
        ans = 0;
    }
    return ans;
}


int main(){
    long long int n;
    cin >> n;
    cout << c(n) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  ll n; scanf("%lld", &n);
  double base = 100;
  if (n == 100) { puts("0"); return 0; }
  int ans = 0;
  while (233) {
    base *= 1.01; base = floor(base);
    ans++;
    if (base >= n) { printf("%d\n", ans); return 0; }
  }
  return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll ans = n;
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  ll tot = 0;
  ll cnt = 0;
  for(int i=0;i<n-1;i++) {
    tot += a[i];
    cnt++;
    if(2 * tot <a[i+1]) {
      ans -= cnt;
      cnt = 0;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
bool check(string s)
{
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
            return false;
    }
    return true;
}
int main()
{
    fastio();
    
    string s,a,b;
    cin>>s;
    int n=s.size();
    a = s.substr(0,n/2);
    b = s.substr(n/2+1,n/2);
    //cout<<s<<" "<<a<<" "<<b<<endl;
    if(check(s) && check(a) && check(b))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, W = map(int, input().split())

WV = [[int(x) for x in input().split()] for _ in range(N)]

dp = [np.zeros(W*2 + 10, dtype=np.int64) for _ in range(N+1)]

for i in range(N):
    w, v = WV[i]
    dp[i + 1][w:] = np.maximum(dp[i][w:], dp[i][:-w] + v)
    dp[i + 1][:w] = np.maximum(dp[i][:w], dp[i+1][:w])
    # print(dp[i+1])

# print(dp)
ans = dp[N][W]

print(ans)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
    string s; cin >> s;
    cout << count(all(s), '1') << endl;
    return;
}

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

Measured memory_bytes: 3644
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(Y, [X|_]) :- to_upper(X, Y).

main :-
    get_string(A),
    get_string(B),
    get_string(C),
    string_chars(A, A2),
    string_chars(B, B2),
    string_chars(C, C2),
    f(X, A2),
    f(Y, B2),
    f(Z, C2),
    S = [X, Y, Z],
    string_chars(S2, S),
    writeln(S2).


Measured memory_bytes: 8100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define popcount(x) __builtin_popcount(x)
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define w(x) cout << (#x) << " is " << x << "\n" ;
const char nl = '\n';

int main()
{
//    fast ;
//#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//#endif
    ll c=0,n,t,x,y;
    cin >> t >> n;
    while(t--)
    {
        cin >> x >> y;
        if(x * x + y * y <= n *n)
            c++;
    }
    cout << c << "\n";

    return 0;


}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i, 0, n) cin >> a[i];
	auto b = a;
	sort(ALL(b));
	reverse(ALL(b));
	int mx = b[0], smx = b[1];
	FOR(i, 0, n) if (a[i] == mx) cout << smx << endl; else cout << mx << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-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 sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

int n,k;

const int MAX=100010;
int64_t fact[MAX];
int64_t fact_inv[MAX];

int64_t power(int64_t x,int64_t n)
{
    int64_t res=1;
    while(n>0){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
void init(){
    fact[0]=1;
    for(int i=0;i<n;i++)fact[i+1]=fact[i]*(i+1)%mod;
    fact_inv[n]=power(fact[n],mod-2);
    for(int i=n-1;i>=0;i--)fact_inv[i]=fact_inv[i+1]*(i+1)%mod;
}
int64_t comb(int64_t n,int64_t r)
{
    if(n<0||r<0||n<r)return 0;
    return (fact[n]*fact_inv[r])%mod*fact_inv[n-r]%mod;
}

void solve() 
{
    cin>>n>>k;
    init();
    ll a[n];REP(i,n)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    REP(i,n)ans-=a[i]*comb(n-i-1,k-1),ans=(ans+a[i]*comb(i,k-1))%mod;
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
count_ac, count_wa, count_tle, count_re = 0, 0, 0, 0
for i in range(n):
    s = input()
    if s == "AC":
        count_ac += 1
    if s == "WA":
        count_wa += 1
    if s == "TLE":
        count_tle += 1
    if s == "RE":
        count_re += 1

print("AC x", count_ac)
print("WA x", count_wa)
print("TLE x", count_tle)
print("RE x", count_re)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int fact(int n){
    int x = 1;
    FOR(i,1,n+1) x *= i;
    return x;
}


int main() {
    int n,k; cin >> n >> k;
    vi p(n);
    rep(i,n) cin >> p[i];
    // 各サイコロの期待値
    vector<double> ex(n);
    rep(i,n) ex[i] = (p[i]+1) / 2.0;
    // rep(i,n) printf("i:%d ex:%f\n",i,ex[i]);
    
    //累積和
    vector<double> cumsum(n+1);
    cumsum[0] = 0;
    FOR(i,1,n+1) cumsum[i] = cumsum[i-1] + ex[i-1];

    double ans = 0.0;
    // if(n==1) {
    //     ans = ex[0];
    // } else {
        rep(i,n-k+1) {
            double tmp = cumsum[i+k]- cumsum[i];
            ans = max(ans,tmp);
        }
    // }
    printf("%.7f\n",ans);
    return 0;
}


Measured memory_bytes: 4096
#include <cstdio>
    int main()
    {
        int num;
        scanf("%d", &num);
        int n[num];
        for (int i = 0; i < num; i++)
            scanf("%d", &n[i]);
        for (int i = num - 1; i > 0; i--)
            printf("%d ", n[i]);
        printf("%d\n", n[0]);
        return 0;
    }


Measured memory_bytes: 2732
// https://atcoder.jp/contests/agc043/tasks/agc043_a

#include <iostream>
#include <cstring>
using namespace std;

int main() {
    int H, W;
    bool map[110][110];
    int dp[110][110];

    cin >> H >> W;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            char c;
            cin >> c;
            map[i][j] = (c == '.');
            dp[i][j] = 1000;
        }
    }

    dp[1][1] = !map[1][1];
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (map[i][j] && !map[i][j + 1]));
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (map[i][j] && !map[i + 1][j]));
        }
    }

    cout << dp[H][W];
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
   void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W, N;
int globalIdx = 0;
int a[10010];
int B[109][109];

void init() {
   rep (i, H) {
      rep (j, W) {
         B[i][j] = -1;
      }
   }
}

void dfs(int y, int x) {
   rep (i, 4) {
      int py = y + dy[i], px = x + dx[i];
      if (py < 0 || py >= H || px < 0 || px >= W || B[py][px] != -1) continue;
      int ny = y, nx = x;
      while (1) {
         ny += dy[i], nx += dx[i];
         if (ny<0 || ny>=H || nx<0 || nx>=W || B[ny][nx]!=-1) break;
         B[ny][nx] = a[globalIdx];
         globalIdx++;
      }
      dfs(ny-dy[i], nx-dx[i]);
   }
}

int main() {
   cin >> H >> W >> N;
   // init();
   int idx = 0;
   rep (i, N) {
      int x;
      cin >> x;
      rep (j, x) {
         a[idx] = i+1;
         idx++;
      }
   }

   idx = 0;
   for (int i = 0; i < H; i++) {
      if (i%2==0) {
         for (int j = 0; j < W; j++) {
            // debug3(i, j, a[idx])
            B[i][j] = a[idx];
            idx++;
         }
      } else {
         for (int j = W-1; j >= 0; j--) {
            // debug3(i, j, a[idx])
            B[i][j] = a[idx];
            idx++;
         }
      }
   }
   
   // B[0][0] = a[0];
   // globalIdx++;
   // dfs(0, 0);
   rep (i, H) {
      rep (j, W-1) {
         cout << B[i][j] << " ";
      }
      cout << B[i][W-1] << endl;
   }

   return 0;
}

Measured memory_bytes: 384
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		String op = scan.next();
		int b = scan.nextInt();
		int ans = 0;

		while(!op.equals("?"))
		{
			if(op.equals("+"))
			{
				ans = a + b;
				System.out.println(ans);
			}else if(op.equals("-")){
				ans = a - b;
				System.out.println(ans);
			}else if(op.equals("*")){
				ans = a * b;
				System.out.println(ans);
			}else if(op.equals("/")){
				BigDecimal BDans = new BigDecimal(a / b);
				BDans.setScale(0,BigDecimal.ROUND_DOWN);
				System.out.println(BDans);
			}else{
				System.out.println("error");
			}
			
//			switch(op)
//			{
//				case "+":
//					ans = a + b;
//					System.out.println(ans);
//					break;
//				case "-":
//					ans = a - b;
//					System.out.println(ans);
//					break;
//				case "*":
//					ans = a * b;
//					System.out.println(ans);
//					break;
//				case "/":
//					BigDecimal BDans = new BigDecimal(a / b);
//					BDans.setScale(0,BigDecimal.ROUND_DOWN);
//					System.out.println(BDans);
//					break;
//				default:
//					System.out.println("error");
//					break;
//			}
			a = scan.nextInt();
			op = scan.next();
			b = scan.nextInt();
		}
	}

}

Measured memory_bytes: 18120
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <bitset>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

bool haiku(int A, int &X, int &Y, int &Z){
    if(A >> (X + Y + Z - 1) & 1 && A >> (Y + Z - 1) & 1 && A >> (Z - 1) & 1) return true;
    else return false;
}

int update(int A, int k, int &P){
    return ((A << k) + (1 << (k - 1))) % (1 << (P + 1));
}

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    
    int P = X + Y + Z;
    vector<vector<int>> dp(N + 1, vector<int>(1 << P, 0));
    dp[0][0] = 1;
    
    rep(i, N) rep(j, 1 << P){
        repd(k, 1, 11){
            int u = update(j, k, P);
//            cout << static_cast<bitset<5>>(j) << ", " << static_cast<bitset<5>>(u) << ": " << haiku(u, X, Y, Z) << endl;
            if(!haiku(u, X, Y, Z)) (dp[i + 1][u % (1 << P)] += dp[i][j]) %= mod;
        }
    }
    
    int ret = 0;
    rep(i, 1 << P){
        (ret += dp[N][i]) %= mod;
    }
    ll all = pow_mod(10, N, mod);
    output((all - ret + mod) % mod, 0);
    
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    s.push_back('0');
    ll k;
    cin >> k;
    vector<pair<char, ll>> v;
    char c = '0';
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != c) {
            if (c != '0') {
                v.emplace_back(c, cnt);
            }
            c = s[i];
            cnt = 1;
        } else {
            ++cnt;
        }
    }
    ll ans = 0;
    if (v.size() == 1) {
        ans += (k * v[0].second) / 2;
    } else if (v[0].first == v.back().first) {
        for (int i = 1; i + 1 < v.size(); ++i) {
            ans += k * (v[i].second / 2);
        }
        ans += v[0].second / 2;
        ans += v.back().second / 2;
        ans += (k - 1) * ((v[0].second + v.back().second) / 2);
    } else {
        for (int i = 0; i < v.size(); ++i) {
            ans += k * (v[i].second / 2);
        }
    }
    cout << ans << endl;
}

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

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

using namespace std;
using ll = long long;

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

    int n, x, t;
    cin >> n >> x >> t;
    printf("%d\n", ((n + x - 1) / x) * t);

    return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <climits>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int cnt = 0;
int main(){
    cnt = 1;
    ll X, Y;
    cin >> X >> Y;
    while(X < Y){
        ll tmp;
        tmp = X * 2;
        if(tmp % X == 0 && tmp <= Y)
            cnt++;
        X = tmp;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    p = s[:i]
    q = s[i:]
    
    res = 0
    for i in range(26):
        c = chr(i+ord('a'))
        if c in p and c in q:res += 1
    ans = max(res,ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 55
int N;
int A[MXN];

bool chk()
{
    FOR(i,1,N-1)
    {
        if( A[i]>A[i+1] )return false;
    }
    return true;
}

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

    cin>>N;
    FOR(i,1,N)cin>>A[i];
    if(chk())
    {
        cout<<"YES\n";
        return 0;
    }
    FOR(i,1,N-1)FOR(j,i+1,N)
    {
        swap( A[i], A[j] );
        if(chk())
        {
            cout<<"YES\n";
            return 0;
        }
        swap( A[i], A[j] );
    }
    cout<<"NO\n";

    return 0;
}


Measured memory_bytes: 256
from itertools import product
n, m = map(int, input().split())
s = []
for _ in range(m):
    _, *t = map(int, input().split())
    s.append(t)
p = [int(i) for i in input().split()]

cnt = 0
for fl in product([0, 1], repeat=n):
    for i in range(m):
        if sum(fl[tmp - 1] for tmp in s[i]) % 2 != p[i]:
            break
    else:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d%d", $s, $e);
$min = 10**10;
if($e > $s){
  $min = min($min, $e-$s);
}
if($e+$s > 0){
  $min = min($min, $e+$s+1);
}
if($s-$e > 0){
  $min = min($min, $s-$e+2);
}
if(-$s-$e >= 0){
  $min = min($min, -$s-$e+1);
}
echo $min;

Measured memory_bytes: 5496
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0;
  int a[200010];
  string s;
  cin >> n >> k;
  rep(i,n) cin >> a[i];
  for(i=k;i<n;i++){
    cout << (a[i]>a[i-k] ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 4332
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  string t, p;
  cin >> t >> p;

  int tn = t.size(), pn = p.size();

  for (int i = 0; i <= tn - pn; i++) {
    bool ok = true;
    for (int j = 0; j < pn; j++)
      if (t[i + j] != p[j]) {
	ok = false;
	break;
      }
    if (ok) printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 1184
from sys import stdin


n = int(stdin.readline().strip())
a_lst = [int(x) for x in stdin.readline().strip().split()]

pos = len(a_lst) // 2
min_diff = 10000000000000000000

while(True):
  left = sum(a_lst[:pos])
  right = sum(a_lst[pos:])
  diff = right - left
  
  if min_diff > abs(diff): min_diff = abs(diff)
  else: break
  
  if diff > 0: pos += 1
  elif diff < 0: pos -= 1
    
print(min_diff)

Measured memory_bytes: 31604
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 2000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"NO\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}

int main() {
    
    get2(n,m);
    vv<vv<bool>> p(n);
    rep(i,m) {
        get(a); gets(b); --a;
        if(b=="AC") p[a].pb(1);
        else p[a].pb(0);
    }

    ll cr = 0, ne = 0;
    rep(i,n) {
        if(p[i].size()) {
            ll j = 0;
            while(j<p[i].size() && p[i][j]==0)
                j++;
            if(j==p[i].size()) continue;
            cr += 1;
            ne += j;
        }
    }

    printf("%lld %lld\n",cr,ne);
    return 0;  
}

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

int main() {
	int suma, sumb, a, b, n;
	while (1) {
		suma = sumb = 0;
		cin >> n;
		if (n == 0) break;
		
		while (n--) {
			cin >> a >> b;
			if (a > b)
				suma += a + b;
			else if (a < b)
				sumb += a + b;
			else {
				suma += a;
				sumb += b;
			}
		}
		cout << suma << ' ' << sumb << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2980
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll INF = 1LL << 60;
ll C[100005];
ll A[16][16];
int main() {
  ios::sync_with_stdio(false);
  int N, M, X;
  cin >> N >> M >> X;
  for (int i=0; i<N; i++) {
    cin >> C[i];
    for (int j=0; j<M; j++) {
      cin >> A[i][j];
    }
  }
  ll ret = INF;
  for (int b=0; b<(1<<N); b++) {
    int s[16];
    for (int i=0; i<M; i++) s[i] = 0;
    ll c = 0;
    for (int i=0; i<N; i++) {
      if (b & (1<<i)) {
        c += C[i];
        for (int j=0; j<M; j++) {
          s[j] += A[i][j];
        }
      }
    }
    bool f = true;
    for (int i=0; i<M; i++) {
      if (s[i] < X) {
        f = false;
        break;
      }
    }
    if (f) {
      ret = min(ret, c);
    }
  }
  if (ret == INF) cout << -1 << endl;
  else cout << ret << endl;
}

Measured memory_bytes: 3660
s = gets.chomp.strip

ans = if s[0] == "A" && s[2..-2].chars.count{|l| l == "C"} == 1
  x_idx = s[2..-2].index("C") + 2
  s[0] = "a"
  s[x_idx] = "c"
  s.downcase == s ? "AC" : "WA"
else
  "WA"
end

puts ans

Measured memory_bytes: 14248
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e5+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve() {
    int a , b;
    cin >> a >> b;
    cout << a*b << endl;
}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

ll calc(ll l, ll r){
    return max(r - l, 0LL);
}

int main() {
    int n;
    cin >> n;
    vector<PL> p(n);
    REP(i,n){
        ll l = in(), r = in() + 1;
        p[i] = PL(r, l);
    }
    sort(ALL(p));
    VL l(n), r(n);
    REP(i,n){
        l[i] = p[i].second;
        r[i] = p[i].first;
    }
    multiset<ll> st;
    REP(i,n) st.insert(l[i]);
    ll ans = -1e18, l1 = -1;
    // REP(i,n) cout << l[i] << " " << r[i] << endl;
    REP(i,n-1){
        ll r1 = r[0], r2 = r[i + 1], l2 = l[i + 1];
        chmax(l1, l[i]);
        st.erase(st.find(l[i]));
        ll lma = *st.rbegin();
        // cout << l1 << " " << r1 << "  " << l2 << " " << r2 << "    " << lma << endl;
        chmax(ans, calc(max(l1, lma), r1) + calc(l2, r2));
        chmax(ans, calc(l1, r1) + calc(max(l2, lma), r2));
        // cout << calc(max(l1, lma), r1) + calc(l2, r2) << " " << calc(l1, r1) + calc(max(l2, lma), r2) << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8064
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val as = new Array[Long](n)
    for (i <- 0 until n) {
      as(i) = sc.nextLong()
    }

    if (as.count(_ < 0) % 2 == 0) {
      // 負の数の個数が偶数の場合、すべての負の符号を反転できる
      val ans = as.foldLeft(0L)((z, v) => z + math.abs(v))
      println(ans)
    } else {
      // 負の数の個数が奇数個の場合、負の数を1つ残して残りの符号を反転できる
      // 残すのは絶対値が最小の数
      val remainedNum = as.foldLeft(Long.MaxValue)((z, v) => if (z > math.abs(v)) math.abs(v) else z)

      // すべての値の絶対値を合算したものから、残った負の数の絶対値 * 2を引く
      val ans = as.foldLeft(0L)((z, v) => z + math.abs(v)) - 2 * remainedNum
      println(ans)
    }
  }
}


Measured memory_bytes: 64072
R,G,B,N=map(int, input().split())

x = 0
for i in range(N//R+1):
    k = N - (i*R)
    for j in range(k//G+1):
        l = k - (j*G)
        if l % B == 0:
            x += 1
        else:
            x += 0

print(x)

Measured memory_bytes: 3060
N = int(input())
s = [input() for n in range(N)]
M = int(input())
t = [input() for m in range(M)]
max_coin = 0
for word in s:
    coin = s.count(word) - t.count(word) 
    max_coin = coin if coin > max_coin else max_coin
print(max_coin)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int n,k,ans;
    cin >> n >> k;
    cout << n-k+1 << endl;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

const ll M = 1000000007;

ll dp[100100][13]; // dp[i][j]: i桁目まで見た時に、あまりがjとなる場合の数

signed main() {
  rep(i,0,100100) rep(j,0,13) dp[i][j]=0;
  string s;
  cin>>s;
  ll N = s.size();
  reverse(begin(s),end(s));
  dp[0][0] = 1;
  for (ll i=1, ten=1; i<=N; i++,(ten*=10)%=13) {
    if (s[i-1] == '?') {
      rep(x,0,10) {
        ll m = (x*ten) % 13;
        rep(j,0,13){
          (dp[i][(j+m) % 13] += dp[i-1][j]) %= M;
        }
      }
    } else {
      ll x = s[i-1] - '0';
      ll m = (x*ten) % 13;
      rep(j,0,13){
        (dp[i][(j+m) % 13] += dp[i-1][j]) %= M;
      }
    }
  }
  cout<<dp[N][5]<<endl;
  return 0;
}


Measured memory_bytes: 10624
#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>;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
    int N, K; cin >> N >> K;
    vector<int> L(K);
    vector<int> R(K);
    rep(i, K) cin >> L[i] >> R[i];

    vector<mint> dp(N+100);
    dp[1] = 1;
    for(int i = 2;i < N+3; i++) {
        dp[i] += dp[i-1];
        rep(j, K){
            int l = max(0, i-L[j]);
            int r = max(0, i-R[j]-1);
            dp[i] += dp[l] - dp[r];
        }
    }
    cout << (dp[N] - dp[N-1]).x << endl;
    return 0;
}


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


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

void solve()
{
	double D,T,S;
	cin>>D>>T>>S;

	double t = D/S;

	if(t <= T)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

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

	return 0;
}

Measured memory_bytes: 3744
#include<iostream>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    int ans = B*10;
    for(int i=0;i<10;i++){
        if ((ans+i)*0.08<A+1 &&(ans+i)*0.08>=A){
            cout << ans + i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
# C - Factors of Factorial

import collections

N = int(input())

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

N_factorial_prime_factors = []
for i in range(1, N+1):
    N_factorial_prime_factors.extend(prime_factors(i))
    
N_factorial_prime_factors = collections.Counter(N_factorial_prime_factors)
ans = 1
for x in N_factorial_prime_factors.values():
    ans *= x + 1
    ans %= 10**9 + 7
    
print(ans)

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



int main()
{
	int taro = 0, hanako = 0, n;
	string taros, hanakos;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> taros >> hanakos;
		if (taros > hanakos){
			taro += 3;
		}
		else if (taros < hanakos){
			hanako += 3;
		}
		else{
			taro++;
			hanako++;
		}
	}
	cout << taro << " " << hanako << endl;
	return 0;
}

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

const int MOD=1000000007;
//~ const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n;cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			ans+=i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>

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

  int n1;
  char *m;
  char num1[5];
  m = (fgets(num1, sizeof(num1), stdin));
  sscanf(num1, "%d\n", &n1);

  int n2 = n1 * n1;
  printf("%d\n", n2);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	double a,b,t;
	cin>>a>>b>>t;
	int i=1;
	int sum = 0;
	t+=0.5;
	int c=a;
	//cout<<t<<' ';
	while(c<=t){
	    sum+=b;
	    i++;
	    c=a*i;
	    //cout<<a<<' '; 		
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	int lasta=0,firstb=0,both=0;
	int ans = 0;
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		if(s[0]=='B' and s.back()=='A'){
			both++;
		}else if(s[0]=='B'){
			firstb++;
		}else if(s.back()=='A'){
			lasta++;
		}
		for(int j=0; j<(int)s.length()-1; j++){
			if(s[j]=='A' and s[j+1]=='B'){
				ans++;
			}
		}
	}
	if(both > 0){
		ans += both-1;
		if(lasta > 0){
			ans++;
			lasta--;
		}
		if(firstb > 0){
			ans++;
			firstb--;
		}
	}
	ans += min(lasta, firstb);
	cout << ans << endl;
    return 0;
}

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

int main()
{
	int n, x, flag = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &x);
		if (x&1) flag = 1; 
	}	
	puts(flag? "first": "second");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define ll long long

using namespace std;

ll gcd(ll x, ll y) {
 ll r;
 
 while(y != 0) {
  r = x % y;
  x = y;
  y = r;
 }

 return x;
}

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

int main() {
 ll a, b;

 while(cin >> a >> b) {
  cout << gcd(a, b) << " " << lcm(a, b) << endl;
 }

 return 0;
}


Measured memory_bytes: 2988
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int A,B,K,ans;
	cin>>A>>B>>K;
	int count=0;
	if(A<B){
		int temp=A;
		A=B;
		B=temp;
	}
	for(int i=B;i>0;i--){
		if(A%i==0){
			if(B%i==0){
				count++;
				if(count==K){
					ans=i;
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long k = sc.nextLong();
		int[] a = new int[n+1];
		for(int i =1;i<n+1;i++) {
			a[i] = sc.nextInt();
		}
		
		boolean[] visited = new boolean[n+1];
		int[] visitIndex = new int[n+1];
		visitIndex[0]=1;
		visited[1]=true;



		for(int i =2;i<n+1;i++) {
			visited[i]=false;
		}
		int counter =0;
		int newone = -1;
		for(int i =1;i<n+1;i++) {
			counter++;
			visitIndex[i]=a[visitIndex[i-1]];
			if(visited[visitIndex[i]]) {
				if(visitIndex[i]!=1) {
					newone=visitIndex[i];
				}
				break;
			}else {
				visited[visitIndex[i]]=true;
			}
			
		}
		
		int branch = 0;
		if(newone!=-1) {
			int holder = 1;
			while(true) {
				branch++;
				if(a[holder]==newone) {
					break;
				}
				holder = a[holder];
			}
			if(k<=branch) {
				System.out.println(visitIndex[(int)k]);
			}else {
				k = k-branch;
				k = k-(counter-branch)*(k/(counter-branch));
				System.out.println(visitIndex[(int)k+branch]);
			}
		}else {
			k= k- counter*(k/counter);
			System.out.println(visitIndex[(int)k]);
		}
		
		





	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 59772
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, K;
int A[200010];
int F[200010];
int D[200010];

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

	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> A[i];
	}
	rep(i, 0, N)
	{
		cin >> F[i];
	}

	sort(A, A + N);
	sort(F, F + N, greater<int>());

	rep(i, 0, N)
	{
		D[i] = A[i] * F[i];
	}

	int l = -1, r = 1e13;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		int sum = 0;
		rep(i, 0, N)
		{
			if (D[i] > mid)
			{
				sum += (D[i] - mid + F[i] - 1) / F[i];
			}
		}
		if (sum <= K)
		{
			r = mid;
		}
		else
		{
			l = mid;
		}
	}

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 4992
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
use std::cmp;
fn main() {
    input! { n: usize, a: usize, b: usize }
    println!("{}", cmp::min(n*a,b)); 
}

Measured memory_bytes: 4352
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var tokens = input[0].split(' ');
    var h = parseInt(tokens[0], 10);
    var w = parseInt(tokens[1], 10);
    var c = new Array(10);
    for (var i = 0; i < 10; i++) {
        c[i] = new Array(10);
        tokens = input[i + 1].split(' ');
        for (var j = 0; j < 10; j++) {
            c[i][j] = parseInt(tokens[j], 10);
        }
    }
    var a = new Array(h);
    for (var i = 0; i < h; i++) {
        a[i] = new Array(w);
        tokens = input[i + 11].split(' ');
        for (var j = 0; j < w; j++) {
            a[i][j] = parseInt(tokens[j], 10);
        }
    }

    for (var k = 0; k < 10; k++) {
        for (var i = 0; i < 10; i++) {
            for (var j = 0; j < 10; j++) {
                c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    var ans = 0;
    for (var i = 0; i < h; i++) {
        for (var j = 0; j < w; j++) {
            if (a[i][j] >= 0) {
                ans += c[a[i][j]][1];
            }
        }
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 10432