akhauriyash/Code-Regression huggingface dataset:
import re

def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]


def main():
    [N, K] = [int(number) for number in input().split()]
    S = input()
    s = [len(rl) for rl in list(nchars(S,1))]
    happy = sum(s)-len(s) + K * 2
    if happy >= N:
        print(N-1)
    else:
        print(happy)


    """
    i = K
    while (i > 0):
        len_s = len(s)
        if len_s < 3:
            break
        if i == K:
            three_range_arr = [s[j] + s[j+1] + s[j+2] for j in range(len_s) if j < len_s-2]
            max_tra = max(three_range_arr)
            index = three_range_arr.index(max_tra)
        else:
            index = s.index(max(s))
            if index == 0:
                max_tra = s[index]+s[index+1]+s[index+2]
            elif index == len_s - 1:
                max_tra = s[index-2] + s[index-1] + s[index]
                index -= 2
            else:
                if index == 1:
                    maxs = [s[index-1] + s[index] + s[index+1], s[index]+s[index+1]+s[index+2]]
                elif index == len_s-2:
                    maxs = [s[index-2] + s[index-1] + s[index], s[index-1] + s[index] + s[index+1]]
                else:
                    maxs = [s[index-2] + s[index-1] + s[index], s[index-1] + s[index] + s[index+1], s[index]+s[index+1]+s[index+2]]
                max_tra = max(maxs)
                offset = maxs.index(maxs) - 2
                if index == 1:
                    offset += 1
                index += offset
        if index == 0:
            ss = [max_tra]
            ss.extend(s[index+3:len_s])
        elif index == len_s - 3:
            ss = s[0:index-1]
            ss.extend([max_tra])
        else:
            ss = s[0:index-1]
            ss.extend([max_tra])
            ss.extend(s[index+3:len_s])
        #s = s[0:index-2].append(max_tra)#.extend(s[index+1, len_s-1])
        i-=1
        s=ss

    if i > 0:
        print(N-1)
    else:
        print(sum(s)-len(s))
    """


if __name__ == '__main__':
    main()


Measured memory_bytes: 12788
//https://codeforces.com/contest/1328/problem/A
//BROWNIE TK

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/

int main()
{
    kira;
    lli k,n;
    cin>>k>>n;
    lli a[n];
    forz(i,n)cin>>a[i];
    lli maxi=-1;
    for(int i=1;i<n;i++)
    {
        maxi=max(a[i]-a[i-1],maxi);
    }
    maxi=max(k-a[n-1]+a[0],maxi);
    cout<<k-maxi;
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main() {
  int n,k; 
  cin>>n>>k;  
  vector<ll>vec(n); 
  rep(i,n) cin>>vec[i];
  
  vector<ll>ans;
  rep(i,n-k+1){
    int l=i;
    int r=i+k-1;
    ll dist1=abs(vec[l])+abs(vec[l]-vec[r]);
    ll dist2=abs(vec[r])+abs(vec[l]-vec[r]);
    ans.push_back(dist1);
    ans.push_back(dist2);
  }
  sort(ans.begin(),ans.end());
  cout<<ans[0]<<endl;
}



Measured memory_bytes: 2168
#include <stdio.h>
int main() {
  int i, j = 1, n, a;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a == j) j++;
  }
  if (j == 1) { puts("-1"); } else { printf("%d\n", n + 1 - j); }
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
char s[11];
int main()
{
	int n,k;
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>s[i];
	cin>>k;
	char dtn=s[k];
	for (int i=1;i<=n;i++)
	{
		if (s[i]!=dtn)  s[i]='*';
	}
	for (int i=1;i<=n;i++)  cout<<s[i];
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  vector<string> vs = {"Sunny", "Cloudy", "Rainy"};
  string s;
  cin>>s;
  int idx = boost::find(vs, s) - begin(vs);
  int nx = (idx+1)%3;
  cout<<vs[nx]<<endl;
  return 0;
}


Measured memory_bytes: 256
let n = int (stdin.ReadLine())
let a = stdin.ReadLine().Split() |> Array.map int
Array.foldBack (fun z (li, back) -> if z <= back then (z :: li, z) else (back :: li, z)) a ([], 100000) |> fun x -> List.sum (fst x) + a.[0] |> printfn "%d"

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

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

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

  int a,b ;
  cin >> a >> b;

  if(a%k == 0 || b/k-a/k >=1 ){
    cout << "OK";
  }else{
    cout << "NG";
  }
  cout << endl;


  return 0;
}

Measured memory_bytes: 3632
// Aizu 1162: Discrete Speed
// 2017.9.18 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 30000
typedef struct { double t; int k, c, p; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
  int l, r;
  int smallest;

  l = LEFT(i), r = RIGHT(i);
  if (l < qsize && que[l].t < que[i].t) smallest = l; else smallest = i;
  if (r < qsize && que[r].t < que[smallest].t) smallest = r;
  if (smallest != i) {
    QUE t = que[i]; que[i] = que[smallest]; que[smallest] = t;
    min_heapify(smallest);
  }
}

int deq(int *k, int *c, int *p)
{
  if (qsize == 0) return 0;
  *k = que[0].k, *c = que[0].c, *p = que[0].p;
  que[0] = que[--qsize];
  min_heapify(0);
  return 1;
}

