akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 100100;

int n;
ll x[M];
ll m, k;
int p[M], t[M], a[M];

void ini() {
  iota(p, p + M, 0);
}

void apply(int *a, int *b) {
  for (int i = 0; i < M; ++i)
    t[i] = a[b[i]];
  for (int i = 0; i < M; ++i)
    b[i] = t[i];
}

void read() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  cin >> m >> k;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    x -= 2;
    swap(p[x], p[x + 1]);
  }
}


void kill() {
  iota(a, a + M, 0);
  while (k) {
    if (k & 1)
      apply(p, a);
    apply(p, p);
    k >>= 1;
  }

  ll cur = x[0];

  cout << cur << "\n";
  for (int i = 0; i < n - 1; ++i) {
    ll d = x[a[i] + 1] - x[a[i]];
    cur += d;
    cout << cur << "\n";
  }
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  ini();
  read();
  kill();
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            var s = ReadLine();

            int kuro = 0;
            int shiro = 0;
            for (int i = 0; i < N; i++)
            {
                if (s[i] == '.') shiro++;
            }

            int ans = shiro;
            for (int i = 0; i < N; i++)
            {
                if (s[i] == '.')
                {
                    shiro--;
                }
                else
                {
                    kuro++;
                }
                ans = Min(ans, shiro + kuro);
            }
            WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define rep(x) for(int i = 0; i < (x); ++i)
using namespace std;
using ull = unsigned long long;
using ll = long long;

int main() {
    int A, B;
    cin >> A >> B;
    if(B % A == 0) cout << A + B << endl;
    else cout << B - A << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    vector<int> adj[n];
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    queue<int> q;
    int prv[n], dst[n];
    fill(dst, dst+n, 1<<30);
    q.push(0);
    dst[0] = 0;
    while (!q.empty()) {
        int i = q.front();
        q.pop();
        for (int j : adj[i]) {
            if (dst[j] != 1<<30) continue;
            prv[j] = i;
            dst[j] = dst[i] + 1;
            q.push(j);
        }
    }
    cout << "Yes\n";
    for (int i = 1; i < n; i++) cout << prv[i]+1 << endl;
    
}


Measured memory_bytes: 10904
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

l = list(input())

k = cl.Counter(l)

jj = k.most_common()

if len(jj) == 2 and jj[0][1] == 2:
    print("Yes")
else:
    print("No")

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

using namespace std;

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

    /* 各部屋が繋がっている部屋の番号を保持する */
    vector<vector<int>> room(N+1);
    for ( int i=0; i<M; i++ ) {
        cin >> A >> B;
        room.at(A).push_back(B);
        room.at(B).push_back(A);
    }

    vector<int> guide(N+1, 0);
    queue<int> que;
    que.push(1);

    int cur_room;
    while ( !que.empty() ) {
        cur_room = que.front(); que.pop();
        for ( auto itr : room.at(cur_room) ) {
            if ( itr == 1 || guide.at(itr) != 0 )
                continue;
            guide.at(itr) = cur_room;
            que.push(itr);
        }
    }

    for ( int i=2; i<N+1; i++ ) {
        if ( guide.at(i) == 0 ) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for ( int i=2; i<N+1; i++ )
        cout << guide.at(i) << endl;
    return 0;
}


Measured memory_bytes: 10152
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    int a,b;
    string u;
    cin>>s>>t>>a>>b>>u;
    if(u==s){
        cout<<a-1<<" "<<b<<endl;
    }
    else cout<<a<<" "<<b-1<<endl;
}


Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
a,b=gi
puts a <= 8 && b <= 8 ? 'Yay!':':('


Measured memory_bytes: 2428
def resolve():
    (a,b,k)=(int(i) for i in input().split())
    count=[]
    for i in range(1,min(a,b)+1):
        if a%i==0 and b%i==0:
            count.append(i)
    print(count[-k])

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;
const int maxn=1e5+7;

