akhauriyash/Code-Regression huggingface dataset:
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    char x;
    cin >>x;
    cout << (('A'<=x && x<='Z') ? "A" : "a") <<'\n';


    return (0);
}

Measured memory_bytes: 3648
#include<set>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2e5+5;
char s[MAXN],t[MAXN];
int c[256+5],d[256+5];

int main() 
{
	scanf("%s%s",s,t);
	int len=strlen(s);
	memset(c,-1,sizeof c);
	memset(d,-1,sizeof d);
	set<char> cnt;
	for(int i=0;i<len;i++)
		cnt.insert(s[i]);
	for(int i=0;i<len;i++) {
		if(c[t[i]]!=-1&&c[t[i]]!=s[i]) {
			if(t[i]==s[i]&&cnt.size()<=26)
				continue;
			puts("No");
			return 0;
		}
		c[t[i]]=s[i];
	}
	for(int i=0;i<len;i++) {
		if(d[s[i]]!=-1&&d[s[i]]!=t[i]) {
			if(t[i]==s[i]&&cnt.size()<=26)
				continue;
			puts("No");
			return 0;
		}
		d[s[i]]=t[i];
	}
	puts("Yes");
	return 0;
}



Measured memory_bytes: 640
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        int n = sc.Int;
        int m = sc.Int;

        BellmanFord bf = new BellmanFord(n);

        for (int i = 0; i < m; i++)
            bf.AddEdge(sc.Int-1, sc.Int-1, -sc.Int);

        bf.CalcDistance(0);

        Console.WriteLine(bf.IsNegInf(n-1) ? "inf" : (-bf.GetDistance(n-1)).ToString());
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Line { get { return Console.ReadLine(); } }

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Line.Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public string[] StrArr { get { return Line.Split(' '); } }
    public int Int { get { return int.Parse(Str); } }
    public int[] IntArr { get { return Line.Split(' ').Select(int.Parse).ToArray(); } }
    public long Long { get { return long.Parse(Str); } }
    public long[] LongArr { get { return Line.Split(' ').Select(long.Parse).ToArray(); } }
    public double Double { get { return double.Parse(Str); } }
    public double[] DoubleArr { get { return Line.Split(' ').Select(double.Parse).ToArray(); } }
}

class BellmanFord
{
    private class Edge
    {
        public int To;
        public long Cost;
    }

    private List<Edge>[] _g;
    private int _n;
    private long[] _dist;
    private bool[] _negInf;

    public bool NegativeCycleDetected = false;

    public BellmanFord(int n)
    {
        _n = n;
        _dist = new long[n];
        _g = new List<Edge>[n];
        _negInf = new bool[n];

        for (int i = 0; i < n; i++)
            _g[i] = new List<Edge>();
    }

    public void AddEdge(int from, int to, int cost)
    {
        _g[from].Add(new Edge { To = to, Cost = cost });
    }

    public bool IsNegInf(int i)
    {
        return _negInf[i];
    }

    public long GetDistance(int i)
    {
        return _dist[i];
    }

    public void CalcDistance(int s)
    {
        NegativeCycleDetected = false;
        for (int i = 0; i < _n; i++)
            _dist[i] = long.MaxValue;

        _dist[s] = 0;

        for (int i = 0; i < _n-1; i++)
            for (int j = 0; j < _n; j++)
                foreach (var edge in _g[j])
                    if (_dist[j] != long.MaxValue)
                        _dist[edge.To] = Math.Min(_dist[edge.To], _dist[j] + edge.Cost);


        for (int i = 0; i < _n; i++)
        {
            foreach (var edge in _g[i])
            {
                if (_dist[i] != long.MaxValue && _dist[i] + edge.Cost < _dist[edge.To])
                {
                    _dist[edge.To] = _dist[i] + edge.Cost;
                    _negInf[edge.To] = true;
                    NegativeCycleDetected = true;
                }
            }
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];
    sort(ALL(a),greater<int>());

    int len1=0,len2=0;
    for(int i=0,j=i;i<N;i=j){
        int cnt=0;
        while(j<N and a[j]==a[i]) cnt++,j++;

//      cout<<j<<' '<<cnt<<endl;

        if(cnt>=4){
            if(len1>0){
                len2=a[i];
                break;
            }
            else{
                len1=len2=a[i];
                break;
            }
        }
        else if(cnt>=2){
            if(len1>0){
                len2=a[i];
                break;
            }
            else{
                len1=a[i];
            }
        }
    }
    cout<<len1*len2<<endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  ll d;
  cin >> n >> m >> d;
  double b;
  ll x = n - d;
  b = (double)x / n / n * (m - 1);

  if (d != 0) b *= 2;
  cout.precision(10);
  cout << fixed << b << endl;

  return 0;
}

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

using namespace std;

int main(){
    int n, cnt=0, tmp;
    vector<pair<int, int>> A;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> tmp;
        A.push_back(pair<int, int>(tmp, i%2));
    }
    sort(A.begin(), A.end());
    for(int i=0;i<n;i++){
        if(i%2!=A[i].second)cnt+=1;
    }
    cout  << cnt/2 << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MAXN 5000

int dp[MAXN+1][MAXN+1];

int solve(int len, int sis) {
	if(len>MAXN || len<0)	return 0;
	if(sis==0)
		return (len==0);

	int &ans = dp[len][sis];
	if(ans!=-1)	return ans;


	// append
	ans = solve(len-1, sis-1);

	//backspace
	ans+= 2*solve(len+1, sis-1)%MOD;

	if(ans>=MOD)
		ans-=MOD;

	// do nothing
	if(len==0)	ans+=solve(len, sis-1);

	if(ans>=MOD)
		ans-=MOD;


	//cout<<len<<" "<<sis<<" "<<dp[len][sis]<<"\n";
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	int n;
	string s;
	cin>>n>>s;
	cout<<solve(s.size(), n)<<"\n";

}

Measured memory_bytes: 98176
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int H, N;
	vector<pair<int,int>> in;
	vector<int> dp;
	