void enq(double t, int k, int c, int p)
{
  int i, ii;

  i = qsize++;
  que[i].t = t, que[i].k = k, que[i].c = c, que[i].p = p;
  while (i > 0 && que[ii = PARENT(i)].t > que[i].t) {
    QUE tt = que[i]; que[i] = que[ii]; que[ii] = tt;
    i = ii;
  }
}

typedef struct { int len, to[32], d[32], c[32]; } TBL;
TBL tbl[32];
double node[32][32][32]; int size;
int start, goal;

double search()
{
	int i, j, a, b, v, pre, v2;
	double t;
	TBL *p;

	qsize = 0;
	memset(node, 0, sizeof(node));
	node[start][0][0] = 0;
	enq(0, start, 0, 0);
	while(deq(&a, &v, &pre)) {
		if (a == goal && v == 1) return node[goal][pre][v];
		for (p = tbl+a, i = 0; i < p->len; i++) {
			if ((b = p->to[i]) == pre) continue;
			for (j = -1; j <= 1; j++) {
				if ((v2 = v + j) > p->c[i] || v2 <= 0) continue;
				t = node[a][pre][v] + (double)p->d[i] / (double)v2;
				if (node[b][a][v2] == 0 || t < node[b][a][v2]) node[b][a][v2] = t, enq(t, b, v2, a);
			}
		}
	}
	return -1.0;
}