int main()
{
//    freopen("input.txt","r",stdin);
    
    int n;
    cin>>n;
    int a=0,b=0,c=0,ans=0;
    for(int i=0;i<n;i++)
    {
    	string s;
    	cin>>s;
    	int len=s.length();
    	for(int j=0;j<len-1;j++) 
			if(s[j]=='A'&&s[j+1]=='B') ans++;
		if(s[0]!='B'&&s[len-1]=='A') a++;
		if(s[0]=='B'&&s[len-1]!='A') b++;
		if(s[0]=='B'&&s[len-1]=='A') c++; 
	}
	if(a&&b) 
	{
		if(c) 
		{
			ans+=2;
			a--;
			b--;
			ans+=min(a,b);
		}
		else 
		{
			ans+=min(a,b);
		}
	}
	else 
	{
		if(a||b) 
		{
			if(c) ans++;
		}
	}
	if(c) ans+=(c-1);
	cout<<ans<<endl;

    return 0;
}















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

int main() {
	int a, b;
    cin >> a >> b;
	vector<int> o(3);
	o[0] = a + b;
	o[1] = a - b;
	o[2] = a * b;
	sort(o.begin(), o.end());
	cout << o[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int one = N * A;
  int two = B;

  if (one > two) {
    cout << two << endl;
  }
  else{
    cout << one << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
// #define int long long
#define mod (int)(1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;


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

  int t,c;
  c=1;
  for(int i=0;i<n;i++){
    cin>>t;
    if(t==c) c++;
  }
  if(c==1) cout<<-1<<endl;
  else cout<<n-c+1<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
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; }

ll cnt(ll a) {
    ll b = 1, ans = 0;
    
    while (a >= b) {
        a =a-b;
        b++;
        ans++;
    }
    return ans;
}
int main(){
    ll N; cin >> N;
    map<ll, int>div;
    ll a;
    int ans = 0;
    a = 2;
    while (N >= a * a) {
        
        if (N % a == 0) {
            div[a]++;
            N /= a;
        }
        else {
            a++;
        }
    }
    if (N != 1) {
        div[N]++;
    }

    for (auto itr = div.begin(); itr != div.end(); itr++) {
        
        ans+=cnt(itr->second);
    }
    cout << ans << endl;
}
        


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner cin = new Scanner(System.in);
        int n = Integer.parseInt(cin.next());
        int[] array = new int[n];
        cin.nextLine();
        for (int i = 0; i < n; i++)
        {
            array[i] = cin.nextInt();
        }

        int cnt = bubbleSort(array, n);
        for (int i = 0; i < n; i++)
        {
            System.out.print(array[i]);
            if (i != n - 1)
            {
                System.out.print(" ");
            }
        }
        System.out.println();
        System.out.println(cnt);
    }

    // Return : count
    public static int bubbleSort(int[] A, int N)
    {
        int cnt = 0;

        int flag = 1;
        while (flag == 1)
        {
            flag = 0;
            for (int j = N - 1; j > 0; j--)
            {
                if (A[j] < A[j - 1])
                {
                    int tmp = A[j - 1];
                    A[j - 1] = A[j];
                    A[j] = tmp;
                    flag = 1;
                    cnt++;
                }
            }
        }
        return cnt;
    }
}

Measured memory_bytes: 19728
V,E,r = map(int, input().split())
edge = []
for i in range(E):
    edge.append(list(map(int, input().split())))
inf = float('inf')
d = [inf for i in range(V)]
d[r] = 0
while True:
    update = False
    for i in range(E):
        e = edge[i]
        if d[e[0]] != inf and d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            update = True
    if update == False:
        break
for i in d:
    if i == inf:
        print('INF')
    else:
        print(i)

Measured memory_bytes: 146488
def solve():
    N, *W = map(int, open(0).read().split())
    left, right = W[0], sum(W[1:])
    ans = abs(left - right)
    for i in range(1, N-1):
        left += W[i]
        right -= W[i]
        ans = min(ans, abs(left - right))
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, A[202020];
map<int, int> M;

void solve() {
    FOR (N) {
        M[i - A[i]] += 1;
    }
    int ans = 0;
    FOR (N) {
        M[i - A[i]] -= 1;
        ans += M[A[i] + i];
    }
    cout << ans << endl;
}

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

    cin >> N;
    FOR (N)
        cin >> A[i];

    solve();
    return 0;
}


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

int n;
string s, sw = "WS";
int memo[100005] = {0};
bool ans = 0;

void solve(int x);

