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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int X, Y;
	cin >> X >> Y;
	int ans = 0;
	if (X==1) {
		ans += 300000;
	}
	else if (X==2) {
		ans += 200000;
	}
	else if (X==3) {
		ans += 100000;
	}
	if (Y == 1) {
		ans += 300000;
	}
	else if (Y == 2) {
		ans += 200000;
	}
	else if (Y == 3) {
		ans += 100000;
	}
	if (X==Y&&X==1) {
		ans += 400000;
	}
	ce(ans)

    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
    
signed main(){
    int n,m;
    cin >> n >> m;
    int k[11],p[11];
    vector<int> s[11];
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int ss;
            cin >> ss;
            s[i].pb(ss);
        }
    }
    rep(i,m)cin >> p[i];
    int ans = 0;
    // rep(i,m){
    //     cerr << k[i] << " : ";
    //     rep(j,k[i])cerr << s[i][j] << " ";
    //     cerr << endl;
    // }



    for(int bit = 0;bit < (1<<(n));bit++){
        //cerr << "bit " << bit << endl;
        int c = 1;
        rep(i,m){
            //cerr << "m " << i ;
            int cnt = 0;
            rep(j,k[i]){
                if(bit&(1<<(s[i][j]-1)))cnt++;
            }
            //cerr << " cnt " << cnt << endl;
            if(cnt%2 != p[i])c = 0;
        }
        if(c == 1){
            ans++;
            //cerr << bit << endl;
        }
    }
    cout << ans << endl;
    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc128.contest.atcoder.jp/tasks/abc128_a

Measured memory_bytes: 256
import numpy as np

s = np.array(list(map(int, input())))

expected = []

for i in range(len(s)):
    if (i % 2 == 0):
        expected.append(0)
    else:
        expected.append(1)

expected = np.array(expected)

union = s + expected
union = union % 2
union = union.tolist()

cnt_0 = union.count(0)
cnt_1 = union.count(1)

print(min(cnt_0, cnt_1))

Measured memory_bytes: 15520
#include <stdio.h>

int main(void)
{
  int n, a;
  char number[100];

  fgets(number, sizeof(number), stdin);
  sscanf(number, "%d", &n);
  fgets(number, sizeof(number), stdin);
  sscanf(number, "%d", &a);

  n %= 500;

  if (n <= a) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n + 1)
    {
        if ((i % 3LL) == 0 || (i % 5LL) == 0)
            continue;
        ans += i;
    }

    cout << ans << endl;

    return 0;
}

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

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

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

