akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

//const int N = ;
int a[66],n,k,s,t;ll C[66][66],all,res,ans[66];
ll b[66][4];int sz[66];
void dfs(int dep, ll all, int xs){
	if(dep>=18){
		res+=ans[__builtin_popcountll(all)]*xs;
		return;
	}
	dfs(dep+1,all,xs);
	rep(i,0,sz[dep]-1)dfs(dep+1,all&b[dep][i],-xs);
}
int main() {
	rep(i,0,62){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1)C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
	read(n);read(k);read(s);read(t);all=(1ll<<n)-1;
	rep(i,0,n)rep(j,1,k){
		ans[i]+=C[i][j];
	}
	rep(i,1,n)read(a[i]);
	rep(i,0,60){
		if(s>>i&1){
			rep(j,1,n)if(~a[j]>>i&1)all&=~(1ll<<j-1);
		}
		else{
			ll s=0;rep(j,1,n)s|=((ll)a[j]>>i&1)<<j-1;
			b[i][sz[i]++]=s;
		}
		if(t>>i&1){
			ll s=0;rep(j,1,n)s|=((ll)~a[j]>>i&1)<<j-1;
			b[i][sz[i]++]=s;
		}
		else{
			rep(j,1,n)if(a[j]>>i&1)all&=~(1ll<<j-1);
		}
	}
	dfs(0,all,1);cout<<res;
	return 0;
	
}


Measured memory_bytes: 3672
H, W, M = map(int, input().split())

rows = [0] * H
cols = [0] * W
s = set()
for _ in range(M):
    h, w = map(lambda x: int(x) - 1,input().split())
    rows[h] += 1
    cols[w] += 1
    s.add((h, w))

max_rows = max(rows)
max_cols = max(cols)

result = max_rows + max_cols - 1
max_rows_indexes = [i for i in range(H) if rows[i] == max_rows]
max_cols_indexes = [i for i in range(W) if cols[i] == max_cols]
for h in max_rows_indexes:
    for w in max_cols_indexes:
        if (h, w) not in s:
            result = max_rows + max_cols
            break
