akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    if(w / 2 == x && h / 2 == y)printf("%.9f 1",w * h / 2);
    else printf("%.9f 0",w * h / 2);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF 10000000
#define NIL -1
#define BLACK 1
#define WHITE 0
#define MAX 101

int n,a[MAX][MAX],d[MAX],pi[MAX],color[MAX];
int w = 0;

void prim(void){

  int mincost,u,v,i;
 
  for( i = 0; i < n; i++){ 
    d[i] = INF;
    pi[i] = NIL;
    color[i] = WHITE;
  }
 
  d[0] = WHITE;
 
  while(1){
    mincost = INF;
    for( i = 0; i < n; i++){ 
      if (color[i] != BLACK && d[i] < mincost){
    mincost = d[i];
    u = i;
      }
    }
    color[u] = BLACK;
 
    if(mincost == INF) break;
 
    for( v = 0; v < n; v++){
      if(a[u][v] != -1){
    if (color[v] != BLACK && a[u][v] < d[v]){
      pi[v] = u;
      d[v] = a[u][v];
    }
      }
    }
  }
}

int main(void){

	int i,j;

	scanf("%d",&n);

	for( i = 0; i < n; i++){
		for( j = 0; j < n; j++){
			scanf("%d",&a[i][j]);
		}
	}

	prim();

	for( i = 0; i < n; i++){
		if(pi[i] != NIL && a[pi[i]][j] != 1){
			w += a[pi[i]][i];
		}  
	}

	printf("%d\n",w);

	return 0;
}

Measured memory_bytes: 640
MOD = 10**9+7

