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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template
str s;
int n,buka,tutup;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int op,cl;
    op = 0; cl = 0;

    cin>>n;
    cin>>s;

    for(int i=0;i<s.size();i++){
        if(s[i]=='(') op++;
        else cl ++;

        buka = max(buka,cl-op);
    }

    op = 0; cl = 0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]==')') cl++;
        else op ++;

        tutup = max(tutup,op-cl);
    }

    for(int i=1;i<=buka;i++)cout<<"(";
    cout<<s;
    for(int i=1;i<=tutup;i++)cout<<")";cout<<newl;


}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, K = map(int, input().split())
A = list(sorted(map(int, input().split())))
s = sum(A)
i = 2
cands = [s]
while i ** 2 <= s:
    if s % i == 0:
        cands.append(i)
        cands.append(s // i)
    i += 1
cands = sorted(cands)

ans = 1
for cand in cands:
    B = deque(list(sorted(map(lambda x: x % cand, A), reverse=True)))
    k = 0
    while len(B) > 0:
        x = B.popleft()
        while x % cand != 0:
            y = B.pop()
            z = x + y
            if z > cand:
                k += cand - x
                x = cand
                y = z - cand
                B.append(y)
            else:
                k += y
                x = z
    if k <= K:
        ans = max(ans, cand)
print(ans)

Measured memory_bytes: 9528
n=int(input())
nc=n
out=[]

while n%2==0:
    out.append(2)
    n//=2

for i in range(3,int(n**0.5)+1,2):
    if n==1 : break
    while n%i==0:
        out.append(i)
        n//=i

if n!=1 : out.append(n)

print("{}: {}".format(nc," ".join(map(str,out))))


Measured memory_bytes: 5640
#include<bits/stdc++.h>
#define pii   pair<int,int>
#define hell  1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb  push_back

typedef long long  ll;
using namespace std;

int main(){
   
    boost;
    
    
    ll n; cin >> n;
    ll x; cin >> x;
    
    ll a[n];
    
    for(int i=0;i<n;i++) cin >> a[i];
    
    sort(a,a+n);
    
    int cnt = 0;
    
    for(int i = 0; i < n-1; i++){
          if(a[i] <= x){
          	x-=a[i];
          	cnt++;
		  }
	}
	
	if(a[n-1] == x) cnt++;
		
	cout << cnt;
	
   	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int f1[100005],f2[100005],a1[100005],a2[100005];
int n,a[100005],mod=1e9+7;
signed main(){
ios::sync_with_stdio(0);
   cin.tie(0);
int ans=0;
cin>>n;
FOR(i,1,n){
cin>>a[i];
}
FOR(i,1,n){
a1[i]=(a1[i-1]+a[i])%mod;
}
for(int i=n-1;i>=1;i--){
a2[i]=(a2[i+1]+a[i])%mod;
}
f1[0]=1;
FOR(i,1,n-1){
f1[i]=f1[i-1]*i%mod;
}
f2[n-1]=n-1;
for(int i=n-2;i>=1;i--){
f2[i]=f2[i+1]*i%mod;
}
f2[n]=f2[n+1]=1;
for(int i=1;i<=n;i++){
    ans=ans+f2[i+2]*f1[i-1]%mod*(a2[i+1]-a1[n-i-1]);
    ans=ans%mod;
}
FOR(i,1,n-1){
ans=ans+f1[n-i-1]*f2[n-i+1]%mod*(a[n]-a[i]);ans=ans%mod;
}
cout<<ans;
return 0;
}


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

const ll MOD = 1000000007;
ll N, K;
map<ll, int> comp;
ll cnt[70000];
ll hoge[70000];
ll dp[111][70000];
ll sm[111][70000];

void solve() {
    cin >> N >> K;
    map<ll, ll> mp;

    for (ll i = 1; i <= N; ) {
        ll x = N / i;
        ll lo = i;
        ll hi = N + 1;
        while (hi - lo > 1) {
            ll mid = (hi + lo) / 2;
            if (N / mid == x) lo = mid;
            else hi = mid;
        }
        mp[x] = lo - i + 1;
        i = lo + 1;
    }

    int M = mp.size();
    int idx = 0;
    for (auto x: mp) {
        cnt[idx] = x.second;
        comp[x.first] = idx++;
    }
    for (auto x: mp) {
        hoge[comp[x.first]] = comp[N/x.first];
    }

    ll prev = -1;
    for (int i = M - 1; i >= 0; --i) {
        dp[0][i] = cnt[i];
        sm[0][i] = cnt[i];
        if (prev != -1) (sm[0][i] += sm[0][prev]) %= MOD;
        prev = i;
    }

    REP2(i, 1, K) {
        prev = -1;
        for (int j = M - 1; j >= 0; --j) {
            (dp[i][j] += sm[i-1][hoge[j]] * cnt[j]) %= MOD;
            sm[i][j] = dp[i][j];
            if (prev != -1) (sm[i][j] += sm[i][prev]) %= MOD;
            prev = j;
        }
    }

    cout << sm[K-1][0] << endl;
}

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


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

using namespace std;

typedef long long ll;

int main(){
    string s, t;
    cin >> s >> t;
    bool f = true;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i])f = false;
    }
    if(f)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int dp[41][444][444];