int main() {
  cin >> n >> s;
  s += s[0];
  s += s[1];
  for(int i = 0; i < n; ++i) memo[i] = -1;
  memo[n + 1] = memo[n] = memo[0] = memo[1] = memo[2] = 1;
  // SSS or WWW
  if(s[1] == 'o')
    solve(0);
  else
    solve(1);
  // WSW or SWS
  memo[n + 1] = memo[1] = 1;
  memo[n] = memo[0] = memo[2] = 0;
  if(s[1] == 'o')
    solve(0);
  else
    solve(1);
  // SSW or WWS
  memo[n + 1] = memo[n] = memo[0] = memo[1] = 1;
  memo[2] = 0;
  if(s[1] == 'o')
    solve(1);
  else
    solve(0);
  // SWW or WSS
  memo[n + 1] = memo[2] = memo[1] = 1;
  memo[n] = memo[0] = 0;
  if(s[1] == 'o')
    solve(1);
  else
    solve(0);
  if(!ans) cout << -1 << endl;
  return 0;
}

void solve(int x) {
  if(ans) return;
  ans = 1;
  for(int i = 2; i <= n; ++i) {
    if(i >= n - 1) {
      if(((s[i] == 'o') ^ x) == memo[i])
        ans &= (memo[i - 1] == memo[i + 1]);
      else
        ans &= (1 - memo[i - 1] == memo[i + 1]);
    }
    if(((s[i] == 'o') ^ x) == memo[i])
      memo[i + 1] = memo[i - 1];
    else
      memo[i + 1] = 1 - memo[i - 1];
  }
  if(!ans) return;
  for(int i = 0; i < n; ++i) cout << sw[memo[i] ^ x];
  cout << endl;
}

Measured memory_bytes: 896
#include <stdio.h>
 
int main()
{
   int a, b, c, d;
   scanf("%d %d %d", &a, &b, &c);
   if (a > b) {
      d = a;
      a = b;
      b = d;
   }
   if (c < a) {
      d = a;
      a = c;
      c = d;
   }
   if (c < b) { 
      d = b;
      b = c;
      c = d;
   }
 
   printf ("%d %d %d\n", a, b, c);
 
   return 0;
}         
          
 
 

Measured memory_bytes: 596
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

int years[] = {9, 19, 29, 39, 49, 59, INF};
const int CNT = 7;

