akhauriyash/Code-Regression huggingface dataset:
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

// -----------------------------------------------------------------------------

void solve() {
    int n, m; cin >> n >> m;
    int b = 1;
    if (n == 1) b = 1;
    else if (n == 2) b = 10;
    else b = 100;
    int s[m], c[m];
    for (int i = 0; i < m; ++i) {
        cin >> s[i] >> c[i];
    }
    int u = 10 * b;
    if (n == 1) b = 0;
    for (int i = b; i < u; ++i) {
        int f = 0;
        auto st = to_string(i);
        for (int j = 0; j < m; ++j) {
            if (st[s[j] - 1] - '0' == c[j]) continue;
            else {
                f = 1;
                break;
            }
        }
        if (!f) {
            cout << i << '\n';
            return;
        }
    }
    cout << -1 << '\n';
}

int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    map<int, int> m;
    ll cnt = 0;
    rep(i, n) {
        m[i+a[i]]++;
        if (i > 0) {
            cnt += m[i-a[i]];
        }
    }
    cout << cnt << endl;
}

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

bool f(string s){
    for(auto x : s){
        if(!isdigit(x)){
            return false;
        }
    }
    return true;
}

int main(){
    int a, b; cin >> a >> b;
    string s; cin >> s;

    if(f(s.substr(0,a)) && s[a] == '-' && f(s.substr(a+1,b))){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
X, N = map(int,input().split())
p = set(tuple(map(int, input().split())))

value_num = X
value_NUM = X

while 1:
    if not(value_num in p):
        print(value_num)
        break

    if not(value_NUM in p):
        print(value_NUM)
        break

    # print(value_num)
    # print(value_NUM)

    value_num -= 1
    value_NUM += 1



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

int main(){

int N, K;
cin >> N >> K;
int ans = 0;

		//ボールが一個
	if(N == 1){
	ans = K; 
	}else{
		
	for(int i =0; i < N; i++){


		//一番左はK通り
		if(i == 0)ans += K;
		
		//2番目以降
		//左隣りの色は塗れないのでK-1通り
		if(i > 0) ans *= (K - 1);

	}
	}
cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int min(long long int a,long long int b){
  if(a>b) return b;
  return a;
}
int main(void){
  int n,i;
  long long int ans=0;
  scanf("%d",&n);
  long long int a[n+1],b[n];
  for(i=0;i<n+1;i++) scanf("%lld",&a[i]);
  for(i=0;i<n;i++) scanf("%lld",&b[i]);
  for(i=0;i<n;i++){
    if((a[i]+a[i+1])<=b[i]){
      ans += a[i]+a[i+1];
      a[i+1] = 0;
    }else{
      ans += b[i];
      if(a[i]<b[i]){
        a[i+1] = a[i+1] - (b[i]-a[i]);
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s; cin >> s;
  if (s=="RRR") cout << 3 << endl;
  if (s=="RRS") cout << 2 << endl;
  if (s=="RSR") cout << 1 << endl;
  if (s=="RSS") cout << 1 << endl;
  if (s=="SRR") cout << 2 << endl;
  if (s=="SRS") cout << 1 << endl;
  if (s=="SSR") cout << 1 << endl;
  if (s=="SSS") cout << 0 << endl;
  return 0;
}

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

int main() {
	int n, r;

	while (cin >> n >> r && n != 0 && r != 0) {
		int card[51];
		for (int i = 1; i <= n; i++) {
			card[i] = n - i + 1;
		}

		int p, c;
		for (int i = 0; i < r; i++) {
			cin >> p >> c;

			int temp[50];
			for (int j = 0; j < c; j++) {
				temp[j] = card[p + j];
			}
			for (int j = 1; j < p; j++) {
				card[p + c - j] = card[p - j];
			}
			for (int j = 0; j < c; j++) {
				card[j + 1] = temp[j];
			}
		}
		cout << card[1] << '\n';
	}

	return 0;
}

Measured memory_bytes: 1160
// syakyo http://d.hatena.ne.jp/simezi_tan/20120906/1346880190

#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int n;
double x[100], y[100], v[100];

inline double d(int i, double a, double b){
    return sqrt((x[i] - a)*(x[i] - a) + (y[i] - b)*(y[i] - b));
}

inline double g(double a, double b){
    double res = 0;
    rep(i, n){
        res = max(res, d(i, a, b)/v[i]);
    }
    return res;
}

inline double f(double x){
    double l = 0, r = 100, a, b;
    double ans;
    rep(i, 75){
        a = (l * 2 + r) / 3;
        b = (l + r * 2) / 3;
        if ((ans = g(x, a)) > g(x, b)) l = a;
        else r = b;
    }
    return ans;
}

int main(){
    while (cin >> n, n){
        rep(i, n){
            cin >> x[i] >> y[i] >> v[i];
        }
        double l = 0, r = 100, a, b;
        double ans;
        rep(i, 75){
            a = (l * 2 + r) / 3;
            b = (l + r * 2) / 3;
            if ((ans = f(a)) > f(b)) l = a;
            else r = b;
        }
        cout << fixed << setprecision(20);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector<vector<int>> a(h, vector<int>(w));
    vector<P> num(h * w + 1);
    vector<int> sum(h*w);
    rep(i, h)rep(j, w){
        cin >> a[i][j];
        num[a[i][j]] = {i, j};
    }
    rep(i, h*w){
        if(i < d)sum[i] = 0;
        else{
            sum[i] = abs(num[i+1].first-num[i-d+1].first)+abs(num[i+1].second-num[i-d+1].second);
            sum[i] += sum[i-d];
        }
    }
    int q;
    cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << sum[r-1]-sum[l-1] << endl;
    }
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define P pair<int,int>
#define fr first
#define se second
using namespace std;
typedef long long ll;
const int maxx=1e5+10;
const ll mod=1e9+7;
int vis[maxx];
vector<int> p;
ll a[maxx],inv[maxx];
ll fpow(ll x,ll n){
    ll res=1;
    while(n){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n >>=1;
    }
    return res;
}
int main(){
    ll n,k; cin>>n>>k;
    for(ll i=2;i<=k;i++){
        if(vis[i]==1) continue;
        for(ll j=i*2;j<=k;j+=i){
            vis[j]=vis[j]-(vis[i]-1);
        }
    }

    ll ans=0;
    ll i,j;
    for(i=1;i<=k;i=j+1){
        ll x=k/i;
        j=k/x;
        ll res=fpow(x,n);
        for(int j=2;j<=x;j++){
            res=(res+(vis[j]-1)*fpow(x/j,n)%mod+mod)%mod;

        }
        (ans+=(i+j)*(j-i+1)/2%mod*res%mod)%=mod;
        //cout<<i<<" "<<j<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3992
N = int(input())
s = 0
for i in range(1, N + 1):
	x = 0
	y = i
	while True:
		if y % 2 == 0:
			x += 1
			y = int(y // 2)
		else:
			break
	if x > s:
		s = x
print(2 ** s)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <bitset>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	int a,b,p,q,r;
	cin >> a >> b >> p >> q >> r;
	double ans = ((double)b*p+r*b+q*a)/(double)(q+r);
	cout << ans << endl;
}



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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  // 例えば，自分以外のXORをそれぞれの要素に対し求めたいときに，
  int total = 0;
  for(int i = 0; i < n; i++) total ^= a[i];
  for(int i = 0; i < n; i++) {
    int totalWithoutMe = total ^ a[i];  // 自分だけ総XOR和から引く
    cout << totalWithoutMe << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 4332
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,ans=1000000007,l[10],chs[10];
void dfs(int x)
{
	if(x>n)
	{
		int c1=0,c2=0,c3=0,s1=0,s2=0,s3=0,res=0;
		for(int i=1;i<=n;i++)
			if(chs[i]==1)
			{
				c1++;
				s1+=l[i];
			}
			else if(chs[i]==2)
			{
				c2++;
				s2+=l[i];
			}
			else if(chs[i]==3)
			{
				c3++;
				s3+=l[i];
			}
		if(!c1||!c2||!c3) return;
		res+=(c1+c2+c3-3)*10;
		res+=abs(a-s1)+abs(b-s2)+abs(c-s3);
		ans=min(ans,res);
		return;
	}
	for(int i=1;i<=3;i++)
	{
		chs[x]=i;
		dfs(x+1);
	}
	chs[x]=0;
	dfs(x+1);
}
int main()
{
	cin>>n>>a>>b>>c;
	for(int i=1;i<=n;i++)
		cin>>l[i];
	dfs(1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input().split())
s1=[]
s2=[]
S=[]
a=''
for i in s[0]:
  s1.append(i)
for j in s[1]:
  s2.append(j)
for k in range(n):
  S.append(s1[k])
  S.append(s2[k])
for l in range(2*n):
  a+=S[l]
print(a)
  

Measured memory_bytes: 38384
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
 

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair < int , pll>           
#define    sp(x)                    setprecision(x)

int32_t main()
{       
    speed upp
    int a,b;
    cin>>a>>b;
    cout<<(a+b-1)/b;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    int a,b;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>a>>b;
    cout<<(((a*b)%2==0)?"Even":"Odd");
    return 0;
}


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

typedef long long ll;
#define gc getchar()
inline int read(){
	int x=0,f=1;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=-1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x*f;
}
#define io read()

int a,b,c;

inline void init(){
	a=io;b=io;c=io;c=io;
	printf("%d\n",c&1?b-a:a-b);
}

inline void solve(){
	
}

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

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

int main(){
    int a,b;

    cin>>a>>b;
    int ans = a+b;
    ans=max(ans,a-b);
    ans=max(ans,a*b);
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>
//#pragma warning(disable : 4996)
#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef long long ll;

const int maxn = (int)1e6 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 7;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101;
const long double pi = 3.1415926535897932;


int main() {
	drobucs;
	
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "safe";
	}
	else
		cout << "unsafe";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
#define pii pair<int,int>
#define pb push_back
#define ll long long
#define MOD 1000000007
 
ll fact[1000] = {0};
ll factorial(int n){
    if (n >= 0) {
        fact[0] = 1;
        for (int i=1;i<=n;++i) fact[i] = i * fact[i - 1];
        return fact[n];
    } else return -1;
}
 
ll mpow(ll a, ll n) {
    ll ret=1;
    ll b=a;
    while(n) {
        if(n&1) 
            ret=(ret*b)%MOD;
        b=(b*b)%MOD;
        n>>=1;
    }
    return (ll)ret;
}
 
int toint(const string &s) { 
    stringstream ss(s);
    int x; 
    ss >> x; 
    return x; 
}
 
int main() {
  ll h,a;
  cin>>h>>a;
  
  if(h%a) cout<<(h/a+1);
  else cout<<(h/a);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "{";
    for (int i = 0; i < v.size(); ++i) {
        if(i) os << ", ";
        os << v[i];
    }
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "{" << p.first << ", " << p.second << "}";
}


int main() {
    vector<int> v = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111, 0};
    int n;
    while(cin >> n, ~n){
        vector<int> a(n+1, 10);
        for (int i = 0; i < n; ++i) {
            cin >> a[i+1];
            cout << bitset<7>(v[a[i+1]]^v[a[i]]) << "\n";
        }
    }
    return 0;
}


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

int main() {
  string s1,s2; cin >> s1 >> s2;
  reverse(s2.begin(),s2.end());
  if ( s1 == s2 ) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename M>
struct SegmentTree{
    using T = typename M::type;

    int numLeaves;
    std::vector<T> data;
    
    SegmentTree(int n){
        numLeaves = 1;
        while(numLeaves < n){
            numLeaves *= 2;
        }
        
        data.resize(numLeaves * 2);
        std::fill(data.begin() + numLeaves, data.end(), M::identity());
        
        for(int i=numLeaves-1;i>0;--i){
            data[i] = M::bop(data[i*2], data[i*2+1]);
        }
    }

    template <typename F>
    SegmentTree(int n, F f){
        numLeaves = 1;
        while(numLeaves < n){
            numLeaves *= 2;
        }

        data.resize(numLeaves * 2);
        for(int i=0;i<n;++i){
            data[i + numLeaves] = std::move(f(i));
        }
        std::fill(data.begin() + numLeaves + n, data.end(), M::identity());

        for(int i=numLeaves-1;i>0;--i){
            data[i] = M::bop(data[i*2], data[i*2+1]);
        }
    }

    void set(int k, T v){
        k += numLeaves;
        data[k] = v;
        
        while(k > 1){
            k /= 2;
            data[k] = M::bop(data[k*2], data[k*2+1]);
        }
    }
    
    T product(int l, int r){
        l += numLeaves;
        r += numLeaves;
        
        T pl = M::identity(), pr = M::identity();
        for(;l<r;l/=2,r/=2){
            if(l & 1){
                pl = M::bop(pl, data[l]);
                l += 1;
            }
            if(r & 1){
                r -= 1;
                pr = M::bop(data[r], pr);
            }
        }
        
        return M::bop(pl, pr);
    }
    
    T at(int i){
        return data[i + numLeaves];
    }
};

struct M{
    using type = int;
    static type identity(){
        return 0;
    }
    static type bop(type &m1, type &m2){
        return std::max(m1, m2);
    }
};

SegmentTree<M> seg(200100);
int N;
int A[200100];
std::vector<int> G[200100];
int res[200100];

void dfs(int v, int p){
    int prev_v = seg.at(A[v]);
    int new_v = std::max(prev_v, seg.product(0, A[v]) + 1);

    seg.set(A[v], new_v);

    res[v] = seg.product(0, N);
    
    for(int w : G[v]){
        if(w == p){continue;}

        dfs(w, v);
    }

    seg.set(A[v], prev_v);
}

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

  std::cin >> N;

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

  for(int i=0;i<N-1;++i){
      int u, v;
      std::cin >> u >> v;

      u -= 1;
      v -= 1;

      G[u].emplace_back(v);
      G[v].emplace_back(u);
  }

  {
      std::vector<int> v(A, A + N);
      std::sort(v.begin(), v.end());
      v.erase(std::unique(v.begin(), v.end()), v.end());

      for(int i=0;i<N;++i){
          A[i] = std::lower_bound(v.begin(), v.end(), A[i]) - v.begin();
      }
  }

  dfs(0, -1);

  for(int i=0;i<N;++i){
      std::cout << res[i] << std::endl;
  }
}


Measured memory_bytes: 32008
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int R;
    cin >> R;
    if(R<1200) cout << "ABC" << endl;
    else if(R<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}


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

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

typedef long long int ll;

const ll INF=(ll)1e18;

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

  vector<ll> a(N);
  REP(i,N){
    cin >> a[i];
    a[i]--;
    a[i] %= K;
  }

  vector<ll> csum(N+1);
  csum[0]=0;
  REP(i,N){
    csum[i+1] = csum[i] + a[i];
    csum[i+1] %= K;
  }
  REP(i,N+1){
//    cout << csum[i] << endl;
  }

  map<ll,ll> mp;
  ll ans=0;
  for(ll i = 1; i < min(K,N+1); i++){
    mp[csum[i-1]]++;
    ans += mp[csum[i]];
  }
  FOR(i,K,N+1){
    mp[csum[i-1]]++;
    mp[csum[i-K]]--;
    ans += mp[csum[i]];
  }
  cout << ans << endl;

}



Measured memory_bytes: 15872
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
x,y=0,0
while(x<h and y<w):
    a[x][y]='.'
    if y+1<w and a[x][y+1]=="#":
        y+=1
    elif x+1<h and a[x+1][y]=="#":
        x+=1
    else:
        break
j=True
for b in a:
    for t in b:
        if t=="#":
            j=False
            break
print("Possible" if j else "Impossible")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

ll powe(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

void solve()
{
    ll i,j,k=0,n,m,l;
    string s,t;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    ll dp[n+1][m+1];
    for(i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(i=0;i<=m;i++)
    {
        dp[0][i]=0;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
           if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
           else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[n][m]<<ee;
    string ans;
    i=n;j=m;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            // else if(dp[i-1][j]==dp[i][j-1])
            // {
            //     i--;
            //     j--;
            // }
            else
                j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;



}

int main() {
    fast;
    ll i,j,l,k,t,n;
    t=1;
    while(t--)
    solve();
}


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);
  sort(S.begin(), S.end());
  for (string i : S) cout << i;
  cout << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
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; }

int main(){
    int h,a;
    cin>>h>>a;
    if(h%a!=0)cout<<h/a+1;
    else cout<<h/a;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    
    	int N = sc.nextInt();
    	int x = sc.nextInt();
    	long ans = 0;
    	
    	int a[] = new int [N+2];
    	a[0] = 0;
    	a[N+1] = 0;
    	
    	for (int i = 1 ; i <= N ; i++){
    		a[i] = sc.nextInt();
    	}
    	
    	for (int j = 1 ; j <= N-1 ; j++){
    		
    		if (a[j] + a[j+1] > x){
    			
    			if (a[j] <= x){
    				ans = ans + (a[j+1] - (x-a[j]));
    				a[j+1] = x  - a[j];
    			} else {
    				ans = ans + (a[j] - x) + (a[j+1]);
    				a[j] = x;
    				a[j+1] = 0;
    			}
    			
    		}
    		
    	}
    	
    	System.out.println(ans);
    	
    	
    }
}
    

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

using namespace std;


void eating_symbols_easy()
{
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 4; ++i)
  {
    if (s[i] == '+') ++cnt;
    else --cnt;
  }
  cout << cnt << "\n";
}


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

  if (n % 2 == 0) cout << n << "\n";
  else cout << 2 * n << "\n";
}


void task_scheduling_problem()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

  sort(a.begin(), a.end());

  cout << a[2] - a[0] << "\n";
}


void rated_for_me()
{
  int r;
  cin >> r;

  if (r < 1200) cout << "ABC\n";
  else if (r < 2800) cout << "ARC\n";
  else cout << "AGC\n";
}


void atcoder_crackers()
{
  int n, k;
  cin >> n >> k;

  if (n % k == 0) cout << 0 << "\n";
  else cout << 1 << "\n";
}


int main()
{
  //eating_symbols_easy();
  //multiple_of_2_and_n();
  //task_scheduling_problem();
  //rated_for_me();
  atcoder_crackers();
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, k, q; cin >> n >> k >> q;
    vector<ll> a(q);
    REP(i, q) cin >> a[i]; // 1-indexed

    vector<ll> x(n, k - q);
    REP(i, q) {
        ++x[a[i] - 1];
    }

    REP(i, n) {
        cout << Yes(x[i] > 0) << endl;
    }
    
}

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

#define INF 1000000007
#define MAX 100000

using namespace std;

int main(){
  int n,m; cin >> n >> m;
  long long f[MAX+1];
  f[0]=1;
  int mm=max(n,m);
  for(int i=1;i<=mm;i++){
    f[i]=(f[i-1]*i) % INF;
  }
  if(m-n+1==0 || m-n+1==2){
    cout << (f[n]*f[m]) %INF << endl;
  }else if(m-n+1 == 1){
    cout << (2*f[n]*f[m]) %INF << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;
int main()
{
  multimap< string, int > m;
  string str;
  int n;
  while(cin >> str >> n){
    m.insert( map<string,int>::value_type(str,n) );
  }
  map<string,int>::iterator it = m.begin();
  while(it != m.end()){
    cout << (*it).first << endl;
    n = m.count((*it).first);
    set<int> s;
    while(n--){
      s.insert((*it).second);
      it++;
    }
    set<int>::iterator i = s.begin();
    cout << *i;
    i++;
    while(i != s.end()){
      cout << " " << *i;
      i++;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;


class Solve
{
  public Solve() { }
  public static int Main()
  {
    new Solve().calc();
    return 0;
  }


  Scanner cin;

  void calc()
  {
    cin = new Scanner();
    string S = cin.next();
    if (S[2]== S[3] && S[4] == S[5])
    {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}
class Modulo
{
  private const int M = 1000000007;
  private readonly int[] m_facs;
  public int Mul(int a, int b)
  {
    return (int)(Math.BigMul(a, b) % M);
  }
  public Modulo(int n)
  {
    m_facs = new int[n + 1];
    m_facs[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
      m_facs[i] = Mul(m_facs[i - 1], i);
    }
  }
  public int Fac(int n)
  {
    return m_facs[n];
  }
  public int Pow(int a, int m)
  {
    switch (m)
    {
      case 0:
        return 1;
      case 1:
        return a;
      default:
        int p1 = Pow(a, m / 2);
        int p2 = Mul(p1, p1);
        return ((m % 2) == 0) ? p2 : Mul(p2, a);
    }
  }
  public int Div(int a, int b)
  {
    return Mul(a, Pow(b, M - 2));
  }
  public int Ncr(int n, int r)
  {
    if (n < r) { return 0; }
    if (n == r) { return 1; }
    int res = Fac(n);
    res = Div(res, Fac(r));
    res = Div(res, Fac(n - r));
    return res;
  }
}

class Scanner
{
  string[] s;
  int i;

  char[] cs = new char[] { ' ' };

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

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }

  public int nextInt()
  {
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0)
  {
    int[] Array = new int[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextInt() + add;
    }
    return Array;
  }

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

  public ulong nextULong()
  {
    return ulong.Parse(next());
  }

  public long[] ArrayLong(int N, long add = 0)
  {
    long[] Array = new long[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextLong() + add;
    }
    return Array;
  }

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


  public double[] ArrayDouble(int N, double add = 0)
  {
    double[] Array = new double[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f // -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

LL n, l;
LL a[N];

int main() {
	read(n), read(l);
	LL id, mx = 0;
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1; i < n; i++) if (a[i] + a[i + 1] > mx) {id = i; mx = a[i] + a[i + 1];}
	if (mx < l) {printf("Impossible\n"); return 0;}
	printf("Possible\n");
	for (int i = 1; i <= id - 1; i++) printf("%d\n", i);
	for (int i = n - 1; i >= id + 1; i--) printf("%d\n", i);
	printf("%d\n", id);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;

int main(){
  cin >> n;
  int frag = 0;
  string s = to_string(n);
  int sum = n/100; int num = n -sum*100;
  //cout << sum << " " << num << "\n";
  if(sum*5 >= num) frag = 1;
  cout << frag << "\n";
}

Measured memory_bytes: 256
def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    cs = [0] * N
    cs[0] = A[0]
    for i in range(1, N):
        cs[i] = cs[i - 1] + A[i]
        cs[i] %= MOD
    ans = 0
    for i in range(1, N):
        ans += A[i] * cs[i - 1]
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 1000*1001/2+1;

/* ...o(^-^)o... */
bool ok[MAX], ng[MAX];

int main(){
    lint n, k; cin >> n >> k;
    vector<lint> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n-1) a[i+1] += a[i];

    vector<lint> vec;
    rep(i, n) vec.push_back(a[i]);
    rep(i, n - 1){
        for(int j = i + 1; j < n; j++) vec.push_back(a[j] - a[i]);
    }

    lint ans = 0;
    for(int i = 40; i >= 0; i--){
        lint m = (1LL << i); lint cnt = 0;
        rep(j, vec.size()){
            ok[j] = false;
            if(!ng[j] && ((vec[j] & m) > 0)){
                ok[j] = true; cnt++;
            }
        }

        if(cnt >= k){
            ans += m;
            rep(j, vec.size()){
                if(!ok[j]) ng[j] = true;
            }
        }
    }

    out(ans);
}


Measured memory_bytes: 6516
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var PQR = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var P = PQR[0];
            var Q = PQR[1];
            var R = PQR[2];

            var output = P + Q + R - Math.Max(P, Math.Max(Q, R));
            Console.WriteLine(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if (abs(a - b) <= w)
        OP(0);
    else
        OP(abs(a - b) - w);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
char s1[1024];
 
int main() {
  scanf("%s", s1);
  for(int i = 0; i < strlen(s1); i++) {
    if(s1[i] == ',') s1[i] = ' ';
  }
  printf("%s\n", s1);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  
  H%=12;
  
  double theta=min(abs(30*H-5.5*M),360-abs(30*H-5.5*M));
  
  double rad=theta/180*PI;
  
  double ans=pow(A*A+B*B-2*A*B*cos(rad),0.5);
  
  cout<<fixed<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 4312
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, x; cin >> n >> m >> x;
	vector<vector<int>> v(n, vector<int>(m + 1));
	rep(i, n)rep(j, m+1) cin >> v[i][j];
	int ans = INF;
	for (int i = 0; i < 1 << 12; i++) {
		vector<int> v2(m + 1, 0);
		rep(j, n) {
			if ((i >> j)&1) {
				rep(k, m + 1) {
					v2[k] += v[j][k];
				}
			}
		}
		
		bool flag = true;
		for (int j = 1; j < m + 1; j++)if (v2[j] < x)
			flag = false;
		if (flag) {
			ans = min(ans, v2[0]);
		}
		//cout <<i<<" "<< v2[0] << " " << ans << endl;
	}
	if (ans == INF)ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
  	int N, P, mn = 200000;
  	scanf("%d",&N);
  	int cnt = 0;
  	for (int i = 0; i < N; i++) {
    	scanf("%d",&P);
      	mn = min(mn,P);
      	if (mn == P) cnt++;
    }
  	printf("%d\n",cnt);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  string s;
  cin >> n >> s;
  vector<int> r, g, b, type(3 * n, 1);
  for (int i = 0; i < 3 * n; ++i) {
    if (s[i] == 'R') {
      r.push_back(i);
    }
    if (s[i] == 'G') {
      g.push_back(i);
    }
    if (s[i] == 'B') {
      b.push_back(i);
    }
  }

  for (int i = 0; i < n; ++i) {
    type[min(min(r[i], g[i]), b[i])] = 0;
    type[max(max(r[i], g[i]), b[i])] = 2;
  }

//  cerr << s << endl;
//  for (int i = 0; i < 3 * n; ++i) {
//    cerr << type[i];
//  }
//  cerr << endl;

  const ll mod = 998244353;
  ll result = 1;
  map<string, ll> m;
  m[""] = n;
  for (int i = 0; i < 3 * n; ++i) {
    string key = "?";
    int numKeys = 0;
    ll totalCount = 0;
    //cerr << "i = " << i  << " s[i] = " << s[i] << ", type[i] = " << type[i] << endl;
    for (auto p : m) {
      if (p.second == 0) continue;
      //cerr <<   " " << p.first << "; " << p.second << endl;
      string curKey = p.first;
      //cerr << "   curKey = " << curKey << endl;
      if (curKey.size() != type[i]) continue;
      bool found = false;
      for (int t = 0; t < curKey.size(); ++t) {
        if (curKey[t] == s[i]) {
          found = true;
        }
      }
      //cerr << "found = " << found << endl;
      if (found) continue;
      key = curKey;
      totalCount += m[key];
    }
    //cerr << key << " " << m[key] << endl << endl;
    result *= totalCount;
    result %= mod;
    m[key]--;
    m[key + s[i]]++;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
#include <cmath>
#include <limits>
#include <queue>
using namespace std;


int main()
{
	long long N;

	cin >> N;

	long long result = 0;

	if (N < 10) {
		result += N;
	}
	else {
		result += 9;
	}

	if (N >= 100) {
		if (N < 1000) {
			result += N - 100 + 1;
		}
		else {
			result += 900;
		}
	}

	if (N >= 10000) {
		if (N < 100000) {
			result += N - 10000 + 1;
		}
		else {
			result += 90000;
		}
	}

	cout << result << endl;

	return 0;
}


//int main()
//{
//	long long A, B, C;
//
//	cin >> A >> B >> C;
//
//	long long lastA = A - B;
//
//	if (C <= lastA) {
//		cout << 0 << endl;
//	}
//	else {
//		cout << C - lastA << endl;
//	}
//
//	return 0;
//}

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

using namespace std;

#define LL long long
#define N 800000

const LL mod=998244353;
LL n,len,vis[N],a[N],ans,sum,num[N],q[N],cnt[N];

void all_1(){
	LL tmp=1;
	for (LL i=1;i<=n;++i){
		if (a[i]!=1) return;
		tmp=tmp*i%mod;
	}
	printf("%lld\n",tmp); exit(0);
}

void no_1(){
	bool fl=1;
	for (LL i=1;i<=n;++i) if (a[i]==1){fl=0; break;}
	if (fl){puts("0"); exit(0);}
}

void too_long(){
	for (LL i=2,j=1;i<=n;++i){
		if (a[i]==a[i-1]) ++j;
		else j=1;
		if (j>len){puts("0"); exit(0);}
	}
}

void not_continue(){
	vis[1]=1;
	for (LL i=2;i<=n;++i){
		if (a[i]!=a[i-1]&&vis[a[i]]){puts("0"); exit(0);}
		vis[a[i]]=1;
	}
	memset(vis,0,sizeof vis);
}

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i) scanf("%lld",a+i);
	all_1(); no_1();
	for (LL i=1;i<=n;++i) a[i+n]=a[i];
	for (LL i=2;i<=n+1;++i)
		if (a[i]==1&&a[i-1]!=1){
			for (LL j=1;j<=n;++j) a[j]=a[j+i-1];
			break;
		}
	a[n+1]=0;
	for (len=1;len<=n;++len) if (a[len+1]!=1) break;
	for (LL i=n,tt=1,ww=0;i;--i){
		for (;tt<=ww&&q[tt]>=i+len;++tt);
		for (;tt<=ww&&a[q[ww]]<a[i];--ww);
		q[++ww]=i;
		++cnt[a[q[tt]]];
	}
	too_long(); not_continue();
	for (LL i=len+1;i<=n;++i){
		if (a[i]>a[i-1]){
			LL x=a[i-1];
			if (vis[x]&&vis[x]!=i-len){puts("0"); return 0;}
			vis[x]=i-len;
			num[x]=1;
		}
		if (a[i]<a[i-1]){
			LL x=a[i];
			if (vis[x]&&vis[x]!=i){puts("0"); return 0;}
			vis[x]=i;
			num[x]=1;
		}
	}
	for (LL i=2;i<=n;++i)
		if (a[i]>a[i-1]&&!vis[a[i]]){
			vis[a[i]]=1;
			for (LL j=i;a[j]==a[i];++j) ++num[a[i]];
			num[a[i]]=len-num[a[i]]+1;
			for (LL j=i-1;j>=i-num[a[i]]+1;--j)
				if (a[j]>a[i]){puts("0"); return 0;}
		}
	ans=1;
	for (LL i=1;i<=n;++i){
		sum+=cnt[i];
		if (vis[i]) ans=ans*num[i]%mod;
		else ans=ans*sum%mod;
		--sum;
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 25344
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {i:0 for i in range(1,m+1)}
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(len([i for i in kdict.values() if i == n]))


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

s = (n**0.5) + 1

li = []

for i in range(1, int(s+1)):
    if n%i == 0:
        li.append(i)
        li.append(n//i)
        
print(max(len(str(li[-1])), len(str(li[-2]))))
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int result = 0;
  int plus = 1;
  
  for (int i = 1; i <= K; i++){
    if (i > A) plus=0;
    if (i > A+B) plus=-1;
    result +=plus;
  }
  cout << result << endl;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	set<char> s;
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		char c;
		cin >> c;
		s.insert(c);
	}
	if(s.size() == 3){
		cout << "Three" << endl;
	}
	else{
		cout << "Four" << endl;
	}
}


Measured memory_bytes: 892
# 173 B
N = int(input())
AC, WA, TLE, RE = 0, 0, 0, 0
for i in range(0, N):
    S = input()
    if S == 'AC':
        AC += 1
    elif S == 'WA':
        WA += 1
    elif S == 'TLE':
        TLE += 1
    else:
        RE += 1

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Measured memory_bytes: 9148
import java.util.Scanner;

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

    int N = sc.nextInt();
    int order[];
    order = new int[N];

    for(int i = 0; i < N; i++) {
      order[sc.nextInt() - 1] = i + 1;
    }
    for(int n = 0; n < N; n++) {
      System.out.println(order[n]);
    }
  }
}


Measured memory_bytes: 61180
function Main(input) {
  input = input.trim()
switch(input){
  case "a":
  case "i":
  case "u":
  case "e":
  case "o":
  console.log("vowel");
  break;
  default:
  console.log("consonant");
    break;
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define white 0
#define black -1
#define grey 1
#define infly 1<<21
using namespace std;
int a[110][110],n;
int d[110];
int color[110];

void bfs()
{
    memset(d,0,sizeof(d));
    queue<int> Q;
    for(int i=1;i<=n;i++)
        d[i]=infly;
    d[1]=0;
    for(int i=1;i<=100;i++)
        color[i]=white;
    Q.push(1);
    while(!Q.empty())
    {
        int u=Q.front();
        Q.pop();
        for(int i=1;i<=n;i++)
        {
            if(a[u][i]==0)
                continue;
            if(d[i]!=infly)
                continue;
                Q.push(i);
                d[i]=d[u]+1;
        }
    }
    for(int i=1;i<=n;i++)
   {
       cout<<i<<" "<<((d[i]==infly)?(-1):d[i])<<endl;
   }

}

int main()
{
   int key,d,x;
   memset(a,0,sizeof(a));
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       scanf("%d%d",&key,&d);
       for(int j=1;j<=d;j++)
       {
        scanf("%d",&x);
        a[key][x]=1;
       }
   }
   bfs();
   return 0;
}

Measured memory_bytes: 3224
def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    count = 0
    for i in range(n - 2):
        if (p[i] < p[i + 1] < p[i + 2]) or (p[i + 2] < p[i + 1] < p[i]):
            count += 1
    return count

print(main())


Measured memory_bytes: 2940