akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    int x; cin >> x;
    if(x < 100){
        cout << 0 << endl;
        return 0;    
    }
    if(2000 <= x){
        cout << 1 << endl;
        return 0;
    }
    int a = x / 100;
    int b = x % 100;
    if(b <= a * 5) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
let R=1..<Int(readLine()!)!,S=readLine()!.characters.map{$0}
var a=R.reduce(0){$0+(S[$1]<"W" ?1:0)},ans=a
R.forEach{a+=(S[$0-1]>"E" ?1:0)-(S[$0]<"W" ?1:0);ans=min(a,ans)}
print(ans)

Measured memory_bytes: 5848
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        ABC: [(i64,i64,i64); N],
    }
    // dp[i][j] : i日目にjを選んだ場合の最大幸福度
    let mut dp = vec![vec![0; 3]; N];
    // dp table init
    dp[0][0] = ABC[0].0;
    dp[0][1] = ABC[0].1;
    dp[0][2] = ABC[0].2;
    // dp
    for i in 1..N{
        let (a,b,c) = ABC[i];
        dp[i][0] = max(dp[i-1][1] + a, dp[i-1][2] + a);
        dp[i][1] = max(dp[i-1][0] + b, dp[i-1][2] + b);
        dp[i][2] = max(dp[i-1][0] + c, dp[i-1][1] + c);
    }
    let mut ans:i64 = 0;
    for i in 0..3{
        ans = max(ans, dp[N-1][i]);
    }
    println!("{}", ans);
}

Measured memory_bytes: 14588
#include<stdio.h>

#define MAX 100000
#define NIL -1

void getDepth(int,int);
void print(int);

struct Node {
  int parent,left,right;
};

struct Node Tree[MAX]; 
int D[MAX],n;
 
int main(){

  int i,j,node,degree,child,left,right;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    Tree[i].parent = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&node,&degree);
    for(j=0;j<degree;j++){
      scanf("%d",&child);
      if(j==0){
	Tree[node].left=child;
      }
      else Tree[left].right=child;
      left = child;
      Tree[child].parent = node;
    }
  }
  
  for(i=0;i<n;i++){
    if(Tree[i].parent==NIL){
      right=i;
    }
  }
  getDepth(right,0);

  for(i=0;i<n;i++){
    print(i);
  }
  
  return 0;
}

void print(int a){
  int i,c;
  
  printf("node %d: ",a); 
  printf("parent = %d, ", Tree[a].parent);
  printf("depth = %d, ", D[a]);
   
  if(Tree[a].parent == NIL) {
    printf("root, ");
  }
  else if(Tree[a].left == NIL) {
    printf("leaf, ");
  }
  else {
    printf("internal node, ");
  }
 
  printf("[");
  c = Tree[a].left; 
  while(c!=NIL){ 
    if(c==Tree[a].left){ 
      printf("%d",c);
    }else {
      printf(", %d", c); 
    }
    c = Tree[c].right;
  }
  printf("]\n");
}

void getDepth(int u,int d){
  D[u] = d;
  if(Tree[u].right!=NIL){
    getDepth(Tree[u].right,d);
  }
  if(Tree[u].left!=NIL){
    getDepth(Tree[u].left,d+1);
  }
}

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }

LL calc_w(LL v){
    LL w = 0;
    while(v > 0){
        ++w;
        v /= 10;
    }
    return w;
}

LL binary_w(LL w, LL A, LL B, LL L){
    if(calc_w(A) >= w) return 0;
    if(calc_w(A + B*L) < w) return L;
    LL left = 0;
    LL right = L;
    while(left+1 < right){
        LL middle = (left+right)/2;
        if(calc_w(A + B*middle) < w){
            left = middle;
        }else{
            right = middle;
        }
    }
    return left+1;
}

LL mod_pow(LL n, LL m, LL p){
    if(m <= 0) return 1;
    LL res = mod_pow(n, m/2, p);
    res = res * res % p;
    if(m&1) res = res * n % p;
    return res;
}