// dp[i][j][k] = min cost i番目までを使用, ma, mb
int main() {
  int n; cin >> n;
  int ma, mb; cin >> ma >> mb;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for(int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i];
  for(int i=0; i<41; i++){
    for(int j=0; j<444; j++){
      for(int k=0; k<444; k++){
        dp[i][j][k] = 1e9;
      }
    }
  }
  dp[0][0][0] = 0;

  for(int i=0; i<n; i++){
    for(int j=0; j<444; j++){
      for(int k=0; k<444; k++){
        if(dp[i][j][k]==1e9) continue;
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
      }
    }
  }

  int ans = 1e9;
  for(int i=1; i<444; i++){
    for(int j=1; j<444; j++){
      if(i*mb == j*ma){
        if(dp[n][i][j] != 1e9)
        ans = min(ans, dp[n][i][j]);
      }
    }
  }

  if(ans == 1e9) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}



///


Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,x;
  cin >> a >> x;
  if(a==0 && x==100){cout << 101 << endl;}
  else if(a==0 && x!=100){cout << x << endl;}
  else if(a==1 && x==100){cout << 101*100 << endl;}
  else if(a==1 && x!=100){cout << x*100 << endl;}
  else if(a==2 && x!=100){cout << 10000*x << endl;}
  else if(a==2 && x==100){cout << 10000*101 << endl;}
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

bool isprime(int p){
	if(p==1){
		return false;
	}
	for(int i=2; i<p; i++){
		if(p%i==0){
			return false;
		}
	}
	return true;
}
 
int n;
 