int main() {
    int n;
    while(cin >> n, n){
        int ans = INF<int>;
        for (int y = 0; y*y <= n; ++y) {
            int yy = y*y;
            for (int z = 0; z*z*z+yy <= n; ++z) {
                ans = min(ans, y+z+n-yy-z*z*z);
            }
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3000
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long int

int n;
int a[100005];
multiset<int> ms;
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i ++)
		cin >> a[i];
	for(int i = 1 ; i <= n ; i ++){
		if(!ms.size()) {
			ms.insert(a[i]);
			continue;
		}
		multiset<int>::iterator it = ms.lower_bound(a[i]);
		if(it == ms.begin()) ms.insert(a[i]);
		else{
			it --;
			ms.erase(it);
			ms.insert(a[i]);
		}
	}
	cout << ms.size();
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
    //cin>>t;
    while(t--){
        ll x;
        cin>>x;

        ll r = (x/500);
        ll rr =(x%500)/5;
        ll res = r*1000 + rr*5;

        printf("%lld\n", res);

        //printf("Case %d: ",++te);
    }
    return 0;
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        scan.nextLine();
        String s1 = scan.nextLine();
        String s2 = scan.nextLine();
        char arr[] = s1.toCharArray();
        if(N == 1){
            System.out.println("3");
            return;
        }
        if(N == 2){
            System.out.println("6");
            return;
        }
        long result = 1;
        boolean horizon = true;
        int i = 0;
        if(arr[0] == arr[1]){   //起始横
            horizon = true;
            result = 6;
            i = 2;
        }else{  //起始竖
            horizon = false;
            result = 3;
            i = 1;
        }
        while(i<N-1){
            if(arr[i] == arr[i+1]){ //横
                if(horizon) result*=3;
                else result*= 2;
                horizon = true;
                i += 2;
            }else {  //竖
                if (horizon) {
                } else result *= 2;
                i++;
                horizon = false;
                if (i == N - 1) result *= 2;
            }
        }
        long res = result%1000000007;
        System.out.println(res);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);

int main() {
    int l, r; cin >> l >> r;
    if (r - l >= 2018) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 2018;
    rep3(i, l, r) rep3(j, i + 1, r + 1) {
        int sa = (ll)i * j % 2019;
        chmin(ans, sa);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
double dp[101][107];
double dp1[101][107];
int val[107];
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),a){
		for(int i=0;i<101;i++){
			for(int j=0;j<107;j++){
				dp[i][j]=0;
				dp1[i][j]=0;
			}
			val[i]=0;
		}
		for(int i=0;i<c;i++){
			int p;
			scanf("%d",&p);
			val[p]=1;
		}
		for(int i=0;i<d;i++){
			int p;
			scanf("%d",&p);
			val[p]=2;
		}
		dp[0][0]=1.0;
		for(int i=0;i<b;i++){
			for(int j=0;j<=a-1;j++){
				for(int k=1;k<=6;k++){
					int m=j+k;
					if(j+k>a)m=a-(j+k-a);
					if(val[m]==1){
						dp[i+2][m]+=dp[i][j]/6;
						dp1[i+1][m]+=dp[i][j]/6;
					}else if(val[m]==2){
						dp[i+1][0]+=dp[i][j]/6;
					}else dp[i+1][m]+=dp[i][j]/6;
				}
			}
		}
		double ret=0;
		for(int i=0;i<=b;i++)
				ret+=dp[i][a]+dp1[i][a];
		printf("%.6f\n",ret);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int x;
  cin >> x;
  int h, m, s;
  h = x / (60 * 60);
  m = (x / 60) % 60;
  s = x % 60;

  cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int n,d;
int **x;
const int inf = 1e5;

int get_norm(int a, int b){
  int norm=0;
  for(int j=0; j<d; j++){
    norm += (x[a][j] - x[b][j])*(x[a][j] - x[b][j]);
  }
  return norm;
}

bool check(int norm){
  int min_sq = (int)sqrt(norm);
  min_sq--;
  for(int i=min_sq; i<inf; i++){
    int sq = i*i;
    if(sq==norm) return true;
    if(sq > norm) return false;
  }
}

int main(){
  cin >> n >> d;
  x = new int*[n];
  for(int i=0; i<n; i++){
    x[i] = new int[d];
    for(int j=0; j<d; j++) cin >> x[i][j];
  }
  int count = 0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      int norm = get_norm(i,j);
      if(check(norm)) count++;
    }
  }
  
  cout << count << "\n";
}
  

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

int main() {
  int K;
  cin >> K;
  vector<int> str;

  str = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  cout << str.at(K - 1);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(n-1, i, -1):
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]
            count += 1

print(' '.join(map(str, a)))
print(count)



Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
using namespace std;
typedef long long ll;
const int mo = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; i++)
char str[210000];
void solve()
{
    scanf("%s",str);
    int n = strlen(str);
    rep(i,n-1)if(str[i]==str[i+1]){printf("%d %d\n",i+1,i+2);return ;}
    rep(i,n-2)if(str[i]==str[i+2]){printf("%d %d\n",i+1,i+3);return ;}
    printf("-1 -1\n");
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 384
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ba = b - a
ca = c - a
da = d - a
ea = e - a
cb = c - b
db = d - b
eb = e - b
dc = d - c
ec = e - c
ed = e - d

if ba > k or ca > k or da > k or ea > k or cb > k or db > k or eb > k or dc > k or ec > k or ed > k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let m: i32 = read();
    let mut xs = vec![];
    let mut ys = vec![];
    xs.push(read::<i32>());
    ys.push(read::<i32>());
    xs.append(&mut (0..n).map({|_| read()}).collect());
    ys.append(&mut (0..m).map({|_| read()}).collect());
    let x_max = xs.iter().max().unwrap();
    let y_min = ys.iter().min().unwrap();
    println!("{}", if x_max < y_min { "No War" } else { "War" });
}


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

