akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

	vector<vector<int>> dp(n, vector<int>(h + 1, INF));
	// 初期条件の設定
	for (int i = 0; i < n; i++) dp[i][0] = 0;
	for (int j = a[0]; j < h + a[0]; j++) {
		int nj = min(j, h);
		dp[0][nj] = dp[0][j - a[0]] + b[0];
	}
	
	// DPメインループ
	for (int i = 1; i < n; i++) {
		for (int j = a[i]; j < h + a[i]; j++) {
			int nj = min(j, h);
			dp[i][j - a[i]] = min(dp[i][j - a[i]], dp[i - 1][j - a[i]]);
			dp[i][nj] = min(dp[i][nj], dp[i][j - a[i]] + b[i]);
			dp[i][nj] = min(dp[i][nj], dp[i - 1][nj]);
		}
	}
	cout << dp[n - 1][h] << endl;
}

Measured memory_bytes: 39424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException{

         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         int n = Integer.parseInt(br.readLine());

         String[] line = br.readLine().split(" ");
         
      	 int a[] = new int[line.length];
      	 
         for(int i=0;i<line.length;i++) {
        	 a[i] = Integer.parseInt(line[i]);
         }
         
         for(int i=n;i>1;i--) {
        	 System.out.print(a[i-1] + " ");
         }
         System.out.println(a[0]);
    }
}


Measured memory_bytes: 24420
using System;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            char s;
            s=char.Parse(Console.ReadLine());
            if (s=='A') Console.WriteLine('T');
            if (s == 'T') Console.WriteLine('A');
            if (s == 'G') Console.WriteLine('C');
            if (s == 'C') Console.WriteLine('G');

        }

    }
}


Measured memory_bytes: 25540
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <queue>
#define xx first
#define yy second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const int N=3e5+10;
const int M=1e6+10;
int a,b,nr,ng,nc,ar[N],ag[N],ac[N];
priority_queue<int,vector<int>,greater<int> > pq;