	cin>>H>>N;
	
	in.resize(N);
	dp.resize(H+1, INF);
	
	dp[0] = 0;
	
	for(int i = 0; i < N; i++){
		cin>>in[i].first>>in[i].second;
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < H; j++){
			if(j + in[i].first <= H) dp[j + in[i].first] = min(dp[j + in[i].first], dp[j] + in[i].second);
			else dp[H] = min(dp[H], dp[j] + in[i].second);
		}
	}
	
	cout<<dp[H]<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;


void solve() {
	int m; cin >> m;
	ll sum = 0;
	ll x = 0;
	rep(i, m) {
		ll c, d; cin >> d >> c;
		x += c;
		sum += d * c;
	}
	ll ans = (x - 1) + (sum-1) / 9;
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	//init();
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<cstdint>
#include<algorithm>
#include<boost/variant.hpp>
#include<boost/range/irange.hpp>
struct update
{
	std::int64_t a, b;
};
struct output
{

};
typedef boost::variant<update, output> query;
template<class T>class binary_indexed_tree
{
	typedef T type;
	std::vector<type> ar;
	std::size_t size;
public:
	binary_indexed_tree(std::size_t size_) :ar(size_), size(size_)
	{

	}
	void add(type val, int index)
	{
		++index;
		while (index <= size)
		{
			ar[index - 1] += val;
			index += index & -index;
		}
	}
	auto get(int index)const
	{
		++index;
		type ret{};
		while (index != 0)
		{
			ret += ar[index - 1];
			index -= index & -index;
		}
		return ret;
	}
};
struct operation
{
	binary_indexed_tree<int> count;
	binary_indexed_tree<std::int64_t> sum;
	std::map<std::int64_t, int> indexes;
	std::vector<std::int64_t> values;
	std::size_t size;
	std::int64_t update_count;
	std::int64_t constant;

	operation(
		std::map<std::int64_t, int>&& _indexes,
		std::vector<std::int64_t>&& _values,
		std::size_t _size) :
		count(_size),
		sum(_size),
		indexes(std::move(_indexes)),
		values(std::move(_values)),
		size(_size),
		update_count(),
		constant()
	{

	}
	
	void operator()(update const& q)
	{
		auto a = q.a;
		auto b = q.b;
		auto i = indexes[a];
		count.add(1, i);
		sum.add(a, i);
		constant += b;
		++update_count;
	}
	void operator()(output const&)
	{
		auto j = (update_count + 1) / 2;
		auto rng = boost::irange<std::size_t>(0, size);
		auto i = *std::partition_point(rng.begin(), rng.end(), [&](std::size_t k)
			{
				auto c = count.get(k);
				return c < j;
			});
		auto c = count.get(i);
		auto d = update_count - c;
		auto v = (c - d) * values[i] + sum.get(size - 1) - 2 * sum.get(i) + constant;
		std::cout << values[i] << " " << v << std::endl;
	}
};

void Main()
{
	int Q;
	std::cin >> Q;
	std::vector<query> queries;
	std::set<std::int64_t> as;
	for (int i : boost::irange(0, Q))
	{
		int q;
		std::cin >> q;
		if (q == 1)
		{
			std::int64_t a, b;
			std::cin >> a >> b;
			as.emplace(a);
			queries.emplace_back(update{ a,b });
		}
		else
		{
			queries.emplace_back(output{});
		}
	}
	std::map<std::int64_t, int> indexes;
	std::vector<std::int64_t> values;
	std::size_t index = 1;
	const std::int64_t min = -1000000000;
	indexes.emplace(min - 1, 0);
	values.emplace_back(min - 1);
	for (auto a : as)
	{
		indexes[a] = index;
		values.emplace_back(a);
		++index;
	}
	operation op(std::move(indexes), std::move(values), index);
	for (auto const& q : queries)
	{
		boost::apply_visitor(op, q);
	}
}

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

Measured memory_bytes: 20912
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
s = input()
ans = []
for x in s:
    if x=='0': ans.append('0')
    elif x == '1': ans.append('1')
    else:
        if len(ans) == 0: pass
        else: ans.pop()
for t in ans: print(t, end = "")



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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

int p[1111],cnt,a[1111],n;
void P(){
	for(int i=2;i<=1000;i++){
		if(!p[i])a[++cnt]=i;
		for(int j=1;j<=cnt and a[j]*i<=1000;j++){
			p[a[j]*i]=1;
			if(i%a[j]==0)break;
		}
	}
}
int Q[1111];
int main(){
	ios::sync_with_stdio(false);
	P();
	cin>>n;
	for(int i=1;i<=n;i++){
		int now=i;
		for(int j=1;a[j]*a[j]<=now;j++){
			if(now%a[j]==0){
				while(now%a[j]==0)Q[a[j]]++,now/=a[j];
			}
		}
		if(now>1)Q[now]++;
	}
	LL ans=1,mod=1e9+7;
	for(int i=1;i<=1000;i++){
		if(Q[i]){
			ans*=Q[i]+1;
			ans%=mod;
		}
	}
	cout<<ans;
	return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;++i)
    {
        if(i%3!=0 && i%5!=0 ) sum+=i;
    }
    cout<<sum;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int, int > Pi;

const int INF = 1 << 30;
// 区間への加算, 最大値が求まればいいかんじに出来る

int64 seg[1 << 18], added[1 << 18];

void add( int a, int b, int64 value, int k = 0, int l = 0, int r = 1 << 17){ // [a,b)にvalueを足すやつ
  if(r <= a || b <= l) return;
  if(a <= l && r <= b) { // 完全に含んでたら足す
    added[k] += value;
  } else {
    int mid = (l + r) >> 1;
    add( a, b, value, 2 * k + 1, l, mid);
    add( a, b, value, 2 * k + 2, mid, r);
    seg[k] = max( seg[2 * k + 1] + added[2 * k + 1], seg[2 * k + 2] + added[2 * k + 2]);
  }
  return;
}

int64 query( int a, int b, int k = 0, int l = 0, int r = 1 << 17){ // [a,b)の最大値を返すやつ
  if(r <= a || b <= l) return -INF;
  if(a <= l && r <= b) return seg[k] + added[k];
  int mid = (l + r) >> 1;
  return max( query( a, b, 2 * k + 1, l, mid), query( a, b, 2 * k + 2, mid, r)) + added[k];
}


 int main()
 {
   int N, H;
   int64 life = 0; // 今の体力
   int64 ret = 0;

   scanf("%d %d", &N, &H);
   life = H;
   priority_queue< Pi > que; // first: 一回あたりの回復体力量, second: どこ
   for(int i = 0; i < N - 1; i++){
     add( i, i + 1, life); // 今の体力を更新
     int d, h;
     scanf("%d %d", &d, &h);
     que.push( Pi( h, i));

     life -= d; // 降りる
     while(life <= 0){
       Pi p = que.top(); que.pop();
       int64 lange = query( p.second, i + 1); // 回復量の最大値
       if(p.first + lange > H)  {
         que.push( Pi( H - lange, p.second));
       } else {
         int64 cnt = min((H - lange) / p.first, -life / p.first + 1LL); // 回復量の最大値 OR lifeまでの回復量
         ret += cnt;
         life += cnt * p.first;
         add( p.second, i + 1, cnt * p.first);
         que.push(p);
       }
     }
   }
   printf("%lld\n", ret);
}

Measured memory_bytes: 5344
#include<stdio.h>
#include<string.h>

int main()
{
    int a;
    char s[10];

    scanf("%d", &a);
    scanf("%s", s);
    if (a >= 3200){
        int n = strlen(s);

        for (int i = 0; i < n; i++) {
            printf("%c", s[i]);
        }
        printf("\n");
    }else{
        printf("red\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);
const uint64_t base = 3;

int n, k;
string s;

void read()
{
	cin >> n >> k;
	cin >> s;
}

uint64_t hsh = 0, rev_hsh = 0;
map<uint64_t, int> mp;

void solve()
{
	list<int> li;
	for(char c: s) if(c == 'A') li.push_back(1); else li.push_back(0);

	for(int i: li)
	{
		hsh = hsh * base + i + 1;
		rev_hsh = rev_hsh * base + (i ^ 1) + 1;
	}

	uint64_t pwn = 1;
	for(int i = 0; i < n - 1; i++)
		pwn = pwn * base;

	int C = 0, cp = 0;
	while(k > 0)
	{
		k--;

		int frs_v = li.front() ^ C;
		if(frs_v == 1)
		{
			li.pop_front();
			li.push_front(frs_v ^ C ^ 1);
			
			hsh = hsh - (frs_v + 1) * pwn;
			rev_hsh = rev_hsh - ((frs_v ^ 1) + 1) * pwn;
		
			hsh = hsh + ((frs_v ^ 1) + 1) * pwn;
			rev_hsh = rev_hsh + (frs_v + 1) * pwn;
		}
		else
		{
			hsh = hsh - (frs_v + 1) * pwn;
			rev_hsh = rev_hsh - ((frs_v ^ 1) + 1) * pwn;
			swap(hsh, rev_hsh);

			hsh = hsh * base;
			rev_hsh = rev_hsh * base;

			hsh += 2;
			rev_hsh += 1;

			li.pop_front();
			li.push_back(C);
			C ^= 1;
		}

		if(mp.count(hsh))
		{
			int len = cp - mp[hsh];
			k %= len;
			break;
		}

		mp[hsh] = cp++;
	}
	
	while(k > 0)
	{
		k--;
		
		int frs_v = li.front() ^ C;
		if(frs_v == 1)
		{
			li.pop_front();
			li.push_front(frs_v ^ C ^ 1);
		}
		else
		{
			li.pop_front();
			li.push_back(C);
			C ^= 1;
		}
	}

	while(!li.empty())
	{
		int v = li.front() ^ C;
		cout << (v == 0 ? 'B' : 'A');
		li.pop_front();
	}

	cout << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 31252
#include <stdio.h>

 
int main(void){
  int n,q,si,ti,l,r,m,c=0;
  int S[100005];
  int T[50005];
   
  scanf("%d", &n);
  for (si=0;si<n;si++){
    scanf("%d", &S[si]);
  } 
  scanf("%d", &q);
  for (ti=0;ti<q;ti++){
    scanf("%d", &T[ti]);
  }
  for (ti=0;ti<q;ti++){
    l=0;
    r=n;
    while (l<r){
      m=(l+r)/2;
      if (S[m]>T[ti]){
	r=m;
      }
      else if (S[m]<T[ti]){
	l=m+1;
      }
      else {
	c++;
	break;
      }
    }
  }
 
  printf("%d\n",c);
   
  return 0;
}


Measured memory_bytes: 3144
X, K, D = (int(i) for i in input().split())
X = max(X, -X)
k, x = divmod(X, D)
if k >= K:
    print(X - K * D)
else:
    if (K - k) % 2 == 0:
        print(abs(x))
    else:
        print(abs(x-D))

Measured memory_bytes: 9040
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];

	vector<array<int, 2>>s;
	rep(i, N) {
		s.push_back({ a[i],i });
	}
	s.push_back({ 0,0 });
	std::sort(ALL(s), std::greater<array<int, 2>>());
	
	vector<int>ans(N, 0);
	int minindex = intmax;
	rep(i, N) {
		minindex = min(minindex, s[i][1]);
		ans[minindex] += (s[i][0] - s[i + 1][0]) * (i + 1);
	}

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

	return 0;
}

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

int main()
{
    set<long long>s;
    long long n;
    cin>>n;
    
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        s.insert(x);
    }
    
    if(s.size()==n){
        cout<<"YES"<<"\n";
    }
    else cout<<"NO"<<"\n";
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    ll a=1,count=1;
    string sub=s.substr(0,1);
    for(ll i=1;i<s.size();i++){
        string text=s.substr(a,i-a+1);
        if(sub==text) continue;
        else{
            count++;
        }
        sub=text;
        a=i+1;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, sum;
  cin >> N;
  int l[N],r[N];
  
  sum = 0;

  for (i = 0; i < N; i++) {
    cin >> l[i] >> r[N];
    sum += abs(r[N] - l[i] + 1);
  }
  
  cout << sum << endl;

}

Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc129/tasks"

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.lang.Math;

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

        int n = in.nextInt();
        int i;
        ArrayList<Integer> V = new ArrayList<>();
        for(i=0;i!=n;i++)
            V.add(in.nextInt());

        int s1,s2;
        s1 = s2 = 0;
        for(i=0;i!=n;i++)
            s2 += V.get(i);
        int m = s2;
        for(i=0;i!=n;i++) {
            m = Math.min(m,Math.abs(s2-s1));
            s1 += V.get(i);
            s2 -= V.get(i);
        }

        m = Math.min(m,Math.abs(s2-s1));

        System.out.print(m);
    }
}


Measured memory_bytes: 23764
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()

    val ansList = mutableListOf<Int>()
    
    val case1 = a * x + b * y
    ansList.add(case1)

    val case2 = c * Math.max(x, y) * 2
    ansList.add(case2)

    var case3: Int
    if (x > y) {
        case3 = (x - y) * a + 2 * y * c
    } else {
        case3 = (y - x) * b + 2 * x * c
    }
    ansList.add(case3)

    println(ansList.min())
}