int N, M, Q;

int dfs(vector<int>& A, const vector<int>& a, const vector<int>& b, const vector<int>& c, const vector<int>& d){
  int ans = 0;
  if(A.size() == N){
    for(int i = 0; i < Q; ++i){
      if(A[b[i]]-A[a[i]] == c[i])
        ans += d[i];
    }
    return ans;
  }
  int k = 1;
  if(A.size()) k = A.back();
  for(int i = k; i <= M; ++i){
    A.push_back(i);
    ans = max(ans,dfs(A,a,b,c,d));
    A.pop_back();
  }
  return ans;
}

int main(){
  cin >> N >> M >> Q;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  for(int i = 0; i < Q; ++i){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i],--b[i];
  }
  vector<int> A;
  int ans = dfs(A,a,b,c,d);
  cout << ans << endl;
}


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

int main() {
  ll n,m;
  cin>>n>>m;
  ll x[m];
  for(int i=0;i<m;i++) cin>>x[i];
  if(n>=m) {
    cout<<0<<endl;
    return 0;
  }
  sort(x,x+m);
  ll l[m-1];
  ll ans=0;
  for(int i=0;i<m-1;i++){
    l[i]=x[i+1]-x[i];
    ans+=l[i];
  }
  sort(l,l+m-1,greater<ll>());
  for(int i=0;i<n-1;i++){
    ans-=l[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
def main():
    numbers = [0] * (10 ** 5 + 1)
    prime = [0] * (10 ** 5 + 1)
    numbers[2] = 1
    prime[2] = 1
    for i in range(3, 10 ** 5 + 1):
        if i % 2:
            is_prime = True
            j = 1
            while j * j <= i and is_prime:
                if (not i % j) and j > 1:
                    is_prime = False
                j += 1
            if is_prime:
                prime[i] = 1
            if is_prime and prime[(i + 1) // 2] and (((i + 1) // 2) % 2 or i == 3):
                numbers[i] = numbers[i - 1] + 1
            else:
                numbers[i] = numbers[i - 1]
        else:
            numbers[i] = numbers[i - 1]
    query = int(input())
    for _ in range(query):
        left, right = map(int, input().split())
        tmp = 0
        if left <= 2 <= right:
            tmp = -1
        print(numbers[right] - numbers[left - 1] + tmp)


if __name__ == '__main__':
    main()

Measured memory_bytes: 4980
#include <cstdio>

long long dp[300009];
long long M = 998244353;

long long modpow(long long b, int e){
    if (e==0) return 1;
    else if (e%2==1) return b*modpow(b,e-1)%M;
    else {
        long long x = modpow(b,e/2);
        return x*x%M;
    }
}

int main(){
    long long N, A, B, K;
    scanf("%lld %lld %lld %lld", &N, &A, &B, &K);
    dp[0] = 1;
    for (int i = 1; i <= N; i++){
        dp[i] = (dp[i-1]*(N-i+1))%M*modpow(i,M-2)%M;
        //printf("%lld ", dp[i]);
    }
    long long ans = 0;
    for (int i = 0; i <= N; i++){
        if ((K-i*A)%B==0LL && (K-i*A)/B<=N&&(K-i*A)/B>=0){
            ans += dp[i]*dp[(K-i*A)/B];
            ans %= M;
        }
    }
    printf("%lld", ans);
}


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

int main(){
  int n;
  cin >> n;
  for(int i=0; i<9; i++){
    for(int j=0; j<9; j++){
      if(n==(i+1)*(j+1)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else if(s=="Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
type point = {x:int; y:int}

let () = Scanf.scanf "%d %d" @@ fun n d ->
  let pp = Array.init n @@ fun _ ->
    Scanf.scanf " %d %d" @@ fun a b -> {x = a; y = b}
  in
  let ans = ref 0 in
  for i = 0 to n - 1 do
    if pp.(i).x * pp.(i).x + pp.(i).y * pp.(i).y <= d * d then ans := !ans + 1
  done;
  Printf.printf "%d\n" !ans

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int a; cin >> a;
    string s; cin >> s;
    cout << (a >= 3200 ? s : "red") << en;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int calc(int n,int i){
  int j=0;
  while(n>1){
    j+=n/i;
    n/=i;
    }
  return j;
  }
    
int main(){
  int m=1001;
  bool isprime[m];
  rep(i,m)isprime[i]=true;
  isprime[0]=isprime[1]=false;
  rep(i,m)
    if(isprime[i])
      for(int j=2;j*i<m;j++)
        isprime[i*j]=false;
  int n;
  ll ans=1;
  cin>>n;
  rep(i,n+1)
    if(isprime[i]){
      ans*=(calc(n,i)+1);
      ans%=1000000007;
      }
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  char t;
  cin >> t;
  switch(t){
    case 'T':
      cout << 'A' << endl;
      break;
    case 'A':
      cout << 'T' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
  }
}

Measured memory_bytes: 256
r, c = map(int, input().split())
hyou = []
tate_sum = [0] * (c + 1)
for i in range(r):
    line = list(map(int, input().split()))
    line.append(sum(line))
    tate_sum = [tate_sum[j] + line[j] for j in range(len(line))]
    line = map(str, line)
    hyou.append(" ".join(line))
    
tate_sum = map(str, tate_sum)
hyou.append(" ".join(tate_sum))
print("\n".join(hyou))

Measured memory_bytes: 7752
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const LL M=1000000007;
int c[100000+10];
int main() {
	c[0]=3;
	LL ret=1;
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		ret*=c[a];
		ret%=M;
		c[a]--;
		c[a+1]++;
	}
	cout << ret << endl;

	return 0;
}



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

int main(){
  string s;
  cin >>s;
  bool AC = false;
  rep(i,s.size()-1){
    string s1;
    for(int j = i; j<i+2; j++){
      s1 += s[j];
    }
    if(s1=="AC") AC = true;
  }
  if(AC) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

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

    string ans;
    if (N%10 == 3) ans = "bon";
    else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8) ans = "pon";
    else ans = "hon";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 600005;
const int MAXT = 2100000;

struct seg{
	lint tree[MAXT];
	int lim;
	void init(int n){
		for(lim = 1; lim <= n; lim <<= 1);
		fill(tree, tree + MAXT, -1e18);
	}
	void upd(int s, int e, lint x){
		auto upd = [&](int x, lint y){
			tree[x] = max(tree[x], y);
		};
		s += lim;
		e += lim;
		while(s < e){
			if(s%2 == 1) upd(s++, x);
			if(e%2 == 0) upd(e--, x);
			s >>= 1;
			e >>= 1;
		}
		if(s == e) upd(s, x);
	}
	lint query(int x){
		lint ret = -1e18;
		for(int i=x+lim; i; i>>=1) ret = max(ret, tree[i]);
		return ret;
	}
}seg[4][2];

struct interval{
	int s, e;
	int color;
	lint cost;
	bool operator<(const interval &i)const{
		return pi(s, e) < pi(i.s, i.e);
	}
};

vector<interval> a;
int n, m, x, y;
vector<int> v;
lint dp[MAXN];

int main(){
	scanf("%d %d %d %d",&n,&m,&x,&y);
	y += x;
	v.push_back(0);
	v.push_back(n);
	for(int i=0; i<m; i++){
		int c, l, r; scanf("%d %d %d",&c,&l,&r);
		v.push_back(l-1);
		v.push_back(r);
		a.push_back({l-1, r, c, 1ll * (r-l+1) * x});
	}
	sort(all(v));
	v.resize(unique(all(v)) - v.begin());
	for(int i=1; i<sz(v); i++){
		a.push_back({v[i-1], v[i], 0, 0});
	}
	for(auto &i : a){
		i.s = lower_bound(all(v), i.s) - v.begin();
		i.e = lower_bound(all(v), i.e) - v.begin();
	}
	sort(all(a));
	for(int i=0; i<8; i++) seg[i/2][i%2].init(sz(a));
	lint dap = 0;
	for(int i=sz(a)-1; i>=0; i--){
		dp[i] = max(dp[i], seg[a[i].color][0].query(a[i].e) - 1ll * v[a[i].e] * x);
		dp[i] = max(dp[i], seg[a[i].color][1].query(a[i].e) - 1ll * v[a[i].e] * (x + y));
		dp[i] += a[i].cost;
		dap = max(dap, dp[i]);
		for(int j=0; j<4; j++){
			if(a[i].color != j){
				seg[j][1].upd(a[i].s, a[i].e, dp[i] + 1ll * v[a[i].s] * (x + y));
			}
			else{
				seg[j][0].upd(a[i].s, a[i].e, dp[i] + 1ll * v[a[i].s] * x);
			}
		}
	}
	cout << dap << endl;
}



Measured memory_bytes: 154736
#include <bits/stdc++.h>
const int B = 2 << 20;
struct streambufcin {
	std::streambuf *in;
	streambufcin() {
		std::ios::sync_with_stdio(false);
		std::cin.tie(NULL);
		in = std::cin.rdbuf();
		bg = ed = NULL;
#ifdef LOCAL
		freopen("in.in", "r", stdin);
#endif
	}
	char buf[B], *bg, *ed, ch;
	char gc() { return bg == ed ? ed = buf + in -> sgetn(bg = buf, B), (bg == ed ? -1 : *bg++) : *bg++; }
	template<class T>
	streambufcin &operator >> (T &x) {
		bool neg = false;
		for (ch = gc(); !isdigit(ch); ch = gc());
		if (ch == '-')
			neg = true;
		for (x = 0; isdigit(ch); ch = gc())
			x = x * 10 + ch - 48;
		if (neg)
			x = -x;
		return *this;
	}
	streambufcin &operator >> (char &c) {
		for (c = gc(); isspace(c); c = gc());
		return *this;
	}
} cin;

struct streambufcout {
	std::streambuf *out = std::cout.rdbuf();
	char buf[B], *optr = buf;
	streambufcout() { out = std::cout.rdbuf(); }
	~streambufcout() { flush(); }
	void flush() { out -> sputn(buf, optr - buf); optr = buf; }
	void pc(char c) {
		if (optr == buf + B)
			flush();
		*optr++ = c;
	}
	template<class T>
	streambufcout &operator << (T x) {
		static int st[233], top;
		if (x < 0) {
			x = -x;
			pc('-');
		}
		do {
			st[++top] = x % 10;
			x /= 10;
		} while (x);
		while (top)
			pc(st[top--] ^ 48);
		return *this;
	}
	streambufcout &operator << (char c) { pc(c); return *this; }
} cout;

int n;
const int N = 1000000;
int cnt[N + 1], mu[N + 1];
long long f[N + 1];

const int mod = 998244353;
int qpow(int x, int y) {
	int result = 1;
	for (; y; y >>= 1, x = 1ll * x * x % mod)
		if (y & 1)
			result = 1ll * result * x % mod;
	return result;
}

int main() {
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	mu[1] = 1;
	for (int i = 1; i <= N; i++)
		for (int j = i * 2; j <= N; j += i)
			mu[j] -= mu[i];
	for (int i = 1; i <= N; i++)
		for (int j = i; j <= N; j += i)
			f[j] += 1ll * mu[i] * i;
	for (int i = 1; i <= N; i++)
		f[i] %= mod;
	long long answer = 0;
	for (int i = 1; i <= N; i++) {
		long long total = 0;
		for (int j = 1; j <= N / i; j++) {
			total += 1ll * j * cnt[i * j];
		}
		total %= mod;
		answer += 1ll * total * total % mod * f[i] % mod * i % mod;
		answer %= mod;
	}
	for (int i = 1; i <= N; i++) {
		answer -= 1ll * cnt[i] * i % mod;
	}
	answer = (answer % mod + mod) % mod;
	answer = 1ll * answer * qpow(2, mod - 2) % mod;
	cout << answer << '\n';
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
 
int main() {
	int m, n;
	cin >> n >> m;
	int b[m], c[n];
	int A[n][m];
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			cin >> A[i][j];
		}
	}
	
	for(int i=0;i<m;i++) {
		cin >> b[i];
	}
	
	for(int i=0;i<n;i++) {
		int k=0;
		for(int j=0;j<m;j++) {
			k += A[i][j] * b[j];
		}
		cout << k << endl;
	}
	
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> f(N + 1);
  for (int x = 1; x < N; x++)
  {
    for (int y = 1; y < N; y++)
    {
      for (int z = 1; z < N; z++)
      {
        int index = x * x + y * y + z * z + x * y + y * z + z * x;
        if (index > N)
        {
          break;
        }
        f.at(index)++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
  {
    cout << f.at(i) << endl;
  }
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main() {
  long k,a,b;
  cin>>k>>a>>b;
  long t=a%k;
  if(t==0)
  cout<<"OK";
  else
  {
      if(a+(k-t)<=b)
      cout<<"OK";
      else
      cout<<"NG";
  }
}

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

int main(void) {
	// your code goes here
	
	int a,b,c;
	int d =3;
	cin>>a>>b>>c;
	
	if(a == b){
		d--;
	}
	if(a == c){
		d--;
	}
	if(b == c){
		d--;
	}
	if(d != 0){
		cout <<d<<endl;
	}else{
		cout <<d+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
total = 0
for i in range(n):
    if B[i] >= A[i]:
        total += A[i]
        B[i] -= A[i]
        if A[i+1] < B[i] :
            total += A[i+1]
            A[i+1] = 0
        else:
            total+= B[i]
            A[i+1] -= B[i]
    else:
        total += B[i]
print(total)

Measured memory_bytes: 82020
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
 
        switch (s) {
            case "SUN":
                ans = 7;
                break;
            case "MON":
                ans = 6;
                break;
            case "TUE":
                ans = 5;
                break;
            case "WED":
                ans = 4;
                break;
            case "THU":
                ans = 3;
                break;
            case "FRI":
                ans = 2;
                break;
            case "SAT":
                ans = 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35688
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	string s;
	cin>>s;
	//trace(s);
	stack<char>S;
	FER(i,0,sz(s)){
		char c=s[i];
		if(sz(S)==0){
			S.push(c);
			continue;
		}
		if(S.top()==c)S.push(c);
		else S.pop();
	}
	cout<<sz(s)-sz(S)<<endl;
	return 0;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

int main()
{
	string a;
	cin >> a;
	printf((~a.find("AC")) ? "Yes" : "No");
	return 0;
}


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

using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
    ios_base::sync_with_stdio(0);

    int u = 10;

    int n; cin >> n;

    vi f(n);

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < u; j++)
        {
            int x; cin >> x;

            if(x) f[i] |= 1 << j;
        }
    }

    vvi p(n, vi(u + 1));

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < u + 1; j++)
        {
            int x; cin >> x;

            p[i][j] = x;
        }
    }

    int ans = INT_MIN;

    for(int mask = 1; mask < 1024; mask++)
    {
        int sum = 0;

        for(int i = 0; i < n; i++)
            sum += p[i][__builtin_popcount(mask & f[i])];

        ans = max(ans, sum);
    }

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

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


int main(){
    int n,m;
    int i;

    cin >> n >> m;
    int a[100010],b[100000];


    vector<vector<int>> data(100000);
    int aa,ba;

    REP(i,n){
        cin >> aa >> ba;
        data[aa].push_back(ba);
    }

    
    int ans = 0;
    int k ;
    int lim = min(m+1,n);
    //cout << "limは" <<  lim << endl;

    priority_queue<int> que;

    for (int i = 0; i < m+1 ; i++){
        REP(k,data[i].size()){
            que.push(data[i][k]);
        }
        //cout << i << "の回" << endl;
        if (que.size() != 0){
            ans += que.top();
            que.pop();
            
        }
        //cout << ans << endl;
    } 
    cout  << ans << endl;
    return 0;

}


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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int L; cin >> L;
	long double x = (long double)L / 3.0;

	printf("%.10Lf\n", x * x * x);

	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;

  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		try (Scanner sc = new Scanner(System.in)) {
			String S = sc.nextLine();
			for (int i = 0; i < S.length(); i++) {
				if (Character.isUpperCase(S.charAt(i))) {
					System.out.print(Character.toLowerCase(S.charAt(i)));
				} else {
					System.out.print(Character.toUpperCase(S.charAt(i)));
				}
			}
			System.out.println("");
		}
	}
}



Measured memory_bytes: 26988
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ans = [1]*n
for i in range(m):
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        ans[ab[i][0]-1] = 0
        ans[ab[i][1]-1] = 0
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        ans[ab[i][1]-1] = 0
    else:
        ans[ab[i][0]-1] = 0
print(sum(ans))


Measured memory_bytes: 31952
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


signed main(){
	int X, Y;
	cin >> X >> Y;

	cout << X + Y/2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;


string t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

int main() {
	
	int n;
	while(cin >> n, n){
		vector<int> k(n);
		rep(i, n) cin >> k[i];
		string s;
		cin >> s;
		
		rep(i, s.size()){
			int d = (s[i] <= 'Z' ? s[i] - 'A' : 26 + s[i] - 'a');
			cout << t[(d+52-k[(i%n)])%52];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3180
import itertools, collections
N = int(input())
XY = sorted([[int(_) for _ in input().split()] for _ in range(N)])
count = collections.defaultdict(int)
for i, j in itertools.combinations(range(N), 2):
    x1, y1 = XY[i]
    x2, y2 = XY[j]
    count[y2 - y1 + (x2 - x1) * 10**10] += 1
if count:
    print(N - max(count.values()))
else:
    print(1)


Measured memory_bytes: 3436
#include<set>
#include<map>
#include<cmath>
#include<deque>
#include<stack>
#include<ctime>
#include<queue>
#include<vector>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define LL long long
#define ULL unsigned long long
using namespace std;
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 300000
#define INF 0x3f3f3f3f
#define Mod 998244353
void Add(int &x,int &y){if(x)x--,y++;return ;}
int cnt[10];
char S[MAXN+5];
int main(){
	int n=read();
	scanf("%s",S+1);
	LL ans=1;
	for(int i=1;i<=3*n;i++){
		int opt=(S[i]=='R'?1:S[i]=='G'?2:3);
		if(cnt[7-opt]) ans=ans*cnt[7-opt]%Mod,cnt[7-opt]--;//a b c ab ac bc
		else if(opt==1&&(cnt[2]+cnt[3])) ans=ans*(cnt[2]+cnt[3])%Mod,Add(cnt[2],cnt[4]),Add(cnt[3],cnt[5]);
		else if(opt==2&&(cnt[1]+cnt[3])) ans=ans*(cnt[1]+cnt[3])%Mod,Add(cnt[1],cnt[4]),Add(cnt[3],cnt[6]);
		else if(opt==3&&(cnt[1]+cnt[2])) ans=ans*(cnt[1]+cnt[2])%Mod,Add(cnt[1],cnt[5]),Add(cnt[2],cnt[6]);
		else cnt[opt]++;
	}
	for(int i=1;i<=n;i++)
		ans=ans*i%Mod;
	printf("%lld\n",ans);
	return 0;
}



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

int N, M;
vector<vector<int>> A;

void dfs (vector<int> v, int d, int p) {
  if (d == N) {
    A.push_back(v);
    return;
  }
  for (int i = p; i <= M; i++) {
    vector<int> nv = v;
    nv.push_back(i);
    dfs(nv, d + 1, i);
  }
}

int main() {
  cin >> N >> M;
  vector<int> start;
  dfs(start, 0, 1);

  int Q;
  cin >> Q;
  vector<vector<int>> V(Q, vector<int>(4));
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> V.at(i).at(j);
    }
  }

  int ans = 0;
  for (int i = 0; i < A.size(); i++) {
    int sum = 0;
    for (int j = 0; j < Q; j++) {
      if (A.at(i).at(V.at(j).at(1) - 1) - A.at(i).at(V.at(j).at(0) - 1) == V.at(j).at(2)) {
        sum += V.at(j).at(3);
      }
    } 
    ans = max(ans, sum);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 9876
#include <iostream>

using namespace std;


constexpr auto BASE = 1000000007;


class atcalc {

public:
	static int add(int a, int b)
	{
		return (int)(((long long)a + b) % BASE);
	}
	static int times(int a, int b)
	{
		return (int)(((long long)a * b) % BASE);
	}
	static int div(int a, int b)
	{
		return (int)(((long long)a * atcalc::modinv(b, BASE)) % BASE);
	}

	static int comb(int a, int b)
	{
		if (a < b) { return 0; }
		if (b > a / 2) { b = a - b; }
		if (b == 0) { return 1; }


		int ans = 1;
		for (int i = 0; i < b; i++) {
			ans = atcalc::times(ans, a - i);
		}
		for (int i = 0; i < b; i++) {
			ans = atcalc::div(ans, i + 1);
		}


		return ans;
	}

	static int modinv(int a, int m)
	{

		long long x = 0, y = 1, gcd = m;
		long long  px = 1, py = 0, pgcd = a;
		long long temp = 0;

		while (gcd > 0)
		{
			long long quotient = pgcd / gcd;

			temp = x;
			x = px - quotient * temp;
			px = temp;

			temp = y;
			y = py - quotient * temp;
			py = temp;

			temp = gcd;
			gcd = pgcd - quotient * temp;
			pgcd = temp;
		}

		while (px < 0) {
			px += BASE;
		}
		return (int)px;
	}
};

int X, Y;
int main()
{
	cin >> X;
	cin >> Y;
	
	if (X < Y) { swap(X,Y); }

	int dif = X - Y;

	if ((Y - dif) % 3) {
		cout << 0 << endl;
		return 0;
	}
	int same = (Y - dif) / 3;
  	if (same < 0) {
		cout << 0 << endl;
		return 0;
	}

	long long ans = 1;

	ans = atcalc::comb(same*2+dif,same);

	cout << ans << endl;

	return 0;


}


Measured memory_bytes: 256
#include <iostream>

struct Node{
	Node *prev, *next;
	int num;
};

int main(){
	while(true){
		int n, m, cnt;
		Node node[1002];

		std::cin >> n >> m;
		cnt = n;
		
		if(n == 0 && m == 0)break;
	
		for(int i = 1; i <= n; i++){
			node[i].next = &node[i + 1];
			node[i].prev = &node[i - 1];
	
			if(i == 1)node[i].prev = &node[n];
			if(i == n)node[i].next = &node[1];
			node[i].num = i;
		}

		Node *now = &node[1];
		int i = 1;
		while(cnt > 1){
			if(i == m){
				now -> prev -> next = now -> next;
				now -> next -> prev = now -> prev;
				i = 1;
				cnt--;
			}
			else i++;
		
			now = now -> next;
		}

		std::cout << now -> num << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1184
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(k>=n){
        cout << n-1 << endl;
        return 0;
    }
    int init = 0;
    REP(i,n){
        if(s[i]=='R'){
            if(i<n-1&&s[i+1]=='R'){
                init++;
            }
        }else{
            if(i>0&&s[i-1]=='L'){
                init++;
            }
        }
    }
    //cout << init << endl;
    
    int now=1;
    int ret;
    {
        int ans = init;
        int mode = 0;
        int t=k;
        while(now<n){
            if(mode==1){
                if(s[now-1]!=s[now]&&t>0){
                    t--;
                    ans=min(n,ans+2);
                    mode=0;
                }
            }else{
                if(s[now-1]!=s[now]){
                    mode=1;
                }
            }
            now++;
        }
        if(t>0&&mode==1){
            ans=min(n,ans+1);
        }
        ret=ans;
    }
    {
        int ans = init;
        int mode = 0;
        int t=k;
        now=n-1;
        while(now>0){
            if(mode==1){
                if(s[now-1]!=s[now]&&t>0){
                    t--;
                    ans=min(n,ans+2);
                    mode=0;
                }
            }else{
                if(s[now-1]!=s[now]){
                    mode=1;
                }
            }
            now--;
        }
        if(t>0&&mode==1){
            ans=min(n,ans+1);
        }
        ret = max(ret,ans);
    }
    cout <<ret << endl;
    return 0;
}

Measured memory_bytes: 512