akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
char a [100][101] , b [102][102];
int main () {
	int H , W ; cin >> H >> W ;
	for ( int i = 0; i < H ; i ++){
		cin>>a[i];
    }
	for ( int i = 0; i < H + 2; i ++){
		for ( int j = 0; j < W + 2; j ++){
			b [ i ][ j ] ='#';
        }
    }
	for ( int i = 0; i < H ; i ++){
		for ( int j = 0; j < W ; j ++){
			b [ i + 1][ j + 1] = a [ i ][ j ];
        }
    }
	for ( int i = 0; i < H + 2; i ++) {
		for ( int j = 0; j < W + 2; j ++){
			cout << b [ i ][ j ];
        }
		cout << endl ;
    }
}

Measured memory_bytes: 3640
// スマホであっとこーだー

#include <bits/stdc++.h>

using namespace std;

int main() {

  int N;

  string S, T;

  cin >> N >> S >> T;

  string ans;

  for (int i = 0; i < N; i++) {

    ans += S[i];

    ans += T[i];

  }

  cout << ans;

  return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(ll, r);
    CIN(ll, D);
    CIN(ll, x);

    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x <<"\n";
    }
    return 0;
}

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

long long gcd(long long x, long long y){
    if(x < y) swap(x, y);
    long long r = x % y;
    if(r == 0) return y;
    else return gcd(y, r);
}

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

    long long a, b;
    cin >> a >> b;

    long long g = gcd(a, b);

    long long gg = g;
    long long ans = 0;
    for(int i = 2; i <= sqrt(g); i++){
        if(gg % i) continue;
        while(gg % i == 0){
            gg /= i;
        }
        ans++;
    }
    if(gg != 1) ans++;

    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

vector<int> cc;
int HH;

int left(int i) {
    return i*2;
}

int right(int i) {
    return i*2+1;
}

void exchange(vector<int> &v, int i, int j) {
    int temp = v[i];
    v[i] = v[j];
    v[j] = temp;
}

void maxHeapify(vector<int> &v, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= HH && cc[l] > cc[i]) {
        largest = l;
    }else {
        largest = i;
    }
    if (r <= HH && cc[r] > cc[largest]) {
        largest = r;
    }
    if (largest != i) {
        exchange(v,i,largest);
        maxHeapify(v, largest);
    }
}

void buildMaxHeap(vector<int> &v) {
    for (int i = HH/2; i > 0; i--) {
        maxHeapify(v, i);
    }
}

int main() {
    cin >> HH;
    cc.push_back(0);
    PUSH(HH, cc);
    buildMaxHeap(cc);
    FOR(i,1,HH+1) {
        cout << " " << cc[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(i<=9)cnt++;
		else if(100<= i && i<=999)cnt++;
		else if(10000<= i && i<=99999)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;

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

    int b_count = 0, w_count = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') {
            b_count++;
        }
        if (S[i] == '.') {
            w_count++;
        }
    }

    int l_black = 0;
    int r_white = w_count;
    int min = l_black + r_white;
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') {
            l_black++;
        } else {
            r_white--;
        }
        int sum = l_black + r_white;
        if (sum < min) {
            min = sum;
        }
    }

    cout << min << endl;
    return 0;
}

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