int main()
{
	int m, a, b, d, c;
	TBL *p;
	double ans;

	while (scanf("%d%d", &size, &m) && size) {
		scanf("%d%d", &start, &goal);
		memset(tbl, 0, sizeof(tbl));
		while (m-- > 0) {
			scanf("%d%d%d%d", &a, &b, &d, &c);
			p = tbl + a, p->to[p->len] = b, p->d[p->len] = d, p->c[p->len] = c, p->len++;
			p = tbl + b, p->to[p->len] = a, p->d[p->len] = d, p->c[p->len] = c, p->len++;
		}
		if ((ans = search()) < 0) puts("unreachable");
		else printf("%.10lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2204
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int main(){
  int n;
  long long ans = 0, ans2, ans3, a[MAX*2], c, d;
  scanf("%d%lld%lld", &n, &c, &d);
  ans2 = c;
  ans3 = d;
  for(int i = 0; i < n-1; i++){
    scanf("%lld%lld", &a[i*2], &a[i*2+1]);
    ans2 += a[i*2];
    ans3 += a[i*2+1];
    if(max(a[i*2], a[i*2+1]) < max(c, d)){
      swap(a[i*2], c);
      swap(a[i*2+1], d);
    }
  }
  sort(a, a+2*n-2);
  for(int i = 0; i < n-2; i++) ans += a[i];
  ans += min(c + d, a[n-2] + a[n-1]);
  printf("%lld\n", min(ans, min(ans2, ans3)));
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(S: str):
    print('ARC' if S == 'ABC' else 'ABC')
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9032
/* Bismillahir Rahmanir Rahim */
#include <bits/stdc++.h>
 
using namespace std ;

int main(){
	
	int a,b ;
	
	scanf("%d %d",&a,&b) ;
	
	if(a==1){
		a=14;
	}
	
	if(b==1){
		b=14;
	}
	
	if(a>b){
		printf("Alice\n") ;
	}
	
	else if(a<b){
		printf("Bob\n") ;
		
	}
	
	else {
		printf("Draw\n") ;
	}
}
	

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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string n;
	cin >> n;
	
	if( count(n.begin(), n.end(), '9') != 0 ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3608
num = int(input())

def factors(x):
  a = []
  for i in range(1, x + 1):
      if x % i == 0:
          a.append(i)
  return a

f = (factors(num))

if (len(f) != 2): 
  while (len(f) != 2): 
    num += 1
    f = factors(num)
  print (num)
else: 
  print (num)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>
#include<limits.h>

int min2(int, int);

int dp[1005][5005][2]={0};

int main()
{
	int i, j, W, N, v[1024], w[1024], c;

	c = 0;
	while(1){
		scanf("%d", &W);
		if(W == 0)
			break;

		memset(v, 0, sizeof(v));
		memset(w, 0, sizeof(w));
		memset(dp, 0, sizeof(dp));

		scanf("%d", &N);

		for(i=0; i<N; i++)
			scanf("%d,%d", &v[i], &w[i]);
		
		c++;
		printf("Case %d:\n", c);

		for(i=0; i<N; i++){
			for(j=0; j<=W; j++){
				if(j < w[i]){
					dp[i+1][j][0] = dp[i][j][0];
					dp[i+1][j][1] = dp[i][j][1];
				}else{
					if(dp[i][j][0] > dp[i][j-w[i]][0] + v[i]){
						dp[i+1][j][0] = dp[i][j][0];
						dp[i+1][j][1] = dp[i][j][1];
					}else if(dp[i][j][0] == dp[i][j-w[i]][0] + v[i]){
						dp[i+1][j][0] = dp[i][j][0];
						dp[i+1][j][1] = min2(dp[i][j][1], dp[i][j-w[i]][1] + w[i]);
					}else{
						dp[i+1][j][0] = dp[i][j-w[i]][0] + v[i];
						dp[i+1][j][1] = dp[i][j-w[i]][1] + w[i];
					}
				}
			}
		}
		printf("%d\n%d\n", dp[N][W][0], dp[N][W][1]);

	}

	return 0;
}

int min2(int a, int b){
	if(a > b)
		return b;
	return a;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int h=a[0];
  int ans=1;
  for(int i=1;i<n;i++){
    if(a[i]>=h){
      ans++;
      h=a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
class Dice{
public:
	vi n;
	int top;
	Dice(){
		n.resize(6);
		top = 0;
	}
	void roll(char c){
		int tmp = n[0];
		if( c == 'E' ){
			n[0] = n[3];
			n[3] = n[5];
			n[5] = n[2];
			n[2] = tmp;
		}else if( c == 'W' ){
			n[0] = n[2];
			n[2] = n[5];
			n[5] = n[3];
			n[3] = tmp;
		}else if( c == 'N' ){
			n[0] = n[1];
			n[1] = n[5];
			n[5] = n[4];
			n[4] = tmp;
		}else if( c == 'S' ){
			n[0] = n[4];
			n[4] = n[5];
			n[5] = n[1];
			n[1] = tmp;
		}
	}
	void input() {rep(i, 0, 6) cin >> n[i];}
	void output() {P(n[top]);}
};
int main() {
	Dice d1, d2;
	d1.input(); d2.input();
	rep(i, 0, 6) {
		if(d1.n[0] == d2.n[0]) {
			rep(j, 0, 4) {
				bool flg = true;
				rep(k, 0, 5) {
					if(d1.n[k] != d2.n[k]) {
						flg = false;
						break;
					}
				}
				if(flg) { P("Yes"); return 0;}
				d2.roll('S');
				d2.roll('E');
				d2.roll('N');
			}
		}
		d2.roll(i % 2 ? 'E' : 'S');
	}
	P("No");
	return 0;
}

Measured memory_bytes: 3220
#include<stdio.h>
#include<stdlib.h>
 
#define N 100000
#define INF 100000000
 
typedef struct{
  int g;
  int b;
  int c;
}data;
 
int n,A[N];
data D[500000];
 
void singlesource(int num)
{
  int i,ch=1;
 
  for(i=0; i<n; i++)A[i]=INF;
  A[0]=0;
 
  while(ch!=0){
    ch=0;
    for(i=0; i<num; i++){
      if(D[i].c+A[D[i].b]<A[D[i].g]){
    A[D[i].g]=D[i].c+A[D[i].b];
    ch=1;
      }
    }
  }
}
 
int main()
{
  int i,j,k,p,con=0;
 
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d%d",&p,&k);
    for(j=0; j<k; j++){
      D[con].b=p;
      scanf("%d%d",&D[con].g,&D[con].c);
      con++;
    }
  }
  singlesource(con);
  for(i=0; i<n; i++)printf("%d %d\n",i,A[i]);
  return 0;
}



Measured memory_bytes: 7608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	ll cnt = 1;
	ll val = 7;
	ll base = 7;
	map<int, int> m;
	bool ok = true;
	while (true) {
		ll rem = val % K;
		if (rem == 0) break;
		if (m[rem]) {
			ok = false;
			break;
		}
		m[rem] = 1;
		base = (base * 10) % K;
		val = val + base;
		cnt++;
	}

	if (ok){
	cout << cnt << "\n";
	} else {
	cout << -1 << "\n";
	}

	return 0;
}


Measured memory_bytes: 50472
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    int vec[n];
    rep(i,n) {
        cin >> vec[i];
    }
    int dp[n];
    dp[0] = 0;
    int ans = 0;
    for(int i=1;i<n;i++){
        if (vec[i-1]>=vec[i]){
            dp[i] = dp[i-1]+1;
        }
        else{
            dp[i] = 0;
        }
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;
}

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

int main(){
	int n;
	cin >> n;
	
	int m = n % 10;
	
	if (m == 3) {
		cout << "bon" << endl;
	} else if (m == 0 || m == 1 || m == 6|| m == 8) {
		cout << "pon" << endl;
	} else {
		cout << "hon" << endl;
	}
}


Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
int main(){
  int i;
  char s[7001];
  scanf("%s",s);
  int n=0,m=2,l=0,k;
  for(i=0;s[i];){
    if(s[i]=='e'){
      if(m==1){
	++n;
      }else{
	if(n>l){
	  l=n;
	  k=m;
	}
	n=1;
      }
      m=0;
      i+=3;
    }else{
      if(m==0){
	++n;
      }else{
	if(n>l){
	  l=n;
	  k=m;
	}
	n=1;
      }
      m=1;
      i+=7;
    }
  }
  if(n>l){
    l=n;
    k=m;
  }
  puts(k?"chicken":"egg");
  return 0;
}

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

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

int N;
P X[200005];
int idx[200005];

int main() {

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

cin>>N; 

for(int i=0; i<N; i++){
  cin>>X[i].first;
  X[i].second=i;
}

sort(X,X+N);

for(int i=0; i<N; i++){
  idx[X[i].second]=i;
}

for(int i=0; i<N; i++){
  if(idx[i]<N/2){
    cout<<X[N/2].first<<endl;
  }else{
    cout<<X[N/2-1].first<<endl;
  }

}

}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  vector<int> va(n);
  map<int, int> cnts;
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
    cnts[va[i]]++;
  }

  vector<int> vc;
  for (auto &p : cnts) {
    vc.push_back(p.second);
  }

  sort(vc.begin(), vc.end());
  int kk = max(0, static_cast<int>(vc.size()) - k);
  int ans = 0;
  for (int i = 0; i < kk; i++) {
    ans += vc[i];
  }

  cout << ans << '\n';
}


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

int main() {
	string S, str;
	int N, Q, ans = 0;
	cin >> N >> Q >> S;
	vector<int> l(Q), r(Q), ac(N+1,0); //累積和
	for (int i = 0; i < Q; i++) {
		cin >> l[i] >> r[i];
	}

	for (int i = 0; i < N ; i++) {
		ac[i + 1] = ac[i];
		if (S[i] == 'A' && S[i + 1] == 'C') {
			ac[i + 1]++;
		}
	}



	for (int i = 0; i < Q; i++) {
		ans = ac[r[i] - 1] - ac[l[i] - 1];
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 2176
date = input()

top = int(date[0:2])
bottom = int(date[2:4])

is_top_mm = False
is_top_yy = False
is_bottom_mm = False
is_bottom_yy = False

def print_result():
    global is_top_mm
    global is_top_yy
    global is_bottom_mm
    global is_bottom_yy

    # check NA case
    if not is_top_mm and not is_top_yy:
        print('NA')
        return
    if not is_bottom_mm and not is_bottom_yy:
        print('NA')
        return


    # check YYMM case
    if is_top_yy:
        if is_bottom_mm:
            print('YYMM')
            return
        if is_bottom_yy:
            print('NA')
            return

    # check MMYY case
    if is_bottom_yy:
        if is_top_mm:
            print('MMYY')
            return
        if is_top_yy:
            print('NA')
            return

    print('AMBIGUOUS')


if 1 <= top <= 12:
    is_top_mm = True

if 13 <= top <= 99 or top == 0:
    is_top_yy = True

if 1 <= bottom <= 12:
    is_bottom_mm = True

if 13 <= bottom <= 99 or bottom == 0:
    is_bottom_yy = True

print_result()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int mi=1000000000;
    for(int i=0;i<=2*(x+y);i+=2){
        int p=max(x-i/2,0);
        int q=max(y-i/2,0);
        mi=min(mi,p*a+q*b+i*c);
    }
    cout<<mi<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;
 
bool isPrime(ll n)  
{    
    if (n <= 1)  return false;  
    if (n <= 3)  return true;  
     
    if (n%2 == 0 || n%3 == 0) return false;  
    
    for (ll i=5; i*i<=n; i=i+6)  
        if (n%i == 0 || n%(i+2) == 0)  
           return false;  
    
    return true;  
}  
 
ll display(ll N) 
{ 
    if (N <= 1) 
        return 2; 
  
    ll prime = N; 
    bool found = false; 
 
    while (!found) { 
        if (isPrime(prime)) found = true;
        prime++; 
    } 
  
    return prime-1; 
} 
 
int main(){
    ll n; cin>>n;
    cout<<display(n);
    return 0;
}

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	long a = n / k, b = n / (k / 2);
	b -= a;
	cout << a * a*a + (k % 2 ? 0 : b * b*b) << endl;
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
pyi=[[] for i in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    pyi[p-1].append([y,i])
ans=[]
for i in range(n):
    pyi[i].sort()
    for j in range(len(pyi[i])):
        ans.append([(6-len(str(i+1)))*"0"+str(i+1)+(6-len(str(j+1)))*"0"+str(j+1),pyi[i][j][1]])
ans.sort(key=lambda x:x[1])
for i in range(m):
    print(ans[i][0])

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

#define MAX_BIT_SIZE 100001

int BIT[MAX_BIT_SIZE];
int n;
int save[MAX_BIT_SIZE];

int sum(int index) {
    int ret = 0;
    index += 1;

    while (index > 0) {
        ret += BIT[index];
        index -= (index & (-index));
    }

    return ret;
}

void add(int index, int value) {
    int i = 1;
    index += 1;

    while (index <= n) {
        BIT[index] += value;
        index += (index & (-index));
    }
}

int main() {
    while (1) {
        int k;
        int i;
        int max_count = 0;

        scanf("%d %d", &n, &k);
        if (n == 0 && k == 0) return 0;

        memset(BIT, 0, MAX_BIT_SIZE);

        for (i=0;i<n;i++) {
            int d;
            scanf("%d", &d);
            save[i] = d;
            add(i, d);
        }

        for (i=0;i<n-k;i++) {
            int now_count = sum(i+k) - sum(i);
            if (now_count > max_count){
                max_count = now_count;
            }
        }

        printf("%d\n", max_count);
    }
}

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

int main() {

    int a, b;
    cin >> a >> b;

//    cout << b << endl;

    int cnt = 0;
    int num = 1;
    while ( 1 ) {
        if ( num >= b ) {
            break;
        }
        else {
            num += a - 1;
            cnt++;
        }
//        cout << "test" << endl;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,a,b,c,d,i=0;
while(scanf("%d\n",&n)!=EOF){
for(a=0;a<=9;a++){
for(b=0;b<=9;b++){
for(c=0;c<=9;c++){
for(d=0;d<=9;d++){
if(a+b+c+d==n){
i++;
}
}
}
}
}
printf("%d\n",i);
i=0;
}
return 0;
}



Measured memory_bytes: 2064
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int pr[1000000];

void eratos(){
	pr[2]=0;
	pr[1]=1;
	for(int i = 2;i < 1000000;i++){
		if(pr[i] == 0){
            int now = 2;
			for(;;){
				if(now*i>=1000000) break;
				pr[now*i] = 1;
				now++;
			}
		}
	}
	return;
}

int main(){
	eratos();
  int x;
  cin>>x;
	for(int i=x;i<123456;i++){
		if(pr[i]==0) {cout<<i<<endl;return 0;}
	}
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 200005
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
#define ld long double
typedef long long int ll;
using  namespace std;
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	ll n,ans=0,i;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=1;i<n;i++){
		if(a[i]<a[i-1]){
			ans+=llabs(a[i]-a[i-1]);
			a[i]=a[i-1];
		}
	}
	cout<<ans;
}


Measured memory_bytes: 5212
#include<iostream>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	long long res;
	if(x%y!=0)
	{
		for(int i=2;;i++)
		{
			if(x*i%y!=0)
			{
				cout<<x*i<<endl;
				break;
			}
		}
	}
	else 
	cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if (A == B && B == C && A > 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int a,b;
	cin>>a>>b;
	if(a!=b){
		char ch=min(a,b)+'0';
		cout<<string(max(a,b),ch)<<endl;
		return 0;
	}
	char ch=a+'0';
	cout<<string(a,ch)<<endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

ll H;

int main()
{
    cin >> H;
    ll ans = 0;
    ll cnt = 1;
    while (H > 0)
    {
        ans += cnt;
        cnt *= 2;
        H /= 2;
    }
    cout << ans << endl;
}


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

int main(){
  while (true){
    int H, W;
    cin >> H >> W;
    if (H==0 && W==0) break;
    for (int i=1; i<=H; i++){
      for (int j=1; j<=W; j++){
	if (i==1 || i==H || j==1 || j==W) cout << '#';
	else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

/* a以下でxで割り切れる数の個数 */
long int fnum(long int a,long int x){
    long int fnumber;
    fnumber = a / x;
    return fnumber;
}

int main() {
    long int a,b,x;
    cin >> a >> b >> x;
    long int ans = 0;
    long int ansmax = 0;
    long int ansmin = 0;
    ansmin = fnum(a, x);
    ansmax= fnum(b, x);
    if (a % x == 0) {
        ans = ansmax - ansmin + 1;
    } else {
        ans = ansmax - ansmin;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
P = list(map(int,input().split()))

if 0 in P:
    print(0)
    exit()

ans=1
P.sort(reverse=True)

for i in range(N):
    ans*=P[i]
    if ans>10**18:
        print(-1)
        exit()

print(ans)

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 0)
		cout << "Positive";
	else if (b < 0) {
		if ((a - b) % 2)
			cout << "Positive";
		else
			cout << "Negative";
	}
	else
		cout << "Zero";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();

		for(int i = 0; i < 10; i++){
			x = r*x - d;
			
			System.out.println(x);
		}
	}

}


Measured memory_bytes: 21716
from math import sqrt, factorial
n = int(input())
x, y = [0] *  n, [0] * n

for i in range(n):
    x[i], y[i] = map(int, input().split())

total = 0
for i in range(n):
    for j in range(n):
        total += sqrt((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2)

print(total / n)

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int dp[100005];
void solve() {
  int n, m;
  cin >> n >> m;
  vi a(m);
  vi b(m);
  rep(i, m) {
    int nb;
    cin >> a[i] >> nb;
    rep(j, nb) {
      int ib;
      cin >> ib;
      ib--;
      b[i] |= (1 << ib);
    }
  }
  dump(n, m);
  dump(b);

  int mask = (1 << n) - 1;
  int open = 0;
  rep(i, m) {
    open |= b[i];
  }
  if (open != mask) {
    cout << -1 << endl;
    return;
  }

  vector<int> dp(mask + 1, INF);
  dp[0] = 0;
  rep(i, mask + 1) rep(j, m) {
    int next = i | b[j];
    mins(dp[next], dp[i] + a[j]);
  }
  cout << dp[mask] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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



ll cost(ll arr[],ll n,ll k)
{
    ll val[n+1];
    
    val[0]=0;
    for(ll i=1;i<=n;i++)
    {
        if(i==1)
        val[i]=abs(arr[i]-arr[i-1])+val[i-1];
        else{
            ll value=abs(arr[i]-arr[i-1])+val[i-1];
            for(ll j=i-1;j>=max((ll)0,i-k);j--)
            {
                value=min(abs(arr[i]-arr[j])+val[j],value);
            }
            val[i]=value;
        }
     }
    
    cout<<val[n-1]<<endl;
    
}

int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n+1];
    for(ll i=0;i<n;i++)
    cin>>h[i];
    cost(h,n,k);

    return 0;
}


Measured memory_bytes: 1792
/*
https://abc105.contest.atcoder.jp/
018.8.11
*/

#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
using namespace std;

int main()
{
 	ios::sync_with_stdio(false);
	int N,K;
	int i,j,k;
	while(cin>>N>>K)
	{
		i=N%K;
		if(i==0)
			cout<<"0"<<endl;
		else
			cout<<"1"<<endl;
	}
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = br.readLine();
    line = line.replace("2017/01", "2018/01");
    System.out.println(line);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> buc(100001);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    buc[a] += b;
  }
  vector<ll> sum(100001);
  rep(i,100001){
    if(i == 0) sum[i] = buc[i];
    else sum[i] = sum[i-1] + buc[i];
  }
  auto Iter =  lower_bound(sum.begin(),sum.end(),k);
  cout << Iter - sum.begin() << endl;
}

Measured memory_bytes: 1792
import heapq

N, M = map(int, input().split(" "))
work_que = []
can_work = []
ans = 0
for i in range(N):
    a, b = map(int, input().split(" "))
    heapq.heappush(work_que, (a, -b))

for i in range(M, -1, -1):
    while len(work_que) > 0 and work_que[0][0] + i <= M:
        top_work = heapq.heappop(work_que)
        heapq.heappush(can_work, top_work[1])
    
    if len(can_work) > 0:
        ans += -heapq.heappop(can_work)
print(ans)

Measured memory_bytes: 17092
n = int(input())
L = sorted(map(int,input().split()))
ans = 0

if n < 3:
    print(ans)
    exit()

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if L[i] != L[j] != L[k]:
                if L[i] + L[j] > L[k]:
                    ans += 1
                    
print(ans)

Measured memory_bytes: 9112
N, M = map(int, input().split())
a = [True for _ in range(N)]
MOD = 10**9+7
for i in range(M):
    a[int(input())] = False
dp = [0 for _ in range(N+1)]
dp[0] = 1
if a[0] == True:
    dp[1] = 1
for i in range(2, N+1):
    if a[i-2] == True:
        dp[i] += dp[i-2]
    if a[i-1] == True:
        dp[i] += dp[i-1]
    dp[i] %= MOD
print(dp[N])

Measured memory_bytes: 7896
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i : irange(0, N)) {
        cin >> p[i];
    }

    int minv = numeric_limits<int>::max();
    int count = 0;
    for (int pi : p) {
        if (pi <= minv) {
            count++;
        }
        minv = min(minv, pi);
    }
    cout << count << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string S,T;
	int num=0;
	cin>>S;
	cin>>T;
	if(S[0]==T[0])
	num++;
	if(S[1]==T[1])
	num++;
	if(S[2]==T[2])
	num++;
	cout<<num<<endl;
	return 0;
	
}

Measured memory_bytes: 256
from sys import stdin

def main():
    N,T=map(int,stdin.readline().strip().split())
    t=list(map(int,stdin.readline().strip().split()))

    x=0
    for i in range(N-1):
        x+=min(T,t[i+1]-t[i])
    print(x+T)

if __name__=='__main__':
    main()


Measured memory_bytes: 30968
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L = sc.nextInt();
    ArrayList<String> list = new ArrayList<String>();
    for (int i = 0; i < N; i++) {
      list.add(sc.next());
    }
    Collections.sort(list);
    StringBuilder A = new StringBuilder();
    for (int i = 0; i < N; i++) {
      A.append(list.get(i));
    }
    System.out.println(A);
  }
}


Measured memory_bytes: 22612
#include<stdio.h>

int main(void){
  int n;
  int i;
  int ct = 0;
  int num[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &num[i]);
  }
  for (i = 1; i < n-1; i++) {
    if ( num[i] > num[i-1] && num[i] < num[i+1] ) {
      ct++;
    }
    if ( num[i] < num[i-1] && num[i] > num[i+1] ) {
      ct++;
    }
  }
  printf("%d", ct);
  return 0;
}

Measured memory_bytes: 128
class SegmentTree:
    def __init__(self, array, seg_func, ide_ele):
        n = len(array)
        self.size = 2**(n - 1).bit_length()
        self.seg_func = seg_func
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele] * (2 * self.size - 1)

        for i in range(n):
            self.seg[i + self.size - 1] = array[i]
        for i in range(self.size - 2, -1, -1):
            self.seg[i] = self.seg_func(self.seg[2 * i + 1], self.seg[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.seg[index] = value
        while index:
            index = (index - 1) // 2
            self.seg[index] = self.seg_func(self.seg[index * 2 + 1], self.seg[index * 2 + 2])

    def query(self, lower_ep, upper_ep):
        if upper_ep <= lower_ep:
            return self.ide_ele
        lower_ep += self.size - 1
        upper_ep += self.size - 2
        res = self.ide_ele
        while (upper_ep - lower_ep) > 1:
            if lower_ep & 1 == 0:
                res = self.seg_func(res, self.seg[lower_ep])
            if upper_ep & 1 == 1:
                res = self.seg_func(res, self.seg[upper_ep])
                upper_ep -= 1

            lower_ep //= 2
            upper_ep = (upper_ep - 1) // 2
        if lower_ep == upper_ep:
            res = self.seg_func(res, self.seg[lower_ep])
        else:
            res = self.seg_func(self.seg_func(res, self.seg[lower_ep]), self.seg[upper_ep])
        return res

N = int(input())
Alist = [int(input()) for _ in range(N)]
S = SegmentTree(Alist, max, 0)
for i in range(N):
    print(max(S.query(0, i), S.query(i + 1, N)))


Measured memory_bytes: 88792
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    char a,b;
    cin >> a >> b;

    if(a == 'H'){
        cout << b << endl;
    }else{
        if(b == 'H'){
            cout << 'D' << endl;
        }else{
            cout << 'H' << endl;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
vector<LL>A;


int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	long double mid = (double)A.back() / 2;
	long double small = LLONG_MAX;
	long double val = -1;
	for (int i = 0; i < N; ++i) {
		//small = min(small, abs(A[i] - mid));
		if (small > abs(A[i] - mid)) {
			small = abs(A[i] - mid);
			val = A[i];
		}
	}
	cout << A.back() << " " << (LL)val << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#include<iostream>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define VI vector<int>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=2e6;
const int MAXV=13;
int bin[15];
int n,m,ans[MAXN];
struct Trie
{
	int son[MAXN][3],tot,root;
	int val[MAXN];
	bool rev[MAXN];
	void insert(int v)
	{
		int p=root;
		for(int i=0;i<=n-1;i++)
		{
			int c=v/bin[i];c%=3;
			if(!son[p][c])son[p][c]=++tot;
			p=son[p][c];
		}val[p]=v;
	}
	void down(int p)
	{
		if(!rev[p])return ;
		swap(son[p][1],son[p][2]);
		rev[son[p][0]]^=1;rev[son[p][1]]^=1;rev[son[p][2]]^=1;rev[p]=0;
	}
	void addone(int p,int dep)
	{
		if(dep==0)return ;
		down(p);int a=son[p][0],b=son[p][1],c=son[p][2];
		son[p][0]=c;son[p][1]=a;son[p][2]=b;
		addone(son[p][0],dep-1);
	}
	void getans(int p,int dep,int nowp)
	{
		if(dep==n){ans[val[p]]=nowp;return ;}
		down(p);
		getans(son[p][0],dep+1,nowp);
		getans(son[p][1],dep+1,nowp+bin[dep]);
		getans(son[p][2],dep+1,nowp+2*bin[dep]);
	}
}tr;
char ch[MAXN];
int main()
{
	#ifdef Rose
		double BeginJudgeTime=clock();
	#endif
	bin[0]=1;for(int i=1;i<15;i++)bin[i]=bin[i-1]*3;
	n=read();
	scanf("%s",ch+1);m=strlen(ch+1);
	tr.tot=tr.root=1;
	for(int i=0;i<bin[n];i++)
		tr.insert(i);
	for(int i=1;i<=m;i++)
	{
		if(ch[i]=='S')tr.rev[1]^=1;
		else tr.addone(1,n);
	}
	tr.getans(1,0,0);
	for(int i=0;i<bin[n];i++)pr1(ans[i]);
	puts("");
	#ifdef Rose
		double EndJudgeTime=clock();
		cerr<<"JudgeTime is"<<" ";
		cerr<<(EndJudgeTime-BeginJudgeTime)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}


Measured memory_bytes: 15396
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        List<Integer> sticks = new ArrayList<Integer>();
        for(int i = 0; i< N; i++){
            sticks.add(scan.nextInt());
        }

        scan.close();
        int count = sticks.size();
        int ans = 0;


        for (int i = 0; i < count; i++){
            for (int j = 0; j < i; j++){
                for (int k = 0; k < j; k++){
                    
                    // 異なる数字であるか
                    if(sticks.get(i).equals(sticks.get(j)) || sticks.get(j).equals(sticks.get(k)) || sticks.get(k).equals(sticks.get(i))){
                        continue;
                    }

                    // 三角形の成立条件を満たすか
                    // Collections.sort();
                    if(sticks.get(i) + sticks.get(j) > sticks.get(k) && sticks.get(j) + sticks.get(k) > sticks.get(i) && sticks.get(k) + sticks.get(i) > sticks.get(j)){
                        ans++;
                    }

                }
            }
        }

        System.out.println(ans);


    }

}

Measured memory_bytes: 37640
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
using namespace std;
int n,y;
int main(){
  cin>>n>>y;
  if(y/10000>n){cout<<"-1 -1 -1"<<endl;return 0;}
  for(int i=0;i<=y/10000;i++){
    int b=y;
    b-=i*10000;
    for(int j=0;j<=b/5000;j++){
      int c=b;
      c-=j*5000;
      if(i+j+c/1000==n){cout<<i<<" "<<j<<" "<<c/1000<<endl;return 0;}
    }
  }
  cout<<"-1 -1 -1"<<endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 110000

ll n,m;
ll dp1[MAXN], dp2[MAXN], ans[MAXN];
vector<vector<int>> edges(MAXN);

void dfs1(int x=0, int p = -1){
  dp1[x]=1;
  for(auto c:edges[x]){
    if(c==p)continue;
    dfs1(c, x);
    dp1[x] = dp1[x] * dp1[c] % m;
  }
  dp1[x] = (dp1[x]+1) % m;
}

void dfs2(int x=0, int p = -1){
  if(p==-1)dp2[x]=1;
  int ec = edges[x].size();

  vector<ll> lprod(ec, 1);
  rep(i, ec){
    if(i)lprod[i] = lprod[i-1];
    int c = edges[x][i];
    if(c==p)continue;
    lprod[i] = lprod[i] * dp1[c] % m;
  }

  vector<ll>rprod(ec, 1);
  rrep(i, ec){
    if(i<ec-1)rprod[i] = rprod[i+1];
    int c = edges[x][i];
    if(c==p)continue;
    rprod[i] = rprod[i] * dp1[c] % m;
  }

  rep(i, ec){
    int c = edges[x][i];
    if(c==p)continue;
    dp2[c] = dp2[x];
    if(i)dp2[c] = dp2[c] * lprod[i-1] % m;
    if(i<ec-1)dp2[c] = dp2[c]*rprod[i+1] % m;
//cout<<c<<' '<<dp2[c]<<endl;
    dp2[c] = (dp2[c]+1)%m;
    dfs2(c, x);
  }
}

void dfs3(int x=0, int p = -1){
  ans[x] = dp2[x];
  for(auto c: edges[x]){
    if(c==p)continue;
    ans[x] = ans[x] * dp1[c] % m;
    dfs3(c, x);
  }
}

int main(){
  cin>>n>>m;
  rep(i, n-1){
    int x,y;cin>>x>>y;x--,y--;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  dfs1();
  dfs2();
  dfs3();

  rep(i, n)cout<<ans[i]<<endl;

  return 0;

rep(i, n)cout<<dp1[i]<<' ';cout<<endl;
rep(i, n)cout<<dp2[i]<<' ';cout<<endl;

  return 0;
}

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

int main(){
  int x, max, min, tgt;
  cin >> x;
  long long sum = 0;
  for (int i = 0; i < x; i++) {
    cin >> tgt;
    if (i == 0) {
      max = tgt;
      min = tgt;
    }
    sum += tgt;
    if (tgt > max) {
      max = tgt;
    }
    if (tgt < min) {
      min = tgt;
    }
  }
  printf("%d %d %ld\n", min, max, sum);
}

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

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


int main(){
	const ll MOD = 998244353;
	int N, S;
	cin >> N >> S;
	vector<int> A(N);
	for(int i=0; i<N; i++){
		cin >> A.at(i);
	}

	const int MAX = 3005;
	vector<vector<ll>> dp(MAX, vector<ll>(MAX, 0));
	//dp[i][j]: Aのi番目までを考慮した時に 和がjにできる個数
	//for(int i=0; i<N; i++) dp[0][i] = 0;
	//ll ans = 0;
	dp[0][0] = 1;
	for(int i=0; i<N; i++){
		for(int j=0; j<=S+1; j++){
			dp.at(i+1).at(j) = (dp.at(i+1).at(j) % MOD  +  2*(dp.at(i).at(j) % MOD)) % MOD; //dp[i+1][j] += 2*dp[i][j];//A[i]番目を使わない場合//なぜ2倍なのかよくわからんがとりあえず
			if(j+A[i] <= S) dp.at(i+1).at(j+A.at(i)) = dp.at(i+1).at(j+A.at(i))%MOD  +  dp.at(i).at(j)%MOD;//A[i]を使う場合//dp[i+1][j+A[i]] = dp[i][j] + A[i];
		}
	}
	//print_vec2(dp);
	// for(int i=0; i<N; i++){
	// 	for(int j=0; j<N; j++){
	// 		for(int k=0; k<=S; k++){
	// 			if(k+A.at(j+1) <= S) dp.at(j+1).at(k+A.at(j+1)) = dp.at(j).at(k) + A.at(j+1);
	// 		}

	// 	}

	// 	cout << "i=" << i << " :---------------------------------" << endl;
	// 	print_vec2(dp);

	// 	ans = (ans%MOD + dp[N][S]%MOD) % MOD;//ans += dp[N][S]
	// 	int a_back = A[A.size()-1];
	// 	A.pop_back();//A.erase(A.begin()+A.size()-1);
	// 	A.insert(A.begin()+0, a_back);//一番後ろの要素を一番前へ
	// }

	cout << dp[N][S] << endl;
	
}

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

int main()
{
  int N,M;scanf("%d %d",&N,&M);
  int count[N+1]={};
  for(int a,b,i=0;i<M;i++)
  {
    scanf("%d %d",&a,&b);
    count[a]++;count[b]++;
  }
  for(int i=1;i<N+1;i++)printf("%d\n",count[i]);
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main(){
  string S;
  cin >> S;
  vector<int> R(13);
  for (int i=0;i<13;i++){
    R.at(i) = (10 * i) % 13;
  }
  vector<int> ML(13);
  for (int i=0;i<13;i++){
    ML.at(i) = 0;
  }
  ML.at(0) = 1;
  for (int i=0;i<S.size();i++){
    vector<int> NL(13);
    if (S.at(i) == '?'){
      for (int j=0;j<130;j++){
        NL.at(j%13) += ML.at(((j/10)*10)%13);
        NL.at(j%13) %= mod;
      }
    }
    else{
      string t = "";
      t = S.at(i);
      int d = stoi(t);
      for (int j=0;j<13;j++){
        NL.at((10*j+d)%13) += ML.at((j*10)%13);
        NL.at((10*j+d)%13) %= mod;
      }
    }
    if (i != S.size() - 1){
      for (int m=0;m<13;m++){
        ML.at((10*m)%13) = NL.at(m);
      }
    }
    else{
      for (int m=0;m<13;m++){
        ML.at(m) = NL.at(m);
      }
    }
  }
  cout << ML.at(5) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
const ll MOD=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    vector<ll> a(3);cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    ll k;cin>>k;
    while(k--)a[2]*=2;
    cout<<a[0]+a[1]+a[2];
}


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

int main(){
    
    int num;
    int a,b,c;
    cin >> a >> b >> c;
    for(int ii= a;ii<=b;ii++){
        if( c % ii == 0){
            num++;
        }
    }
    
    cout << num << endl;
    
    return 0;
    
}

Measured memory_bytes: 1164