int main() {
	for(int N; cin >> N, N;) {
		vector<int> ans(7);
		for(int i = 0; i < N; i++) {
			int p; cin >> p;
			for(int j = 0; j < CNT; j++) {
				if(p <= years[j]) {
					ans[j]++;
					break;
				}
			}
		}
		rep(i,CNT) cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 908
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    for (int X = 1; X <= 50000; ++X)
    {
        int price = static_cast<double>(X) * 1.08;
        if (price == N) {
            cout << X << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 256
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    p_list = li()
    second_count = 0
    for i in range(n - 2):
        if p_list[i] < p_list[i + 1] < p_list[i + 2] or p_list[i] > p_list[i + 1] > p_list[i + 2]:
            second_count = second_count + 1
    print(second_count)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<62)-1
#define MAX 1000000000
signed main(){
    int N,K,Q; cin>>N>>K>>Q;
    vi A(N);
    rep(i,0,N) cin>>A[i];
    int ans=INF;
    rep(i,0,N){
        priority_queue<int,vi,greater<int>> que,queu;
        rep(j,0,N){
            if(A[j]<A[i]){
                int P=que.size();
                REP(k,0,P-K){
                    queu.push(que.top());
                    que.pop();
                }
                while(que.size()>0) que.pop();
            }
            else que.push(A[j]);
        }
        int P=que.size();
        REP(k,0,P-K){
            queu.push(que.top());
            que.pop();
        }
        if((int)queu.size()>=Q){
            int X=0,Y=A[i];
            rep(j,0,Q){
                X=max(queu.top(),X);
                queu.pop();
            }
            ans=min(ans,X-Y);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
const int N = 0;
 
typedef long long int ll;
 
using namespace std;

 
int main(){
    FIN;
    //freopen("../input.txt", "r", stdin);freopen("../output.txt", "w", stdout);
    int x,y;cin>>x>>y;
    int pos = false;
    fore(i,0,x+1){
        if((i*2)+((x-i)*4) == y){
            pos = true;break;
        }
    }
    if(pos){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader 
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

typedef pair<int, int> P;

const int N_MAX = 100000;

int N;
P as[N_MAX];

void solve() {
  sort(as, as + N);
  int ans = 0;
  for (int i = 0; i < N; i += 2) {
    ans += as[i].second % 2;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) {
    int A;
    scanf("%d", &A);
    as[i] = P(A, i);
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 9999999999;
const ll mod = 1e9 + 7;


int main(){
	ll n,k;
	cin>>n>>k;
	map<ll,int> mp;
	map<ll,int> mp2;
	ll ans = 0, pt = 0;
	ll x;
	string s;
	rep(i,k){
		cin>>x>>s;
		if(s == "AC"){
			if(mp[x] == 0){
				ans++;
				mp[x] = 1;
				pt += mp2[x];
			}

		}else if(s == "WA"){
			if(mp[x] == 0){
				mp2[x]++;
			}
		}
	}
	cout<<ans<<" "<<pt<<endl;

	return 0;
}





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

int main()
{
    int a,b,c,d,e;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>=d&&c>=e){
        cout<<c<<endl;
    }
    else if(d>c&&d>=e){
        cout<<d<<endl;
    }
    else{
        cout<<e<<endl;
    }
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
 
  ll N  ;
  cin >> N ;
  vector<ll> A(5) ;
  rep(i,5) cin >> A.at(i) ;
  ll ans = 10e16 ;
  rep(i,5) ans = min( ans , A.at(i) ) ;
  if( N % ans == 0 ) cout << (ll) 5 + N/ans -1  << endl ;
  else cout << (ll) 5 + N/ans << endl ;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    ans = 0
    cnt_only_head_b = 0
    cnt_only_end_a = 0
    cnt_headb_enda = 0
    for i in range(n):
        s = input()
        slen = len(s)
        for j in range(slen-1):
            if s[j:j+2] == 'AB':
                ans += 1
            
        if s[0] == 'B' and s[-1]!='A':
            cnt_only_head_b += 1
        if s[-1] == 'A' and s[0]!='B':
            cnt_only_end_a += 1
        if s[0] == 'B' and s[-1] == 'A':
            cnt_headb_enda += 1

    

    if cnt_headb_enda:
        ans += cnt_headb_enda - 1
        if cnt_only_end_a:
            ans += 1
            cnt_only_end_a -= 1
        if cnt_only_head_b:
            ans += 1
            cnt_only_head_b -= 1
        
        
    
    minab = min(cnt_only_end_a, cnt_only_head_b)
    ans += minab

    print(ans)


    
    

solve()


Measured memory_bytes: 3064
#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;
    cin >> N;
    std::string S;
    cin >> S;

    int count = S.length();
    char pre_char;

    rep(i,S.length()){
        if(S[i] == S[i+1]){
            count -= 1;
        }
    }

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

    return 0;
}

Measured memory_bytes: 512
#define _USE_MA_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=a;i<b;i++)
#define REP(i,a,b) for(int i=a;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
#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;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    vvi dp(n+1,vi(2));
    dp[0][1]=-inf;
    rep(i,n){
        dp[i+1][0]=max(dp[i][0]+a[i],dp[i][1]-a[i]);
        dp[i+1][1]=max(dp[i][0]-a[i],dp[i][1]+a[i]);
    }
    cout<<dp[n][0]<<endl;
}

Measured memory_bytes: 6528
import scala.annotation.tailrec
import scala.util.matching.Regex
object Main extends App {

  import scala.io.StdIn._

  val arg = readLine.trim
  val real = """^(\d+).(\d*)(\(\d+\))?$""".r
  val inLoop = """\((\d+)\)""".r
  println(arg match {
    case real(integer, null, null) ⇒ integer.toLong
    case real(integer, underPoint, null) ⇒ Rational((integer + underPoint).toLong, toInteger(underPoint).toLong)
    case real(integer, null, inLoop(loop)) ⇒ Rational((integer + loop).toLong - integer.toLong, toInteger(loop).toLong - 1)
    case real(integer, underPoint, inLoop(loop)) ⇒ Rational((integer + underPoint + loop).toLong - (integer + underPoint).toLong, toInteger(underPoint + loop).toLong - toInteger(underPoint).toLong)
    case _ ⇒ ???
  })
  def toInteger(underPoint: String): String = {
    s"1${underPoint.map{_ ⇒ "0"}.mkString}"
  }
  object Rational{
    def apply(numerator: Long, denominator: Long): Rational = {
      val signum = math.signum(numerator) * math.signum(denominator)
      val g = gcd(math.abs(numerator), math.abs(denominator))
      new Rational(math.abs(numerator) * signum / g, math.abs(denominator) / g)
    }
    def apply(integer: Long): Rational = Rational(integer, 1)
    def apply(integer: Int): Rational = Rational(integer, 1)
    @tailrec
    def gcd(a: Long, b: Long): Long = {
      b match {
        case 0 ⇒ a
        case _ ⇒ gcd(b, a % b)
      }
    }
  }
  
  class Rational private (val numerator: Long, val denominator: Long){
    override def toString: String = s"$numerator/$denominator"
    def +(that: Rational): Rational = Rational(numerator * that.denominator + denominator * that.numerator, denominator * that.denominator)
    def *(that: Rational): Rational = Rational(numerator * that.numerator, denominator * that.denominator)
    def -(that: Rational): Rational = this + (that * Rational(-1))
  }

  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 43956
import java.util.Scanner;

/**
 * Toggling Cases
 */
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        char[] charArray = scan.nextLine().toCharArray();
        scan.close();
        StringBuffer sb = new StringBuffer();
        for (char chara: charArray) {
            if (Character.isUpperCase(chara)) {
                sb.append(String.valueOf(chara).toLowerCase());
            } else {
                sb.append(String.valueOf(chara).toUpperCase());
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 17272
import java.util.*;
public class Main
{
	
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
        	if (i % 3 != 0 && i % 5 != 0) sum += i;
        }
        System.out.println(sum);
    }
    
}

Measured memory_bytes: 35616
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>
#include <queue>

#define r(i, v, n) for(int i = v; i < n; i++)
#define re(i, v, n) for(int i = v; i <= n; i++)
#define rr(e, v) for(auto&& (e) : (v))
#define ALL(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using ul = unsigned long;

int main() {
    string s, t, answer;

    cin >> s >> t;
    reverse(ALL(s));
    reverse(ALL(t));

    ul sl = s.length(), tl = t.length();
    bool m = false;
    string sc = s;
    vector<string> v;

    r(i, 0, (sl - tl + 1)) {
        string ss = s.substr((ul)i, tl);
        ul ssl = ss.length();
        sc = s;

        if(ssl == tl) {
            bool subm = true;

            r(j, 0, ssl) {
                if(ss[j] == '?') {
                    sc[i + j] = t[j];
                    continue;
                }
                if(ss[j] == t[j]) continue;
                subm = false;
                break;
            }

            if(subm) v.push_back(sc);
            if(!m) m = subm;
        }
    }

    r(i, 0, v.size()) {
        string vs = v[i];
        reverse(ALL(vs));
        r(j, 0, sl) {
            if(vs[j] == '?') vs[j] = 'a';
        }
        v[i] = vs;
    }

    sort(ALL(v));

    if(m) {
        cout << v[0];
    } else {
        cout << "UNRESTORABLE";
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

int main(){
	int n, k;
	double ans = 0;
	int score;
	double tmp;
	scanf("%d%d\n", &n, &k);
	for(int i=1; i<=n; i++){
		tmp = (double)1 / n;
		score = i;
		while(score < k){
			tmp /= 2;
			score *= 2;
		}
		ans += tmp;
	}
	printf("%.9lf\n", ans);
	return 0;
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

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

int sm(ll n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int fact(ll n){
    if(n==1)
        return 1;
    else
        return n*fact(n-1);
}

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll res=7%n;
        for(int i=1;i<1e7;i++){
            if(res==0){
                cout<<i<<endl;
                return 0;
            }
            res=(res*10+7)%n;
        }
        cout<<"-1"<<endl;
    }   
    return 0;
}


Measured memory_bytes: 3660
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        for(int i = 0; i < s.length(); i++){
        	if(s.charAt(i) == '7'){
            	System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
	}
}

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

using ll = long long;
#define MAXH 1010
#define MAXW 1010
const int MOD = 1e9+7;

int H, W;
char g[MAXH][MAXW];

int dx[] = {1, 0};
int dy[] = {0, 1};
int dp[MAXH][MAXW];

void debug() {
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            cout << dp[i][j];
        }
        cout << endl;
    }
}
int main() {
    cin >> H >> W;
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            cin >> g[i][j];
        }
    }

    memset(dp, 0, sizeof(dp));
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            if(i==1&&j==1){
                dp[i][j] = 1;
                continue;
            }
            if(g[i-1][j] == '#')
                dp[i-1][j] = 0;
            if(g[i][j-1] == '#')
                dp[i][j-1] = 0;
            if(g[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
        }
    }
    cout << dp[H][W] << endl;
//    debug();
    return 0;
}

Measured memory_bytes: 5248
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {
	static int[] vx = new int[] {1, -1};
	static int[] vy = new int[] {-1, 1}; 
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cCunt = 1;
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int[][] ans = new int[n][n];
			boolean E = true;
			int count = 2;
			int DD = 0;
			int x = 1;
			int y = 0;
			ans[0][0] = 1;
			if(n != 1)
			while(true) {
				ans[y][x] = count++;
				if(y == n-1 && x == n-1) break;
				if(E) {
					E = false;
					if(x == 0 || y == n-1) {
						DD = 0;
					}
					else if(x == n-1 || y == 0) {
						DD = 1;
					}
					x += vx[DD];
					y += vy[DD];
					continue;
				}
				if(x == 0) {
					E = true;
					if(y != n-1) {
						y++;
						continue;
					}
				}
				if(x == n-1) {
					E = true;
					if(y != n-1) {
						y++;
						continue;
					}
				}
				if(y == 0) {
					E = true;
					if(x != n-1) {
						x++;
						continue;
					}
				}
				if(y == n-1) {
					E = true;
					if(x != n-1) {
						x++;
						continue;
					}
				}
				
				x += vx[DD];
				y += vy[DD];
			}
			System.out.println("Case " + cCunt++ + ":");
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					System.out.printf("%3d",ans[i][j]);
				}
				System.out.println();
			}
		}
		
		
	}
 }

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int MAXS = 100100;
int main(){
  int n, k;
  cin >> n >> k;
  bool dp[MAXS];
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, MAXS) dp[i] = false;

  rep(i, k + 1) {
    rep(j, n) {
      if(i - a[j] >= 0 && dp[i - a[j]] == false) dp[i] = true;
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;

}

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

typedef long long ll;

using namespace std;

const int inf=1000000007;

string s;

int main()
{
    int n;
    scanf("%d",&n);
    cin >> s;
    int ans=0;
    for(int i=0,j=n-1;i<j;)
    {
        while(i<j&&s[i]=='R')
        {
            i++;
        }
        while(i<j&&s[j]=='W')
        {
            j--;
        }
        if(i>=j)
        {
            break;
        }
        ans++;
        i++;
        j--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3824
S = input()
q1 = 0
q2 = 0
q3 = 0
num = len(S)
num_2 = int((num -1)/2)
num_3 = int((num +3)/2-1)


def ispalindrome(str): return 1 if str == str[::-1] else 0

q1 = ispalindrome(S)

S_2 = S[0:num_2]
q2 = ispalindrome(S_2)

S_3 = S[num_3:num]
q3 = ispalindrome(S_3)

if q1 == 1 and q2 == 1 and q3 == 1:
  print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
  int r;cin>>r;
  cout<<3*r*r<<endl;
}

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

int main(){
  int N;
  cin >> N;
  bool a=false;
  for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
      if((i+1)*(j+1)==N){
        a=true;
      }
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;


int my_a(int x, int y){
    if(x > y) return x - y;
    else return y - x;
}

int f(int x){
    return x*x;
}


int n, d;
int z[30][30];

int main(){

    int ans = 0;

    cin >> n >> d;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> z[i][j];
        }
    }

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            int length = 0;

            for(int k = 0; k < d; k++){
                length += f(my_a(z[i][k], z[j][k]));
            }

            if(f(static_cast<int>(sqrt(length))) == length){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<60)
#define EPS (1e-5)

signed main(){
    int n, a, b;
    cin>>n>>a>>b;
    
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    vector<pair<pii, int>> vd;
    for(int k=a;k<=b;k++){
        int dp[51][51] = {};
        int dpn[51][51] = {};
        dpn[0][0] = 1;
        
        rep(i,n){
            rep(j,k+1){
                dp[i+1][j] = dp[i][j];
                dpn[i+1][j] = dpn[i][j];

                if(j-1<0)continue;
                int tmp = dp[i][j-1] + v[i];
                if(dp[i+1][j]<tmp){
                    dp[i+1][j] = tmp;
                    dpn[i+1][j] = dpn[i][j-1];
                }else if(dp[i+1][j]==tmp){
                    dpn[i+1][j] += dpn[i][j-1];
                }
            }
        }
        vd.pb(pii(dp[n][k],k), dpn[n][k]);
    }
    
    pii max_value = vd[0].first;
    for(auto elm:vd){
        int x,y;
        tie(x,y) = elm.first;
        if(x*max_value.second>y*max_value.first){
            max_value = elm.first;
        }
    }
    int ans = 0;
    for(int i=vd.size()-1;i>=0;i--){
        int x,y;
        tie(x,y) = vd[i].first;
        if(x*max_value.second==y*max_value.first){
            ans += vd[i].second;
        }
    }
    
    printf("%.20lf\n", max_value.first/(double)max_value.second);
    cout<<ans<<endl;
}


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

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static boolean[] hasParent;

static class Node{
int id;
int p;
int rank;
int k;
int[] c;
String type;
Node(int id){
this.id=id; this.p=-1; this.rank=-1; this.type="internal node";
}
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int num=Integer.parseInt(br.readLine());
Node[] ns=new Node[num];
hasParent=new boolean[num];
StringTokenizer st;
StringBuilder sb;
for(int i=0;i<num;i++){
ns[i]=new Node(i);
}
for(int i=0;i<num;i++){
st=new StringTokenizer(br.readLine());
int id=Integer.parseInt(st.nextToken());
Node n=ns[id];
int k=Integer.parseInt(st.nextToken());
n.k=k;
if(k==0) n.type="leaf";
else{
n.c=new int[k];
for(int j=0;j<k;j++){
int c=Integer.parseInt(st.nextToken());
n.c[j]=c;
ns[c].p=id;
hasParent[c]=true;
}
}
}
for(int i=0;i<num;i++){
if(ns[i].rank<0) ns[i].rank=setRank(i,ns);
}
for(int i=0;i<num;i++){
Node an=ns[i];
sb=new StringBuilder();
sb.append("node "+i+": parent = "+an.p+", depth = "+an.rank+", "+an.type+", [");
if(an.k!=0){
for(int j=0;j<an.k;j++) sb.append((j==an.k-1)?an.c[j]:an.c[j]+", ");
}
sb.append("]"+System.getProperty("line.separator"));
out.print(sb);
}
out.flush();
}

private static int setRank(int now,Node[] ns){
if(ns[now].rank>=0) return ns[now].rank;
if(!hasParent[now]){
ns[now].type="root";
return ns[now].rank=0;
}
return ns[now].rank=setRank(ns[now].p,ns)+1;
}
}

Measured memory_bytes: 121028
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define ll long long
using namespace std;
int main() {
  ll n;
  cin >> n;
  for (int i = 0; i < 10000; i++) {
    if (n - 1000 <= 0) {
      cout << 1000 - n << endl;
      return 0;
    }
    n = n - 1000;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1] && s[0]==s[2]) cout<<"Yes"<<endl;
    else if(s[1]==s[2] && s[1]==s[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let n = readln();
    let mut v: Vec<i32> = readlns(n);
    v.sort();
    let ans = v.windows(2).filter(|&a| a[0] < a[1]).count() + 1;
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
def binary_search_left(n, key, in_list):
    left = 0
    right = n
    while left < right:
        mid = int((left+right)/2)
        if in_list[mid] < key:
            left = mid + 1
        else:
            right = mid
    return left


def binary_search_right(n, key, in_list):
    left = 0
    right = n
    while left < right:
        mid = int((left+right)/2)
        if in_list[mid] <= key:
            left = mid + 1
        else:
            right = mid
    return left


if __name__ == "__main__":
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    c_list = list(map(int, input().split()))
    a_list.sort()
    c_list.sort()
    ans = 0
    for b in b_list:
        a = binary_search_left(n, b, a_list)
        c = binary_search_right(n, b, c_list)
        ans += a*(n-c)
    print(ans)


Measured memory_bytes: 24180
#include<stdio.h>
#include <string.h>
int main()
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	
	if(b<a){
		c=a-1;
		printf("%d\n",c);
	}
	else {
		c=a;
		printf("%d\n",c);
	}
	return 0;
}

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

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

    //good luck, kittu
    int n; cin>>n;
    vector<pair<int, int>> a(n+1);
    for(int i = 0; i<n; i++) cin>>a[i].first>>a[i].second;

    int fact = 1, count = 0;
    for(int i = 1; i<=n; i++) fact *= i;

    long double ans = 0;
    vector<int> p(n);
    for(int i = 0; i<n; i++) p[i] = i;

    do{
        for(int i = 0; i<n-1; i++){
            ans += sqrt((a[p[i]].first - a[p[i+1]].first)*(a[p[i]].first - a[p[i+1]].first) + (a[p[i]].second - a[p[i+1]].second)*(a[p[i]].second - a[p[i+1]].second));
        }
        count++;
        if(count==fact) break;
    }while(next_permutation(p.begin(), p.end()));

    ans = ans/fact;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int num;
  
  cin >> num;
  
  for(int i = 1; i < num + 1; i++) {
    int x = i;
    
    if(x % 3 == 0) {
      cout << " " << i;
    } else {
      while(x != 0) {
        if(x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }
  cout << endl;
}

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
  cin >> s >>t;
  cout << t<<s<<endl;
	return 0;
}


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

const int N = 10005;
const int mod = 1e9 + 7;

int n, A, B, C;
int fact[N], ifact[N];
int res;

void add(int &x, int y) {
    x += y; while(x >= mod) x -= mod; while(x < 0) x += mod;
}

int pw(int a, int b) {
    int ret = 1;
    while(b) {
        if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ret;
}

int comb(int n, int k) {
    if (n == k) return 1;
    if (n < 0 || k < 0 || n < k) return 0;
    return 1LL * fact[n] * (1LL * ifact[k] * ifact[n - k] % mod) % mod;
}

int candy(int n, int k) {
    return comb(n + k - 1, k - 1);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> A >> B >> C;
    if (B % 2 != 0) return cout << 0 << endl, 0;

    fact[0] = 1; for (int i = 1; i < N; ++i) fact[i] = 1LL * fact[i - 1] * i % mod;
    ifact[0] = 1; for (int i = 1; i < N; ++i) ifact[i] = pw(fact[i], mod - 2);

    // type 1: 11
    // type 2: 3113
    // type 3: 333333
    // type 4: 2222
    // type 5: 2323333232

    // remC = C - t2 - t3 (t3 % 3 == 0)
    // candy(remC, B / 2)
    // C(B / 2 + 1, t3 / 3)
    // C(B / 2 + 1 + t3 / 3, t2)
    // C(B / 2 + 1 + t2 + t3 / 3, t1)

    B /= 2;
    for (int t2 = 0; t2 <= min(A, C); ++t2) {
        for (int t3 = 0; t3 <= C / 3; ++t3) {
            int t1 = A - t2;
            int remC = C - t2 - 3 * t3; if (remC < 0) continue;
            
            int mul = 1;
            mul = 1LL * mul * candy(remC, B) % mod;
            mul = 1LL * mul * candy(t3, B + 1) % mod;
            mul = 1LL * mul * candy(t2, B + 1 + t3) % mod;
            mul = 1LL * mul * candy(t1, B + 1 + t3 + t2) % mod;

            add(res, mul);
        }
    }

    cout << res << endl;
}

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

#define Bye return 0
#define ll long long

void solve(){
    string str; cin>>str;
    int i = 0, j = str.size() - 1;
    while(str[i]!='A') i++;
    while(str[j]!='Z') j--;
    cout<<(j-i)+1<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3700