int main(){
	scanf("%d%d%d%d%d",&a,&b,&nr,&ng,&nc);
	for(int i=1;i<=nr;i++) scanf("%d",&ar[i]);
	for(int i=1;i<=ng;i++) scanf("%d",&ag[i]);
	for(int i=1;i<=nc;i++) scanf("%d",&ac[i]);
	LL sum=0;
	sort(ar+1,ar+nr+1,greater<int>());
	sort(ag+1,ag+ng+1,greater<int>());
	sort(ac+1,ac+nc+1,greater<int>());
	for(int i=1;i<=a;i++) sum+=ar[i],pq.push(ar[i]);
	for(int i=1;i<=b;i++) sum+=ag[i],pq.push(ag[i]);
	for(int i=1;i<=nc;i++){
		if(pq.top()>=ac[i]) break;
		sum-=pq.top();
		pq.pop();
		pq.push(ac[i]);
		sum+=ac[i];
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 2552
n, m = map(int, input().split())
MAX_PRIME = 10 ** 5
is_prime = [1] * MAX_PRIME
primes = []
is_prime[0] = 0
is_prime[1] = 0
for i in range(MAX_PRIME):
    if is_prime[i]:
        primes.append(i)
        for j in range(2, MAX_PRIME // i):
            is_prime[i*j] = 0
def fact(m):
    ret = {}
    for p in primes:
        if p * p > m:
            if m != 1:
                ret[m] = 1
            return ret
        while(m % p == 0):
            if p not in ret:
                ret[p] = 1
            else:
                ret[p] += 1
            m //= p
def c(n,i):
    child = 1
    parent = 1
    k = n - 1 + i
    for j in range(1,i+1):
        parent *= j
        child *= k - j + 1
    return child // parent
factors = fact(m)
ret = 1
for _, power in factors.items():
    ret *= c(n,power)
    ret %= 10 ** 9 + 7
print(ret)


Measured memory_bytes: 4196
L=int(input());S=bin(L);N=len(S)-2;print(N,N+N+S.count("1")-3)
for i in range(1,N):
 print(i,-~i,1<<~-i,i,-~i,0)
 if int(S[-i]):L^=1<<~-i;print(i,N,L)

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n;
string a,b,c;

int main(){
	cin >> n;
	cin >> a >> b >>c;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == b[i] && b[i] == c[i])
			continue;
		else if(a[i] == b[i] || a[i] == c[i] || b[i] == c[i])
			cnt++;
		else cnt += 2;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 123;
int n , a[maxn];
bool dp[maxn][10009];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<=n;i++) dp[i][0] = 1;
	for(int i=1;i<=n;i++)
	{
		for(int have=1;have<=10000;have++)
		{
			if(have - a[i-1] >= 0) dp[i][have] = dp[i-1][have] | dp[i-1][have - a[i-1]];
			else dp[i][have] = dp[i-1][have];
		}
	}
	
	for(int i=10000;i>0;i--)
	{
		if(dp[n][i] && i % 10 != 0)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << 0;
}

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

int n;

/* [man][day] */
char aki[50][30];
char visited[50][30];

void tansaku(int man,int day) {
	int i;
	if(visited[man][day])return;
	visited[man][day]=1;
	if(aki[man][day]) {
		for(i=0;i<n;i++) {
			if(aki[i][day])tansaku(i,day);
		}
	}
	if(day>0)tansaku(man,day-1);
}

int main(void) {
	while(scanf("%d",&n)==1 && n>=1) {
		int i,j;
		int left,right,mid;
		memset(aki,0,sizeof(aki));
		for(i=0;i<n;i++) {
			int f,day;
			scanf("%d",&f);
			for(j=0;j<f;j++) {
				scanf("%d",&day);
				aki[i][day-1]=1;
			}
		}
		left=0;right=29;
		while(left<=right) {
			int ok;
			mid=(left+right)/2;
			ok=0;
			for(i=0;i<n && !ok;i++) {
				memset(visited,0,sizeof(visited));
				tansaku(i,mid);
				ok=1;
				for(j=0;j<n;j++) {
					if(!visited[j][0]){ok=0;break;}
				}
			}
			if(ok)right=mid-1; else left=mid+1;
		}
		printf("%d\n",left>29?-1:right+2);
	}
	return 0;
}

Measured memory_bytes: 664
require 'set'

N = gets.to_i
s = []
N.times {
    s << gets.chomp
}

M = gets.to_i
t = []
M.times {
    t << gets.chomp
}

ans = 0
set = Set.new(s)
set.each { |si|
    ans = [ans,s.count(si)-t.count(si)].max
}
puts ans

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)


struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = node[i*2+1]+node[i*2+2];
    }

    void eval(int k,int l,int r) {
        if (lazy[k] != 0) {
            node[k] += lazy[k];
            if (r-l > 1) {
                lazy[2*k+1] += lazy[k]/2;
                lazy[2*k+2] += lazy[k]/2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a,int b,ll x,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += (r-l)*x;
            eval(k,l,r);
        } else {
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = node[2*k+1]+node[2*k+2];
        }
    }

    ll getsum(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getsum(a,b,k*2+1,l,(l+r)/2);
        ll vr = getsum(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    LazySegmentTree raq(vector<ll>(n,0));
    for (int i = 0;i < q;++i) {
        int c;
        cin >> c;
        if (c) {
            int t;
            cin >> t;
            cout << raq.getsum(t-1,t) << endl;
        } else {
            int s,t,x;
            cin >> s >> t >> x;
            raq.add(s-1,t,(ll)x);
        }
    }
    return 0;
}


Measured memory_bytes: 7612
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/

signed main(){
    int n,h;
    cin>>n>>h;
    P p[114514];
    for(int i=0;i<n;i++)cin>>p[i].first>>p[i].second;
    vector<P> q;
    for(int i=0;i<n;i++)q.push_back(P(p[i].first,i));
    sort(q.begin(),q.end(),greater<P>());
    int m=q[0].second;
    int cnt=0;
    vector<P> t;
    for(int i=0;i<n;i++)t.push_back(P(p[i].second,i));
    sort(t.begin(),t.end(),greater<P>());
    int sum=0;
    for(int i=0;i<n;i++){
        if(t[i].first>=q[0].first){
            sum+=t[i].first;
            cnt++;
            if(h-sum<=0){
                cout<<cnt<<endl;
                return 0;
            }
        }
        else break;
    }
    cout<<cnt+(h-sum+p[m].first-1)/p[m].first<<endl;
}


Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

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

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

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y, b, p; cin >> x >> y >> b >> p;

    int ans1 = x * b + y * p;
    if (b >= 5 && p >= 2) ans1 *= 0.8;

    int ans2 = 12001;
    if (b < 5 || p < 2) {
      ans2 = 0;
      if (b < 5) ans2 += x * 5;
      else ans2 += x * b;
      if (p < 2) ans2 += y * 2;
      else ans2 += y * p;
      ans2 *= 0.8;
    }

    if (ans1 < ans2) cout << ans1 << endl;
    else cout << ans2 << endl;
  }

  return 0;
}


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