def resolve():
  ans = 0
  q1 = 0
  n, k = map(int, input().split())
  a = list(map(int, input().split()))
  c = [0] * n  # 自分より小さい値が全体に何個あるか
  for i in range(n):
    for j in range(i, n):
      if a[i] > a[j]:
        q1 += 1  

  ans = q1 * k % MOD

  q2 = 0
  for i in range(n):
    for j in range(n):
      if a[i] > a[j]:
        q2 += 1

  s = (k * (k - 1)) // 2
  s %= MOD

  ans += (s * q2) % MOD

  print(int(ans % MOD))
  return  

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int a, b;
int main (){
    scanf ("%d %d", &a, &b);
    printf ("%d\n", max({a + b, a - b, a * b}));
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static void Main()
    {
      var n = ScanUlong();
      if(n%2==1) { WriteLine(0); return; }
      ulong res = 0;
      ulong fivep = 5;
      ulong pre = 0;
      for(uint i=0; i<30; i++, fivep *= 5){
        res += n/(fivep*2);
        if(fivep > n) break;
      }
      WriteLine(res);
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        string S = cin.nextString();
        int ans = 700;
        for (int i = 0; i < 3; i++)
        {
            if (S[i] == 'o')
            {
                ans += 100;
            }
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

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

int main(){
    int n, in;
    cin >> n;
    int ans = 0;
    int max = 0;
    rep(i, n){
        cin >> in;
        if(max <= in){
            max = in;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,A,B,C,D = map(int,readline().split())
S = readline().rstrip()

if C < D:#抜かさなくて良い
    if "##" not in S[A-1:D]:
        print("Yes")
    else:
        print("No")
else:#抜かす必要がある
    if "..." in S[B-2:D+1] and "##" not in S[A-1:C]:
        print("Yes")
    else:
        print("No")



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

int N; 
vector<vector<int>> G(200010);
vector<int> parity(200010, -1);

vector<int> ans(200010, -1);
vector<bool> used(2000010, false);

void fill(){
    int id = 0;
    for(int i=1; i<=N; i++){
        if(used[i]) continue;

        while(ans[id] != -1) id++;
        ans[id] = i;
    }
}

void bfs(){
    queue<int> Q; Q.push(0); parity[0] = 0;
    bool E = true;
    while(!Q.empty()){
        int v = Q.front(); Q.pop();

        rep(i, G[v].size()){
            int u = G[v][i];
            if(parity[u] == -1){
                parity[u] = 1-parity[v];
                Q.push(u);
            }
        }
    }
}
 
int main(){
    cin >> N;
    rep(i, N-1){
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b); G[b].push_back(a);
    }

    bfs();

    vector<int> even, odd;
    rep(i, N){
        if(parity[i] == 0) even.push_back(i);
        else odd.push_back(i);
    }
    int E = even.size(), O = odd.size();

    
    if(E > N/3 && O > N/3){
        rep(i, E) if(3*i+1 <= N) {ans[even[i]] = 3*i+1; used[3*i+1] = true;}
        rep(i, O) if(3*i+2 <= N) {ans[odd[i]] = 3*i+2; used[3*i+2] = true;}
        fill();
    } else if(E <= N/3){
        rep(i, E) {ans[even[i]] = 3*(i+1); used[3*(i+1)] = true;}
        fill();
    } else if(O <= N/3){
        rep(i, O) {ans[odd[i]] = 3*(i+1); used[3*(i+1)] = true;}
        fill();
    }

    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 16884
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

string s, t;
int nxt[26][500000];
int n;
long long ans = 0;
int last[26];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t;
    n = s.size();
    s = s + s;
    fill(last, last + 26, 2 * n);
    for (int i = s.size() - 1; i >= n; i--)
    {
        last[s[i] - 'a'] = i;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++) nxt[j][i] = last[j];
        last[s[i] - 'a'] = i;
    }
    long long pos = n - 1;
    for (int i = 0; i < t.size(); i++)
    {
        int go = nxt[t[i] - 'a'][pos];
        if (go == 2 * n)
        {
            cout << -1;
            return 0;
        }
        ans += go - pos;
        go %= n;
        pos = go;
    }
    cout << ans << endl;
}


Measured memory_bytes: 48364
#include <stdio.h>
#include <stdlib.h>
int main(){
  int *A,N,i,j,v,n;
  scanf("%d",&N);
  A=(int*)malloc(N*sizeof(int));
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(n=0;n<N;n++){
    printf("%d",A[n]);
    if(n<N-1)printf(" ");
  }
  printf("\n");
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(n=0;n<N;n++){
      printf("%d",A[n]);
      if(n<N-1)printf(" ");
    }
    printf("\n");
  }  
  free(A);
  return 0;
}

Measured memory_bytes: 604
#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 INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N, A, B; cin >> N >> A >> B;
	string s; cin >> s;
	int a = 0, b = 0;
	rep(i, N) {
		if (s[i] == 'a') {
			if (a + b < A + B) {
				cout << "Yes" << endl;
				a++;
			} else {
				cout << "No" << endl;
			}
		} else if (s[i] == 'b') {
			if ((a + b < A + B) && b < B) {
				cout << "Yes" << endl;
				b++;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 3740
a, b, c = gets.chomp.split(" ")
if ((a == "5") && (b == "5") && (c == "7")) || ((a == "7") && (b == "5") && (c == "5")) || ((a == "5") && (b == "7") && (c == "5")) then
  puts "YES"
else
  puts "NO"
end


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

//#define int long long
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int dp[10001];

inline bool chmax(int &a, int b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

signed main() {
    int n, wei;
    cin >> n >> wei;
    int v[n], w[n];
    rep(i,n) cin >> v[i] >> w[i];
    
    reps(i,1,n){
        reps(j,1,wei){
            chmax(dp[j],dp[j-1]);
            if(j-w[i-1] >= 0) chmax(dp[j], dp[j-w[i-1]]+v[i-1]);
        }
    }
    
    cout << dp[wei] << endl;
}


Measured memory_bytes: 3132
import sys

sys.setrecursionlimit(10 ** 7)

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

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if W >= V:
    print("NO")
    exit()

D = abs(B - A)
X = V - W

if D <= X * T:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9192
//El Lool
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <string>
#include <string.h>
#include <vector>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
void fast()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
bool paln(string x)
{
	string y;
	y = x;
	reverse(all(y));
	if (x == y)
		return 1;
	else
		return 0;
}
int main()
{
	fast();
	string s;
	vector<vector<int> >v(300);
	cin >> s;
	long long n = sz(s) - 1;
	long long ans = n*(n + 1);
	ans /= 2;
	ans++;
	for (int i = 0; i < sz(s); i++)
	{
		v[s[i]].push_back(i);
	}
	long long d=0;
	for (int i = 'a'; i <= 'z'; i++)
	{
		long long ax = sz(v[i])-1;
		if (ax>0)
		{
			d += (ax*(ax + 1)) / 2;
		}
	}
	cout <<ans - d;
	return 0;

}

Measured memory_bytes: 1936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N;
    string S, ans;
    cin >> N >> S;
    if(N % 2 == 1){
        ans = "No";
    } else {
        if(S.substr(0, N / 2) == S.substr(N / 2, N / 2)){
            ans = "Yes";
        } else {
            ans = "No";
        }
    }
    cout << ans << endl;
        
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,d;
    cin>>n>>d;
    int x[n][d];
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    int cnt=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            double dis=0;
            rep(k,d){
                dis+=pow(x[i][k]-x[j][k],2);
            }
            int a=sqrt(dis);
            a=pow(a,2);
            if(dis==a)cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n, m;
  cin >> n >> m;

  if (n == m) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
indexed :: [Double] -> [(Int, Double)]
indexed = zip [1..]

fromHeightToTemperature :: Double -> Double -> Double
fromHeightToTemperature base height = base - (0.006 * height)

fromHeightsToTemperatures :: Double -> [(Int, Double)] -> [(Int, Double)]
fromHeightsToTemperatures base = map (\(index, height) -> (index, fromHeightToTemperature base height))

fromTemperaturesToDiffs :: Double -> [(Int, Double)] -> [(Int, Double)]
fromTemperaturesToDiffs average = map (\(index, temperature) -> (index, abs $ (temperature - average)))


extract :: [(Int, Double)] -> (Int, Double)
extract [x] = x
extract (x:xs)
  | diff == 0.0 = x
  | diff < diffOfRemains = x
  | otherwise = another
  where another@(indexOfRemains, diffOfRemains) = extract xs
        index = fst x
        diff = snd x

main :: IO ()
main = do
  _ <- getLine
  [base, average] <- map read . words <$> getLine
  heights <- map read . words <$> getLine
  let indexedHeights = indexed heights
  let indexedTemperatures = fromHeightsToTemperatures base indexedHeights
  let indexedDiff = fromTemperaturesToDiffs average indexedTemperatures
  let extracted = extract indexedDiff
  print $ fst extracted

Measured memory_bytes: 1404
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int t, int[] ts) {
    long time = 0;
    long to = ts[0] + t;
    for (int i = 1; i < ts.length; i++) {
        if (ts[i] <= to) {
            time += ts[i] - ts[i-1];
        }
        else {
            time += to - ts[i-1];
        }
        to = ts[i] + t;
    }
    time += to - ts[$-1];
    return time;
}

void main() {
    auto nt = readints;
    int t = nt[1];
    auto ts = readints;

    writeln(calc(t, ts));
}


Measured memory_bytes: 11608
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,m;
    cin >> n;
    string s;
    map<string,ll> maap;
    F0R(i,n){
      cin >>s;
      maap[s]++;
    }
    cin >> m;
    F0R(i,m){
      cin >> s;
      maap[s]--;
    }
    ll ans = 0;

    for(auto it = maap.begin(); it != maap.end(); it++){
      if(it->second > ans) ans = it->second;
    }

    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
N = int(input())
numbers_r = tuple(map(int, input().split(' ')))
numbers_s = sorted(numbers_r)

med_high = numbers_s[N // 2]
med_low = numbers_s[N // 2 - 1]

for number in numbers_r:
    if number == med_low:
        print(med_high)
    elif number == med_high:
        print(med_low)
    elif number < med_low:
        print(med_high)
    elif number > med_high:
        print(med_low)


Measured memory_bytes: 25356
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
bool judge(int t)
{
	if(t%10!=t/10000||t%100/10!=t/1000%10) return 0;
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=n;i<=m;i++)
	if(judge(i)) ans++;
	cout<<ans;
	return 0;
}

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

int n;

int main(void){
  cin >> n;
  int a=0, b=0, c=0, d=0;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if(s[0] == 'B' && s[s.size()-1] == 'A') d++;
    else if(s[0] == 'B') b++;
    else if(s[s.size()-1] == 'A') a++;
    for(int j = 0; j < s.size()-1; j++){
      if(s.substr(j, 2) == "AB") c++;
    }
  }
  if(d == 0) c+=min(a, b);
  else{
    if(a+b == 0) c+=d-1;
    else c+=d+min(a, b);
  }
  cout << c << endl;

  return 0;
}


Measured memory_bytes: 3644
fun main() {
    val n = readLine()!!.toInt()
    val fbList = mutableListOf<String>()
    val nfbList = mutableListOf<Long>()

        for(i in 1L .. n){
            if(i % 3 != 0L && i % 5 != 0L){
                nfbList.add(i)
            }else{
                fbList.add("piyo")
            }
        }



    println(nfbList.sum())
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n, m; cin >> n >> m;
  vi a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
    a[i]--;
  }

  vector<ll> b(m);

  for(int i=0;i<n-1;++i) {
    if(a[i] != m-1) b[a[i]+1]--;
    b[a[i+1]]++;
    if(a[i] > a[i+1] && a[i] != 0) {
      b[0]--;
    }
  }

  vll su(m);
  su[0] = b[0];
  for(int i=1;i<m;++i) {
    su[i] = su[i-1] + b[i];
  }
  
  for(int i=1;i<n;++i) {
    su[a[i]] += (a[i] + m - a[i-1]) % m - 1;
  }
  //printv(su);

  ll ans = 0;
  for(int i=1;i<n;++i) {
    ans += min((a[i] + m - a[i-1]) % m, a[i] + 1);
  }
  //cout << ans << endl;

  ll mi = ans;
  for(int i=0;i<m;++i) {
    ans += su[i];
    mi = min(mi, ans);
  }
  cout << mi << endl;

}


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

typedef long long ll;

void solve() {
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N), min_a(N);
    rep(i, N) {
        cin >> a[i];
        min_a[i] = a[i];
    }
    ll ans = 1e18;;
    rep(i, N) {
        ll s = x * i;
        rep(j, N) {
            min_a[j] = min(min_a[j], a[(i + j) % N]);
            s += min_a[j];
        }
        ans = min(ans, s);
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    ll ans;
    if (abs(a-b) & 1ll) {
        if (abs(a-b) == 1) ans = min(max(a-1, b-1), max(abs(n-a), abs(n-b)));
        else {
            if (a > b) swap(a, b);
            ans = (a-1) + 1 + (b-a-1)/2;
            ans = min(ans, (n-b) + 1 + (b-a-1)/2);
        }
    }
    else {
        ans = abs(a-b) / 2ll;
    }

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

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

const int MOD = 1e9 + 7;

inline int mod_add(int a, int b, int m = MOD) {
    int sum = a + b;
    return sum >= m ? sum - m : sum;
}

const int N_MAX = 10005;
const int D_MAX = 100;

int N, D;
string number;
int dp[N_MAX][D_MAX][2];

int solve(int position, int sum, bool match) {
    if (position >= N)
        return sum == 0 ? 1 : 0;

    int &answer = dp[position][sum][match];

    if (answer >= 0)
        return answer;

    answer = 0;
    int number_digit = number[position] - '0';

    for (int digit = 0; digit <= (match ? number_digit : 9); digit++)
        answer = mod_add(answer, solve(position + 1, (sum + digit) % D, match && digit == number_digit));

    return answer;
}

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

    cin >> number >> D;
    N = number.size();
    memset(dp, -1, sizeof(dp));
    printf("%d\n", mod_add(solve(0, 0, true), MOD - 1));
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> ver(N);
  for (int i = 0; i < N; i++ ) cin >> ver.at(i);
  int count;
  while(true){
    bool odd = false;
    for (int i = 0; i < N; i++ )
      if (ver.at(i)%2!=0) odd = true;
    if (odd) break;
    for (int i = 0; i < N; i++ )
      ver.at(i) /= 2;
    count++;
  }
  cout << count << endl;
}

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

int main(void){
    ll N, M;
    cin >> N >> M;

    if(M == 2*N){
        cout << N << endl;
    } else if( M < 2*N){
        cout << M/2 << endl;
    } else {
        cout << N + (M-2*N) /4 << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
n,m = map(int,input().split())
data = []
for i in range(n):
    a,b = map(int,input().split())
    data.append((a,b))
data.sort()
cnt = 0
ans = 0
for i,j in data:
    if cnt + j < m:
        cnt += j
        ans += j*i
    else:
        ans += (m-cnt)*i
        print(ans)
        break

Measured memory_bytes: 16892
import sys

n,p = map(int, input().split())
s = input()

if p == 2 or p == 5:
  ans = 0
  for i in range(len(s)):
    if int(s[i]) % p == 0:
      ans += i + 1
    
  print(ans)
  sys.exit(0)
  

last_mod = 0
keta_mod = 1
mod_array = [0] * p
mod_array[0] = 1



for i in reversed(range(len(s))):
  tmp = int(s[i]) * keta_mod
  last_mod = (last_mod + tmp) % p
  keta_mod = (keta_mod * 10) % p
  mod_array[last_mod] += 1
  
ans = 0
for v in mod_array:
  ans += v * (v-1) // 2
  
print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5+5 , M = 1e18+5, OO = 0x3f3f3f3f;
typedef long long ll;
pair<int, int> p[N];
int main()
{
    int n, x;
    cin >> n;
    for(int i=0; i<n; ++i)
    {
        cin >> x;
        p[i]={x, i+1};
    }
    sort(p, p+n);
    for(int i=0; i<n; ++i) cout << p[i].second << " ";
	return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
int main()
{
  int W, H, x, y, r;
  scanf("%d %d %d %d %d" ,&W ,&H ,&x ,&y ,&r);
  if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H) {
    printf("Yes\n");
  }
  else if(x-r<0 || x+r>W || y-r<0 || y+r>H) {
 printf("No\n");
  }
  return 0;
}

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

int main() {
	string a;
	cin>>a;
	int ans=0;
	for(int i=0;i<a.length();i++){
		ans+=(a[i]-'0');
	}
	if(stoi(a)%ans==0) cout<<"Yes";
	else cout<<"No";
}

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

int main(){
  string a,b;cin>>a>>b;
  if((a.size())!=(b.size())) cout<<(a.size()>b.size()?"GREATER":"LESS");
  else cout<<(a>b?"GREATER":(a<b?"LESS":"EQUAL"));
}

Measured memory_bytes: 256
N, M = map(int, input().split())
I = [[i, 1] for i in range(N)]
B = [0] * M
for i in range(M):
  B[M - 1 - i] = [int(x) - 1 for x in input().split()]
NC = [0] * M
def n2(n):
  return n * (n - 1) // 2
NC[-1] = n2(N)
def root(a):
  #print(a, I[a][0])
  if I[a][0] == a:
    return a
  else:
    I[a][0] = root(I[a][0])
    return I[a][0]
def union(a, b):
  ra = root(a)
  rb = root(b)
  na = I[ra][1]
  nb = I[rb][1]
  if ra == rb:
    return 0
  if ra < rb:
    I[rb][0] = ra
    I[ra][1] += I[rb][1]
  else:
    I[ra][0] = rb
    I[rb][1] += I[ra][1]
  return n2(na + nb) - n2(na) - n2(nb)
for i in range(M - 1):
  a, b = B[i]
  NC[M - 2 - i] = NC[M - 1 - i] - union(a, b)
for nc in NC:
  print(nc)

Measured memory_bytes: 108048
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<long> h;

  for(int i=0;i<N;i++){
    long a;
    cin >> a;
    h.push_back(a);
  }
  sort(h.begin(), h.end());

  long ans = 1000000000;
  for(int i=0;i<N-K+1;i++){
    ans = min(ans, h[i+K-1]-h[i]);
  }
  cout << ans <<endl;
  
  return 0;

}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int main()
{
	int a, b;
	cin >> a >> b;
	if(a > b)	swap(a,b);
	for (int i = 0; i < b; i++) {
		cout << a;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int a,b,c,n,m,l[100000110],o[10010],k,i,d,dx[10]={0,1,-1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,1,-1,1,-1};
long long x,y,z[100010];
stack<int> s;
struct P
{
    int x;
    int y;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};
 //map<int, int> p;
queue<P> q;
priority_queue<int> q1;
string r;
vector<int> v[200010];

bool sdf(P a,P b){return a.y<b.y;}



int main()
{
    scanf("%lld",&x);
    y=x/11*2;
    if(x%11>6) y++;
    if(x%11) y++;
    printf("%lld",y);
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>

int main(void){
	
	double a,b,c;
	double f;

	scanf("%lf%lf",&a,&b);
	
	if(b < 10){
	c = a * 10 + b;
	}
	else if(b < 100){
	c = a * 100 + b;
	}
	else{
	c = a * 1000 + b;
	}

	f = sqrt(c);

	if( f == ceil(f) ){
	printf("Yes");
	}
	else{
	printf("No");
	}

 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l),i##R=(r);i<=i##R;i++)
#define DOR(i,r,l) for(int i=(r),i##L=(l);i>=i##L;i--)
#define loop(i,n) for(int i=0,i##R=(n);i<i##R;i++)
#define sf scanf
#define pf printf
#define mms(a,x) memset(a,x,sizeof a)
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chkmax(A &x,const B y){if(x<y)x=y;}
template<typename A,typename B>inline void chkmin(A &x,const B y){if(x>y)x=y;}
const int N=1e5+5;
int n;
ll a[N];
ll sum;
ll ans[N];
int main(){
	sf("%d",&n);
	FOR(i,1,n)sf("%lld",&a[i]),sum+=a[i];
	ll val=sum;
	for(int i=1;i<n;i+=2)val-=2ll*a[i];
	ans[n]=val;
	DOR(i,n-1,1)ans[i]=2ll*a[i]-ans[i+1];
	FOR(i,1,n)pf("%lld ",ans[i]);puts("");
	return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
#include<string.h>
struct node
{
    char name[1000];
    int score;
    int k;
};
int main()
{
    int n,i,j;
    node re[1005];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%s%d",re[i].name,&re[i].score);
        re[i].k=i;
    }
    for(i=1;i<=n;i++)
    {
         for(j=i+1;j<=n;j++)
         {
             if(strcmp(re[i].name,re[j].name)>0)
               {
                   node c;
                   c=re[i];
                   re[i]=re[j];
                   re[j]=c;
               }
               if(strcmp(re[i].name,re[j].name)==0)
               {
                   if(re[i].score<re[j].score)
                   {
                       node c;
                       c=re[i];
                       re[i]=re[j];
                       re[j]=c;
                   }
               }
         }
    }
    for(i=1;i<=n;i++)
   printf("%d\n",re[i].k);
   return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = [int(i) for i in input().split()]

l = []
for i in range(n):
    l.append([0, 0])
    for j in range(n):
        if (j < i and a[j] < a[i]):
            l[i][0] += 1
        if (j > i and a[j] < a[i]):
            l[i][1] += 1

s = 0
for i in range(n):
     s += int(l[i][0] * k * (k - 1) // 2)
     s += int(l[i][1] * k * (k + 1) // 2)
     s = int(s % (1000000007))

print(s)


Measured memory_bytes: 3372
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	cout << max((min(b, d) - max(a, c)), 0) << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i) >> b.at(i);
    }

    long long cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
        cnt += (b.at(i) - (a.at(i) + cnt) % b.at(i)) % b.at(i);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K>A+B){cout<<A-(K-A-B)<<endl;}
  else{cout<<min(A,K)<<endl;}
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
    
int main(){
    int A,B,M;
    cin >> A >> B >> M;
    int frige[A],renge[B];
    int x[M],y[M],c[M];

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

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

    for (int i = 0; i < M; i++){
        cin >> x[i] >> y[i] >> c[i];
    }

    int mnf=10000000,mnr=10000000;

    for (int i = 0; i < A; i++){
        if(mnf>frige[i]){
            mnf=frige[i];
        }
    }
    for (int i = 0; i < A; i++){
        if(mnr>renge[i]){
            mnr=renge[i];
        }
    }

    int mn=mnf+mnr;
    

    for (int i = 0; i < M; i++){
        int cash=frige[x[i]-1]+renge[y[i]-1]-c[i];
        //cout << cash << "!!";
        if(mn>cash){
            mn=cash;
        }
    }

    cout << mn;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template<typename A, typename B>
ostream& operator << (ostream& out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}

int med(string s) {
	static string t = "ACBBCBBBABBAACABBBAAAACBBAB";
//	static string t = "Atcod3rIsGreat";
	int n = s.size(), m = t.size();
	vector< vector<int> > f(n, vector<int>(m, n + m + 1));
	auto get = [&](int x, int y) {
		if(x == -1) return y + 1;
		else if(y == -1) return x + 1;
		else return f[x][y];
	};
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j) {
			chmin(f[i][j], get(i - 1, j) + 1);
			chmin(f[i][j], get(i, j - 1) + 1);
			if(s[i] == t[j]) chmin(f[i][j], get(i - 1, j - 1));
			else chmin(f[i][j], get(i - 1, j - 1) + 1);
		}
	return f.back().back();
}

int cnt = 0;
int query(string q) {
	++cnt;
	if(cnt > 845) {
		while(1) {
			cnt++;
		}
		return cnt;
	}
#ifdef LOCAL
	return med(q);
#else
	cout << "? " << q << endl;
	int r; cin >> r;
	return r;
#endif
}

vector<char> bet;
vector<int> occ;
int len;

string solve(int l, int r) {
	if(l == r) return string(occ[l], bet[l]);
	else {
		int m = (l + r) / 2;
		string s1 = solve(l, m), s2 = solve(m + 1, r);
		string s;
		while(s1.size() && s2.size()) {
			string q = s + s2[0] + s1;
			int r = query(q);
			r -= len - (int)q.size();
			if(r == 0) {
				s += s2[0];
				s2 = s2.substr(1);
			} else {
				s += s1[0];
				s1 = s1.substr(1);
			}
		}
		return s + s1 + s2;
	}
}

int main() {
	for(char c = 'a'; c <= 'z'; ++c) bet.push_back(c);
	for(char c = 'A'; c <= 'Z'; ++c) bet.push_back(c);
	for(char c = '0'; c <= '9'; ++c) bet.push_back(c);
	int sigma = bet.size();
	
	occ.assign(sigma, 0);
	for(int i = 0; i < sigma; ++i) {
		occ[i] = 128 - query(string(128, bet[i]));
	}
	len = accumulate(occ.begin(), occ.end(), 0);
	string ans = solve(0, sigma - 1);
	assert(query(ans) == 0);
	cout << "! " << ans << endl;
	display(cnt);
	return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <utility>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cmath>
using namespace std;

int main (){
    int n,m;
    cin >> n >> m;
    int a[m];
    int b[m];
    int ans[n];

    for(int i=0;i<n;i++)
        ans[i]=0;
    for(int j=0;j<m;j++){
        cin >>a[j]>>b[j];
    }
    for(int k=0;k<m;k++){
        ans[a[k]-1]++;
        ans[b[k]-1]++;
    }
    for(int l=0;l<n;l++){
        cout<<ans[l]<<endl;
    }
    return 0;
            }



Measured memory_bytes: 256
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val s = (0 until n).map {
        readLine()!!
    }.toTypedArray()
    val m = readLine()!!.toInt()
    val t = (0 until m).map {
        readLine()!!
    }.toTypedArray()

    val map = mutableMapOf<String, Int>()
    s.forEach {
        if(map.containsKey(it)){
            map.set(it, map[it]!! + 1)
        }else{
            map.set(it, 1)
        }
    }
    t.forEach {
        if(map.containsKey(it)){
            map.set(it, map[it]!! - 1)
        }
    }
    map.values.toIntArray().max()!!.let {
        if(it < 0) println(0) else println(it)
    }
}

Measured memory_bytes: 37980
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define siz 1005
#define f first
#define s second
#define endl "\n"
#define ci cin.ignore()
using namespace std;
int main()
{
	ll n,i,j,k;
	cin>>n>>k;
	ll a[n],dp[n];
	for(i = 0;i<n;i++)
	cin>>a[i],
	dp[i] = INT_MAX;
	dp[0] = 0;
	
	for(i = 0;i<n;i++)
	{
		for(j = 1;j<=k;j++)
		if(i+j<n)
		dp[i+j] = min(dp[i+j],dp[i] + abs(a[i]-a[i+j]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int num[3], k;
    cin >> num[0] >> num[1] >> num[2];
    cin >> k;

    sort(num, num+3);
    for(int i=0;i<k;i++)num[2] *= 2;
    cout << num[0] + num[1] + num[2] << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,e) for(int i = a;i < e;++i)
using LL = long long;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	double sum = 0;
	FOR(i, 0, N) {
		sum += 1.0 / a[i];
	}
	cout << fixed << setprecision(10) << 1 / sum << endl;

}




Measured memory_bytes: 256
s=input()
a=[1,0,0,0]
for i in s:
    if i=="A": a[1]+=a[0]
    elif i=="B": a[2]+=a[1]
    elif i=="C": a[3]+=a[2]
    else: a=[ a[0]*3 ] + [ a[j+1]*3+a[j] for j in range(3) ]

    a=[a[i]%1000000007 for i in range(4)]
print(a[3])


Measured memory_bytes: 3188
# include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  bool fin = false;
  int sum = 0;
  for(int i = 0; i < 110; i++){
    sum += A;
    if(sum % B == C){
      fin = true;
    }
  }
  if(fin){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
{
  const Main = (input: string) => {
    let count = 0;

    const inputArray: string[] = input.split(/ |\n/);
    const N: number = parseInt(inputArray[0]);
    for (let i = 1; i < N + 1; i++) {
      if (i.toString().length % 2 === 1) {
        count++;
      }
    }
    console.log(count);
    
  }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 11980
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	vector<vector<int>>g(3, vector<int>(3));
	rep(i, 3) {
		rep(j, 3)cin >> g[i][j];
	}
	bool is = true;
	rep(i, 2) {
		int a = g[i][0] - g[i + 1][0];
		rep(j, 3) {
			if (a != g[i][j] - g[i + 1][j]) {
				puts("No");
				return 0;
			}
		}
	}
	rep(i, 2) {
		int a = g[0][i] - g[0][i + 1];
		rep(j, 3) {
			if (a != g[j][i] - g[j][i + 1]) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, cnt = 2;
long long res[507][507];
map<int, int>a, b;
int nxt()
{
	while (1)
	{
		bool ok = 1;
		for (int i = 2; i * i <= cnt && ok; i++)
			if (cnt % i == 0)ok = 0;
		if (ok)return cnt++;
		cnt++;
	}
	return 0;
}
long long gcd(long long a, long long b)
{
	if (!b)return a;
	return gcd(b, a % b);
}
long long lcm(long long a, long long b)
{
	if (!a || !b)return 0;
	return a / gcd(a, b) * b;
}
int main()
{
	cin >> n;
	if (n == 2) {
		printf("4 7\n23 10\n");
		return 0;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			res[i][j] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (((i + j) & 1) && !a[i + j])
				a[i + j] = nxt();
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (((i + j) & 1) && !b[i - j])
				b[i - j] = nxt();
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if ((i + j) & 1)
			{
				res[i][j] = 1LL * a[i + j] * b[i - j];
				res[i - 1][j] = lcm(res[i - 1][j], res[i][j]);
				res[i][j - 1] = lcm(res[i][j - 1], res[i][j]);
				res[i + 1][j] = lcm(res[i + 1][j], res[i][j]);
				res[i][j + 1] = lcm(res[i][j + 1], res[i][j]);
			}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (!((i + j) & 1))
				res[i][j]++;
	for (int i = 1; i <= n; i++, putchar('\n'))
		for (int j = 1; j <= n; j++)
			printf("%lld ", res[i][j]);
	return 0;
}

Measured memory_bytes: 5120
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INARR(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

string s;
int n;
int a[MAXN];
set<int> bag;

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> s;
	n = s.size();
	
}


void preprocess() {
	
	for (int i = 0; i < n-1; ++i)
		if (s[i] == 'R' && s[i+1] == 'L')
			bag.insert(i);
	
	FOR(i, 0, n-1) {
		if (s[i] == 'R') {
			auto it = bag.lower_bound(i);
			int num = ((*it) - i) % 2;
			if (num == 0)
				a[(*it)]++;
			else
				a[(*it)+1]++;
		}
		else {
			auto it = bag.lower_bound(i);
			it--;
			int num = (i - (*it)) % 2;
			if (num == 0) 
				a[(*it)]++;
			else
				a[(*it)+1]++;
		}
	}
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	for (int i = 0; i < n; ++i)
		cout << a[i] << " ";
	cout << endl;
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 3280