Measured memory_bytes: 31392
#include <iostream>
using namespace std;
typedef long long ll;
ll n,k,ans,L,ans2;
string s;

int main(void){
    cin>>n>>k;
    cin>>s;
    L=s[0];
    ll cnt=0;
    for(int i=1;i<n;i++){
        if(L==s[i])cnt++;
        else {
            L=s[i];
            ans+=cnt;
            ans2++;
            cnt=0;
        }
    }
    ans+=cnt;
    ans2++;
    cout<<ans+min(2*k,ans2-1)<<endl;
    }


Measured memory_bytes: 512
pub fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    s.clear();
    let mut count: Vec<Vec<usize>> = vec![vec![0; 10]; 10];
    for i in 1..10 {
        for j in 1..10 {
            let mut cnt = 0;
            if i == j && i <= n {
                cnt += 1;
            }
            if i * 10 + j <= n {
                cnt += 1;
            }
            let mut pow_ten = 100;
            while i * pow_ten + j <= n {
                cnt += std::cmp::min(pow_ten / 10, (n - (i * pow_ten + j)) / 10 + 1);
                pow_ten *= 10;
            }
            count[i][j] = cnt;
        }
    }
    let mut ans = 0;
    for i in 1..10 {
        for j in 1..10 {
            ans += count[i][j] * count[j][i];
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n_a: usize = sc.read();
    let n_b: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<usize> = sc.vec(n_a);
    let b: Vec<usize> = sc.vec(n_b);

    let mut min = *a.iter().min().unwrap() + *b.iter().min().unwrap();
    for _ in 0..m {
        let x = sc.read::<usize>() - 1;
        let y = sc.read::<usize>() - 1;
        let c: usize = sc.read();
        let p = a[x] + b[y] - c;
        min = cmp::min(min, p);
    }
    println!("{}", min);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
#include<cstdio>
#include<algorithm>
using namespace std;

struct node{
	double val,money,per;
	bool operator<(const node &aa) const{
	  return per<aa.per;
	}
}a[12];
double q,h,s,d,n;long long ans=0;
int main(){
	scanf("%lf%lf%lf%lf",&q,&h,&s,&d);
	scanf("%lf",&n);
	a[1].val=0.25,a[1].money=q,a[1].per=q/0.25;
	a[2].val=0.5,a[2].money=h,a[2].per=h/0.5;
	a[3].val=1,a[3].money=s,a[3].per=s/1;
	a[4].val=2,a[4].money=d,a[4].per=d/2;
	sort(a+1,a+1+4);
	//for (int i=1;i<=4;i++)
	//  printf("%lf\n",a[i].per);
	for (int i=1;i<=4;i++)
	{
	  int k=(int)(n/a[i].val);
	  n-=k*a[i].val,ans+=(long long)a[i].money*k;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
X = lr()
remain = [[] for _ in range(M)]
for x in X:
    remain[x%M].append(x)

num = [0] * M
for i in range(M):
    num[i] = len(remain[i])

answer = 0
for i in range(M//2 + 1):
    if i == 0:
        answer += num[0] // 2
        num[0] %= 2
    elif i == (M-i):
        answer += num[i] // 2
        num[i] %= 2
    else:
        x = min(num[i], num[M-i])
        answer += x
        num[i] -= x; num[M-i] -= x

for i in range(M):
    counter = Counter(remain[i])
    pair = 0
    for v in counter.values():
        pair += v//2
    answer += min(pair, num[i] // 2)

print(answer)
# 17

Measured memory_bytes: 19804
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 800 + 10;
int N, M, K;
int A[Maxn][Maxn], sx, sy;
inline int safe_read()
{
	char ch = getchar();
	while (ch != '#' && ch != '.' && ch !='S')ch = getchar();
	if (ch == '#') return 1;
	if (ch == '.') return 0;
	return 2;
}
struct node
{
	int x, y, t;
};
queue <node> q;
int main()
{
	scanf("%d%d%d", &N, &M, &K);
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
		{
			A[i][j] = safe_read();
			if (A[i][j] == 2)sx = i, sy = j;
		}
	q.push((node){sx, sy, 0});
	int fl = 0;
	A[sx][sy] = 0;
	while (!q.empty())
	{
		node a = q.front();
		q.pop();
		if (a.x < 1 || a.y < 1 || a.x > N || a.y > M || a.t == (K + 1) || A[a.x][a.y]){continue;}
		if (a.x == 1 || a.y == 1 || a.x == N || a.y == M)fl = 1;
		A[a.x][a.y] = 2;
		q.push((node){a.x + 1, a.y, a.t + 1});
		q.push((node){a.x - 1, a.y, a.t + 1});
		q.push((node){a.x, a.y + 1, a.t + 1});
		q.push((node){a.x, a.y - 1, a.t + 1});
	}
	if (fl)
	{
		cout<<1<<endl;
		return 0;
	}
	int Ans = 0x3f3f3f3f, ai, aj;
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
			if (A[i][j] == 2)
			{
				int cnt = min(min(i - 1, j - 1), min(N - i, M - j));
				int sum = (cnt + K - 1) / K + 1;
				if (sum < Ans)
					Ans = sum, ai = i, aj = j;
			}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 2816
#include <algorithm>
#include <cstddef>
#include <functional>
#include <initializer_list>
#include <vector>
using namespace std;
template <typename T> class SegmentTree {
  using F = std::function<T(T, T)>;

private:
  F operation; // 葉ノード更新時処理、区間に対する処理
  T e;         // 単位元
  vector<T> data;
  size_t n;

  void init(int n_) {
    n = 1;
    while (n < n_)
      n *= 2;
    data.resize(n * 2, e);
  }

public:
  SegmentTree(size_t N, T e, F operation) : e(e), operation(operation) {
    init(N);
  }

  template <typename Ite>
  SegmentTree(size_t N, T e, F operation, Ite start, Ite end)
      : e(e), operation(operation) {
    init(N);
    build(start, end);
  }
  template <typename Ite> void build(Ite start, Ite end) {
    for (auto i = start; i < end; i++) {
      int idx = i - start + n;
      data[idx] = *i;
    }
    for (int i = n - 1; i > 0; i--) {
      data[i] = operation(data[2 * i], data[2 * i + 1]);
    }
  }

  void set_val(int idx, T x) {
    // idxの値をxに更新
    data[idx += n] = x;
    while (idx /= 2)
      data[idx] = operation(data[2 * idx], data[2 * idx + 1]);
  }

  T query(size_t a, size_t b) {
    // [a,b)の処理
    T vl = e, vr = e;
    for (int l = a + n, r = b + n; l < r; l /= 2, r /= 2) {
      if (l % 2)
        vl = operation(vl, data[l++]);
      if (r % 2)
        vr = operation(data[--r], vr);
    }
    return operation(vl, vr);
  }

  const T &operator[](size_t idx) { return data[idx + n]; }
};

// verify with AOJ DSL_2_A
#include <iostream>
using ll = long long;
int main() {
  int n, q;
  cin >> n >> q;
  auto st =
      SegmentTree<ll>(n, (1ll << 31) - 1, [](ll a, ll b) { return min(a, b); });
  for (int i = 0; i < q; i++) {
    ll com, a, b;
    cin >> com >> a >> b;
    if (com == 0)
      st.set_val(a, b);
    else
      cout << st.query(a, b + 1) << '\n';
  }
}



Measured memory_bytes: 4956
#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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    char c;
    vector<int> alp(26);
    while (cin>>c) {
        if (islower(c)) alp[c - 'a']++;
        else if (isupper(c)) alp[c - 'A']++;
    }

    rep(i, 26) {
        cout<<(char)('a' + i)<<" : "<<alp[i]<<endl;
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair


const int mod = 1e9+7;

inline int add(int a,int b){a+=b;if(a>=mod)a-=mod; return a;} 
inline int sub(int a,int b){a-=b;if(a<0) a += mod; return a;}
inline int mul(int a, int b){ return a*1ll*b%mod;}
inline int power(int x, ll y){
  int res = 1;
  while(y){
    if(y&1) res = mul(res , x);
    x = mul(x,x);
    y >>= 1;
  }
  return res;
}

int main(){
  fio; cout<<fixed<<setprecision(25);	
  ll n , x; cin >> n >> x;
  cout << 3ll*(n - __gcd(n,x)) << endl; 
  return 0;
}









Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pr pair<int, int>
#define v1d vector<int>
#define mp make_pair
#define pb push_back
#define v1p vector<pr>
#define vb vector<bool>
#define v2d vector<vector<int>>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define S(v) sort(v.begin(), v.end())
#define RS(v) sort(v.rbegin(), v.rend())
#define eb emplace_back
#define endl "\n"
#define MOD 1000000007
#define pqx priority_queue <int>
#define pqn priority_queue <int, v1d, greater<int> >
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

int solve(int k) {
    int lo = 1, hi = k;
    int ans = 1;
    while(lo <= hi) {
        int m = (lo + hi) >> 1;
        int x = (m * m + m) / 2;
        if(x <= k) {
            ans = m;
            lo = m + 1;
        }
        else {
            hi = m - 1;
        }
    }
    return ans;
}

int32_t main() {
    fio
    int n; cin >> n;
    if(n == 1) {
        cout << 0; return 0;
    }
    int ans = 0;
    for(int i=2; i * i <= n; ++i) {
        int cnt = 0;
        while(n % i == 0) {
            ++cnt;
            n /= i;
        }
        if(cnt) {
            ans += solve(cnt);
            // cout << cnt;
        }
    }
    if(n > 1) {
        ans++;
    }
    cout << ans;

}

Measured memory_bytes: 3688
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int a, b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;

  return 0;
}


Measured memory_bytes: 256
import fractions
a, b, c, d = map(int, input().split())

f = (c * d) // fractions.gcd(c, d)

ret_b = b - (b // c + b // d - b // f)
ret_a = (a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // f)
ans = ret_b - ret_a
print(ans)


Measured memory_bytes: 5048
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

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

  int ans = 0;
  while (1) {
    string T;
    cin >> T;
    if (T == "END_OF_TEXT") {
      break;
    }

    for (int i = 0; i < T.size(); i++) {
      T[i] = tolower(T[i]);
    }

    if (W == T) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3172
N,K=map(int, input().split())
if K%2==1:
    print((N//K)**3)
else:
    modKp2 = 0
    for i in range(1, N+1):
        if i%K==K//2:
            modKp2+=1
    print((N//K)**3+modKp2**3)

Measured memory_bytes: 39408
from collections import deque

n = int(input())
adj = [[] for _ in range(n)]

for i in range(n):
  u,k,*v = map(int, input().split())
  v = [w-1 for w in v]
  adj[u-1].extend(v)

queue = deque([0])
ans = [-1] * n
ans[0] = 0

while queue:
  now = queue.popleft()
  
  for u in adj[now]:
    if ans[u] < 0:# 未訪問
      ans[u] = ans[now] + 1
      queue.append(u)

for i in range(n):
  print(i+1,ans[i])


Measured memory_bytes: 6032
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a%2==b%2==c%2==0) cout<<0<<endl;
	else cout<<min(b*c,min(a*c,a*b))<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  N,D,A = map(int,input().split())
  XH = [list(map(int,input().split())) for _ in range(N)]
  XH = sorted(XH)
  ans = 0
  S = [0]*(N+1)
  x = XH[0][0]
  h = XH[0][1]
  j = 0
  b = (h+A-1)//A
  ans += b
  y = b*A
  while True:
    if j+1>=N:
      break
    if XH[j+1][0]<=x+2*D:
      j+=1
    else:
      break
  S[0]+=y
  S[j+1]-=y
  S[1]+=S[0]
  for i in range(1,N):
    xh = XH[i]
    h = xh[1]
    s = S[i]
    rec = h-s
    if rec<=0:
      S[i+1]+=s
      continue
    else:
      x = xh[0]
      j = max(j,i)
      while True:
        if j+1>=N:
          break
        if XH[j+1][0]<=x+2*D:
          j+=1
        else:
          break
      b = (rec+A-1)//A
      ans += b
      y = b*A
      S[i]+=y
      S[j+1]-=y
      S[i+1]+=s+y
  print(ans)
main()

Measured memory_bytes: 59736
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a, b, x;
    
    a = sc.nextInt();
    b = sc.nextInt();
    x = (a + b) / 2;
    if((a + b) % 2 != 0) {
      x += 1;
    }
    System.out.println(x);
  }
}


Measured memory_bytes: 24916
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n,k = inp
ans = 0
nowc = n+1
nowt = n
nowd = 0
n.times do |i|
  if(i >= k-1)
    ans += nowc
  end
  nowt += (n-i-1)
  nowd += (i+1)
  nowc = nowt -nowd+1
  ans %= (10**9+7)
end
ans += nowc
p ans % (10**9+7)

Measured memory_bytes: 14376
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <bits/stdc++.h>

using namespace std;

class DUnbalanced {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        string s;
        cin >> s;
        for (int i = 0; i < s.size() - 2; ++i) {
            string tmp = s.substr(i, 3);
            set<char> set_s;
            for (const auto &ch : tmp) {
                set_s.insert(ch);
            }
            if (set_s.size() <= 2) {
                cout << i + 1 << " " << i + 3 << endl;
                return;
            }
        }
        if (s[0] == s[1]) {
            cout << 1 << " " << 2 << endl;
        } else {
            cout << -1 << " " << -1 << endl;
        }

    }
};


int main() {
	DUnbalanced solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
String input()=>process.readLine()else""; 
Integer int(String s)=>parseInteger(s)else 0;
shared void main(){
  Array<String>s=Array.ofSize(50,"");
  Array<Integer>t=Array.ofSize(50,0);
  Integer n=int(input());
  for(i in 0:n){
    {String+}st=input().split();
    s.set(i,st.first);
    t.set(i,int(st.last));
  }
  variable Integer a=0;
  for(i in(s.firstIndexWhere(input().equals)else 0)+1..n){
    a+=t[i]else 0;
  }
  print(a);
}


Measured memory_bytes: 191552
#include <cstdio>
#include <cctype>


int main(){
    char ch;
    
    while(1){

        scanf("%c", &ch);
        if (ch == '\n') break;

        if(isalpha(ch)){
            if (islower(ch)){
                printf("%c", toupper(ch));
            } else{
                printf("%c", tolower(ch));
            }
        } else printf("%c", ch);
        
    }
    printf("%c", '\n');
    
    return 0;
}


Measured memory_bytes: 2688
def main():
    S = str(input())
    longest = 0
    if len(S) < 2:
        if S == 'A' or S == 'G' or S == 'C' or S == 'T':
            print(1)
            return
        else:
            print(0)
            return
    for i in range(len(S)):
        cnt = 0
        loop = 0
        t = 0
        while cnt == 0 and loop + i < len(S):
            if S[loop + i] == 'A' or S[loop + i] == 'G' or S[loop + i] == 'C' or S[loop + i] == 'T':
                t += 1
                if longest < t:
                    longest = t
                loop += 1
            else:
                cnt = 1
    print(longest)
main()

Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
int n,v,l[200005],b,e;
int main(){
    cin>>n;
    b=ceil((double)(n+1)/2);
    e=(n%2==0)?(-1):(1);
    for(int i=1;i<=n;i++){
        cin>>v;
        l[b]=v;
        b+=i*e;
        e*=-1;
    }
    for(int i=1;i<=n;i++)
    cout<<l[i]<<" ";
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

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

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

int main(){
    ll n,ans = 1;
    cin >> n;
    rep(i,0,n){
        ll a;
        cin >> a;
        ans = lcm(ans,a);
    }

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



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long 
using namespace std ;
const int  mod = 1e9+7 ; 
char a[3005][3005] ;  
int dp[3005][3005] ; 
int  no_of_path(int n , int m ){
		if(n == 0  && m == 0) {
			 return  1 ; 
		 }
          
          if(dp[n][m] != -1)
             return dp[n][m] ; 
              ll ans = 0 ;
		  if(m > 0 && a[n][m-1] == '.'){
			  ans = (ans +  no_of_path(n , m-1))%mod ; 
			}
			if(n > 0 && a[n-1][m] == '.')
		     ans = (ans +  no_of_path(n -1  , m))%mod ; 
			
      dp[n][m] =  ans%mod ; 
      return ans%mod ; 
  }
	
int main(){
	int n , m ;
	cin>> n >> m ; 
	for(int i = 0 ; i < n; ++i){
		for (int j = 0 ; j < m ; ++j)
		cin>>a[i][j] ; 
	}
	memset(dp , -1 , sizeof dp) ; 
	cout<<no_of_path(n - 1 , m - 1)<<endl ; 
		//cout<<ans%mod ;
		
	}
		


Measured memory_bytes: 39296
/**
 *  author: mahfuzz
 *  created: 27.12.2019
**/
 
#include <iostream>
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n; cin >> n;
    string s, t; cin >> s >> t;
    
    for(int i = 0; i < n; i++){
        cout << s[i] << t[i];
    }
    
    cout << "\n";
       
    return 0;
}

Measured memory_bytes: 256