print(result)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  if (N <= 999) {
    cout << "ABC" << endl;
  } else {
    cout << "ABD" << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon {
    initon() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
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;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
int main()
{
    int n, k, a, an;
    cin >> n >> k;
    rep(i, k)
    {
        cin >> a;
        d[a] = 1;
    }
    while (!ans(n))
        n++;
    cout << n;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int get_numpair( int num );

int main(void)
{
	int num;

	for(;;)
	{
		cin >> num;
		if( cin.eof() ) break;
		cout << get_numpair(num) << endl;
	}

	return 0;
}

int get_numpair( int num )
{
	int numpair = 0;
	int pair[4];

	for( int i = 0 ; i <= 9999 ; i++ )
	{
		pair[3] = i/1000;
		pair[2] = (i%1000)/100;
		pair[1] = ((i%1000)%100)/10;
		pair[0] = ((i%1000)%100)%10;

		int sum = 0;
		for( int j = 0 ; j < 4 ; j++ )
		{
			sum += pair[j];
		}
		if( sum == num ) numpair ++;
	}

	return numpair;
}

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


ll mod = 1000000007;
ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll com(ll a, ll b){
	ll res = 1;
	b = min(b, a-b);
	ll n = b;
	for(int i=0; i<n; i++){
    	res *= a;
    	if(res >= mod) res %= mod;
    	res *= modpow(b, mod-2);
    	if(res >= mod) res %= mod;
    	a--;
    	b--;
    }
	return res;
}

int main(){
    int x, y;
    cin >> x >> y;
    int sa = max(x, y) - min(x, y);
    int tz = min(x, y) -sa;
    if(tz%3 == 0 && tz >= 0){
        ll ans = com(tz/3*2+sa, tz/3);
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	REP(k, N) {
		vector<string> S(2);
		cin >> S[0] >> S[1];
		int cur = 1;
		int ans = 0;
		REP(i, 2) {
			REP(j, SZ(S[i])) {

				switch (S[i][j]) {
				case 'm':
					cur *= 10;
				case 'c':
					cur *= 10;
				case 'x':
					cur *= 10;
				case 'i':
					ans += cur;
					cur = 1;
					break;
				default:
					cur = S[i][j] - '0';
				}
			}
		}
		string SA = "";
		int r = 10000;
		char c[] = { 'm','c','x','i' };
		REP(i, 4) {
			ans %= r;
			r /= 10;
			if (ans / r == 0)continue;
			else if (ans / r != 1)SA += (char)('0' + (ans / r));
			SA += c[i];
		}
		cout << SA << endl;
	}
	return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll r, g, b, n;
	cin >> r >> g >> b >> n;

	ll ans = 0;
	for (ll rr = 0; rr <= n; rr += r) {
		for (ll gg = 0; gg <= n; gg += g) {
			ll bb = n - (rr + gg);

			if (bb < 0LL || bb > n || (bb % b != 0LL)) {
				continue;
			}

			ll score = rr + gg + bb;
			ans += (score == n);
		}
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    SegmentTree<int> seg(n, [](int a, int b){return min(a, b);}, INF);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        seg.set(i, a[i]);
    }
    seg.build();
    
    vector<int> dp(n);
    dp[0] = 0;
    int maxsales = 0;
    for(int i = 1; i < n; ++i){
        int foo = seg.query(0, i);
        dp[i] = max(0, a[i] - foo);
        chmax(maxsales, dp[i]);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(dp[i] == maxsales)   ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include<string>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
//#include <vector.h>
//#include <malloc.h>

#include <math.h>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
long long store[100009];

  
void fun(){
    for(int i=2;i<=100001;i++){
        store[i] = (i*(i-1))/2;
    }
}
int upperBound(int n,int key){
    int s =2,e=n;
    int ans = -1;

    while(s<=e){
        int mid = (s+e)/2;
        if(s==e){
            ans=s;
            break;
        }

        if(store[mid]==key){
            ans = mid+1;
            s = mid+1;
            break;
        }
        else if(store[mid]>key){
            e = mid - 1;
        }
        else{
            s = mid + 1;
        }
    }

    return ans;
}

int main(){
    int t,a,b;
    cin>>t>>a>>b;
    cout<<b<<" "<<t<<" "<<a<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int datanum;
    cin >> datanum;
    rep(d, datanum) {
        string a, b;
        cin >> a >> b;

        int aLen = a.length();
        int bLen = b.length();

        int dp[aLen + 1][bLen + 1];
        rep(i, aLen + 1) {
            dp[i][0] = 0;
        }
        rep(i, bLen + 1) {
            dp[0][i] = 0;
        }

        rep(i, aLen) {
            rep(j, bLen) {
                if (a[i] == b[j]) {
                    dp[i+1][j+1] = std::max(std::max(dp[i+1][j], dp[i][j+1]), dp[i][j] + 1);
                } else {
                    dp[i+1][j+1] = std::max(dp[i+1][j], dp[i][j+1]);
                }
            }
        }

        cout << dp[aLen][bLen] << endl;
    }
}


Measured memory_bytes: 7140
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		if (x % y == 0) {
			System.out.println(-1);
			return;
		}
		long a = gcd(x, y);
		System.out.println(x / a * y - x);
	}
	
	static long gcd(long a, long b) {
		if (a % b == 0) {
			return b;
		} else {
			return gcd(b, a % b);
		}
	}
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for (int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
template <typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T sqr(const T &a) { return a * a; }
typedef long long LL;
typedef long double LD;
void procStatus() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}
LL read() {
	LL x = 0, flag = 1;
	char ch = getchar();
	for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}
void write(LL x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) write(x / 10);
	putchar(x % 10 + '0');
}

const int Maxn = 5e5 + 9, Mod = 998244353;
int mmul(int a, int b){
    int ret;
    __asm__ __volatile__ ("\tmull %%ebx\n\tdivl %%ecx\n":"=d"(ret) : "a"(a), "b"(b), "c"(Mod));
    return ret;
}
int mplus(int a, int b) {
	a += b;
	if (a >= Mod) a -= Mod;
	return a;
}
int fpm(int base, int tims) {
	int r = 1;
	for (; tims; base = mmul(base, base), tims >>= 1) 
		if (tims & 1) r = mmul(r, base);
	return r;
}
int fac[Maxn], inv[Maxn], invFac[Maxn];

void Init() {
	fac[0] = 1;
	rep (i, 1, Maxn - 1) fac[i] = mmul(fac[i - 1], i);
	inv[1] = 1;
	rep (i, 2, Maxn - 1) inv[i] = mmul(inv[Mod % i], Mod - Mod / i);
	invFac[0] = 1;
	rep (i, 1, Maxn - 1) invFac[i] = mmul(invFac[i - 1], inv[i]);
}

int C(int n, int m) {
	if (n < m || n < 0 || m < 0) return 0;	
	return mmul(fac[n], mmul(invFac[n - m], invFac[m]));
}

int n, m;
int f(int k) {
	return mmul(C(n, k), mmul(C(m, k), mmul(fac[k], mmul(fpm(n + 1, m - k), fpm(m + 1, n - k)))));
}

void Solve() {
	n = read(), m = read();
	int ans = 0;
	rep (k, 0, min(n, m)) {
		int coef = (k & 1) ? (Mod - 1) : 1;
		ans = mplus(ans, mmul(coef, f(k)));
	}
	cout << ans << endl; 
}

int main() {
//	freopen("bosky.in", "r", stdin);
//	freopen("bosky.out", "w", stdout);

	Init();
	Solve();	

#ifdef Qrsikno
//	procStatus();
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return 0;
}


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

int main() {
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  vector<vector<int>> gr(H,vector<int>(W,0));
  for (int i=0; i < H; i++) {
    for (int j=0; j < W; j++) {
      gr.at(i).at(j) = ((i < B && j < A) || (i >= B && j >= A) ? 0 : 1);
    }
  }
  for (int i=0; i < H; i++) {
    for (int j=0; j < W; j++) {
      cout << gr.at(i).at(j);
        if (j == W - 1)  cout << endl;
    }
  }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;

int main() {
    char b;
    cin >> b;
    if (b == 'A') PRINT('T');
    if (b == 'T') PRINT('A');
    if (b == 'C') PRINT('G');
    if (b == 'G') PRINT('C');
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef map<ll,ll> M;

#define REP(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define FOR(i,j,n) for(ll (i) = (j); (i) < (n); ++(i))
#define REPR(i,n) for(ll (i) = (n); (i) >= 0; --i))


signed main(){
    int w,h;
    string c;
    cin >> w >> h>> c;
    REP(i,h){
        REP(j,w){
            if(i * 2 + 1 == h && j * 2 + 1 == w)
                cout << c;
            else if((i == 0 || i == h - 1) && (j == 0 || j == w - 1))
                cout << "+";
            else if(i == 0 || i == h - 1)
                cout << "-";
            else if(j == 0 || j == w - 1)
                cout << "|";
            else
                cout << ".";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3168
tmp = input()
userInps = tmp.split()

tmp = input()
times = tmp.split()

total = 0


def check(i):
	# tmp = int(userInps[0])

	if int(userInps[1]) > int(times[i]) - int(times[i-1]):
		# total += (int(times[i]) - int(times[i-1]))
		n = (int(times[i]) - int(times[i-1]))
		# print(times[i-1])
		# print(times[i-2])
		# print(1)


	else:
		# total += int(userInps[0])
		n = int(userInps[1])
		# print(2)

	# print(n)
	return n	


for x in range(1,int(userInps[0])):
	# print(x)
	total += check(x)



total += int(userInps[1])
print(total)



Measured memory_bytes: 19344
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main(){
    string s;
    cin >> s;
    map<char, int> mp;
    for (char str:s){
        mp[str]++;
    }
    bool beautiful = true;
    for (auto x:mp){
        if (x.second % 2 != 0) beautiful = false;
    }
    if (beautiful) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007

using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	string a,b;
	cin>>a>>b;
	ll ans=0;
	for(ll i=0;i<3;i++)
	{
		if(a[i]==b[i])
			ans++;
	}
	cout<<ans;
}

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

int main(){
    long N;
    cin >> N;
    if(N % 2 == 1){
        cout << 0 << endl;
    }else{
        long cnt = 0;
        long tmp1 = 5;
        long x = N/2;
        while(x > 0){
            cnt += long(x/tmp1);
            x = x/tmp1;
        }
        cout << cnt << endl;
    }
    return(0);
}

Measured memory_bytes: 256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

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

    vector<ll> a(n);

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

    vector<ll> pref(n);

    pref[0] = a[0];

    for(int i = 1; i < n; i++)
    {
        pref[i] = pref[i - 1] + a[i];
        pref[i] %= MOD;
    }

    ll ans = 0;

    for(int i = 0; i < n; i++)
    {
        ll diff = pref[n - 1] - pref[i];
        diff %= MOD;
        diff += MOD;
        diff %= MOD;
        
        ans += (a[i] * diff) % MOD;
        ans %= MOD;
    }

    cout << ans << "\n";
    
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}




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

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

    int W, H, x, y, r;
    bool b = true;
    cin >> W >> H >> x >> y >> r;

    if(x + r > W or x + r < 0 or x - r < 0){
        b = false;
    }
    if(y + r > H or y + r < 0 or y - r < 0){
        b = false;
    }
    
    if(b == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>

int main(){
    int a;
    scanf("%d",&a);
            int res = 1;

    for(int i = 0; i<a;i++){
        int n;
        scanf("%d",&n);
        if(n%2==0){
            if(n%3==0 || n%5==0){
            }
            else{
                res=0;
            }
        }
    }
    if(res==0){
        printf("DENIED");
    }
    else{
        printf("APPROVED");
    }
}

Measured memory_bytes: 128
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    X = list(map(int, readline().split()))
    sort_X = sorted(X)
    if N%2==0:
        med_l = sort_X[N//2-1]
        med_r = sort_X[N//2]
        for i in range(N):
            if X[i]<=med_l:
                print(med_r)
            else:
                print(med_l)
    else:
        l = sort_X[N//2-1]
        m = sort_X[N//2]
        r = sort_X[N//2+1]
        for i in range(N):
            if X[i]<=l:
                print((m+r)/2)
            elif X[i]==m:
                print((l+r)/2)
            else:
                print((l+m)/2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21924
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
#define display(v) f(v.size())cout << v[i] << " "
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ll n;   cin>>n;
   map<ll,ll> m;
   ll arr[n];   f(n){cin>>arr[i];m[arr[i]]++;}
   ll ans = 0;
   for(auto it : m)
   {
      ans = ans + ((it.ss) * (it.ss -1 ))/2;
   }
   for(int i =0;i<n;i++)
   {
      if(m[arr[i]] == 1)cout << ans <<"\n";
      else
      {
         ll x = m[arr[i]] ; ll v1 = (x*(x-1))/2;
         ll y = m[arr[i]] - 1;  ll v2 = (y*(y-1))/2;
         cout << ans - v1 + v2 << "\n";

      }
      
   }



   return 0;
}     

Measured memory_bytes: 11136
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll A(N + 1), B(N);
    REP(i, N + 1) cin >> A[i];
    REP(i, N) cin >> B[i];

    ll ans = 0;
    REP(i, N) {
        ll cur = min(B[i], A[i]);
        ans += cur;

        ll nxt = min(A[i+1], B[i] - cur);
        ans += nxt;
        A[i+1] -= nxt;
    }

    print(ans);
    
}


Measured memory_bytes: 4780
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  int key;
  struct node *right,*left,*parent;
};
typedef struct node * Node;

void prerder(Node);
void insert(int);
void inorder(Node);
Node root = NIL;

void insert(int k){
struct node *y=NIL;
struct node *x=root;
struct node *z;

z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;

  while( x != NIL ){
    y = x;
    if( z->key < x->key ) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if( y == NIL ){
    root = z;
  }
  else if( z->key < y->key ){
    y->left = z;
  }
  else y->right = z;
}

void inorder(Node z){
 if(z==NIL)return;
  inorder(z->left);
  printf(" %d",z->key);
  inorder(z->right);
}

void preorder(struct node *z){
  if(z==NIL)return;
  printf(" %d",z->key);
  preorder(z->left);
  preorder(z->right);
}
int main(void){
  int m;
  int i;
  int f;
  int q;
  char cf[82];
  scanf("%d", &m);
  i = 0;
  while(i < m ){
  	
    scanf("%s", cf);
    if ( cf[0] == 'i' ){
      scanf("%d", &f);
      insert(f);
    }

    else if ( cf[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
     i++;
  }
  
  return 0;
}


Measured memory_bytes: 25132
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    int n; cin >> n;
    vector<int>v(n);
    rep(i,n) cin >> v[i];
    vector<int>ans;
    map<int,int>s;
    map<int, int>t;
    string a,b;
    rep(i,n){
        s[v[i]]++;
        t[v[n-i-1]]++;
          if(s == t)ans.push_back(i);
        
    }
    if(ans.size()){
        rep(i,ans.size()){
            if(i){
                cout << " ";
            }
            cout << ans[i]+1;
        }
    }else{
        cout << 0;
    }
    cout<<endl;
}



Measured memory_bytes: 9984
import math
X = int(input())
i_max = math.floor(math.sqrt(X))

result = 1
for i in range(2,i_max+1,1):
    for j in range(1,X):
        n = (i**j)
        if (n > X):
            break
        else:
            result = max(result, n)

print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    while(cin>>N, N){
        vector<vector<int>> edge(N, vector<int>(N+1));
        vector<int> dp(1<<N, INF);
        dp[0] = 0;
        
        for(int i=0; i<N; i++)
            for(int j=0; j<N+1; j++)
                cin >> edge[i][j];
        
        for(int i=1; i<1<<N; i++){
            for(int j=0; j<N; j++){
                if((i>>j)&1){
                    int d = edge[j][0];
                    for(int k=0; k<N; k++)
                        if(k != j && (i>>k)&1)
                            d = min(d, edge[j][k+1]);
                    dp[i] = min(dp[i], dp[i- (1<<j)] + d);
                }
            }
        }
        cout << dp[(1<<N)-1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1484
/*=======================
Author    : Shounak Dey
Filename  : d.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

#define MOD 1000000007

int main()
{
	fast_io;
	ll n;
	cin >> n;
	vector<ll> c(70,0);
	REP(i,n){
		ll x;
		cin >> x;
		ll pos=0;
		while(x){
			c[pos] += x&1;
			x >>= 1;
			pos++;
		}
	}
	ll ans=0;
	ll curr=1;
	REP(i,70){
		ll tmp = (n-c[i])*c[i] % MOD;
		tmp = (tmp * curr)%MOD;
		ans = (ans + tmp)%MOD;
		curr = (curr*2)%MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = gets.chomp.split(" ").map(&:to_i)
AB = []
N.times do |i|
  AB << gets.chomp.split(" ").map(&:to_i)
end

ans = 0
mm = 0
AB.sort_by {|v| v[0] }.each do |v|
  m = [v[1], M - mm].min
  ans += v[0] * m
  mm += m
  break if mm >= M
end
puts ans


Measured memory_bytes: 12664
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	int n,q,opt,t,x;
	cin >> n >> q;
	priority_queue<int,vector<int>,less<int> > pq[n];
	while (q--)
	{
		cin >> opt;
		if (opt==0)
		{
			cin >> t >> x;
			pq[t].push(x); 
		}
		if (opt==1)
		{
			cin >> t;
			if (!pq[t].empty())
			cout << pq[t].top() << endl;
		}
		if (opt==2)
		{
			cin >> t;
			if (!pq[t].empty())
			pq[t].pop();
		}
	}
	return 0;
}


Measured memory_bytes: 4100
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def gcd(n, m):
  while m:
    n, m = m, n%m
  return n

def main():
    a, b = na()

    print(a * b // gcd(a, b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N, M = map(int, input().split())
ABs = []
for i in range(N):
    A, B = map(int, input().split())
    ABs.append([A, B])

ABs.sort(key=lambda x: x[0])

ans = 0
num = 0
i = 0
while True:
    if num + ABs[i][1] >= M:
        ans += (M - num) * ABs[i][0]
        break
    ans += ABs[i][1] * ABs[i][0]
    num += ABs[i][1]
    i += 1

print(ans)

Measured memory_bytes: 21224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << arr[k-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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 n;

void dfs(ll x,int a,int b,int c,int &res) {
	if(x>n) return;
	if(a&&b&&c) res++;
	dfs(x*10+7,1,b,c,res);
	dfs(x*10+5,a,1,c,res);
	dfs(x*10+3,a,b,1,res);
}

int main() {
	cin >> n;
	int ans = 0;
	dfs(0,0,0,0,ans);
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
    int N;cin >> N;
    int tmp;
    int size = N + 1;
    vector<int> bucket(size);
    rep(i,101){
        rep(j,101){
            rep(k,101){
                tmp = i*i + j*j + k*k + i*j +j*k + i*k;
                if ((tmp > 1) && (tmp <= 10000)){
                    bucket[tmp]++;
                }
            }
        }
    }
    rep(i,N+1){
        cout << bucket[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cstring>
#include <map>
using namespace std;

int X, Y, n;
int id[15], k[15];
int sx[16], sy[16];
int bd[10][10];

vector<pair<int,int> > area[101];
int ans[10][10];

int dfs(int u) {
	if (u == n) {
		memcpy(ans, bd, sizeof ans);
		return 1;
	}
	int h, w, tx, ty, lx, rx, uy, dy;
	tx = sx[id[u]];
	ty = sy[id[u]];
	bd[ty][tx] = 0;
	int ret = 0;
	for (int i=0; i<(int)area[k[u]].size(); ++i) {
		h = area[k[u]][i].first;
		w = area[k[u]][i].second;
		lx = max(tx-w+1, 0);
		rx = min(tx+w-1, X-1);
		uy = max(ty-h+1, 0);
		dy = min(ty+h-1, Y-1);
		if (rx-lx+1 < w || dy-uy+1 < h) continue;
		for (int y=uy; y+h-1<=dy; ++y) {
			for (int x=lx; x+w-1<=rx; ++x) {
				bool ok = true;
				for (int y2=y; y2<y+h && ok; ++y2) {
					for (int x2=x; x2<x+w; ++x2) {
						if (bd[y2][x2] != 0) {
							ok = false;
							break;
						}
					}
				}
				if (ok) {
					for (int y2=y; y2<y+h; ++y2) {
						for (int x2=x; x2<x+w; ++x2) {
							bd[y2][x2] = id[u];
						}
					}
					ret += dfs(u+1);
					for (int y2=y; y2<y+h; ++y2) {
						for (int x2=x; x2<x+w; ++x2) {
							bd[y2][x2] = 0;
						}
					}
					if (2 <= ret) return 2;
				}
			}
		}
	}
	bd[ty][tx] = id[u];
	return ret;
}

int main() {
	for (int i=1; i<=10; ++i) {
		for (int j=1; j<=10; ++j) {
			area[i*j].push_back(make_pair(i, j));
		}
	}
	while (cin >> X >> Y >> n, X) {
		int sum = 0;
		for (int i=0; i<n; ++i) {
			cin >> id[i] >> k[i];
			sum += k[i];
		}
		for (int i=0; i<Y; ++i) {
			for (int j=0; j<X; ++j) {
				cin >> bd[i][j];
				if (bd[i][j] != 0) {
					sx[bd[i][j]] = j;
					sy[bd[i][j]] = i;
				}
			}
		}
		int res = dfs(0);
		if (X * Y != sum || res == 0 || 2 <= res) {
			cout << "NA\n";
		} else {
			for (int i=0; i<Y; ++i) {
				for (int j=0; j<X; ++j) {
					cout << (j == 0 ? "" : " ") << ans[i][j];
				}
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ","){
    if(v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for(int i=1;i<v.size();i++){
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

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

    vector<int> s(N);

    rep(i,N){
        if(S[i]=='R')
            s[i] = 0;
        else if(S[i]=='G')
            s[i] = 1;
        else
            s[i] = 2;
    }

    vector<vector<ll>> sum(3, vector<ll>(N + 1 , 0));

    rep(i,N){
        rep(c,3){
            sum[c][i + 1] = sum[c][i];
            if(c == s[i])
                sum[c][i + 1]++;
        }
    }

//    cerr << join(sum[0]) << endl;
//    cerr << join(sum[1]) << endl;
//    cerr << join(sum[2]) << endl;

    ll ans = 0;
    rep(i, N) FOR(j, i+1, N)
    {
        if(s[i] == s[j])
            continue;

        vector<bool> b(3,true);
        b[s[i]] = false;
        b[s[j]] = false;
        
        char x = b[0]? 0 : b[1]?1 : 2;

        ans += sum[x][N] - sum[x][j + 1];

        int k = j - i;
        if(j+k < N)
            ans -= sum[x][j + k + 1] - sum[x][j + k];

    }

    cout << ans << endl;
}


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

namespace std {
	#define u(x, a, b) for(ll x = a; x < b; x++)
	#define d(x, a, b) for(ll x = a; x > b; x--)
}

typedef long long ll;
typedef long double ld;

ll MOD = 1000000007;

ll modpow(ll a, ll b){
    if(b == 0){
        return 1;
    }
    else if(b%2 == 1){
        b--;
        b/=2;
        ll x = modpow(a, b);
        x = x*x;
        x = x%MOD;
        x = x*a;
        x = x%MOD;
        return x;
    }
    else{
        ll x = modpow(a, b/2);
        x = x*x;
        x = x%MOD;
        return x;
    }
}

ll solve(ll n, ll val){
	ll tp = n, cnt = 0;
	while(tp>0){
		if(tp%2){cnt++;}
		tp-=(tp%2);
		tp/=2;
	}
	if(cnt == 0){return val;}
	else{return solve(n%cnt, val+1);}
}

int main(){
	
	ll n;
	string x;
	cin >> n >> x;
	
	ll pc = 0;
	u(one, 0, n){if(x[one]=='1'){pc++;}}
	
	if(pc==0 || pc==1){
		
		//only two possible pc vals
		ll m_pc_plus = 0;
		u(one, 0, n){
			ll c = n-1-one;
			
			if(x[c]=='1'){
				MOD = pc+1;
				m_pc_plus += modpow(2, one);
				m_pc_plus %= MOD;
				
			}
		}
		
		u(one, 0, n){
			//currently change the n-1-oneth bit
			if(x[one]=='1'){
				cout << 0 << endl;
			}
			else{
				MOD = pc+1;
				m_pc_plus += modpow(2, n-1-one);
				m_pc_plus += MOD;
				m_pc_plus %= MOD;
				
				cout << solve(m_pc_plus, 1) << endl;
				
				m_pc_plus -= modpow(2, n-1-one);
				m_pc_plus += MOD;
				m_pc_plus %= MOD;
			}
		}
		
		
		
	}
	else{
		//only two possible pc vals
		ll m_pc_min = 0, m_pc_plus = 0;
		u(one, 0, n){
			ll c = n-1-one;
			
			if(x[c]=='1'){
				MOD = pc-1;
				m_pc_min += modpow(2, one);
				m_pc_min %= MOD;
				MOD = pc+1;
				m_pc_plus += modpow(2, one);
				m_pc_plus %= MOD;
				
			}
		}
		
		u(one, 0, n){
			//currently change the n-1-oneth bit
			if(x[one]=='1'){
				MOD = pc-1;
				m_pc_min -= modpow(2, n-1-one);
				m_pc_min += MOD;
				m_pc_min %= MOD;
				
				cout << solve(m_pc_min, 1) << endl;
				
				m_pc_min += modpow(2, n-1-one);
				m_pc_min += MOD;
				m_pc_min %= MOD;
			}
			else{
				MOD = pc+1;
				m_pc_plus += modpow(2, n-1-one);
				m_pc_plus += MOD;
				m_pc_plus %= MOD;
				
				cout << solve(m_pc_plus, 1) << endl;
				
				m_pc_plus -= modpow(2, n-1-one);
				m_pc_plus += MOD;
				m_pc_plus %= MOD;
			}
		}
	}
}


Measured memory_bytes: 3756
import math
import itertools
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

all_root = list(itertools.permutations(xy))

ret = 0
for root in all_root:
    for i in range(len(root)-1):
        x = (root[i][0] - root[i+1][0]) ** 2
        y = (root[i][1] - root[i+1][1]) ** 2
        ret += math.sqrt(x+y)

print(ret/len(all_root))

Measured memory_bytes: 8052
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for (int i = 0; i < N; i++)
    cin >> T[i];
  sort(T.begin(), T.end());
  int from = T[0];
  int to = from + K;
  int ans = 1;
  int count = 1;
  for (int i = 1; i < N; i++)
  {
    if (count < C && from <= T[i] && T[i] <= to)
      count++;
    else
    {
      ans++;
      count = 1;
      from = T[i];
      to = from + K;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
X, Y = map(int, input().split())
a = 0
if X == 1:
  a += 300000
elif X == 2:
  a += 200000
elif X == 3:
  a += 100000

if Y == 1:
  a += 300000
elif Y == 2:
  a += 200000
elif Y == 3:
  a += 100000

if X == 1 and Y == 1:
  a += 400000
print(a)


Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const int INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    int h,w;
    cin>>h>>w;
    string a;
    for(int i=0;i<w+2;++i)cout<<'#';
    cout<<"\n";
    for(int i=0;i<h;++i){
        cout<<'#';
        cin>>a;
        cout<<a;
        cout<<'#';
        cout<<"\n";
    }
    for(int i=0;i<w+2;++i)cout<<'#';
    cout<<"\n";


}

Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


n,k=map(int,input().split())
xyc=[list(input().split()) for i in range(n)]

ww=[[0]*(2*k+1) for i in range(2*k+1)]
bb=[[0]*(2*k+1) for i in range(2*k+1)]

for i in range(n):
    x,y,c=xyc[i]
    x,y=int(x),int(y)
    if c=="W":
        ww[x%(2*k)+1][y%(2*k)+1]+=1
    else:
        bb[x%(2*k)+1][y%(2*k)+1]+=1

for i in range(2*k):
    for j in range(2*k):
        ww[i+1][j+1]=ww[i+1][j+1]+ww[i+1][j]+ww[i][j+1]-ww[i][j]
        bb[i+1][j+1]=bb[i+1][j+1]+bb[i+1][j]+bb[i][j+1]-bb[i][j]
# print(ww)

def cnt(i1,i2,j1,j2,lst):
    return lst[i2+1][j2+1]-lst[i1+1][j2+1]-lst[i2+1][j1+1]+lst[i1+1][j1+1]

ans=0
for i in range(k+1):
    for j in range(k+1):
        w,b=0,0
        # 左下
        w+=cnt(-1, i-1, -1, j-1, ww)
        # 中央
        w+=cnt(i-1, i+k-1, j-1, j+k-1, ww)
        # 左上
        w+=cnt(-1, i-1, j+k-1, 2*k-1, ww)
        # 右下
        w+=cnt(i+k-1, 2*k-1, -1, j-1, ww)
        # 右上
        w+=cnt(i+k-1, 2*k-1, j+k-1, 2*k-1, ww)

        b+=cnt(-1, i-1, j-1, j+k-1, bb)
        b+=cnt(i-1, i+k-1, -1, j-1, bb)
        b+=cnt(i+k-1, 2*k-1, j-1, j+k-1, bb)
        b+=cnt(i-1, i+k-1, j+k-1, 2*k-1, bb)
        # print(w,b)
        ans=max(ans,w+b)
ww,bb=copy.deepcopy(bb),copy.deepcopy(ww)
for i in range(k+1):
    for j in range(k+1):
        w,b=0,0
        # 左下
        w+=cnt(-1, i-1, -1, j-1, ww)
        # 中央
        w+=cnt(i-1, i+k-1, j-1, j+k-1, ww)
        # 左上
        w+=cnt(-1, i-1, j+k-1, 2*k-1, ww)
        # 右下
        w+=cnt(i+k-1, 2*k-1, -1, j-1, ww)
        # 右上
        w+=cnt(i+k-1, 2*k-1, j+k-1, 2*k-1, ww)

        b+=cnt(-1, i-1, j-1, j+k-1, bb)
        b+=cnt(i-1, i+k-1, -1, j-1, bb)
        b+=cnt(i+k-1, 2*k-1, j-1, j+k-1, bb)
        b+=cnt(i-1, i+k-1, j+k-1, 2*k-1, bb)
        # print(w,b)
        ans=max(ans,w+b)
print(ans)

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

int main(){
  int n;
  int field[255][255];
  int d;
  string tmp;

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++){
      cin >> tmp;
      for(int j=0;j<n;j++)field[i][j] = tmp[j]-'0';
    }

    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(field[i][j]){
	  d = 1;
	  while(i+d<n &&  j-d>=0 && field[i+d][j-d])d++;
	  if(ans<d)ans = d;

	  d = 1;
	  while(i+d<n && field[i+d][j])d++;
	  if(ans<d)ans = d;

	  d = 1;
	  while(i+d<n && j+d<n && field[i+d][j+d])d++;
	  if(ans<d)ans = d;

	  d = 1;
	  while(j+d<n && field[i][j+d])d++;
	  if(ans<d)ans = d;
	}
      }
    }

    cout << ans << endl;
  }
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

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

Measured memory_bytes: 256