int main(){
	cin >> n;
	for(int i=31; i<=55555; i+=30){
		if(isprime(i)==true){
			if(i!=31){
				cout << " ";
			}
			cout << i; n--;
		}
		if(n==0){
			break;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rep0(i, n) for(int i = (0); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plli pair<pll,int>
#define mp make_pair
#define endl '\n'
#define pb push_back
#define x first
#define y second
#define pt pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpll vector<pll>
#define vpt vector<pt>
#define pdd pair<double, double>
#define vpdd vector<pair<double, double> >
#define pq priority_queue
//#define _USE_MATH_DEFINES
using namespace std;
#define left(i) (i << 1)
#define right(i) ((i << 1) + 1)


int main()
{
	//freopen("E.in", "r", stdin);
	//freopen("E2.txt", "w", stdout);
	int n, p;
	cin >> n >> p;
	vector<bool> isEven(n);
	unsigned ll res = 1;
	ll countEven = 0, countOdd = 0;
	for (int i = 0; i < n; ++i) {
		int numb;
		cin >> numb;
		isEven[i] = (numb % 2 == 0);
		if (isEven[i]) {
			countEven++;
			res *= 2;
		}
		else {
			countOdd++;
		}
	}

	vector<vector<unsigned ll>> C(51, vector<unsigned ll>(51));
	for (int i = 0; i <= 50; i++) {
		// C(i,0) = 1 for i = 0...n  
		C[i][0] = 1;
	}
	for (int j = 0; j <= 50; j++) {
		// if n = 0, C(n,r) = 0 for all 'r'
		C[0][j] = 0;
	}
	for (int i = 1; i <= 50; i++) {
		for (int j = 1; j <= i; j++) {
			if (i == j) {
				// C(n,n) = 1
				C[i][j] = 1;
			}
			else if (j > i) {
				// case when r > n in C(n,r)        
				C[i][j] = 0;
			}
			else {
				// apply the standard recursive formula        
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
	}

	C[0][0] = 1;
	if (p == 0) {
		unsigned ll sumC = 0;
		for (int i = 0; i <= countOdd; i += 2) {
			sumC += C[countOdd][i];
		}
		res *= sumC;
	}
	else {
		
		unsigned ll sumC = 0;
		for (int i = 1; i <= countOdd; i += 2) {
			sumC += C[countOdd][i];
		}
		res *= sumC;
	}

	cout << res << endl;
	
}


Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int,input().split()))
T = [0]*(N+1)
temp = 0
for i in range(1,N+1):

    T[i] = T[i-1] + L[i-1]
for i in T:
    if i <= X:

        temp+=1
print(temp)      

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1000000007;

ll powmod(ll x, ll y){
    ll res =1;
    for(ll i=0;i<y;i++){
        res = res*x%mod;
    }
    return res;
}
int main(void){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
    return 0;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  map<int,int> ma;
  lol ans=1;
  lol o=m;/*
  while(o%2==0){
    ma[2]++;
    o/=2;
    }*/
  for(lol i=2;i*i<=m;i++){
    while(o%i==0){
      o/=i;
      ma[i]++;
    }
    if(n<=ma[i]){
      ans*=pow(i,ma[i]/n);
    }
  }/*
  for(auto l=ma.begin();l!=ma.end();l++){
    if(n<=l->se){
      ans*=pow(l->fi,(l->se/n));
    }
    }*/
  if(n==1) cout <<m<<'\n';
  else cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 47104
#include<stdio.h>
typedef long long int lli;
int main() {
  int x;
  scanf("%d", &x);

  if(x>=400 && x<=599)
    printf("8");
  else if(x>=600 && x<=799)
    printf("7");
  else if(x>=800 && x<=999)
    printf("6");
  else if(x>=1000 && x<=1199)
    printf("5");
  else if(x>=1200 && x<=1399)
    printf("4");
  else if(x>=1400 && x<=1599)
    printf("3");
  else if(x>=1600 && x<=1799)
    printf("2");
  else
    printf("1");

  return 0;
}



Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=1e5+5;


int32_t main(){
	IOS;
	
	//code
	char c;
	cin>>c;
	cout<<(char(c+1));
	//code
	
	return 0;

}



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

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

    int N;
    cin >> N;
    vector<int> a(N);
    unordered_map<int, int> mp;
    for (int& item : a) {
        cin >> item;
        mp[item]++;
    }
    ll ans = 0;
    for (auto& p : mp) {
        int val = p.second;
        ans += (ll)val * (val - 1) / 2;
    }
    for (int item : a) {
        ll res = ans - (mp[item] - 1);
        cout << res << "\n";
    }
}

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

namespace ALDS1_2_A
{
    class Program
    {
        static private int count = 0;

        static void Main(string[] args)
        {
            int intLength = int.Parse(Console.ReadLine());
            int[] aryInput = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            
            for (int i = 0; i < intLength; i++)
            {
                aryInput = Program.BubbleSort(aryInput, i);
            }
            Console.WriteLine(string.Join(" ", aryInput));
            Console.WriteLine(Program.count);
        }

        /// <summary>
        /// index - 1番目まで整列していると仮定して、index番目以降の要素に対してソートを行う
        /// </summary>
        /// <param name="aryIn"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        static private int[] BubbleSort(int[] aryIn, int index)
        {
            for (int i = aryIn.Length - 1; i > index ; i--)
            {
                if (aryIn[i] < aryIn[i - 1])
                {
                    int tmp = aryIn[i];
                    aryIn[i] = aryIn[i - 1];
                    aryIn[i - 1] = tmp;
                    count++;
                }
            }
            return aryIn;
        }
    }
}



Measured memory_bytes: 18356
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;

vector<int> ans, vec;

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int n; scanf("%d", &n);
	vec.assign(n,0);
	for(int i = 0; i < n; i++)
		scanf("%d", &vec[i]);

	while(vec.size())
	{
		// for(auto i : vec) printf("%d ", i); printf("\n"); fflush(stdout);
		int idx = -1;
		for(int i = 1; i <= vec.size(); i++)
			if(vec[i-1] == i)
				idx = i;
		
		if(idx == -1)
		{
			printf("-1\n");
			return 0;
		}
		ans.push_back(idx);
		// printf("IDX : %d\n", idx);
		vec.erase(vec.begin()+idx-1);
	}
	reverse(ans.begin(), ans.end());
	for(int i = 0; i < ans.size(); i++)
		printf("%d\n", ans[i]);
}










Measured memory_bytes: 256
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
K = ri()
X = rl()
answer = 0
for i in range(N):
    answer += min(X[i], abs(X[i]-K))
print(answer * 2)


Measured memory_bytes: 3060
#include <stdio.h>
	int main(void){
		int sum=0,m,f,r;
		while(1){
			scanf("%d %d %d",&m,&f,&r);

			if(m==-1 && f==-1 && r==-1) break;

			if(m==-1 || f==-1){
				printf("F\n");
			}else{

				sum=m+f;

				if(sum>=80){
					printf("A\n");
				}else if(65<=sum && sum<80){
					printf("B\n");
				}else if(50<=sum && sum<65){
					printf("C\n");
				}else if(30<=sum && sum<50){
					if(r<50){
						printf("D\n");
					}else if(r>=50){
						printf("C\n");
					}
				}else{
					printf("F\n");
				}
			}
		}
	return 0;
}

Measured memory_bytes: 584
import sys
q = int(input())

ans = []
d = []
for i in range(q):
    # a = list(map(int, input().split()))
    a = sys.stdin.readline()
    
    if a[0] == '0':
        d.append(a[2:])
    elif a[0] == '1':
        ans.append(d[int(a[2:])])
    else:
        d.pop(-1)
for i in ans:
    print(i.strip())


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

string str;

int main() {
	cin>>str;
	for(int i=0;i<str.length();i++){
		if(str[i]=='1') str[i]='9';
		else if(str[i]=='9') str[i]='1';
		cout<<str[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    vector<long long int> b(n+1);
 
    b.at(0) = 0;
 
    for(long long int i = 0; i < n; ++i){
        cin >> a.at(i);
        b.at(i+1) = a.at(i) + b.at(i);
    }
 
    long long int ans = 0;
 
    sort(b.begin(), b.end());
    
    long long int c = 1;
    for(long long int i = 1; i < n+1; ++i){
        if(b.at(i) == b.at(i-1) && i != n){
            ++c;
        }else{
            if(b.at(i) == b.at(i-1) &&  i == n){
                ++c;
            }
            ans += c*(c-1)/2;
            c = 1;
        }
    }
 
    cout << ans << endl;
 
}

Measured memory_bytes: 3328
import math
a, b, C = map(float, input().split())
sin_C = math.sin(math.radians(C))
cos_C = math.cos(math.radians(C))
S = 0.5 * a * b * sin_C
print(S)
c = math.sqrt(a**2 + b**2 - 2*a*b*cos_C)

print(a+b+c)
print(S*2/a)


Measured memory_bytes: 5692
N, A, B, C, D = map(int, input().split())

S = [1] + [ 1 if x == "#" else 0 for x in input()]

S[A] = 2
S[B] = 3


if B < A:
    A, B = B, A
    C, D = D, C

enable = True

for i in range(min(A, B)+1, max(C, D)-1):
    if S[i] == S[i+1] == 1:
        enable = False
        break

if A < B < D < C:
    vcnt = 0
    for i in range(B-1, D+1+1):
        if S[i] != 1:
            vcnt += 1
            if vcnt >= 3:
                break
        else:
            vcnt = 0
    else:
        enable = False

print("Yes" if enable else "No")


Measured memory_bytes: 6260
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll N;

int main(){
    cin>>N;

    ll ans=0;
    repn(i,N){
        if(i%3!=0 && i%5!=0) ans+=i;
    }

    cout<<ans<<endl;
}

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

int H, W, K;
char S[1010][1010];
vector<vector<int>> dp(1010, vector<int>(1010, 0));
int res = 1000000;
/*dp[i][j] //(1,1)から(i,j)までに含まれるWち数*/

int main(){
  cin >> H >> W >> K;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++) cin >> S[i][j];
  }

  /*2次元累積和配列の生成*/
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
      if(S[i-1][j-1] == '1') dp[i][j] += 1;
    }
  }

  for(int bit = 0; bit < (1 << (H-1)); bit++){
    int cn = 0;
    bool cutable = true;
    vector<int> div;     //切断箇所格納配列
    div.push_back(0);  //最初  これはチョコの側面(意味なし)を切るという意味
    for(int i = 0; i < H-1; i++){
      if( (bit >> i) & 1 ) div.push_back(i+1);
    }
    div.push_back(H);  //最後　チョコの右側面(意味なし)を切るという意味

    int bw = 0, w = 1;    //bwはwの一つ前の切断場所
    while(w <= W){
      if(w == W){
        for(int i = 1; i < div.size(); i++){
          if(dp[div[i]][w] + dp[div[i-1]][bw]-dp[div[i]][bw]-dp[div[i-1]][w] <= K);
          else { 
            if(w-bw > 1){ ++cn; break; }//w-1で縦分割する
            else { cutable = false; break; }   //実現不可能
          }
        }
        break;
      }else{
        for(int i = 1; i < div.size(); i++){
          if(dp[div[i]][w]+dp[div[i-1]][bw]-dp[div[i]][bw]-dp[div[i-1]][w] <= K);
          else {
            if(w-bw > 1){ bw = w-1; w = bw; cn++; }
            else { cutable = false; break; }
          }
        }
      }
      
      if(cutable) ++w;
      else break;
    }

    if(cutable){ cn += div.size()-2; res = min(cn, res); }

  }

  cout << res << endl;
 
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> l(2*N);
  for(int i=0;i<2*N;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  int sum=0;
  for(int i=0;i<2*N;i++){
    if(i%2==0)sum+=l[i];
  }
  cout << sum;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a = 0, b = 0;
	REP(i, n) {
		int x;
		cin >> x;
		if (x % 4 == 0)a++;
		else if (x % 2 == 0)b++;
	}
	b = max(0, b - 1);
	if (a >= (n - b) / 2)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A, B, C;
  cin >> N >> A >> B >> C;  
  vector<int> bamboo(0, 0);
  for(int i=0; i<N; i++){
  int l;
  cin >> l;
  bamboo.push_back(l);
  }
  int num=1;
  for(int i=0; i<N; i++){
    num*=4;
  }
  int ans=8000;
  for(int i=0; i<num; i++){
    int k=i, asum=0, bsum=0, csum=0, temp=0;
    vector<int> a(0,0), b(0,0), c(0,0);
    for(int j=0; j<N; j++){
      int x=k%4;
      k/=4;
      if(x==0) continue;
      else if(x==1) {
      a.push_back(bamboo[j]);
      asum+=bamboo[j];
      }
      else if(x==2) {
      b.push_back(bamboo[j]);
      bsum+=bamboo[j];
      }
      else if(x==3) {
      c.push_back(bamboo[j]);
      csum+=bamboo[j];
      }
    }
  int as=a.size(), bs=b.size(), cs=c.size(); 
//  cout<<"as:"<<as<<" bs:"<<bs<<" cs:"<<cs<<" asum:"<<asum<<endl;
  if(as==0 || bs==0 || cs==0) continue;  
  temp+=(as+bs+cs-3)*10;
  temp+=(abs(A-asum)+abs(B-bsum)+abs(C-csum));
  ans=min(ans, temp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

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

    ll N;
    cin >> N;
    vector<ll> P(N);

    for (auto&& p : P) {
        cin >> p;
        p--;
    }

    ll count = 0;
    for (ll i = 0; i < N / 2; i++) {
        if (i == P[i]) {
            count++;
            swap(P[i], P[i + 1]);
        }
        
        if (N - 1 - i == P[N - 1 - i]) {
            count++;
            swap(P[N - 1 - i], P[N - 1 - i - 1]);
        }
    }

    if (N % 2) {
        if (N / 2 == P[N / 2]) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}



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

int main () {
    int n; cin >> n;
    bool ans = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (n == i * j) ans = true;
            else continue;
        }
    }
    if (ans == true) {
         cout << "Yes\n";
    }
    else {
         cout << "No\n";
    }
   
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int N;
  cin >> N;

  bool yes = false;
  FOR(i, 1, 10) {
    FOR(j, 1, 10) {
      if (i * j == N) {
        yes = true;
      }
    }
  }
  if (yes) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 256
//
// Created by watemus on 24.06.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

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

template<typename T>
using vec = vector<T>;

template<typename T>
using uset = unordered_set<T>;

template<typename T1, typename T2>
using umap = unordered_map<T1, T2>;

#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

void run() {
    int n, x;
    cin >> x >> n;
    set<int> p;
    for (int i = 0; i < n; i++) {
        int el;
        cin >> el;
        p.insert(el);
    }
    int ans = 10000;
    for (int i = -1000; i <= 1000; i++) {
        if (!p.count(i) && abs(x - i) < abs(x - ans)) {
            ans = i;
        }
    }
    cout << ans << '\n';
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    cout << fixed << setprecision(20);
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}



Measured memory_bytes: 3616
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
t = 0
for s in A:
    if sum([s[i]*B[i] for i in range(M)]) +C > 0:
        t += 1
print(t)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
map<string,bool>m;
int n,cnt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	while(n--)
	{
		string s;
		cin>>s;
		if(!m[s])
		{
			m[s]=1;
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 19244
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int a[100];
ll dp[2][100001];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i <= K; i++) dp[0][i] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= K; j++) {
			dp[(i + 1) & 1][j] = dp[i & 1][j];
			if (j - a[i] - 1 >= 0) (dp[(i + 1) & 1][j] += (MOD - dp[i & 1][j - a[i] - 1])) %= MOD;
		}
		for (int j = 1; j <= K; j++) (dp[(i + 1) & 1][j] += dp[(i + 1) & 1][j - 1]) %= MOD;
	}
	ll ans = dp[N & 1][K];
	if (K > 0) (ans += (MOD - dp[N & 1][K - 1])) %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 1792
n,a,b=map(int,input().split())
s=list(input())
count=0
cnt=0
for i in range(n):
  if(cnt>=a+b):
    print("No")
  else:
    if(s[i]=="a"):
      print("Yes")
      cnt+=1
    elif(s[i]=="b"):
      if(count<b):
        print("Yes")
        count+=1
        cnt+=1
      else:
        print("No")
    else:
      print("No")

Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);


	int N, M, X;
	cin >> N >> M >> X;
	vi C(N);
	vvi A(N, vi(M));
	//一旦INFに設定して小さくしていく
	int minimum = INF;
	rep(i, N) {
		cin >> C.at(i);
		rep(j, M) {
			cin >> A.at(i).at(j);
		}
	}

	// {0, 1, ..., n-1} の部分集合の全探索
	for (int bit = 0; bit < (1 << N); ++bit) {
		vi skill(M, 0);
		bool flag = true;
		vector<int> S;
		for (int i = 0; i < N; ++i) {
			if (bit & (1 << i)) { // 列挙に i が含まれるか
				S.push_back(i);
			}
		}
		for (int i = 0; i < (int)S.size(); ++i) {
			for (int j = 0; j < M; ++j) {
				skill.at(j) += A.at(S.at(i)).at(j);
			}
		}
		for (int i = 0; i < M; ++i) {
			if (skill.at(i) < X)flag = false;
			//cout << skill.at(i) << " ";
		}
		if (flag == true) {
			int temp = 0;
			rep(i, (int)S.size()) {
				temp += C.at(S.at(i));
			}
			if(minimum > temp)minimum = temp;
			//cout <<temp << " ";
		}
		//cout << minimum << endl;
	}
	if (minimum == INF) {
		cout << -1;
		return 0;
	}
	else {
		cout << minimum;
	}
	return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
#include<math.h>

int main(){
	int n = 0;
	int w[20] = {0};
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &w[i]);
	
	int m = 0;
	scanf("%d", &m);
	for (int i = 0; i < m; i++){
		int s = 0;
		scanf("%d", &s);
		// 総当たり
		int b[21] = {0};
		;while(1){
			bool kuriage = true;
			for (int j = 0; j < n+1; j++){
				if  (kuriage) b[j]++;
				if (b[j] == 2){
					b[j] = 0;
					kuriage = true;
				}
				else kuriage = false;
			}
			if (b[n]) {
				printf("no\n");
				break;
			}
			int sum = 0;
			for (int j = 0; j < n; j++) sum += w[j] * b[j];
			if (sum == s){
				printf("yes\n");
				break;
			}
		}
	}
}


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

int main(){

	int n, i;
	double debt = 100000;
	cin >> n;

	for( i=0;i<n;i++ ){
		debt = debt * 1.05;

		debt /= 1000;
		debt = ceil( debt );
		debt *= 1000;

	}

	cout << (int)debt << endl;
	return 0;
}

Measured memory_bytes: 1164
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
b = []
ans = "No"
for i in range(n):
    b.append(int(input()))

count = 0
for i in a1:
    if i in b:
        count += 1
if count == 3:
    ans = "Yes"

count2 = 0
for i in a2:
    if i in b:
        count2 += 1
if count2 == 3:
    ans = "Yes"

count3 = 0
for i in a3:
    if i in b:
        count3 += 1
if count3 == 3:
    ans = "Yes"

for i in range(3):
    if (a1[i] in b) and (a2[i] in b) and (a3[i] in b):
        ans = "Yes"


if (a1[0] in b) and (a2[1] in b) and (a3[2] in b):
    ans = "Yes"

if (a1[2] in b) and (a2[1] in b) and (a3[0] in b):
    ans = "Yes"
print(ans)


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

signed main(){
  int N,M;
  string S,T;
  cin>>N>>M>>S>>T;
  int k;
  int out=0;
  for(int i=100000;i>=0;i--)if(N%i==0&&M%i==0){k=i;break;}
  for(int i=0;i<k;i++)if(S[i*N/k]!=T[i*M/k])out++;
  if(out)cout<<-1<<endl;
  else cout<<N/k*M<<endl;
}


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

int main() {
    int N, count = 0;
    long long int D, X, Y;
    cin >> N >> D;

    for (int i = 0; i < N; i++) {
        cin >> X >> Y;
        if (D * D >= X * X + Y * Y) {
            count++;
        }
    }

    cout << count << endl;
}


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

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

int main() {
    int n, m;
    cin >> n >> m;

    priority_queue<ll> A;
    rep(i, n) {
        ll a;
        cin >> a;
        A.push(a);
    }
    rep(i, m) {
        ll a = A.top();
        A.pop();
        A.push(a / 2);
    }

    ll ans = 0;
    rep(i, n) {
        ans += A.top();
        A.pop();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i = 0; i < N; i++){
    cin >> num.at(i);
  }
  sort(num.begin(), num.end());
  cout << num.at(N - 1) - num.at(0) << endl;
}

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

using lint = long long;

template<class T> T lcs(const T &X, const T &Y) {
	int a = X.size(), b = Y.size();
	vector<vector<int>> dp(a+1, vector<int>(b+1));
	for(int i = 1; i < a+1; i++) for(int j = 1; j < b+1; j++)
		dp[i][j] = X[i-1]==Y[j-1] ? dp[i-1][j-1]+1 :
			max(dp[i][j-1],dp[i-1][j]);
	int len = dp[a][b];
	T ans(len,0);
	while(a && b)
		if(X[a-1]==Y[b-1]) ans[--len] = X[--a], --b;
		else if(dp[a][b-1]>dp[a-1][b]) --b;
		else --a;
	return ans;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string a, b;
    cin >> a >> b;
    cout << lcs(a, b) << '\n';
}

Measured memory_bytes: 35712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main(void) {
	int i;
	string str;
	cin >> str;

	for (i = 0; i < 5; i++)
		cout << str[i];
	cout << ' ';
	for (i = 6; i < 13; i++)
		cout << str[i];
	cout << ' ';
	for (i = 14; i < 19; i++)
		cout << str[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;

char mp[1000];

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string str;
    cin >> n >> str;

    vector <int> fr(8);
    mp['R'] = 0, mp['G'] = 1, mp['B'] = 2;

    int ans = 1, cnt = n;
    for(i = 3 * n - 1; i >= 0; i--) {
        int ch = mp[str[i]];
        if(fr[7 - (1 << ch)] > 0) {
            mul(ans, fr[7 - (1 << ch)]);
            fr[7 - (1 << ch)]--;
            fr[7]++;
        }
        else {
            bool ok = 0;
            for(int j = 0; j < 3; j++) {
                if(j != ch && fr[1 << j] > 0) {
                    ok = 1;
                    mul(ans, fr[1 << j]);
                    fr[1 << j]--;
                    fr[(1 << j) + (1 << ch)]++;
                    break;
                }
            }
            if(!ok) {
                mul(ans, cnt);
                fr[1 << ch]++;
                cnt--;
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
int main(){
    int r,g,b,mul;
    scanf("%d %d %d",&r,&g,&b);
    mul = (r*100)+(g*10)+b;
    if(mul%4==0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


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

int main(){
  ll N,x;
  cin>>N>>x;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  ll s,ans=0;
  for(int i=1;i<N;i++){
    s=A[i]+A[i-1];
    if(s>x){
      A[i]-=s-x;
      ans+=s-x;
    }
    if(A[i]<0){
      A[i]=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  FOR(i,1,9){
    int a;
    a = n/i;
    if(a<10 && n%i==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

}



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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

int main() {
    ll a, b;
    cin >> a >> b;
    ll k = b - a;
    ll m = k * (k - 1) / 2;
    ll ans = m - a;

    cout << ans << endl;

}


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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

char a[3002],b[3002];
ll dp[3002][3002];
string ans="";
void LCSPrint(){
int i=strlen(a),j=strlen(b);
while(min(i,j)>0){
        if(a[i-1]==b[j-1]){
            ans+=a[i-1];
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])i--;
        else j--;
      }
      reverse(ans.begin(),ans.end());
      cout<<ans<<endl;
      }
void LCS(){
    int len1=strlen(a);
    int len2=strlen(b);
    for(int i=0;i<=len1;i++){
        for(int j=0;j<=len2;j++){
            if(min(i,j)==0)dp[i][j]=0;
            else if(a[i-1]==b[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

        }
    }
}
int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ck,k,p,q,r,t,add=0,x,y,z;
    string s;
    memset(dp,-1,sizeof(dp));
    cin>>a>>b;
    LCS();
    LCSPrint();
   // cout<<ck<<endl;
    return 0;
}




Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define LLI long long int

const int _mx = 2e6;
int arr[_mx+5];

int main() {
    // freopen("in.txt", "r", stdin);

    int n;
    map <string, int> m;
    string a, b;
    for (cin >> n; n--; ) {
        cin >> a >> b;
        if (a[0] == 'i') m[b]++;
        else if (a[0] == 'f') cout << (m[b] ? "yes\n" : "no\n");
    }

    return 0;
}



Measured memory_bytes: 52560
def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= numerator[k]
            if result >10**9+7:
                result = result%(10**9+7)
    return result
x,y=map(int,input().split())
if (x+y)%3!=0 or 2*x<y or 2*y<x:
    print(0)
else:
    a=(2*y-x)//3
    b=(2*x-y)//3
    print(int(ncr(a+b,a)%(10**9+7)))


Measured memory_bytes: 44148
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	V a(n); rep(i, n)a[i] = i + k;
	int sum = 0;
	rep(i, n) {
		sum += a[i];
	}
	int now = INF;
	int ans = 0;
	rep(i, n) {
		int tmp = 0;
		rep(j, n) {
			if (i == j)continue;
			tmp += a[j];
		}
		if (abs(sum - tmp) < now) {
			now = abs(sum - tmp);
			ans = tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256