LL pow_seq(LL b, LL len, LL p){
    if(len == 0) return 0;
    if(len == 1) return 1;
    LL part = pow_seq(b, len/2, p);
    LL base = mod_pow(b, len/2, p);
    LL res = part + base * part % p;
    if(len&1) res = (res + mod_pow(b, len-1, p)) % p;
    return res;
}

LL calc(LL A, LL B, LL left, LL right, LL reed, LL w, LL M){
    LL begin = (A + left * B) % M * mod_pow(10, reed, M) % M;
    if(left == right) return 0;
    if(left + 1 == right) return begin;

    LL w2 = mod_pow(10, w, M);
    LL right2 = left + (right - left) / 2;
    LL part = calc(A, B, left, right2, reed, w, M);
    LL base = mod_pow(w2, right2-left, M);
    LL res = (part * base % M + part + (right2-left) * B % M * pow_seq(w2, (right2-left), M) % M) % M;
    if((right - left) & 1){
        LL last = (A + (right-1) * B) % M;
        res = (res * w2 % M + last) % M;
    }
    return res;
}

int main(){
    LL L, A, B, M;
    cin >> L >> A >> B >> M;
    LL ans = 0;
    for(LL w = 1; w < 19; ++w){
        LL left = binary_w(w, A, B, L);
        LL right = binary_w(w+1, A, B, L);
        cerr << "w=" << w << ", left=" << left << ", right=" << right << ", " << A + left*B << endl;
        LL part = calc(A, B, left, right, 0, w, M);
        //ans = (ans * mod_pow(10, w * (right - left), M) % M + part) % M;
        ans = (ans * mod_pow(mod_pow(10, w, M), (right - left), M) % M + part) % M;
        if(right == L) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int s;
	cin >> s;
	int second = s % 60;
	int minute = s % 3600 / 60;
	int hour = s / 3600;
	cout << hour << ":" << minute << ":" << second << endl;
}


Measured memory_bytes: 3104
N = int(input())
H = list(map(int, input().split()))
Hmax = H[0]
flag = True
for height in H:
    if height <= Hmax - 2:
        flag = False
        break
    Hmax = max(Hmax, height)

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    priority_queue<int> q;
    int N;
    cin >> N;
    rep(i, N)
    {
        int a;
        cin >> a;
        q.push(a);
    }

    int ans = 0;
    while (q.size())
    {
        int count = 0;
        int tmp = q.top();
        while ((!q.empty()) && q.top() == tmp)
        {
            q.pop();
            count++;
        }
        if (count % 2)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define sz(x) (int)x.size()
typedef pair<int, int> pii;

int main(){
    fastio;
    int a, b, c, x;
    string at1, at2;
    cin >> at1;
    for(int i=0; i<sz(at1); i++){
        if(i%2==0 && (at1[i]=='R' || at1[i]=='U' || at1[i]=='D')){
            continue;
        }else if(i%2!=0 && (at1[i]=='L' || at1[i]=='U' || at1[i]=='D')){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int m=1e9+7;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%m;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans)%m;
    return (x*(ans*ans)%m)%m;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
   // cin>>t;
    // int tmp=t;
    while(t--)
    {
      string s;
      cin>>s;
      if(s=="RRR") cout<<3<<endl;
      else if(s=="SSS") cout<<0<<endl;
      else if(s=="RRS"||s=="SRR") cout<<2<<endl;
      else cout<<1<<endl;
    }
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void) {
	// your code goes here
	int x,y;
	int d,r;
	double f;
	
	scanf("%d %d",&x,&y);
	d = x / y;
	r = x % y;
	f = 1.0000 * x / y;
	
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 632
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
// UnionFind
struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
 
    bool unite(int x, int y) {//要素xとyの各々の木を併合（もともと同じ木ならfalse）
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {//要素kが属する木の根を得る
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {//要素kが属する木の要素数
        return (-data[find(k)]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

};

int main(){
    
    int N,M;
    cin >> N >> M;
    UnionFind A(N);
    int x,y,z;
    REP(i,M){
        cin >> x >> y >>z;
        x--;
        y--;
        A.unite(x,y);
    }
    set<int> cnt;
    int num;
    REP(i,N){
        num=A.find(i);
        cnt.insert(num);
    }
    cout << cnt.size() << endl;
    
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll x = (c+b-1)/b, y=(a+d-1)/d;
    if(x>y)cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3652
#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>


#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-10
#define infi  1000000000ll
#define infll 1000000000000000000ll


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;


const int N = 200003;
int n,m,a[N];
ll fav[N],shift[N];

int main(){
    scanf("%d%d",&n,&m);
    lp(i, 1, n) scanf("%d",&a[i]);
    lp(i, 2, n) {
        if(a[i] > a[i-1]) {
            ++fav[a[i]] , --fav[a[i-1]];
            shift[m] += a[i]-a[i-1],shift[a[i]] -= a[i]-a[i-1];
        }
        else {
            ++fav[a[i]],--fav[0];
            ++fav[m],--fav[a[i-1]];
            shift[m] += a[i] , shift[a[i]] -= m-a[i-1]+a[i];
        }
    }
    
    lpd(i, m-1, 0) fav[i] += fav[i+1] , shift[i] += shift[i+1];
    
    lpd(i, m-1, 1) fav[i] += fav[i+1];
    
    ll ans = infll;
    
    lp(i, 1, m) ans = min(ans, shift[i]+fav[i]);
    printf("%lld\n",ans);
    return 0;
}



/*
 */

//ios::sync_with_stdio(0);cin.tie(0);

Measured memory_bytes: 2176
/*
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void){
	int a,b,c,d=0,y=1;
	cin>>a>>b>>c;
	int z=1;
	for(int i=0;i<b;i++)z*=(y+a);
	while(z<=c){
		int s=0,x=z;
		while(x)s+=x%10,x/=10;
		if(y==s)d++;
		y++;
		z=1;
		for(int i=0;i<b;i++)z*=(y+a);
	}
	cout<<d<<endl;
}*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
long long val(long long x){
	long long sum=0;
	while(x){
		sum+=x%10;
		x/=10;
	}
	return sum;
}

int main(){
	long long a,n,m,y,t,x,cnt=0;
	cin>>a>>n>>m;
	
	for(y=1;y<=72;y++){
		x=1;
		for(t=1;t<=n;t++){
			x*=(y+a);
		}
		if(x<=m&&val(x)==y)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

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

const int MOD = 1000'000'007;
const double EPS = 0.000'000'001;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const int N = 3010;
string s, t;
int dp[N][N];

int solve(int i, int j)
{
	if(i == LEN(s) || j == LEN(t)) return 0;

	int& r = dp[i][j];

	if(r == -1)
	{
		if(s[i] == t[j])
			r = 1 + solve(i + 1, j + 1);
		else r = max(solve(i + 1, j), solve(i, j + 1));
	}

	return r;
}

string ans;

void rec(int i, int j)
{
	if(i == LEN(s) || j == LEN(t)) return;

	if(s[i] == t[j])
	{
		ans.push_back(t[j]);
		rec(i + 1, j + 1);
	}
	else
	{
		if(solve(i, j) == solve(i + 1, j))
			rec(i + 1, j);
		else rec(i, j + 1);
	}
}

int main()
{
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);
	cout.precision(10);

	cin >> s >> t;

	memset(dp, -1, sizeof(dp));

	solve(0, 0);
	rec(0, 0);

	cout << ans << endl;
	//cerr << "Tempo de execucao: " << (double)clock() / CLOCKS_PER_SEC << endl;
	return 0;
}

Measured memory_bytes: 35968
a, b=[int(i) for i in input().split()]
s=input()
#print(a, b, s)

flag=1

if s.count('-') < 1 or  s.count('-') > 1:
  flag=0
else:
  s1, s2=[i for i in s.split('-')]
#print(s1,s2)
  if len(s1) < a or a < len(s1) or len(s2) < b or b < len(s2):
    flag=0

print('Yes' if flag==1 else 'No') 

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);
int main(){
    ll n, a, b;
    sc(n) sc(a) sc(b)
    if (n % (a + b) < a) cout << n / (a + b) * a + n % (a + b) << endl;
    else cout << n / (a + b) * a + a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool valid(int val, int mask){
	while(val){
		int v = val%10;
		if(mask&(1<<v)) return false;
		val /= 10;
	}
	return true;
}

int main(){
	int N, K;
	while(cin >> N >> K){
		int mask = 0;
		for(int i=0;i<K;i++){
			int D; cin >> D;
			mask |= (1 << D);
		}
		for(int i=N;;++i){
			if(valid(i, mask)){
				cout <<i << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define rep2(x,from,to) for(int (x)=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
int n;
int res;
int p;
int dp[100004];
int main()
{
    cin>>n;
    rep2(i,1,100001)
    {
        res=dp[i-1]+1;
        p=6;
        while(p<=i)
        {
            res=min(res,dp[i-p]+1);
            p*=6;
        }
        p=9;
        while(p<=i)
        {
            res=min(res,dp[i-p]+1);
            p*=9;
        }
        dp[i]=res;
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

//多倍長整数, cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9+7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	cpp_int ans = 1, a;
	bool flag = false;
	rep(i, n) {
		cin >> a;
		if (a == 0)ans = 0, flag = false;
		else {
			if (ans * a > 1000000000000000000 or ans == -1 or flag)ans = -1, flag = true;
			else ans *= a;
		}
	}
	if (flag) puts("-1");
	else cout << ans << endl;

	Please AC;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>a(k);
  vector<bool>b(n+10,0);
  for(int i = 0;i<k;i++){
    int e;cin >> e;
  for(int i = 0;i<e;i++){
    int c;cin >> c;
    b[c] = 1;
  }
  }
  int d = 0;
  for(int i = 1;i<=n;i++){
    if(b[i]==0) d++;
  }
  cout << d;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll= long long;
using ld= long double;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N,Q;
    cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    REP(i,N){
        ll x;
        cin >> x;
        fw.add(i,x);
    }
    REP(i,Q){
        ll b;
        cin >> b;
        if(b == 0){
            ll p,t;
            cin >> p >> t;
            fw.add(p,t);
        }else{
            ll l,r;
            cin >> l >> r;
            cout << fw.sum(l,r) << "\n";
        }
    }
}

Measured memory_bytes: 8240
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let x = scan!(i64);
    for n in 1.. {
        if (n - 1) * n / 2 < x && x <= n * (n + 1) / 2 {
            println!("{}", n);
            return;
        }
    }
}


Measured memory_bytes: 4352
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(ans)
    return ans


n = int(input())
nums = sorted(list(map(int, input().split())))
if(nums[0]==0):
    print(0)
else:
    ans = 1
    for i in range(n):
        ans*=nums[i]
        if(ans>int(10e17)):
            ans = -1
            break
    print(ans)

Measured memory_bytes: 89748
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    ll n;
    cin>>n>>s;
    for(ll i=0;i<s.size();i++){
        if(s[i]+n>'Z'){
            s[i]=s[i]+n-'Z'+'A'-1;
        }else{
            s[i]+=n;
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep_1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define rep_2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll choose2(ll n)
{
    return n * (n - 1) / 2;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n);
    vector<ll> ans(n);
    vector<ll> tmp(n);
    vector<ll> tmp2(n);

    rep(i, n)
    {
        cin >> a[i];
        a[i]--;
        sum[a[i]]++;
    }

    ll cnt = 0;
    ll ch = 0;
    rep(i, n)
    {
        tmp[i] = choose2(sum[i]);
        sum[i]--;
        tmp2[i] = choose2(sum[i]);
        sum[i]++;
        ch += tmp[i];
    }

    rep(i, n)
    {
        ll ok = 0;
        ok = ch - tmp[a[i]] + tmp2[a[i]];
        cout << ok << endl;
    }

    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int a, b, q;
ll s[maxx], t[maxx], dd;

int solve1(ll x) {
	ll y = s[a];
	int n = a;
	int l = 1, r = n, ans1 = n + 1, ans2 = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(x <= s[mid]) r = mid - 1, ans1 = mid;
		else l = mid + 1;
	}
	l = 1, r = n;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(y >= s[mid]) l = mid + 1, ans2 = mid;
		else r = mid - 1;
	}
	return ans2 - ans1 + 1;
}

int solve2(ll x) {
	ll y = t[b];
	int n = b;
	int l = 1, r = n, ans1 = n + 1, ans2 = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(x <= t[mid]) r = mid - 1, ans1 = mid;
		else l = mid + 1;
	}
	l = 1, r = n;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(y >= t[mid]) l = mid + 1, ans2 = mid;
		else r = mid - 1;
	}
	return ans2 - ans1 + 1;
}

int main() {
	scanf("%d %d %d", &a, &b, &q);
	for(int i = 1; i <= a; i++) scanf("%lld", &s[i]);
	for(int i = 1; i <= b; i++) scanf("%lld", &t[i]);
	s[0] = s[1], t[0] = t[1];
	s[a + 1] = s[a], t[b + 1] = t[b];
	while(q--) {
		scanf("%lld", &dd);
		int cnt1 = solve1(dd); //s中有pos1个比dd大的
		int cnt2 = solve2(dd); //t中有pos2个比dd大的
		ll res = 0;
		ll ans1 = abs(dd - s[a - cnt1]);
		ll ans2 = abs(dd - s[a - cnt1 + 1]);
		ll res1 = abs(s[a - cnt1] - t[b - cnt2]);
		ll res2 = abs(s[a - cnt1 + 1] - t[b - cnt2]);
		res = min(ans1 + res1, ans2 + res2);
		ans1 = abs(dd - s[a - cnt1]);
		ans2 = abs(dd - s[a - cnt1 + 1]);
		res1 = abs(s[a - cnt1] - t[b - cnt2 + 1]);
		res2 = abs(s[a - cnt1 + 1] - t[b - cnt2 + 1]);
		ll tmp1 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp1);
		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1]);
		ll tmp2 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp2);
		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1 + 1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1 + 1]);
		ll tmp3 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp3);
		cout << res << endl;
	}
}

Measured memory_bytes: 2816
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new Main().solve(in, out);
		in.close();
		out.close();
	}
	
	public void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
		long s = 0;
		for (int i = 0; i + 1 < n; ++i) {
			s += a[i];
			++ ans;
			if (a[i + 1] > 2 * s) {
				ans = 0;
			}
		}
		++ ans;
		out.println(ans);
	}
}

Measured memory_bytes: 50048
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int mn = INF, flag = 0;
        int sum = 0;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            sum += x;
            if(x % 10){
                mn = min(mn, x);
                flag = 1;
            }
        }
        if(!flag){
            cout << "0\n";
        }else{
            if(sum % 10 == 0){
                sum -= mn;
            }
            cout << sum << '\n';
        }
    }
}

Measured memory_bytes: 31488
#include<iostream>
#include<cstdio>
#include<map>
//#include<>
using namespace std;
int main()
{
    int test;
    scanf("%d",&test);
        if(test<1200)
            printf("ABC\n");
        else if(test>=1200 && test<2800)
            printf("ARC\n");
        else if(test>=2800)
            printf("AGC\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;


int main(){
  int N;cin>>N;
  vector<int>A(N);
  vector<int>memo(N);
  rep(i,N){cin >>A[i];memo[i]=A[i];}
  sort(memo.begin(),memo.end());
  int ma=memo[N-1],nex=memo[N-2];
  rep(i,N){
    int x=A[i];
    if(x==ma){cout<<nex<<endl;}
    else{cout<<ma<<endl;}
  }
  
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 200010
//#define endl '\n'
#define mp make_pair
#define INF 10000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)
#define coutyes cout<<"Yes"
#define coutno cout<<"No"
#define pi 3.141592653589793238
using namespace std;

int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int m=s.length();
	if(m<=n)	cout<<s;
	else{
		forn(i,n)	cout<<s[i];
		cout<<"...";
	}
}
 

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	S := sc.nextRuneSlice()
	D := []int{}
	cnt := 1
	for i := 1; i < N; i++ {
		if S[i-1] == S[i] {
			cnt++
		} else {
			if S[i-1] == '0' {
				D = append(D, -cnt)
			} else {
				D = append(D, cnt)
			}
			cnt = 1
		}
	}
	if S[N-1] == '0' {
		D = append(D, -cnt)
	} else {
		D = append(D, cnt)
	}
	ans := 0
	sum := 0
	l := 0
	k := 0
	//fmt.Fprintln(wtr, D)
	for i := 0; i < len(D); i++ {
		if D[i] < 0 {
			if k == K {
				if ans < sum {
					ans = sum
				}
				if D[l] < 0 {
					sum += D[l]
					l++
				} else {
					sum -= D[l]
					sum += D[l+1]
					l += 2
				}
				k--
			}
			sum += -D[i]
			k++
		} else {
			sum += D[i]
		}
	}
	if ans < sum {
		ans = sum
	}

	fmt.Fprintln(wtr, ans)
}


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

int main(){
    std::string s;
    std::cin >> s;

    int red = std::count(s.begin(), s.end(), '0');
    int blue = std::count(s.begin(), s.end(), '1');

    if(1 == s.size()){
        std::cout << 0 << std::endl;
    }else if(red <= blue){
        std::cout << red * 2 << std::endl;
    }else{
        std::cout << blue * 2 << std::endl;
    }

    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(1,1);
const D tpie = 2*pie;

string vow = "aeiou";

void solve( int test_case )
{
    string s;
    cin >> s;

    stack < char > t;
    for ( char c : s )
    {
        if ( c=='B' )
        {
            if ( t.size()==0 ) C;
            t.pop();
            C;
        }
        t.push(c);
    }

    s.clear();
    int n = 0;
    while ( t.size() )
    {
        s += t.top();
        n++;
        t.pop();
    }

    for ( n-- ; n>-1 ; cout << s[n] , n-- );
}

int main()
{
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define ull unsigned long long

int compare_smallorder(const void *a, const void *b){return *(int*)a - *(int*)b;}

int main(){
    int i,x,n,p[102]={},num=1;
    scanf("%d%d",&x,&n);
    for (i=0; i<n; i++) scanf("%d",&p[i]);
    qsort(p, n, sizeof(p[0]), compare_smallorder);
    for (i=0; i<n; i++) {
        if (p[i]==x) break;
    }
    if (i==n) {
        printf("%d",x);
        return 0;
    }
    while (1) {
        for (i=0; i<n; i++) {
            if (p[i]==x-num) break;
        }
        if (i==n) {
            printf("%d",x-num);
            return 0;
        }
        for (i=0; i<n; i++) {
            if (p[i]==x+num) break;
        }
        if (i==n) {
            printf("%d",x+num);
            return 0;
        }
        num++;
    }
    return 0;
}




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

int N,mod = 10007;
int dp[1010][8] = {};
string s;
int main(){
	cin >> N >> s;
	dp[0][1] = 1;
	map<char,int> m;
	m['J'] = 0;
	m['O'] = 1;
	m['I'] = 2;
	for(int i=1;i<=N;i++){
		for(int S=0;S<8;S++){
			for(int T=0;T<8;T++){
				if(!(T & (1<<m[s[i-1]])) || (S&T)==0) continue;
				(dp[i][T] += dp[i-1][S])%=mod;
			}
		}
	}
	int ans = 0;
	for(int S=0;S<8;S++) (ans += dp[N][S])%=mod;
	cout << ans << endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>
 
using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
 
int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);
 
	ll a, b, c, n;
	string s;
	cin >> a >> b;
	if (a <= b) cout << a << endl;
	else cout << a - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
		Runtime rt = Runtime.getRuntime();
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<String>();
		while(in.hasNext()){
			input.add(in.next());
		}
		String s=input.get(0);
		char[] s2=s.toCharArray();
		String a="";
		for (int i=0;i<s.length();i=i+2){
			a+=s2[i];
			if(i%1000==0)rt.gc();
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 102160
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,maxn,minn=4000,k;
int a[305][305];
int t[305];
bool flag;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	scanf("%d",&a[i][j]);
//	for(int g=1;g<=m;g++)
//	for(int i=1;i<=m;i++)
	while(1)
	{
		memset(t,0,sizeof(t));
		maxn=0;
		if(flag==1)break;
		for(int j=1;j<=n;j++)
		{
			//p=i;
			//while(a[j][p]==0)p++;
			if(a[j][1]==0)flag=1;
			t[a[j][1]]++;
			if(t[a[j][1]]>maxn)maxn=t[a[j][1]],k=a[j][1];
		}
		for(int ii=1;ii<=n;ii++)
		for(int jj=1;jj<=m;jj++)
		{
			if(a[ii][jj]==k)
			for(int h=jj;h<=m;h++)
			a[ii][h]=a[ii][h+1];
		}
		//del++;
		minn=min(minn,maxn);
//		for(int c=1;c<=n;c++)
//		{
//			for(int b=1;b<=m;b++)
//			cout<<a[c][b]<<" ";
//			cout<<endl;
//		}
		
		
	}
	cout<<minn<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w,m; cin>>h>>w>>m;
	vector<int>y(h,0),x(w,0);
	set<pair<int,int>>st;
	for(int i=0;i<m;++i){
		int H,W; cin>>H>>W; --H,--W;
		++y.at(H),++x.at(W);
		st.insert({H,W});
	}
	int hmxc=*max_element(y.begin(),y.end()),wmxc=*max_element(x.begin(),x.end());
	vector<int>hmx,wmx;
	for(int i=0;i<h;++i){
		if(y.at(i)==hmxc)hmx.emplace_back(i);
	}
	for(int i=0;i<w;++i){
		if(x.at(i)==wmxc)wmx.emplace_back(i);
	}
	int ans=hmxc+wmxc-1;
	for(auto&&i:hmx){
		for(auto&&j:wmx){
			if(st.find({i,j})==st.end()){
				cout<<ans+1<<"\n"s;
				return 0;
			}
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 23820
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;

vector<vector<int>> e;
vector<int> c;
map<pair<int,int>,int> mp;

void dfs(int parent,int now){
  for(int v:e[now]){

    if(v != parent){

      if(mp[make_pair(v,now)] % 2 == 0){

	c[v] = c[now];

      }else{

	c[v] = (c[now] + 1) % 2;

      }

      dfs(now,v);
    }
  }    
  return;
}

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

  e.resize(N);
  c.resize(N,0);

  for(int i = 0;i < N-1;i++){
    int u,v,w;
    cin >> u >> v >> w;
    u--;
    v--;
    e[u].push_back(v);
    e[v].push_back(u);
    mp[make_pair(u,v)] = w;
    mp[make_pair(v,u)] = w;
  }

  c[0] = 0;

  dfs(-1,0);

  for(int i = 0;i < N;i++)cout << c[i] << endl;

}

Measured memory_bytes: 22912
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    int ans=0;
    rep(i,n){
        rep(j,n){
            if(i==j) continue;
            ans+=d[i]*d[j];
        }
    }
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

const int pat[]={1,2,3,5,8,13,21};

int main(){
    int yaku[110]={0};
    int N; cin>>N;
    for(int i=2;i<=N;++i){
        int tmp=i;
        for(int j=2;j<=i;++j){
            int cnt=0;
            while(tmp%j==0){
                tmp/=j;
                cnt++;
            }
            yaku[j]+=cnt;
        }
    }
    //sort(yaku,yaku+110);

    int a[]={2,4,14,24,74};
    int cnt[5]={0};
    for (int i = 0; i < 110; ++i) {
        for(int j=0;j<5;++j){
            if(yaku[i]>=a[j]) cnt[j]++;
        }
    }

    ll ans=0ll;
    // a^74
    ans+=cnt[4];
    // a^24*b^2
    ans+=cnt[3]*(cnt[0]-1);
    // a^14*b^4
    ans+=cnt[2]*(cnt[1]-1);
    //a^4*b^4*c^2
    ans+=cnt[1]*(cnt[1]-1)*(cnt[0]-2)/2;

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/


int prime[1000000] ;
vector < int > pr;
void calculateprime()
{
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            pr.pb(i);
            for(ll j = i*2 ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}


void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n)
{
  ll a = 0, b = 1, c, i;
  if( n == 0)
    return a;
  for (i = 2; i <= n; i++)
  {
    c = (a + b);
    a = b;
    b = c;
  }
  return b;
}


ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}


ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}


void solve(){
    int x,a;
    in(x)>>a;
    if(x < a){
        out(0);
    }
    else{
        out(10);
    }
}


int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3644