akhauriyash/Code-Regression huggingface dataset:
//file_name:ABC75_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);


    int ans = 0;
    if(x==y){
        ans =z;
    }else if(y== z){
        ans = x;
    }else{
        ans = y;
    }

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



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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (auto &v: b) cin >> v;
    int ans = 0;
    for (int x = 0; x < n; ++x) {
        int val = 0;
        for (int i = 0; i < m; ++i) {
            int a;
            cin >> a;
            val += a * b[i];
        }
        if (val + c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll n;
    cin >> n;
    ll va[3], vb[3];
    cin >> va[0] >> va[1] >> va[2];
    cin >> vb[0] >> vb[1] >> vb[2];
    vector<ll> dpa(n + 1);
    iota(ALL(dpa), 0LL);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j <= n; j++){
            if(j - va[i] < 0) continue;
            dpa[j] = max(dpa[j], dpa[j - va[i]] + vb[i]);
        }
    }
    vector<ll> dpb(dpa[n] + 1);
    iota(ALL(dpb), 0LL);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j <= dpa[n]; j++){
            if(j - vb[i] < 0) continue;
            dpb[j] = max(dpb[j], dpb[j - vb[i]] + va[i]);
        }
    }
    cout << dpb[dpa[n]] << endl;
    return 0;
}

Measured memory_bytes: 195584
#include <stdio.h>
#include <string.h>

int main() {
    char s[51], t[51];
    scanf("%s %s", s, t);
    int ls = strlen(s);
    int lt = strlen(t);
    for(int i = ls - 1; 0 <= i; i--) {
        int j = i, k = lt - 1;
        while((s[j] == '?' || s[j] == t[k]) && 0 <= k && 0 <= j) {
            j--;
            k--;
        }
        if(k < 0) {
            j = ls - 1;
            while(j > i) {
                if(s[j] == '?') {
                    s[j] = 'a';
                }
                j--;
            }
            k = lt - 1;
            while(0 <= k) {
                s[j] = t[k];
                j--;
                k--;
            }
            while(0 <= j) {
                if(s[j] == '?') {
                    s[j] = 'a';
                }
                j--;
            }
            printf("%s", s);
            return 0;
        }
    }
    printf("UNRESTORABLE");
    return 0;
}

Measured memory_bytes: 128
S = input()
N = len(S)