typedef long long int ll;
int main(){
  string S;
  cin >> S;
  int n = S.size();
  ll ans = 0;
  vector<int> cnt(n);
  for(int i = 0;i < n-1;i++){
     if(S[i] == 'B'){
        cnt[i+1] = cnt[i]+1;
     }else{
        cnt[i+1] = cnt[i]; 
     }
  }
  for(int i = 0;i < n;i++){
     if(S[i] == 'W'){
        ans += cnt[i];
     }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC133A
{
    class Program
    {
        static void Main(string[] args)
        {
            //データを受け取るために文字型配列string[] inputを準備する
            //Console.readLine().Split()で受け取ったデータは
            //順番にinput[0],input[1],input[2]・・・に入る

            string[] input = Console.ReadLine().Split();

            int N = int.Parse(input[0]);//１番目のデータを整数型にして、Ｎに保存する
            int A = int.Parse(input[1]);//２番目のデータを整数型にして、Ａに保存する
            int B = int.Parse(input[2]);//３番目のデータを整数型にして、Ｂに保存する
            //　電車　１人あたりＡ円　Ｎ人ならＮ×Ａ円かかる
            //　タクシー　Ｎ人でＢ円
            //　どっちが安くなるかを計算する
            //　小さい方を選ぶMath.Min(x,y)を使おう

            int ans = Math.Min(N * A, B);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
n = gets.to_i
tests = []
n.times do
  tests << gets.to_i
end
# binding.pry
tests.sort!
sum = tests.inject(:+)
if sum % 10 != 0
  puts sum
  exit
else
  tests.each do |test|
    if test % 10 != 0
      puts sum - test
      exit
    end
  end
end
puts "0"

Measured memory_bytes: 1788
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll x, k , d;
	cin >> x >> k >> d;
	x = abs(x);
	ll z = x / d;
	if(z >= k)
	{
		ll ans = x % d + d * (z - k);
		cout << ans << '\n';
	}
	else
	{
		k = k - z;
		x = x % d;
		ll xx = d - x;
		if(k % 2== 0)
			cout << x;
		else 
			cout << xx;
	}

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v1(n), v2(n), v3(n);
    for (int i = 0; i < n; ++i) scanf("%d", &v1[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &v2[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &v3[i]);
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    sort(v3.begin(), v3.end(), greater<>());
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += (lower_bound(v1.begin(), v1.end(), v2[i])-v1.begin())*
                (lower_bound(v3.begin(), v3.end(), v2[i], greater<>())-v3.begin());
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(std::vector<long long> x){
	REP(i,5){
		if(x[i]==0){
			cout<<i+1<<endl;
			return;
		}
	}
}

int main(){
  std::vector<long long> x(5);
  for(int i = 0 ; i < 5 ; i++){
    scanf("%lld",&x[i]);
  }
  solve(std::move(x));
  return 0;
}


Measured memory_bytes: 3676
<?php
    $abk = array_map("intVal", explode(" ", trim(fgets(STDIN))));
    $a = $abk[0];
    $b = $abk[1];
    $k = $abk[2];
    $ans = [];
    for($i=$a; $i<$a+$k; $i++){
        if($i<=$b){
            $ans[] = $i;
        }    
    }
    for($i=$b-$k+1; $i<=$b; $i++){
        if($a<=$i){
            $ans[] = $i;
        }
    }
    $ans = array_unique($ans);
    foreach($ans as $a){
        echo $a . PHP_EOL;
    }
?>

Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

template<typename T, long long MOD_VALUE>
class ModInt {
    static constexpr long long MOD = MOD_VALUE;
private:
    T value_;
public:
    ModInt() {}
    ModInt(const T& value) {if (value >= 0) {value_ = value % MOD;} else {T k = (MOD - 1 - value) / MOD; value_ = (value + k * MOD) % MOD;}}
    ModInt& operator+=(const ModInt& x)  {value_ += x.value_; if (value_ >= MOD) value_ -= MOD; return *this;}
    friend ModInt& operator+=(const T& x, const ModInt& y) {ModInt res(x); res.value_ += x.value_; if (res.value_ >= MOD) res.value_ -= MOD; return res;}
    ModInt& operator-=(const ModInt& x) {if (value_ < x.value_) value_ += MOD; value_ -= x.value_; return *this;}
    friend ModInt& operator-=(const T& x, const ModInt& y) {ModInt res(x); if (res.value_ < y.value_) res.value_ += MOD; res.value_ -= y.value_; return res;}
    ModInt& operator*=(const ModInt& x) {value_ = (value_ * x.value_) % MOD; return *this;}
    friend ModInt& operator*=(const T& x, const ModInt& y) {ModInt res(x); res.value_ = (res.value_ * y.value_) % MOD; return res;}
    const ModInt operator+(const ModInt& x) const {return ModInt(*this) += x;}
    friend const ModInt operator+(const T& x, const ModInt& y) {return ModInt(x) += y;}
    const ModInt operator-(const ModInt& x) const {return ModInt(*this) -= x;}
    friend const ModInt operator-(const T& x, const ModInt& y) {return ModInt(x) -= y;}
    const ModInt operator*(const ModInt& x) const {return ModInt(*this) *= x;}
    friend const ModInt operator*(const T& x, const ModInt& y) {return ModInt(x) *= y;}
    static ModInt modpow(ModInt x, long long y) {ModInt z = 1; while (y > 0) {if (y & 1) {z *= x;}x *= x; y /= 2;} return z;}
    ModInt& operator/=(const ModInt& x) {return *this *= modpow(x, MOD - 2);}
    const ModInt operator/(const ModInt& x) const {return ModInt(*this) /= x;}
    friend const ModInt operator/(const T& x, const ModInt& y) {return ModInt(x) /= y;}
    ModInt operator++(int) {ModInt tmp(*this); value_ = (value_ + 1 == MOD ? 0 : value_ + 1); return tmp;}
    ModInt operator--(int) {ModInt tmp(*this); value_ = (value_ - 1 < 0 ? MOD - 1 : value_ - 1); return tmp;}
    friend istream& operator>>(istream& stream, ModInt& x) {stream >> x.value_; x.value_ %= MOD; return stream;}
    friend ostream& operator<<(ostream& stream, const ModInt& x) {stream << x.value_; return stream;}
};

using mint = ModInt<ll, 1000000007>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << mint::modpow(10, N) - mint::modpow(9, N) * 2 + mint::modpow(8, N) << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

template<typename T>
vector<T> enumdiv(T x) {
	vector<T> res;
	for (T i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			res.emplace_back(i);
			if (i != x / i) res.emplace_back(x / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k; cin >> n >> k;
	int sum = 0;
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i], sum += a[i];

	auto ed = enumdiv(sum);
	int res = 1;
	for (auto d : ed) {
		auto b = a;
		for (int i = 0; i < n; i++) b[i] %= d;
		sort(b.begin(), b.end());
		if (b.back() == 0) {
			chmax(res, d);
			continue;
		}
		vector<int> s1(n + 1), s2(n + 1);
		for (int i = 0; i < n; i++) {
			s1[i + 1] = s1[i] + b[i];
			s2[i + 1] = s2[i] + d - b[i];
		}
		for (int i = 0; i <= n; i++) {
			if (s1[i] == s2.back() - s2[i] and s1[i] <= (ll)k) {
				chmax(res, d);
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3672
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  double a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << prec(32) << hypot(a - c, b - d) << endl;
}



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

int main() {
    int N, K, x;
    cin >> N >> K;

    int sum = 0;

    for(int i = 0; i < N; i++) {
        cin >> x;

        if(x < K - x) {
            sum += x * 2;
        } else {
            sum += (K - x) * 2;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 5e5 + 10;

ll n;int ans = 0;
void judge(int v){
    int a = 0;int b = 0;int c = 0;
    while(v%10){
        int u = v%10;
        v /=10;
        if(u==3)a++;
        else if(u==5)b++;
        else if(u==7)c++;
    }
    if(a>0&&b>0&&c>0) ans++;
}

void dfs(ll v){
   if(v>n) return;
   judge(v);
   dfs(v*10+3);
   dfs(v*10+5);
   dfs(v*10+7);
}

void solve(){
    cin >> n;
    dfs(0);
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int a[(int)10e5+1];

    REP(i,n) cin>>a[i];

    //シェルソート
    ll cnt = 0;
    vi g;
    int tmp=1;
    while(n>=tmp){
        g.emplace_back(tmp);
        tmp = tmp*3+1;
    }
    reverse(ALL(g));

    REP(i, g.size()){
        int h = g[i];
        FOR(j,h,n){
            int v = a[j];
            int k = j-h;
            while(k>=0 && a[k]>v){
                a[k+h] = a[k];
                k = k-h;
                cnt++;
            }
            a[k+h] = v;
        }
    }

    cout<< g.size() <<endl;
    REP(i,g.size()){
        cout<<g[i];
        if(i<g.size()-1) cout<<" ";
        else cout<<endl;
    }
    cout << cnt << endl;
    REP(i,n){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7072
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<int> rem(2e5+1), digm(n+1), digp(n+1);
    rem[0] = 0;
    rep2(i, 1, n+1){
      int onecnt = 0;
      int tmp = i;
      while (tmp > 0) {
        onecnt += tmp & 1;
        tmp >>= 1;
      }
    //   cout << onecnt << endl;
      int x = i;
      int cnt = 0;
      while (x > 0) {
        tmp = x;
        onecnt = 0;
        while (tmp > 0) {
          onecnt += tmp & 1;
          tmp >>= 1;
        }
        x %= onecnt;
        cnt++;
      }
    //   cout << i << " : " << cnt << endl;
        rem[i] = cnt;
    }

    int summ = 0, sump = 0, twom = 1, twop = 1, y=0;
    string x;
    cin >> x;
    vector<bool> bit;
    bit.push_back(false);
    rep2(i, 1, n+1){
        if(x[n-i]=='1'){
            y++;
            bit.push_back(true);
        }else{
            bit.push_back(false);
        }
    }
    int m = y-1, p = y+1;
    rep2(i, 1, n+1){
      digm[i] = twom;
      digp[i] = twop;
      if (bit[i]) {
          if(m!=0){
            summ = (summ + twom) % m;
          }
        sump = (sump + twop) % p;
        }
        if(m!=0){
          twom = (twom * 2) % m;
        }
        twop = (twop * 2) % p;
    }

    rep2(i, 1, n+1){
        int res;
        if(bit[n+1-i]){
            if(m==0){
                cout << 0 << endl;
                continue;
            }
            // cout << summ << endl;
            res = (summ - digm[n+1-i]) % m;
            if(res<0){
                res += m;
            }
        }else{
            // cout << "sump : " <<  sump << endl;
            res = (sump + digp[n+1-i]) % p;
            // if (res < 0) {
            //   res += p;
            // }
        }
        cout << rem[res] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5996
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int student = scan.nextInt();
		int[] array = new int[student+1];

		for(int i=1;i<=student;i++) {
			int a = scan.nextInt();
			array[a] = i;
		}

		for(int i=1;i<=student;i++) {
			System.out.println(array[i]+" ");
		}
/*		Map番
 * Map<Integer,Integer> toukou = new TreeMap<Integer,Integer>();

		for(int i=1;i<=student;i++) {
			toukou.put(scan.nextInt(),i);
		}
		for(Integer key:toukou.keySet()){
			System.out.println(toukou.get(key) + " ");
		}

*/
		scan.close();

	}

}


Measured memory_bytes: 63580
n = int(input())

z = [0]*n
w = [0]*n

for i in range(n):
    x, y = map(int, input().split())
    z[i] = x+y
    w[i] = x-y

a = max(z)
b = min(z)
c = max(w)
d = min(w)

print(max(a-b, b-a, c-d, d-c))

Measured memory_bytes: 24536
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int a[MAXN];
int main() {
	int n; read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	if (a[1] != 0) {
		puts("-1");
		return 0;
	}
	ll ans = 0; int now = 0;
	for (int i = n; i >= 1; i--, now = max(0, now - 1)) {
		if (now > a[i]) {
			puts("-1");
			return 0;
		}
		if (now < a[i]) {
			now = a[i];
			ans += now;
		}
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	cout<<int(pow(2,double(m)))*(m*1900+(n-m)*100)<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        a, b, x = line.rstrip("\n").split(" ", 3)
        a = int(a)
        b = int(b)
        x = int(x)

        start_index, start_reminder = divmod(a, x)
        end_index, end_reminder = divmod(b, x)

        result = end_index - start_index
        if a == 0 or start_reminder == 0:
            result += 1
        print result

if __name__ == "__main__":
    main(sys.argv)

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

long long fn(long long x)
{
    long long num_of_one = (x + 1) / 2;
    if (num_of_one % 2 == 0)
    {
        if (x % 2 == 0)
        {
            return 0LL ^ x;
        }
        else
        {
            return 0LL;
        }
    }
    else
    {
        if (x % 2 == 0)
        {
            return 1LL ^ x;
        }
        else
        {
            return 1LL;
        }
    }
}

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

    long long A, B;
    cin >> A >> B;
    long long ans = fn(A - 1) ^ fn(B);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll x;
    cin>>x;
    ll ans=0;
    ll x2=x%500;
    ans+=(x/500)*1000;
    ans+=(x2/5)*5;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# /user/bin/python
# -*- coding: utf-8 -*-
import sys


n,m = map(int, sys.stdin.readline().rstrip().split())
ab = [[0 for j in range(2)] for i in range(m)]
for i in range(m):
  ab[i] = list(map(int, sys.stdin.readline().rstrip().split()))
ab.sort(key=lambda x:x[1])

ans, last = [0, -1]
for a, b in ab:
  if a < last:
    continue
  else:
    ans += 1
    last = b

print(ans)


Measured memory_bytes: 28456
#include<bits/stdc++.h>
#define MAX 101
#define inf 1<<28
#define eps (1e-11)
using namespace std;

struct edge{ int to,cap,rev; };

vector<edge> G[MAX*2+2];
bool used[MAX*2+2];
int n,m;

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to] && e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    fill(used,used+(n+m+2),0);
    int f=dfs(s,t,inf);
    if(f==0)return flow;
    flow+=f;
  }
}

double abs(double a,double b,double c,double d){
  return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}

int main()
{
  int x[MAX],y[MAX],v[MAX];
  int bx[MAX],by[MAX];
  int s,t;

  while(1){
    cin>>n>>m;
    if(n+m==0)break;
    s=n+m;
    t=s+1;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>v[i];
    for(int i=0;i<m;i++)cin>>bx[i]>>by[i];
    
    double l=0,r=inf,mid;
    for(int k=0;k<100;k++){
      double mid=(l+r)/2.0;
      for(int i=0;i<MAX*2+2;i++)G[i].clear();
      for(int i=0;i<n;i++){
	add_edge(s,i,1);
      }
      for(int i=0;i<m;i++){
	add_edge(n+i,t,1);
      }
      for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
	  if(abs(x[i],y[i],bx[j],by[j])/(double)v[i]<=mid)add_edge(i,n+j,1);
	}
      }
      int sum=max_flow(s,t);
      if(m==sum)r=mid;
      else l=mid;
    }
    printf("%.10f\n",l);
  }
  return 0;
}

Measured memory_bytes: 1564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()




int main() {
    vector<int> primes;
    for (int num = 6; num <= 55556; num += 5) {
        bool flag = true;
        for (int i = 2; i * i <= num; ++i) {
            if (num % i == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            primes.push_back(num);
        }
    }
    int n;
    cin >> n;
    rep (i, n) {
        if (i) {
            cout << " ";
        }
        cout << primes[i];
    }
    cout << endl;
}



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

int main(){
  int n;
  cin >> n;
  int h[n];
  for(int i=0; i<n; ++i) cin >> h[i];
  
  int res = 0;
  int temp = 0;
  for(int i=0; i<(n-1); ++i){
    if(h[i] >= h[i+1]){
      ++ temp;
    }
    else{
      res = max(res, temp);
      temp = 0;
    }
  }
  res = max(res, temp);
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<pair<ll,int> >vec;
    for(int i=0;i<a;i++){
        ll p;
        cin>>p;
        vec.pb({p,0});
    }
    for(int i=0;i<b;i++){
        ll p;
        cin>>p;
        vec.pb({p,1});
    }
    for(int i=0;i<c;i++){
        ll p;
        cin>>p;
        vec.pb({p,2});
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());

    int r=0;
    int g=0;
    int C=0;

    for(int i=0;i<x+y;i++){
        if(vec[i].second==0)r++;
        if(vec[i].second==1)g++;
        if(vec[i].second==2)C++;
    }

    if(r<=x && g<=y){
        ll ans=0;
        for(int i=0;i<x+y;i++){
            ans+=vec[i].first;
        }
        cout<<ans<<"\n";
    }
    else if(r>=x){
        ll ans =0;
        int tempr=0,tempg=0;
        for(int i=0;i<x+y;i++){
            if(tempr==x)break;
            if(vec[i].second==0){
                ans+=vec[i].first;
                tempr++;
            }
        }
        for(int i=0;i<x+y;i++){
            if(tempg==y)break;
            if(vec[i].second==1 || vec[i].second==2){
                ans+=vec[i].first;
                tempg++;
            }
        }
        for(int i=x+y;i<vec.size();i++){
            if(tempg==y)break;
            if(vec[i].second==1 || vec[i].second==2){
                ans+=vec[i].first;
                tempg++;
            }
        }
        cout<<ans<<"\n";
    }
    else if(g>=y){
        ll ans =0;
        int tempr=0,tempg=0;
        for(int i=0;i<x+y;i++){
            if(tempg==y)break;
            if(vec[i].second==1){
                ans+=vec[i].first;
                tempg++;
            }
        }
        for(int i=0;i<x+y;i++){
            if(tempr==x)break;
            if(vec[i].second==0 || vec[i].second==2){
                ans+=vec[i].first;
                tempr++;
            }
        }
        for(int i=x+y;i<vec.size();i++){
            if(tempr==x)break;
            if(vec[i].second==0 || vec[i].second==2){
                ans+=vec[i].first;
                tempr++;
            }
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 10476
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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 gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N,M,K;  cin>>N>>M>>K;
  string ans = "No";
  rep(s,0,N+1)rep(t,0,M+1){
    if(s*M+t*N-2*s*t == K){
      ans = "Yes";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


void compress(vector<int> &a, vector<int> &com){
  // vector<int> com = a;
  sort(all(com));
  com.erase(unique(all(com)), com.end());
  rep(i, a.size()) a[i] = lower_bound(all(com), a[i]) - com.begin();
}

int main() {
  int N; cin >>N;
  vector<int> A(N); rep(i, N) cin >>A[i];
  sort(all(A));
  int res = 0;
  if (A[0]%2) res ^= N;
  for (int i=1; i<N; i++){
    if (A[i-1] == A[i]) continue;
    int num = N-i;
    if ((A[i]-A[i-1])%2) res ^= num;
  }
  cout <<(res==0 ? "second" : "first") <<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define MD 1000000007
#define INF 1ll<<60
const double PI=3.141592653589;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
ll n,p,q,sum;
priority_queue<ll> Q;

ll solve(){
  ll res=sum*n;
  while(!Q.empty()){
    n--;
    sum+=Q.top();Q.pop();
    res=max(res,n*sum);
  }
  return res;
}

int main(){
  while(1){
  cin>>n;
  if(!n)break;
  sum=0;
  for(int i=0,a;i<n;i++) cin>>a,sum+=a;
  for(int i=0,a;i<n-1;i++) cin>>a,Q.push(a);
  cout<<solve()<<endl;
  }
  return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  t.erase(t.size()-1);
  if(s==t){
    cout << "Yes" << endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#(41)ゴッホ曲線

import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
    
def Koch(n, x1,y1, x2,y2):
    if n==0:
        plot(x1,y1)
        return
    
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1, x1,y1, sx,sy)
    Koch(n-1, sx,sy, ux,uy)
    Koch(n-1, ux,uy, tx,ty)
    Koch(n-1, tx,ty, x2,y2)
n=int(input())
Koch(n, 0,0, 100,0)
plot(100,0)


Measured memory_bytes: 5748
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;

    vector<int> R(N+1),W(N+1);
    rep(i,N) {
        W[i+1] = W[i];
        if (S[i]=='W') W[i+1]++;
    }
    for (int i = N-1; i >= 0; i--) {
        R[i] = R[i+1];
        if (S[i]=='R') R[i]++;
    }

    int ans = 1e9;
    rep(i,N+1) {
        chmin(ans,max(W[i],R[i]));
    }

    cout << ans << ln;
}


Measured memory_bytes: 5184
using System;
class test {
    public static void Main() {
        string[] a = Console.ReadLine().Split();
        var W = int.Parse(a[0]);
        var H = int.Parse(a[1]);
        var x = int.Parse(a[2]);
        var y = int.Parse(a[3]);
        var r = int.Parse(a[4]);
        
        if (x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0) {
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }
    }
}



Measured memory_bytes: 17940
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 998244353;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this;}
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this;}
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this;}
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this;}
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this;}
	mint operator+(const mint& a)const{ return mint(*this) += a;}
	mint operator-(const mint& a)const{ return mint(*this) -= a;}
	mint operator*(const mint& a)const{ return mint(*this) *= a;}
	mint operator/(const mint& a)const{ return mint(*this) /= a;}
	bool operator<(const mint& a)const{ return v < a.v;}
	bool operator==(const mint& a)const{ return v == a.v;}
	mint pow(int k)const{mint r(1),t(v);while(k){if(k&1)r*=t;t*=t;k>>=1;} return r;}
	mint inv()const{return pow(MOD-2);}
};
std::istream& operator>>(std::istream&i,mint&a){int t;i>>t;a=mint(t);return i;}
std::ostream& operator<<(std::ostream&o,const mint&a){o<<a.v;return o;}


signed main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	std::vector<int> dp(8-1,0);
	std::map<char, int> map;
	map['R'] = 1; map['G'] = 2; map['B'] = 4;
	mint prod = 1;
	for(char c:s) {
		int d = 0b111 ^ map[c];
		if(dp[d]) {
			prod *= dp[d];
			dp[d]--;
			continue;
		}
		for(int x: {1,2,4}) {
			if(x==map[c]) continue;
			if(dp[x]) {
				prod*=dp[x];
				dp[x|map[c]]++;
				dp[x]--;
				goto ex;
			}
		}
		dp[map[c]]++;
ex:;
	}
	for(int i=1;i<=n;i++) prod*=i;
	print(prod);

	return 0;
}


Measured memory_bytes: 900
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,j,n,m;cin>>n;
	m=n+n;
	string s;cin>>s;
	vector<int>ban(m);
	int ac=0,bc=0;
	vector<int>Adco(n);
	vector<int>Bdco(n);
	for(i=0;i<m;i++){
		if(s[i]=='a'){ban[i]=ac;Adco[ac]=i;ac++;}
		else{ban[i]=bc;Bdco[bc]=i;bc++;}
	}
	vector<tuple<string,int,int>>site(n);
	//string,始点b,終点絶
	for(i=0;i<n;i++){
		get<1>(site[i])=-i;
		if(Adco[i]<Bdco[i]){continue;}
		int mde=i-1;//ここまでみた
		for(j=Bdco[i];j<m;j++){
			if(s[j]=='b'){
				mde++;
				get<0>(site[i]).pub('b');
			}else{
				if(i<=ban[j]){get<0>(site[i]).pub('a');}
				if(mde<=ban[j]){get<2>(site[i])=j+1;break;}
			}
		}
	}
	SO(site);REV(site);
	for(i=0;i<n;i++){get<1>(site[i])=-get<1>(site[i]);}
	int cut=0;//cut以降を見る
	string ans;
	string kara;
	for(i=0;i<n;i++){
		if(get<0>(site[i])==kara){break;}
		if(Bdco[get<1>(site[i])]<cut){continue;}
		cut=get<2>(site[i]);
		ans+=get<0>(site[i]);
	}
	//これ以降はaaabbabbみたいな状況 ba無理
	for(;cut<m;cut++){
		if(s[cut]=='b'){continue;}//あるはずないので
		if(Bdco[ban[cut]]<cut){continue;}
		ans.pub('a');
		ans.pub('b');
		cut=Bdco[ban[cut]];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16384
#include<stdio.h>
 
int search(int A[], int n, int key){
    int i = 0;
    A[n] =key;
    while( A[i] != key ) i++;
    return i != n;
}
 
int main(void){
    int i,n,A[10000+1],q,key,sum = 0;
     
    scanf("%d",&n);
    for( i = 0; i < n; i++)scanf("%d",&A[i]);
     
    scanf("%d",&q);
    for( i = 0; i < q; i++){
        scanf("%d",&key);
        if(search(A,n,key))sum++;
    }
    printf("%d\n",sum);
     
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, a, b;
  cin >> n;
  if (n == 1)
    cout << "Hello World" << endl;
  else {
    cin >> a >> b;
    int ans = a + b;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int x;
  cin >> x;
  int ans = 0;
  FOR(b,1,x+1){
    int a = b;
    FOR(p,2,x+2){
      a *= b;
      if(a<=x) ans = max(ans,a);
      else break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, s int
	fmt.Scan(&k, &s)
	cnt := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - (x + y)
			if 0 <= z && z <= k {
				//fmt.Printf("x,y,z = %d, %d, %d\n", x, y, z)
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 405;
int dp[N][N], tmp[N][N], a[N], b[N], c[N];

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	MEM(dp, -1);

	dp[0][0] = 0;
	int n, ma, mb; cin >> n >> ma >> mb;
	REPU(i, 0, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	REPU(it, 0, n) {
		REPU(i, 0, N) REPU(j, 0, N) tmp[i][j] = dp[i][j];
		for (int i = 0; i + a[it] < N; ++i) {
			for (int j = 0; j + b[it] < N; ++j) if (dp[i][j] >= 0) {
				int& x = tmp[i + a[it]][j + b[it]];
				if (x == -1) x = dp[i][j] + c[it];
				else amin(x, dp[i][j] + c[it]);
			}
		}
		REPU(i, 0, N) REPU(j, 0, N) dp[i][j] = tmp[i][j];
	}
	int ans = INT_MAX;
	REPU(i, 1, N) REPU(j, 1, N) if (dp[i][j] >= 0) {
		int g = gcd(i, j);
		int ni = i / g, nj = j / g;
		if (ni == ma && nj == mb) amin(ans, dp[i][j]);
	}
	if (ans == INT_MAX) ans = -1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1536