int main(){
  int A, B, C;
  cin >> A >> B >> C;
  set<int> d;
  int Z = 0;
  while(true){
    Z += A;
    Z %= B;
    if(d.find(Z) != d.end()){
      cout << "NO" << endl;
      return 0;
    }
    d.insert(Z);
    if(Z==C){
      cout << "YES" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define rep(i, l, r) for(int i=l; i<=r; i++)
#define dow(i, l, r) for(int i=l; i>=r; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr(x, c) memset(x,c,sizeof(x))
#define lowbit(x) (x)&(-(x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;

inline int read() {
    int x=0,f=0; char ch=getchar();
    while (ch<'0' || '9'<ch) f|=ch=='-', ch=getchar();
    while ('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
    return f?-x:x;
}

#define maxn 200009

// int s[maxn];
// inline int sum(int x) {int sum=0; while (x) sum+=s[x], x-=lowbit(x); return sum;}
// inline void add(int x) {while (x<=n) s[x]+=1, x+=lowbit(x);}

// struct edge {int x, y, c; edge *n;} e[maxm], *fir[maxn], *pt=e;
// inline void addEdge(int x, int y, int c) {
//     pt->x = x; pt->y = y; pt->c = c; pt->n = fir[x]; fir[x] = pt++;
//     pt->x = y; pt->y = x; pt->c = c; pt->n = fir[y]; fir[y] = pt++;
// }
// #define travel(x) for(edge *p=fir[x]; p; p=p->n)

// #define Q 1000000007

// inline int pow(int x, int t) {
//     int g = 1;
//     while (t) {
//         if (t&1) g = 1LL*g*x%Q;
//         x = 1LL*x*x%Q;
//         t >>= 1;
//     }
//     return g;
// }

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

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

ll _n, q[30], ans; int m;

void dfs(int x, ll a) {
    if (x>m) {
        ll b = _n/a, x, y;
        if (gcd(a,b)==1) {
            ex_gcd(a,b,x,y);
            y*=-1; while (x<=0 || y<=0) y+=a, x+=b;
            ans=min(ans,b*y);
        }
    } else {
        dfs(x+1, a);
        dfs(x+1, a*q[x]);
    }
}

int main() {
    ll n; scanf("%lld", &n);
    if (n==1) {puts("1"); return 0;}
    ans=n*3; n*=2; _n=n;
    int x=2; while(1LL*x*x<=n) {
        if (n%x==0) {
            ll g=1;
            while (n%x==0) n/=x, g*=x;
            q[++m]=g;
        } x+=1;
    }
    if (n!=1) q[++m]=n;
    dfs(1,1);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3828
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;



int main(void){
	ll x,y,t=0;
	bool is_x=true,first=true,x_can=false,y_can=false;
	string s;
	vector<ll> X,Y;
	set<ll> S;
	queue<ll> Q;
	cin>>s;
	scanf("%lld%lld",&x,&y);
	rep(i,s.size()){
		if(s[i]=='F')t++;
		if(s[i]=='T'){
			if(first){
				x-=t;
				is_x=false;
				first=false;
			}else if(is_x){
				X.push_back(t);
				is_x=false;
			}else{
				Y.push_back(t);
				is_x=true;
			}
			t=0;
		}
	}
	if(first){
		x-=t;
		is_x=false;
		first=false;
	}else if(is_x){
		X.push_back(t);
		is_x=false;
	}else{
		Y.push_back(t);
		is_x=true;
	}

	S.erase(S.begin(), S.end());
	if(X.size()>0){
		S.insert(X[0]);
		S.insert(-X[0]);
		reg(i,1,X.size()-1){
			for(set<ll>::iterator itr = S.begin(); itr != S.end(); ++itr) {
				Q.push(*itr);
			}
		    S.erase(S.begin(), S.end());
		    while(!Q.empty()){
		    	S.insert(Q.front()+X[i]);
		    	S.insert(Q.front()-X[i]);
		    	Q.pop();
		    }
		}
		if(S.count(x)==1)x_can=true;
	}else{
		if(x==0)x_can=true;
	}

	S.erase(S.begin(), S.end());
	if(Y.size()>0){
		S.insert(Y[0]);
		S.insert(-Y[0]);
		reg(i,1,Y.size()-1){
			for(set<ll>::iterator itr = S.begin(); itr != S.end(); ++itr) {
				Q.push(*itr);
			}
		    S.erase(S.begin(), S.end());
		    while(!Q.empty()){
		    	S.insert(Q.front()+Y[i]);
		    	S.insert(Q.front()-Y[i]);
		    	Q.pop();
		    }
		}
		if(S.count(y)==1)y_can=true;
	}else{
		if(y==0)y_can=true;
	}
	
	if(x_can && y_can){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}



int main(){FIN
    ll n,m,k;cin>>n>>m>>k;
    ll x;
    vll a(n);
    vll b(m); vll sumb(m);

    REP(i,n) cin>>a[i];
    REP(i,m) {
        cin>>b[i];
        if (i==0) sumb[i]=b[i];
        else sumb[i] = sumb[i-1] + b[i]; 
    }
    ll suma=0;
    ll count=0;
    ll ans=0;
    REP(i,n+1){ //i=a's sum
        count=0;
        if (i>0) suma += a[i-1];
        count += i;
        if (k-suma<0) break;
        count += upper_bound(ALL(sumb), k-suma)-sumb.begin();
        ans = max(ans,count);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7920
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


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

  ll sum=0,a,b,c;
  a=x%100;
  for(ll i=5;i;i--){
    b=a;
    a=a%i;
    c=b/i;
    sum+=c*100;
  }

  if(sum>x){
    cout << 0 << endl;
    return 0;
  }

  cout << 1 << endl;

}


Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int main(){
  int n,m;
  long a;
  cin >> n;
  m=0;
  REP(i,n){
    cin >> a;
    while(a%2==0){
      m++;
      a/=2;
    }
  }
  cout << m;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <string>

//#define _USE_MATH_DEFINES
//#include<math.h>

using namespace std;



using namespace std;

int main()
{
	const double PI = 3.14159265358979323846;
	double R;
	cin >> R;

	cout << 2 * PI * R << endl;
	return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 998244353
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(ll i=0;i<n;i++)
#define revf(i,n) for(ll i=n-1;i>=0;i--)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define inp(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define outp(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "
#define outp1(a,n) for(ll i=1;i<n;i++)cout<<a[i]<<" "
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define pb push_back
#define mp make_pair
#define mem(x,n) memset(x,n,sizeof(x))
#define BINSC binary_search
#define BITOUT __builtin_popcount
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define cn cout<<"\n";
int main()
{
     ll n,x,m;
     cin>>n>>x>>m;
     ll a=x;
     ll out=a;
     set<ll>s;
     ll j=-1,k=-1;
     vll v;
     v.pb(a);
     forr(i,n-1)
     {
          a=(a*a)%m;
          ll size=s.size();
          s.insert(a);
          if(size==s.size())
          {
               j=i;k=a;break;
          }
          else
          {
               v.pb(a);
               out+=a;
          }
     }
     if(j==-1)
          cout<<out;
     else
     {
          j++;
          ll j1=-1;
          forr(i,v.size())
          {
               if(v[i]==k)
               {
                    j1=i;
                    break;
               }
          }
          ll sum=0;
          for(ll i=0;i<j1;i++)
               sum+=v[i];
          ll diff=(j-j1);
          ll q=(n-j1)/diff;
          ll w=(n-j1)%diff;
          //cout<<sum<<" "<<q-1;cn
          out=out+(out-sum)*(q-1);
          //cout<<out;cn
          for(ll i=j1;i<w+j1;i++)
               out+=v[i];
          cout<<out;
     }
}

Measured memory_bytes: 5884
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s[10001],q,t[500],c=0,i,j;

  cin>>n;
  for(i=0;i<n;i++)cin>>s[i];
  cin>>q;
  for(j=0;j<q;j++){ 
    i=0;
    cin>>t[j];
    s[n]=t[j];
    while(s[i]!=t[j]){
      i++;
    }
    if(i<n)c++;
  }  
  cout<<c<<endl;
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
 
int main(){
	string mojiretsu;
	stringstream ss;
	int year, month;

	cin >> mojiretsu;
	ss << mojiretsu;
	ss >> year;	ss.ignore();
	ss >> month;

 	if(year < 2019){
 		cout << "Heisei" << endl;
 	}else if(year == 2019){
 		if(month > 4){
 			cout << "TBD" << endl;
 		}else{
 			cout << "Heisei" << endl;
 		}
 	}else{
 		cout << "TBD" << endl;
 	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
typedef unsigned long long ull;
typedef  long long ll;

int tmpcheck(char tmps)
{
	int si;
	if (tmps == '0') {
		si = 0;
	}
	else {
		si = 1;
	}
	return si;
}

int main() {
	std::string  s;

	std::cin >> s;

	int nsize = (int)s.size();
	ll ncount = 0;
	std::vector< int > nvec;
	nvec.reserve(nsize);

	for(int i = 0 ; i < nsize ; i++)
	{ 
		if (nvec.size() == 0)
		{
			int si = tmpcheck(s[i]);
			nvec.push_back(si);
		}
		else {
			int si = tmpcheck(s[i]);
			if(si != nvec[nvec.size() - 1])
			{
				nvec.pop_back();
				ncount += 2;
			}
			else
			{
				nvec.push_back(si);
			}
		}
	}
	std::cout << ncount << std::endl;

	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
  int id;
  struct node *left;
  struct node *right;
  int parent;
  int n_child;
}Node;

void print_tree(Node *x,int order) {
  if (order == 0) {
    printf(" %d", x->id);    
  }
  if(x->left != NULL) print_tree(x->left,order);
  if (order == 1) {
    printf(" %d", x->id);    
  }
  if(x->right != NULL) print_tree(x->right,order);
  if (order == 2) {
    printf(" %d", x->id);    
  }
}

int main()
{
  int i,n,id,left,right;
  Node *T;
  scanf("%d",&n);
  T = (Node*)malloc(sizeof(Node) * n);
  for (i = 0; i < n; i++) {
    T[i].id = i;
    T[i].left = NULL;
    T[i].right = NULL;
    T[i].parent = 0;
    T[i].n_child = 0;
  }

  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &id, &left,&right);
    if(left != -1) {
      T[id].left = T+left;
      T[left].parent++;
      T[id].n_child++;;
    }
    if(right != -1) {
      T[id].right = T+right;
      T[right].parent++;
      T[id].n_child++;
    }
  }

  for (i = 0; i < n; i++) {
    if(T[i].parent == 0) id = i;
  }


  printf("Preorder\n");
  print_tree(T+id,0);
  printf("\nInorder\n");
  print_tree(T+id,1);
  printf("\nPostorder\n");
  print_tree(T+id,2);
  printf("\n");

  return 0;
}

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

int main(){
  int a,b,c; cin>>a>>b>>c;
  int ans;
  if(c > a+b+1){
    ans = a+b+1+b;
  }else{
    ans = b+c;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;

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

	if (!U.compare(S)) A--;
	else B--;
	printf("%d %d", A, B);


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (k > x / d) {
        k -= x / d;
        x -= d * (x / d);
        if (k % 2 == 1) {
            cout << min(abs(x + d), abs(x - d)) << endl;
        } else {
            cout << min(x, abs(x - d * 2)) << endl;
        }
    } else {
        cout << x - d * k << endl;
    }
}


Measured memory_bytes: 3620
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		TreeSet<Integer> setA = new TreeSet<Integer>();
		for (int i = 0; i < n; i++) {
			setA.add(sc.nextInt());
		}
		TreeSet<Integer> setB = new TreeSet<Integer>();
		for (int i = 0; i < m; i++) {
			setB.add(sc.nextInt());
		}
		sc.close();

		if (setA.size() != n || setB.size() != m) {
			System.out.println(0);
			return;
		}

		int[] cntA = new int[n * m + 1];
		cntA[0] = n;
		for (int i = 1; i < cntA.length; i++) {
			if (setA.contains(i)) {
				cntA[i] = cntA[i - 1] - 1;
			} else {
				cntA[i] = cntA[i - 1];
			}
		}
		int[] cntB = new int[n * m + 1];
		cntB[0] = m;
		for (int i = 1; i < cntB.length; i++) {
			if (setB.contains(i)) {
				cntB[i] = cntB[i - 1] - 1;
			} else {
				cntB[i] = cntB[i - 1];
			}
		}

		int mod = 1000000007;
		long ans = 1;
		for (int i = n * m; i > 0; i--) {
			if (setA.contains(i) && setB.contains(i)) {
			} else if (setA.contains(i)) {
				ans *= cntB[i];
				ans %= mod;
			} else if (setB.contains(i)) {
				ans *= cntA[i];
				ans %= mod;
			} else {
				int cnt = cntA[i] * cntB[i] - (n * m - i);
				ans *= Math.max(cnt, 0);
				ans %= mod;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 67856
size = [int(i) for i in input().split()]
matrix = [[0 for i in range(size[1])] for j in range(size[0])]
vector = [0 for i in range(size[1])]
for gyou in range(size[0]):
    x = [int(i) for i in input().split()]
    matrix[gyou] = x
for retsu in range(size[1]):
    x = int(input())
    vector[retsu] = x

for gyou in range(size[0]):
    print(sum(map(lambda val1, val2: val1 * val2, matrix[gyou], vector)))



Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " "
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3) << endl;
    return 0;
}

Measured memory_bytes: 4164
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int K;
	cin >> K;
	string S;
	cin >> S;

	if (S.length() <= K)
	{
		cout << S << endl;
	}
	else
	{
		cout << S.substr(0, K) << "..." <<endl;
	}
	return 0;
}


Measured memory_bytes: 3628
N,M= map(int,input().split())

xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))

ans = 0
tmp = []
for a,b,c in ((1,1,1),(1,1,-1),(1,-1,1),(-1,1,1),(1,-1,-1),(-1,1,-1),(-1,-1,1),(-1,-1,-1)):
    tmp = []
    for x,y,z in xyz:
        tmp.append(a*x + b*y + c*z)

    tmp = sorted(tmp,reverse = True)
    tmp2 = 0
    for i in range(M):
        tmp2 += tmp[i]
    if ans < tmp2:
        ans = tmp2
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = (1ll << 31) - 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
struct Data
{
	int num;
	Data() :num(INF) {};
	Data(int n) :num(n) {};
};
struct SegmentTree
{
	int n; vector<Data> data;
	SegmentTree(int N)
	{
		n = 1;
		while (n < N) n *= 2;
		data.resize(2 * n);
	}
private:
	Data sub(int left, int right, int node, int nleft, int nright)
	{
		if (nright <= left || right <= nleft) return Data();
		if (left <= nleft && nright <= right) return data[node];
		Data vl = sub(left, right, node * 2 + 1, nleft, (nleft + nright) / 2);
		Data vr = sub(left, right, node * 2 + 2, (nleft + nright) / 2, nright);
		return min(vl.num, vr.num);
	}

public:
	void update(int pos, Data value)
	{
		pos += n - 1;
		data[pos] = value;
		while (pos > 0)
		{
			pos = (pos - 1) / 2;
			data[pos] = min(data[pos * 2 + 1].num, data[pos * 2 + 2].num);
		}
	}
	Data min_query(int left, int right)
	{
		return sub(left, right, 0, 0, n);
	}
};

int main()
{
	int n, q; cin >> n >> q;
	SegmentTree st(n);
	REP(i, q)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 0) st.update(b, c);
		else cout << st.min_query(b, c+1).num << endl;
	}
	return 0;
}

Measured memory_bytes: 3836
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

    sc.Split(bufio.ScanWords)
    n, m := nextInt(), nextInt()

    total := 0

    for i := 0; i < m; i++ {
        total += nextInt()
    }

    if total > n {
        fmt.Println(-1)
    } else {
        fmt.Println(n - total)
    }

}



//==================================================
//
// Library
//
//==================================================

//===========================
//  round(12.54, 0) -> 13.0
//  round(12.54, -1) -> 12.5
//===========================

func round(num float64, digit uint) float64 {
    d := float64(digit)
    return float64(int(num * math.Pow(10, d) + 0.5)) / math.Pow(10, d)
}

func abs(n int) int {
    return int(math.Abs(float64(n)))
}

func max(a, b int) int {
    return int(math.Max(float64(a), float64(b)));
}

func min(a, b int) int {
    return int(math.Min(float64(a), float64(b)));
}

func gcd(x, y int) int {
    if y == 0 {
        return x
    }

    return gcd(y, x%y)
}

//===========================
//  var q Queue
//  q.Enqueue(n)
//  n := q.Dequeue()
//===========================
type Queue struct {
    data []int
}

func (q *Queue) Enqueue(n int) {
    q.data = append(q.data, n)
}

func (q *Queue) Dequeue() int {
    tmp := q.data[0]
    q.data = q.data[1:]
    return tmp
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

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

func swap(a, b int) (int, int) {
    return b, a
}

func mySort(list []int, start int, end int) {
    var l []int
    for i := start; i < end; i++ {
        l = append(l, list[i])
    }
    sort.Ints(l)

    j := 0
    for i := start; i < end; i++ {
        list[i] = l[j]
        j++
    }
}

func mySortRev(list []int, start int, end int) {
    var l []int
    for i := start; i < end; i++ {
        l = append(l, list[i])
    }

    sortIntsRev(l)

    j := 0
    for i := start; i < end; i++ {
        list[i] = l[j]
        j++
    }
}

func nextPermutation(array []int) bool {
    n := len(array)

    for i:= n - 2; i >= 0; i-- {
        if array[i] < array[i+1] {
            j := n;
            for {
                j--;
                if (array[i] < array[j]) {
                    break
                }
            }
            array[i], array[j] = swap(array[i], array[j])
            mySort(array, i + 1, n)
            return true
        }
        if i == 0 {
            mySortRev(array, 0, n)
        }
    }
    return false
}



Measured memory_bytes: 1792
using System;
using System.Linq;
namespace atcoder110B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int N = input[0];
            int M = input[1];
            int X = input[2];
            int Y = input[3];

            var inputx = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToList();
            var inputy = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToList();
            inputx.Add(X); 
            int mx = inputx.Max();  //x1,x2…xNとXの中の最大値
            inputy.Add(Y);
            int my = inputy.Min();　//y1,y2…yMとYの中の最小値

            Console.WriteLine(mx < my ? "No War" : "War");
        }
    }
}

Measured memory_bytes: 13396
N, Q = map(int, input().split())
S = input()
asum = [0] * (N + 1)
for i in range(1, N):
    asum[i + 1] = asum[i] + (S[i - 1] == 'A' and S[i] == 'C')

for q in range(Q):
    l, r = map(int, input().split())
    if S[l - 1] != 'C':
        l -= 1
    print(asum[r] - asum[l])


Measured memory_bytes: 7748
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/



string T,S;

void input() {
	cin>>T;
	S=T+"R";
}

void solve() {
	ll N=S.size();
	vector<ll> a(N,0);

	ll kisucount=0,gusucount=0;
	ll rindex=-1,lindex=-1;
	rep(i,N){
		/*
		if(i==N-1){
			if(i%2==1)kisucount++;
			else gusucount++;
			if(lindex==-1)lindex=N-1;
		}
		 */
		//if(S[i]=='R' || i==N-1){
		if(S[i]=='R'){
			if(lindex==-1){
				rindex=i;
			}else{
				if(rindex%2==1){
					a[rindex]=kisucount;
					a[lindex]=gusucount;
				}else{
					a[lindex]=kisucount;
					a[rindex]=gusucount;
				}
				rindex=i;
				lindex=-1;
				gusucount=0;
				kisucount=0;
			}
		}else{
			if(lindex==-1)lindex=i;
		}
		if(i%2==1)kisucount++;
		else gusucount++;

		debug(rindex);
		debug(lindex);
	}


	rep(i,N-1){
		cout<<a[i]<<' ';
	}
	cout<<endl;
}

signed main() {
	input();
	solve();
	return 0;
}


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

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N); for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N - K; ++i) {
        int j = i + K;
        if (A[i] < A[j]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));


signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,x,t; cin >> n >> x >> t;
    int y=(n+x-1)/x;
    cout << y*t << endl;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int q = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < q; i++){
			String input = br.readLine();
			System.out.println(solve(input));
		}
	}
	
	static int solve(String str){
		int times = 0;
		while(true){
			int len = str.length();
			
			//1???????????????????????????
			if(len == 1){
				return times;
			}
			
			int max = 0;
			for(int i = 1; i < len; i++){
				int a = Integer.parseInt(str.substring(0, i));
				int b = Integer.parseInt(str.substring(i, len));
				
				if(max < a*b){
					max = a*b;
				}
			}
			
			str = Integer.toString(max);
			times++;
		}
	}

}

Measured memory_bytes: 28004
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	int w, h;
	while ( cin >> h >> w, h || w ) {
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				if ((x + y) % 2) {
					cout << '.';
				}
				else {
					cout << '#';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

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

vector<bool> c;
vector<vector<pair<ll,ll>>> g;

void dfs(ll node,ll par,ll cost){
    c[node]=cost%2==0;
    for(pair<ll,ll> p:g[node]){
        if(p.first==par)continue;
        dfs(p.first,node,cost+p.second);
    }
}

int main(){
    ll n;
    cin>>n;
    g.assign(n,vector<pair<ll,ll>>());
    c.assign(n,false);
    rep(i,n-1){
        ll u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        g[u].push_back(make_pair(v,w));
        g[v].push_back(make_pair(u,w));
    }
    dfs(0,-1,0);
    rep(i,n){
        if(c[i]){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
    }
}


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

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

    string ans = S.substr(0, S.size() - 2);
    while (ans.substr(0, ans.size() / 2) != ans.substr(ans.size() / 2, ans.size() / 2))
    {
        ans = ans.substr(0, ans.size() - 2);
    }
    cout << ans.size() << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N, X;
	scanf("%d%d", &N, &X);
	int *A = (int *)malloc(sizeof(int)*N);
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
		if (i >= 1 && A[i] + A[i - 1] > X) {
			int tmp = A[i] + A[i - 1];
			if (A[i] + A[i - 1] - X <= A[i]) {
				A[i] = A[i] - (A[i] + A[i - 1] - X);
			}
			else {
				A[i] = 0;
				A[i - 1] = A[i - 1] - (A[i] + A[i - 1] - X);
			}
			ans += tmp - (A[i] + A[i - 1]);
			//printf("%d:%lld\n", i,ans);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	int n, negcnt = 0, zerocnt = 0;
	cin >> n;

	vector<ll> a(n);

	for(auto& el: a)
	{
		cin >> el;
		negcnt += (el < 0);
		zerocnt += (el == 0);
	}

	if(zerocnt)
	{
		ll answ = 0;

		for(auto el: a)
			answ += abs(el);

		cout << answ << endl;
		return;
	}

	if(negcnt & 1)
	{
		ll answ = 0;

		for(auto el: a)
			answ += abs(el);

		ll mn = LL_INF;

		for(auto el: a)
			mn = min(mn, abs(el));

		cout << answ - 2 * mn << endl;
	}
	else
	{
		ll answ = 0;

		for(auto el: a)
			answ += abs(el);

		cout << answ << endl;
	}
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

int main(){
  int n;
  cin>>n;
  if(400<=n&&n<=599)cout<<8;
  else if(600<=n&&n<=799)cout<<7;
  else if(800<=n&&n<=999)cout<<6;
  else if(1000<=n&&n<=1199)cout<<5;
   else if(1200<=n&&n<=1399)cout<<4;
   else if(1400<=n&&n<=1599)cout<<3;
   else if(1600<=n&&n<=1799)cout<<2;
   else if(1800<=n&&n<=1999)cout<<1;
  

}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string> vc;
    string s;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        vc.push_back(s);
    }
    for (int i = 0; i < n; i++)
    {
        sort(vc[i].begin(), vc[i].end());
    }
    sort(vc.begin(),vc.end());
    long counter = 0;
    long ans=0;
    long temp=0;
    for (int i = 0; i < n-1; i++)
    {
        if (vc[i]==vc[i+1])
        {
            counter++;
        }else
        {
            temp = (counter*(counter+1))/2;
            ans = ans + temp;
            counter = 0;
        }
    }
    if (counter !=0)
    {
        temp = (counter*(counter+1))/2;
        ans = ans + temp;
    }
    
    cout << ans << endl;
    
    
}

Measured memory_bytes: 7284
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 222222
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
char s[N];
int n,cnt;
LL ans;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)
	{
		if(s[i]=='B')++cnt;
		else ans+=cnt;
	}
	printf("%lld\n",ans);
}
/*


*/


Measured memory_bytes: 384