def f1(S):
    N = len(S)
    subset3 = S[0:(N - 2) // 2 + 1]
    subset4 = S[(N + 2) // 2:]
    return subset3, subset4


subset1, subset2 = f1(S)
_subset2 = ''.join(list(reversed(subset2)))
if subset1 != _subset2:
    print('No')
    exit()

if (N - 1) % 4 == 0:
    # print('subset1 2', subset1, subset2)
    subset3 = subset1[:((N - 1) // 4)]
    subset4 = subset1[((N - 1) // 4):]
    _subset4 = ''.join(list(reversed(subset4)))
    # print('subset3 4', subset3, subset4)
    subset5 = subset2[:((N - 1) // 4)]
    subset6 = subset2[((N - 1) // 4):]
    _subset6 = ''.join(list(reversed(subset6)))
    # print('subset5 6', subset5, subset6)
else:
    subset3, subset4 = f1(subset1)
    _subset4 = ''.join(list(reversed(subset4)))
    subset5, subset6 = f1(subset2)
    _subset6 = ''.join(list(reversed(subset6)))
if subset3 != _subset4:
    print('No')
    exit()
if subset5 != _subset6:
    print('No')
    exit()
print('Yes')


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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

long long int l[87];
int n;

long long int num(int x){
  if(x==1){return 1;}
  if(x==0){return 2;}
  if(l[x]!=0){
    return l[x];
  }
  if(l[x]==0){
    return l[x]=num(x-1)+num(x-2);
  }
}

int main(){
  cin>>n;
  rep(i,87){
    l[i]=0;
  }
  num(n);
  if(n==0){
    cout<<2<<endl;
  }else if(n==1){
    cout<<1<<endl;
  }else
  cout<<l[n]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
set<int> s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x,n;
	cin>>x>>n;
	rept(i,1,n)
	{
		int a;
		cin>>a;
		s.insert(a);
	}
	for(int i=0;;i++)
	{
		if(s.find(x-i)==s.end())
		{
			cout<<x-i<<"\n";
			return 0;
		}
		if(s.find(x+i)==s.end())
		{
			cout<<x+i<<"\n";
			return 0;
		}
	}
	
}

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int abc(int a)
{
	int ans=0;
	while(a)
	{
		ans++;
		a/=10;
	}
	return ans;
}
int main()
{
    long long a;
    cin>>a;
    for(int i=sqrt(a)+1;i>=1;i--)
    if(a%i==0)
    {
    	cout<<abc(a/i);
    	return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      ll i=__gcd(a,b);
      cout<<(a*b)/i;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
first = 0
second = 0
for num in range(n):
	hoge = int(input())
	a.append(hoge)
	if hoge >= first:
		second = first
		first = hoge
	elif second <= hoge and hoge <= first:
		second = hoge

#print(first, second)
for num in range(n):
	if(first <= a[num]):
		print(second)
	else:
		print(first)

Measured memory_bytes: 12532
#include<iostream>
using namespace std;
int main(int,char**){
    int x,y,i;
    cin>>x>>y;
    for(i=0;i<=x;i++){
        if(y==i*2+(x-i)*4){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<long long int> que;
    long long int ans=0;
    for(int n=0; n<N; n++) {
        long long int A;
        cin >> A;
        que.push(A);
        ans += A;
    }
    for(int m=0; m<M; m++) {
        ans -= que.top()-que.top()/2;
        que.push(que.top()/2);
        que.pop();
    }
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 1400
# ABC067D - Fennec VS. Snuke (ARC078D)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

from collections import deque


def bfs(s, d) -> None:
    q = deque([s])
    while q:
        v = q.popleft()
        for u in G[v]:
            if not d[u]:
                q.append(u)
                d[u] = d[v] + 1


def main():
    global G, DB, DW
    N = int(input())
    E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    G = [[] for _ in range(N + 1)]
    for v, u in E:
        G[v] += [u]
        G[u] += [v]
    DB, DW = [0] * (N + 1), [0] * (N + 1)
    bfs(1, DB), bfs(N, DW)
    b, w = 0, 0
    for i, j in zip(DB[1:], DW[1:]):
        if i <= j:
            b += 1
        else:
            w += 1
    flg = b > w
    print("Fennec" if flg else "Snuke")


if __name__ == "__main__":
    main()

Measured memory_bytes: 38096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<int> v[26];
    int cals[26] {0};
    int calt[26] {0};
    for(int i = 0; i < n; i++){
        cals[s[i] - 'a']++;
        v[s[i] - 'a'].push_back(i);
    }
    for(int i = 0; i < m; i++){
        calt[t[i] - 'a']++;
    }
    for(int i = 0; i < 26; i++){
        if(cals[i] == 0 && calt[i] != 0){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < 26; i++){
//        cout << i << " ";
//        for(int x : v[i]) cout << x << " ";
//        cout << endl;
//        cout << cals[i] << endl;
    }
    ll now = -1;
    ll cir = 0;
    for(int i = 0; i < m; i++){
        int u = t[i] - 'a';
//        cout << now << " ";
        int next = upper_bound(v[u].begin(), v[u].end(), now) - v[u].begin();
//        cout << u << " " << next << endl;
        if(next == cals[u]){
//            cout << u << endl;
            now = -1;
            cir++;
            next = upper_bound(v[u].begin(), v[u].end(), now) - v[u].begin();
        }
        now = v[u][next];
//        cout << next << endl;
    }
    ll ans = cir * n + now + 1;
    cout << ans << endl;
//    cout << cir << n << now << endl;
}

Measured memory_bytes: 1216
N = int(input())
A, B = map(int, input().split())
*P, = map(int, input().split())

first = []
second = []
third = []
for p in P:
    if p in range(A+1):
        first.append(p)
    elif p in range(A+1, B+1):
        second.append(p)
    else:
        third.append(p)
print(min(len(first), len(second), len(third)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string n;
  int k;
  cin >> n >> k;
  vector<vector<vector<lint>>> dp(n.length() + 1, vector<vector<lint>>(2, vector<lint>(k + 2)));
  dp[0][1][0] = 1;
  rep (i, n.length()) {
    rep (j, k + 1) {
      dp[i + 1][0][j] += dp[i][0][j];
      dp[i + 1][0][j + 1] += dp[i][0][j] * 9;
      if (n[i] == '0') {
        dp[i + 1][1][j] += dp[i][1][j];
      } else {
        dp[i + 1][0][j] += dp[i][1][j];
        dp[i + 1][1][j + 1] += dp[i][1][j];
        dp[i + 1][0][j + 1] += dp[i][1][j] * (n[i] - '0' - 1);
      }
    }
  }
  cout << dp.back()[0][k] + dp.back()[1][k] << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
if n < 105:
    print(0)
else:
    ans = 0
    for i in range(105, n+1, 2):
        cnt = 0
        for p in range(1, i+1):
            if i%p==0:
                cnt += 1
        if cnt == 8:
            ans += 1
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int abs(int a,int b) {
  if (a>=b ) {
    return a-b;
    
  }
  else {
    return b-a;
  }
}
 
int main() {
  int64_t a,b,v,w;
  cin >> a >> v >> b >> w;
  int64_t t;
  cin >> t;
  int64_t sub = abs(a,b);
  int64_t r = abs(v,w);
  if ( v> w  ) {
    if (sub <= r*t) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }  
  else {
    cout << "NO" << endl;
  }
}

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

int main()
{
    string str;
    int f = 1;
    int cnt = 0;

    cin >> str;
    
    if (str[0] != 'A') f = 0;
    
    for (int i = 2; i < str.size() - 1; i++) {
        if (str[i] == 'C') cnt++;
    }
    for (int i = 0; i < str.size(); i++) {
        if (str[i] != 'A' && str[i] != 'C' &&
            'A' <= str[i] && str[i] <= 'Z') f = 0;
    }

    if (cnt != 1) f = 0;

    cout << (f ? "AC" : "WA") << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  char a[5];
  scanf("%s", a);
  if(a[0] == a[1] && a[1] == a[2])
  {
    printf("No\n");
  }
  else
  {
    printf("Yes");
  }
  
  return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	string st;
	cin >> st;
	if((st[0] == 'A' and st[1] == 'C') or (st[0] == 'A' and st[(ll)st.length()-1] == 'C'))
		cout << "WA";
	else if(st[0] != 'A')
		cout << "WA";
	else{
		ll cnt1 = 0, cnt2 = 0;
		for(ll i=0; st[i]; i++){
			if(st[i] == 'A')
				cnt1 ++;
			else if(st[i] == 'C')
				cnt2 ++;
			else if(st[i] >= 'A' and st[i] <= 'Z'){
				cout << "WA";
				return 0;
			}
		}
		if(cnt1 > 2 or cnt2 != 1)
			cout << "WA";
		else
			cout << "AC";
	}
	return 0;
}

Measured memory_bytes: 3648
n,a,b = gets.split().map(&:to_i)
array = []
for x in 1..n do
  x = x.to_s.split("").map(&:to_i)
  y = x.inject(:+)
  if y >= a && y <= b
    x = x.map(&:to_s).inject(:+).to_i
    array << x
  end
end

ans = array.inject(:+)
puts ans

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

#define ff first
#define ss second
#define endl '\n'

const int MAX = 1e5 + 5;
const int MOD = 1e9 + 7;
int a[MAX], dp[MAX][2];

int addMod(int a, int b) {
	return ((a + b) % MOD + MOD) % MOD;
}

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

	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	for (int r = 0; r <= a[0]; ++r) {
		dp[r][0] = 1;
	}

	int prefix = 0;
	for (int c = 1, old_c, i = 1; i < n; ++i, c = !c) {
		prefix = dp[0][c] = 1;
		old_c = !c;

		for (int r = 1; r <= a[i]; ++r) {
			prefix = addMod(prefix, dp[r][old_c]);
			dp[r][c] = prefix;
		}

		for (int r = a[i] + 1; r <= k; ++r) {
			prefix = addMod(prefix, dp[r][old_c] - dp[r-a[i]-1][old_c]);
			dp[r][c] = prefix;
		}
	}

	cout << dp[k][!(n & 1)] << endl;
	return 0;
}


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

const int N = 3000;

int dp[N + 1][N + 1];

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  s = '$' + s;
  t = '$' + t;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i == 0 || j == 0)
        dp[i][j] = 0;
      else if (s[i] == t[j]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  int i = n, j = m;
  string ans = "";
  while (i > 0 && j > 0) {
    if (s[i] == t[j]) {
      ans += s[i];
      i--, j--;
    } else {
      if (dp[i-1][j] > dp[i][j-1]) {
        i--;
      } else {
        j--;
      }
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 38796
N = int(input())
A = []
for a in range(5):
    b = int(input())
    A.append(b)

A.sort()
if A[0] >= N:
    print(5)
    exit()
else:
    if N % A[0] == 0:
        print(N // A[0] + 4)
        exit()
    else:
        print(N // A[0] + 5)
        exit()

Measured memory_bytes: 3060
import math

d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]

ans = float("inf")
for i in range(1 << d):
    score = 0
    took = 0
    not_took = []
    for j in range(d):
        p, c = pc[j]
        if i & 1 << j:
            score += (j + 1) * 100 * p + c
            took += p
        else:
            not_took.append(j)
    if score >= g:
        ans = min(ans, took)
    elif len(not_took) != 0:
        last = not_took[-1]
        need = math.ceil((g - score) / ((last + 1) * 100))
        if need <= pc[last][0]:
            ans = min(ans, took+need)
print(ans)


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

int main() {
  int ans = 0;
  vector<int>data(3);
  vector<bool>odd(3,false);
  cin >> data[0] >> data[1] >> data[2];
  sort(data.begin(),data.end());
  for(int i = 0;i < 3;i++) if(data[i]%2 != 0) odd[i] = true;
  if(odd[0] != odd[2] && odd[1] != odd[2]){
    data[0]++;
    data[1]++;
    ans++;
  }
  else if(odd[0] != odd[1] && odd[2] != odd[1]){
    data[0]++;
    data[2]++;
    ans++;
  }
  else if(odd[1] != odd[0] && odd[2] != odd[0]){
    data[1]++;
    data[2]++;
    ans++;
  }
  ans += (data[2]-data[0])/2+(data[2]-data[1])/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

const char newl = '\n';

ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans*=a;a*=a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mod){ll ans=1;do{if(b&1)ans=ans*a%mod;a=a*a%mod;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    int hp1, atk1, hp2, atk2;
    cin >> hp1 >> atk1 >> hp2 >> atk2;

    while(true) {
        hp2 -= atk1;
        if (hp2 <= 0) {
            cout << "Yes" << newl;
            break;
        }
        hp1 -= atk2;
        if (hp1 <= 0) {
            cout << "No" << newl;
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

int main() {

    int N;

    cin >> N;

    set<int> S;

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

        if (S.find(t) == S.end()) {
            S.insert(t);
        } else {
            S.erase(S.find(t));
        }
    }

    cout << S.size() << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll A, B, C;
	cin >> A >> B >> C;

	ll S = A + B + C;

	ll M = max(A, max(B, C));

	
	if ((3 * M - S) % 2 == 0) { cout << (3 * M - S) / 2; }
	else { cout << (3 * M + 3 - S) / 2; }
	

	system("PAUSE");

	

}


Measured memory_bytes: 504
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int a[22],b[22],c[22];
//map<int,int> la;
int main(){
	int n;
	cin>>n;
	int res=0;
	rb(i,1,n) cin>>a[i];
	rb(i,1,n) cin>>b[i];
	rb(i,1,n-1) cin>>c[i];
	rb(i,1,n){
		if(a[i-1]==a[i]-1)
		{
			res+=c[a[i-1]];
		}
		res+=b[a[i]];
	}
	cout<<res<<endl;
	return 0;
}

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

int a[3][3];
bool used[3][3];

int main(){
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(ni,n){
        int b;
        cin >> b;
        rep(i,3){
            rep(j,3){
                if(b == a[i][j])
                    used[i][j] = 1;
            }
        }
    }
    bool ok = false;
    rep(i,3){
        int cnt = 0;
        rep(j,3){
            if(used[i][j])
                cnt++;
        }
        if(cnt==3)
            ok = true;
    }
    rep(i,3){
        int cnt = 0;
        rep(j,3){
            if(used[j][i])
                cnt++;
        }
        if(cnt==3)
            ok = true;
    }
    int cnt = 0;
    rep(i,3){
        if(used[i][i])
            cnt++;
    }
    if(cnt==3)
            ok = true;
    cnt = 0;
    rep(i,3){
        if(used[i][2-i])
            cnt++;
    }
    if(cnt==3)
        ok = true;
    if(ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a,b):
    if b == 0:
        return a
    if a % b == 0:
        return b
    else:
        return gcd(b,a%b)

N = int(input())
A = [i for i in map(int,input().split())]
L = [0]
R = [0]
for i in range(N):
    L.append(gcd(L[-1],A[i]))
for i in range(N-1,-1,-1):
    R.append(gcd(R[-1],A[i]))
R.reverse()
g = []
for i in range(N):
    g.append(gcd(L[i],R[i+1]))
print(max(g))

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

// vector<int> dp(100000, 1e9);

int main()
{
    // string S,T,U;
    ll N;
    ll ans = 0;
    cin >> N ;
    // scanf("%lld%lld", &A,&B);
    // cin >> U;
    ans = (N+1) / 2;
    printf("%lld",ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string result(string s)
{
    int len=s.length();
    if(len%2==0)
    return "No";
    for(int i=0,j=len-1;i<j;i++,j--)
    {
        if(s[i]!=s[j])
        return "No";
    }
    int sec=(len-1)/2;
    for(int i=0,j=sec-1;i<j;i++,j--)
    {
        if(s[i]!=s[j])
        return "No";
    }
    int third=(len+3)/2;
    for(int i=third-1,j=len-1;i<j;i++,j--)
    {
        if(s[i]!=s[j])
        return "No";
    }
    return "Yes";
}


int main() {
    string inp;
    cin>>inp;
    cout<<result(inp);
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

typedef long long ll;

int main () {
	ll n, r;
	ll i, j;
	ll ret;
	
	cin >> n >> r;
	
	if (n<10) {
		cout << r+100*(10-n) << endl;
	}
	else {
		cout << r << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++14
TASK:
*/
#include<iostream>
//#include<fstream>
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(b/a,c);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 200007;
const int MAX2 = 1000007;
const int LEN = 21;
const int BASE = 1000000000;

const int MOD = 998244353;

int n;
int C[MAX];

int main()
{
  cin >> n;
  FOR (i,0,n)
  {
    int x;
    scanf("%d", &x);
    C[x] ++;

    if (i == 0 && x != 0)
    {
      cout << 0 << endl;
      return 0;
    }
  }

  int tot = 1;

  if (C[0] != 1)
  {
    cout << 0 << endl;
    return 0;
  }
  
  Int res = 1;

  FOR (i,1,n)
    FOR (j,0,C[i])
      res = res * C[i-1] % MOD;


  cout << res << endl;

  






 
  return 0;
}


Measured memory_bytes: 3888
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt().groupBy { it }
    val ans = A.all { it.value.size == 1 }
    println(if (ans) "YES" else "NO")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

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

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	if (*max_element(v.begin(), v.end()) == *min_element(v.begin(), v.end())) {
		cout << n / 2 << endl;
		return 0;
	}
	map<int, int> cnt[2];
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			cnt[1][v[i]]++;
		}
		else {
			cnt[0][v[i]]++;
		}
	}
	vector<pair<int, int>> p1, p2;
	for (auto v1 : cnt[0]) {
		p1.emplace_back((n + 1) / 2 - v1.second, v1.first);
	}
	for (auto v2 : cnt[1]) {
		p2.emplace_back(n / 2 - v2.second, v2.first);
	}
	sort(p1.begin(), p1.end());
	sort(p2.begin(), p2.end());
	int res = 0;
	if (p1.front().second == p2.front().second) {
		res = min(p1.front().first + ((int)p2.size() >= 2 ? p2[1].first : n / 2), ((int)p1.size() >= 2 ? p1[1].first : (n + 1) / 2) + p2.front().first);
	}
	else {
		res = p1.front().first + p2.front().first;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 6520
#include<iostream>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 1; i <= n;i++)
const int MOD = 1000000007;
const ll INF = (1LL << 60);
string s; ll n, m, k, q = 0, ans, sum =INF; 
vector<vector<vector<int>>> v(200, vector<vector<int>>(200, vector<int>(200, -1)));
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int ngcd(int a,int b,int c) {
    int res;
    res = gcd(c, a);
    res = gcd(b, res);
    return res;
}
int main() {
    cin >> n;
    rep(i, n) {
        rep(j, n) {
            rep(k, n) {
                q += ngcd(i, j, k);
            }
        }
    }
    cout << q << endl;
}

Measured memory_bytes: 36360
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define ll long long

using namespace std;

const ll INF = LLONG_MAX / 2 - 1;


struct Edge {
	ll t;
	ll c;
	Edge(ll to, ll cost):t(to),c(cost){}
	Edge(){}
};

vector<ll> weigh;
ll R, C;
ll xmin, ymin;

bool DFS(ll node, vector<vector<Edge> >& edge) {
	if (node < R) xmin = min(xmin, weigh[node]);
	else ymin = min(ymin, weigh[node]);
	for (auto &to : edge[node]) {
		if (weigh[to.t] == INF) {
			weigh[to.t] = to.c - weigh[node];
			if (not DFS(to.t, edge)) return false;
		}
		else {
			if (weigh[to.t] + weigh[node] != to.c) return false;
		}
	}
	return true;
}
int main() {
	cin >> R >> C;
	ll N;
	cin >> N;
	weigh.resize(R + C, INF);
	vector<vector<Edge> > edge(R+C);
	for(int i = 0; i < N; i++){
		ll r, c, a; cin >> r >> c >> a;
		--r; --c;
		edge[r].push_back(Edge(R+c,a));
		edge[R+c].push_back(Edge(r, a));
	}

	bool res = true;
	for(int i = 0; i < R + C; i++){
		if(weigh[i] == INF and edge[i].size() > 0) {
			//xmin = ymin = numeric_limits<int>::max();
			xmin = ymin = INT_MAX;
			weigh[i] = 0;
			if (not DFS(i,edge) or xmin+ymin < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 16384
open Batteries;;
let () =
  let c11,c12,c13 = Scanf.scanf "%d %d %d\n" (fun x y z -> x,y,z) in
  let c21,c22,c23 = Scanf.scanf "%d %d %d\n" (fun x y z -> x,y,z) in
  let c31,c32,c33 = Scanf.scanf "%d %d %d\n" (fun x y z -> x,y,z) in
  let condlist =
    (c11-c12 = c21-c22 && c21-c22 = c31-c32)
    :: (c12-c13 = c22-c23 && c22-c23 = c32-c33) 
    :: (c11-c21 = c12-c22 && c12-c22 = c13-c23)
    :: (c21-c31 = c22-c32 && c22-c32 = c23-c33)
    :: (2*(c11+c22+c33) = c21+c31+c32+c12+c13+c23)
    :: []
  in
  let ans = if List.fold_left (&&) true condlist = true then "Yes" else "No" in
  print_string ans
;;


Measured memory_bytes: 1024
#include<stdio.h>

int main() {

  char s[100], t[200], p[100];
  int i=0, j=0, jg=0, lenp=0;

  scanf("%s", s);
  scanf("%s", p);

  while(s[i]){
    t[j]=s[i];
    i=i+1;
    j=j+1;
  }

  i=0;

  while(s[i]){
    t[j]=s[i];
    i=i+1;
    j=j+1;
  }

  while (p[lenp])
    lenp++;

    i=0; j=0;
  while (s[i]){
    if (p[0] == t[i] ){
      for (j=0; j<lenp; j++){
        if (p[j] == t[i+j])
          jg=1;
        else{
          jg=0;
          break;
        }
      }
      if (jg == 1)
        break;
    }
    i=i+1;
  }
  if (jg == 1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) {
    	cout << k << "\n";
    }
    else if (k <= a + b) {
    	cout << a << "\n";
    }
    else {
    	cout << a - (k - a - b) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = LONG_LONG_MIN;
    chmax(ans, a * c);
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>
typedef long long int ll;

ll factorial(ll n, ll md)
{
    ll res = 1;
    for (int i = 1; i < n+1; ++i)
    {
        res *= i;
        res %= md;
    }
    return res;
}

int main()
{
    ll N, ans;
    ll mod = 1000000007;
    scanf("%lld", &N);
    char S[200005];
    scanf("%s", S);

    if (S[0] == 'W' || S[2*N-1] == 'W')
    {
        puts("0\n");
        return 0;
    }
    else ans = 1;

    int op[200005] = {};
    ll ct_L = 1;
    ll ct = 1;
    for (int i = 1; i < 2*N; ++i)
    {
        if (S[i] == S[i-1])
        {
            if (op[i-1] == 0)
            {
                op[i] = 1;
                ans *= ct_L;
                ans %= mod;
                ct_L--;
            }
            else
            {
                op[i] = 0;
                ct_L++;
                ct++;
            }
        }
        else
        {
            if (op[i-1] == 0)
            {
                op[i] = 0;
                ct_L++;
                ct++;
            }
            else
            {
                op[i] = 1;
                ans *= ct_L;
                ans %= mod;
                ct_L--;
            }
        }
    }

    if (ct != N)
    {
        puts("0\n");
        return 0;
    }

    printf("%lld\n", factorial(N, mod) * ans % mod);

    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= 9; ++i)
		if(n % i == 0 && n / i >= 1 && n / i <= 9)
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	return 0;
}

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

int main() {
        string str, com, tempstr, tempstr2;
        int i, j, q, x, y;
        cin >> str;
        cin >> q;
        for (i = 0; i < q; i++) {
                cin >> com >> x >> y;
                tempstr.clear();
                if (com == "replace") {
                        cin >> tempstr;
                        str.replace(x, y - x + 1, tempstr);
                } else if (com == "print") {
                        cout << str.substr(x, y - x + 1) << endl;
                } else {
                        for(j = y; j >= x; j--) tempstr += str[j];
                        str.replace(x, y - x + 1, tempstr);
                }
        }
}

Measured memory_bytes: 3216
n=int(input())
a=list(map(int,input().split()))
b_4=0
b_2=0
b_i=0
for i in a:
    if i%4==0:
        b_4+=1
    elif i%2==0:
        b_2+=1
    else:
        b_i+=1
if b_2==0:
    if b_i<=b_4+1:
        print("Yes")
    else:
        print("No")
else:
    if b_i<=b_4:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;

  for (long i = 1; i < N+1; i++) {
    long count =0;
    long n = sqrt(i);
    for (long j = 1; j < n; j++) {
        for (long k = j; k < n; k++) {
            for (long l = k; l < n; l++) {
               if (j*j+k*k+l*l+j*k+k*l+l*j == i && j == k && k == l) {
                   count += 1;
                }else if (j*j+k*k+l*l+j*k+k*l+l*j == i && j == k && k != l) {
                   count += 3;
                }else if (j*j+k*k+l*l+j*k+k*l+l*j == i && j != k && k == l) {
                   count += 3;
                }else if (j*j+k*k+l*l+j*k+k*l+l*j == i && j != k && k != l) {
                   count += 6;
                }
            }
        }
    }
    cout << count <<endl;
  }
     
}

Measured memory_bytes: 3572
#include<iostream>
#include<exception>
#include<stdexcept>
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int n; string s;
int solve(const string & p){
	int ret=0;
	vector<int> pre(n+1);
	pre.clear();
	for(int i=0;i<n;++i) pre[i+1]=pre[i] + (s[i]==p[0]);
	for(int i=0;i<n;++i){
		if(s[i]==p[1]){
			for(int j=i+1;j<n;++j){
				if(s[j]==p[2]){
					ret+=pre[i];
					// j-x=k-j
					int x=2*i-j;
					if(x>=0 && s[x]==p[0]) ret--;
				}
			}
		}
	}
	return ret;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    cin>>n;cin>>s;
	string p="BGR";
	int ret=0;
	do{
		ret+=solve(p);
	}while(next_permutation(p.begin(), p.end()));
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,pair<int,int>>m;
int main()
{
string s;cin>>s;
int mx=0,sum=0;
for(auto i:s){
    if(i=='R') sum++,mx=max(sum,mx);
    else sum=0;
}
mx=max(mx,sum);
cout<<mx;
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> c(m);
  rep(i, m) cin >> c[i];
  vector<int> dp(n+5, INF);
  dp[0] = 0;
  for(int sum_n = 0; sum_n <= n; ++sum_n) {
    rep(i, m) if(sum_n+c[i] <= n) chmin(dp[sum_n+c[i]], dp[sum_n]+1);
  }
  cout << dp[n] << endl;
}


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

int main(void){
    int N;
    long long A[100000];
    long long ans = 1;

    cin >> N;
    rep(i, N){
        cin >> A[i];
        if(A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    rep(i, N){
        if(ans > 1000000000000000000/A[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4408
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		long s = sc.nextLong();
		for(int i = 0; i<=k; i++){
			for(int j =0; j<=k; j++){
				if(k-i-j>=0 && s-1000*i-5000*j>=0 && s-1000*i-5000*j==10000*(k-i-j)){
					System.out.println(k-i-j+" "+j+" "+i);
					return;
				}
			}
		}
		System.out.println(-1+" "+-1+" "+-1);
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(void) {
	int k, n;
	cin >> k >> n;
	int a[200000] = { 0 };
	for (int i(0); i < n; i++) {
		cin >> a[i];
	}
	int max(k + a[0] - a[n - 1]);
	for (int i(0); i < n-1; i++) {
		if (max < a[i + 1] - a[i])max = (a[i + 1] - a[i]);
	}
	cout << k - max << endl;
	return 0;
}

Measured memory_bytes: 1024
printLine n m
  | n == 0 = "\n"
  | n > 1 && n < m = "." ++ printLine (n - 1) m
  | otherwise = "#" ++ printLine (n - 1) m

printLineW n
  | n == 0 = "\n"
  | otherwise = "#" ++ printLineW (n - 1)

printRect h hh w
  | h == 0 = ""
  | h > 1 && h < hh = printLine w w ++ printRect (h - 1) hh w
  | otherwise = printLineW w ++ printRect (h - 1) hh w

main = do
  hw <- getLine
  if hw == "0 0"
    then
      return []
    else do
      let lhw = map (read :: String -> Int) $ words hw
      putStrLn $ printRect (lhw !! 0) (lhw !! 0) (lhw !! 1)
      main

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	bool res = true;
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] > a[i + 1]) {
			if (a[i] == a[i + 1] + 1) a[i]--;
			else res = false;
		}
	}
	std::cout << (res ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Collatz Problem
            int s = int.Parse(Console.ReadLine());

            //過去に出てきた数字を記憶しておく
            var numbers = new List<int> { s };

            while (true)
            {
                if (s % 2 == 0)
                {
                    s /= 2;
                }
                else
                {
                    s = s * 3 + 1;
                }

                if (numbers.Contains(s))
                {
                    Console.WriteLine(numbers.Count + 1);
                    return;
                }
                else
                {
                    numbers.Add(s);
                }
            }
        }
    }
}

Measured memory_bytes: 13148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
using ll = long long; 
using namespace std;
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 gcd(int a,int b) {
	if(b==0) return a;
	return gcd(b,a%b);
}
int main() {
	int n,X;
	cin >> n >> X;
	vector<int>x(n);
	rep(i,n) {
		cin >> x[i];
	}
	sort(x.begin(),x.end());
	vector<int>g(n);
	rep(i,n) {
		g[i] = abs(X-x[i]);
	}
	int ans = g[0];
	rep(i,n-1) {
		ans = gcd(ans,g[i+1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Main extends App {
    val inp = readLine.split(" ").map(_.toInt)
    val a = inp(0)
    val b = inp(1)
    val c = inp(2)
    val d = inp(3)

    def ceil(a:Long, b:Long): Long = {
        (a+b-1)/b
    }
    if(ceil(c,b)<=ceil(a,d)) print("Yes");
    else print("No");

}

Measured memory_bytes: 54520
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
LL n,i,maxi,mini=OO;
scanf("%lld",&n);
for(i=1;i*i<=n;++i){
    if(n%i==0){
        LL num1=i,num2=n/i,counter1=0,counter2=0;
        while(num1){
            num1/=10;
            counter1++;
        }
        while(num2){
            num2/=10;
            counter2++;
        }
        maxi=max(counter1,counter2);
        mini=min(mini,maxi);
    }
}
printf("%lld",mini);


    return 0;
}


Measured memory_bytes: 3820