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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef pair<ll, pll> plll;

template<class V, int ME> class BIT {
public:
    V bit[1<<ME];
    V total(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
    void add(int e, V val) {e++; while(e<=1<<ME) bit[e-1]+=val,e+=e&-e;}
};

BIT<ll, 18> bit1;
BIT<ll, 18> bit2;
const ll MA = (1ll << 18)-1;

map<ll,ll> zip;
ll unzip[MA];

ll compress(vector<ll> &x) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(),x.end()),x.end());
    for(ll i = 0; i < x.size(); i++){
        zip[x[i]] = i;
        unzip[i] = x[i];
    }
    return x.size();
}

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

    REP(i, MA-1) bit1.bit[i] = 0, bit2.bit[i] = 0;

    ll Q;
    cin >> Q;
    vector<plll> queries;
    vector<ll> as;
    REP(i, Q){
    	ll q;
    	cin >> q;
    	if(q == 1){
    		ll a, b;
    		cin >> a >> b;
    		as.push_back(a);
    		queries.push_back({1, {a, b}});
    	}else{
    		queries.push_back({2, {-1, -1}});
    	}
    }
    compress(as);

    ll B = 0;
    ll cnt = 0;
    REP(i, Q){
    	auto query = queries[i];
    	if(query.first == 1){
    		ll a = query.second.first;
    		ll b = query.second.second;
    		B += b;
    		ll a_comp = zip[a];
    		bit1.add(a_comp, 1);
    		bit2.add(a_comp, a);
    		cnt++;
    	}else{
    		ll lb = -1, ub = MA; //?
    		while(ub-lb>1){
    			ll mid = (lb+ub)/2;
    			bool ok;
    			ll sum = bit1.total(mid);
    			ok = (sum >= (cnt+1)/2);
    			if(ok){
    				ub = mid;
    			}else{
    				lb = mid;
    			}
    		}
    		ll med = ub;
    		ll med_x = unzip[med];

    		ll res = 0;
    		res -= bit2.total(med);
    		res += med_x * bit1.total(med);

    		res += (bit2.total(MA) - bit2.total(med));
    		res -= med_x * (bit1.total(MA) - bit1.total(med));

    		res += B;

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

Measured memory_bytes: 20012
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
char s[200],t[200],c[200];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	scanf("%s",c+1);
	int ans=0;
	for (int i=1;i<=n;i++) 
	{
		if (s[i]==t[i]&&s[i]==c[i]) continue;
		if (s[i]!=t[i]&&s[i]!=c[i]&&t[i]!=c[i]) ans=ans+2;else ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
 
func getHeadTail(i int) (string) {
  s := strconv.Itoa(i)
  head := s[:1]
  tail := s[len(s)-1:]
  
  return head + tail
}

func getTailHead(i int) (string) {
  s := strconv.Itoa(i)
  head := s[:1]
  tail := s[len(s)-1:]
  
  return tail + head
}

func main() {
  sc.Split(bufio.ScanWords)
  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())
  
  headTailMap := make(map[string]int)
  tailHeadMap := make(map[string]int)
  for k := 1; k <= n; k++ {
    if k % 10 == 0 {
      continue
    }
    if val, ok := headTailMap[getHeadTail(k)]; ok {
      headTailMap[getHeadTail(k)] = val + 1
    } else {
      headTailMap[getHeadTail(k)] = 1
    }
    if val, ok := tailHeadMap[getTailHead(k)]; ok {
      tailHeadMap[getTailHead(k)] = val + 1
    } else {
      tailHeadMap[getTailHead(k)] = 1
    }
  }
  
  sum := 0
  for key, valHT := range headTailMap {
    if valTH, ok:= tailHeadMap[key]; ok {
      sum += valHT * valTH
    }
  }
  fmt.Println(sum)
}

Measured memory_bytes: 4736
// AOJ 1603: 500-yen Saving
// 2018.1.30 bal4u

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

#define MAX  49900

int p[101];
char dc[101][50000]; int ds[101][50000];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, i, k, ii, j, c, s, a, b, f;

	while (n = in()) {
		for (i = 0; i < n; i++) p[i] = in();
		memset(dc, -1, sizeof(dc)), memset(ds, 0, sizeof(ds));
        dc[0][0] = 0;

		for (i = 0, ii = 1; i < n; i++, ii++) for (j = 0; j <= MAX; j++) if (dc[i][j] >= 0) {
            if (dc[ii][j] < dc[i][j] || dc[i][j] == dc[ii][j] && ds[i][j] < ds[ii][j]) {
                dc[ii][j] = dc[i][j], ds[ii][j] = ds[i][j];
            }
            a = dc[i][j], b = ds[i][j] + p[i];
            f = (5000 - p[i]) % 1000;
			k = j + f; if (k >= 500) a++, k -= 500;
            if (dc[ii][k] < a || dc[ii][k] == a && b < ds[ii][k]) dc[ii][k] = a, ds[ii][k] = b;
        }
        c = s = 0;
		for (j = 0; j <= MAX; j++) {
			if (c < dc[n][j] || dc[n][j] == c && ds[n][j] < s)
				c = dc[n][j], s = ds[n][j];
		}
        printf("%d %d\n", c, s);
	}
	return 0;
}


Measured memory_bytes: 26508
using System;

namespace ConsoleApp24
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int N = S.Length;
            var x = new int[N];
            int CountA = 0;
            int CountB = 0;

            for (int i = 0; i < N; i++)
            {
                x[i] =int.Parse(S.Substring(i, 1));
                if (i % 2 == 0)
                {
                    if (x[i] != 0)
                    {
                        CountA++;
                    }
                    else
                    {
                        CountB++;
                    }
                }
                else if (i % 2 == 1)
                {
                    if(x[i] != 1)
                    {
                        CountA++;
                    }
                    else
                    {
                        CountB++;
                    }
                }


               // Console.WriteLine("{0 },{1 }", CountA, CountB);

            }

            if (CountA > CountB)
            {
                Console.WriteLine(CountB);
            }
            else
            {
                Console.WriteLine(CountA);
            }
        }
    }
}


Measured memory_bytes: 15156
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n + 1), b(n);
    for (int &ai: a) cin >> ai;
    for (int &bi: b) cin >> bi;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int left = min(a[i], b[i]);
        a[i] -= left; ans += left; b[i] -= left;
        int right = min(a[i + 1], b[i]);
        a[i + 1] -= right; ans += right; b[i] -= right;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    vi x(5);
    rep(i,5)cin>>x[i];
    rep(i,5){
        if(x[i]!=i+1){
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <cassert>
using namespace std;
typedef long long ll;

const int INF = 1e9;
int H, W, K;
bool s[10][1000];

int check(vector<int>& sep)
{
    int out = sep.size() - 2;
    int sum[10] = {0};
    for (int i = 0; i < W; i++)
    {
        int cnt[10] = {0};
        for (int j = 0; j < sep.size() - 1; j++)
        {
            for (int k = sep[j]; k < sep[j + 1]; k++)
            {
                cnt[j] += s[k][i];
            }
        }
        
        bool cut = false;
        for (int j = 0; j < sep.size() - 1; j++)
        {
            sum[j] += cnt[j];
            if (cnt[j] > K)
                return INF;
            else if (sum[j] > K)
            {
                cut = true;
            }
        }

        if (cut)
        {
            for (int j = 0; j < sep.size() - 1; j++)
                sum[j] = cnt[j];
            out++;
        }
    }
    return out;
}

int main()
{
    int ans = INF;
    cin >> H >> W >> K;
    cin.get();
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            s[i][j] = cin.get() == '1';
        }
        cin.get();
    }

    for (int i = 0; i < (1 << H - 1); i++)
    {
        vector<int> sep;
        sep.push_back(0);
        for (int j = 0; j < H - 1; j++)
        {
            if (i & (1 << j))
            {
                sep.push_back(j + 1);
            }
        }
        sep.push_back(H);
        ans = min(ans, check(sep));
    }
    cout << ans << endl;
    // system("pause");
}

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

int main(){
	
	int N;
	int d[100];
	
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++){
		scanf("%d", &d[i]);
	}
	
	sort(d, d+N);
	reverse(d, d+N);
	int X = -1;
	int count = 0;
	
	for(int i = 0; i < N; i++){
		
		if(X != d[i]){
			X = d[i];
			count++;
		}
	
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N; cin >> N;
	vector<ll> A(N),B(N);
	rep(i,N) cin >> A[i] >> B[i];

	ll K = 0;
	for (int i = N-1; i >= 0; i--) {
		A[i] += K;
		ll k = A[i] % B[i];
		if (k != 0) K += (B[i] - k);
	}

	cout << K << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    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 fast_pow(long long base, long long n, long long M)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return base;
    long long halfn = fast_pow(base, n / 2, M);
    if (n % 2 == 0)
        return ( halfn * halfn ) % M;
    else
        return ( ( ( halfn * halfn ) % M ) * base ) % M;
}
int32_t main() {

    zeus();

    int n; cin >> n;
    string s; cin >> s;


    int low = 0, high = n - 1;
    int cnt = 0;
    while (low <= high) {
        while (s[low] != 'W') {
            low++;
            if (low >= high) {
                break;
            }
        }
        while (s[high] != 'R') {
            high--;
            if (low >= high) {
                break;
            }
        }
        if (low >= high) {
            break;
        }
        s[low] = 'R';
        s[high] = 'W';
        // cout << low << " " << high << endl;
        cnt++; low++;
        high--;


    }
    // cout << n - high << endl;
    while (high >= 0 & s[high] == 'W') {
        high--;
    }
    forn(i, 0, high) {
        if (s[i] == 'W') {
            cnt++;
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;

  cin >> s;

  for(int i = 1;i < s.size();i++){
	if(s[i] == s[i - 1]){
	  cout << "Bad" << endl;
	  return 0;
	}
  }
  cout << "Good" << endl;
		  
  return 0;
}



Measured memory_bytes: 256
import sys

n, q = [int(i) for i in sys.stdin.readline().split()]
graph = {i: [] for i in range(n)}
ct = [0 for i in range(n)]
for i in range(n - 1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

for i in range(q):
    p, x = [int(i) for i in sys.stdin.readline().split()]
    p -= 1
    ct[p] += x
already = {0}
stack = [(0, ct[0], -1)]
res = [0 for i in range(n)]
while len(stack) > 0:
    cur, cost, _from = stack.pop(-1)
    res[cur] = cost
    for _next in graph[cur]:
        if _next == _from:
            continue
        next_cost = ct[_next]
        stack.append((_next, cost + next_cost, cur))
        already.add(cur)
print(" ".join([str(r) for r in res]))

Measured memory_bytes: 126988
// F
#include<bits/stdc++.h>
#define mo 998244353
using namespace std;
int n,m,i,j,k,x,y,book[20005],zhan[20005],flag,f[2005][2005];
int top,nex[20005],to[20005],fir[20005];
int lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
long long read(){
	long long xx=0,flagg=1;
	char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')
		ch=getchar();
	if(ch=='-'){
		flagg=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return xx*flagg;
}
void pus(long long xx,int flagg){
	if(xx>=10)
		pus(xx/10,0);
	putchar(xx%10+'0');
	if(flagg==1)
		putchar(' ');
	if(flagg==2)
		putchar('\n');
	return;
}
void ss(int v){
	if(flag!=0)
		return;
	if(book[v]!=0){
		flag=book[v];
		return;
	}
	top++;
	book[v]=top;
	zhan[top]=v;
	for(int top1=fir[v];top1;top1=nex[top1])
		ss(to[top1]);
	if(flag!=0)
		return;
	book[v]=0;
	zhan[top]=0;
	top--;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();m=read();
	for(i=1;i<=m;i++){
		x=read();y=read();
		f[x][y]=1;
		lj(x,y);
	}
	for(i=1;i<=n;i++)
		if(flag==0)
			ss(i);
	if(flag==0){
		printf("-1\n");
		return 0;
	}
	for(i=1;i<=top-flag+1;i++)
		zhan[i]=zhan[i+flag-1];
	top=top-flag+1;
	for(i=1;i<=n;i++)
		book[i]=0;
	for(i=1;i<=top;i++)
		book[zhan[i]]=i;
	while(1){
		flag=0;
		for(i=1;i<=top;i++){
			for(j=1;j<=top;j++)
				if(i+1!=j&&(i!=top||j!=1)){
					if(f[zhan[i]][zhan[j]]==1){
						flag=1;
						if(j<i){
							for(k=1;k<=i-j+1;k++)
								zhan[k]=zhan[j+k-1];
							top=i-j+1;
						}
						else{
							for(k=1;;k++){
								zhan[i+k]=zhan[j+k-1];
								if(j+k-1==top){
									top=i+k;
									break;
								}
							}
						}
					}
					if(flag==1)
						break;
				}
			if(flag==1)
				break;
		}
		if(flag==0)
			break;
	}
	pus(top,2);
	for(i=1;i<=top;i++)
		pus(zhan[i],2);
	return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
int n, arr[1000];

bool check(int i, int j, int k){
	if(arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k])
		return false;
	if((arr[i] + arr[j] > arr[k]) && (arr[i] + arr[k] > arr[j]) && (arr[k] + arr[j] > arr[i]))
			return true;
	return false;
}

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
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> arr[i];
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			for(int k = j + 1; k < n; ++k){
				if(check(i, j, k))
					ans++;
			}
		}
	}
	cout << ans;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
       ll n;
      cin>>n;
      ll sum = 0;
        for(int i=1;i<=n;i++)
        {
            if(i%3==0 && i%5!=0)
            {
                continue;
            }
            else if(i%5==0 && i%3!=0)
            {
                continue;
            }
            else if(i%3==0 && i%5==0)
            {
                continue;
            }
            else
            { sum = sum + i ;}
        }
        
        cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000000000000
#define mod 1000000007

int main(){
	ll n;cin>>n;
	vector<string> s(2);cin>>s[0]>>s[1];

	ll ans=1,num=0;

	if(s[0][num]==s[1][num]){
		ans=(ans*3)%mod;
	}else{
		ans=(ans*3*2)%mod;
	}

	while(1){
		if(num+1<n && s[0][num]==s[1][num] && s[0][num+1]==s[1][num+1]){
			ans=(ans*2)%mod;
			num++;
		}else if(num+2<n && s[0][num]!=s[1][num] && s[0][num+1]!=s[1][num+1] && s[0][num+2]==s[1][num+2]){
			ans=(ans)%mod;
			num+=2;
		}else if(num+1<n && s[0][num]==s[1][num] && s[0][num+1]!=s[1][num+1]){
			ans=(ans*2)%mod;
			num++;
		}else if(num+2<n && s[0][num]!=s[1][num] && s[0][num+1]!=s[1][num+1] && s[0][num+2]!=s[1][num+2]){
			ans=(ans*3)%mod;
			num+=2;
		}else{
			break;
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define TUBO_UNIT 3.305785
using namespace std;

int main(void) {
    int a, b; cin >> a >> b;
    
    double ans = a*b;
    ans = ans / TUBO_UNIT;
    
    printf("%.7f\n", ans);
    return(0);
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define lld long long 
#define pb push_back
#define mk make_pair
using namespace std;

int main()
{
	int k;
	lld sum=0;

	cin>>k;

	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int m=1;m<=k;m++)
			{
				sum+=__gcd(__gcd(i,j),m);
			}
		}
	}

	cout<<sum<<endl;
}

Measured memory_bytes: 3624
S=input()
N=len(S)
mod=pow(10,9)+7
dpa=[0]*N
dpl=[0]*N
dpc=[0]*N
dpr=[0]*N
for i in range(1,N):
    if S[i-1]=='A':
        dpa[i]=dpa[i-1]+1
        dpl[i]=dpl[i-1]
    elif S[i-1]=='?':
        dpa[i]=dpa[i-1]
        dpl[i]=dpl[i-1]+1
    else:
        dpa[i]=dpa[i-1]
        dpl[i]=dpl[i-1]
for i in range(N-2,-1,-1):
    if S[i+1]=='C': 
        dpc[i]=dpc[i+1]+1
        dpr[i]=dpr[i+1]
    elif S[i+1]=='?': 
        dpc[i]=dpc[i+1]
        dpr[i]=dpr[i+1]+1
    else: 
        dpc[i]=dpc[i+1]
        dpr[i]=dpr[i+1]
ans=0 
for i in range(1,N-1):
    if S[i]=='?' or S[i]=='B':
        x=pow(3,dpl[i],mod)
        y=pow(3,max(dpl[i]-1,0),mod)
        z=pow(3,dpr[i],mod)
        w=pow(3,max(dpr[i]-1,0),mod)
        x=(x*dpa[i])%mod
        y=(y*dpl[i])%mod
        z=(z*dpc[i])%mod
        w=(w*dpr[i])%mod
        s=(x+y)%mod
        u=(z+w)%mod
        t=(s*u)%mod
        ans = (ans+t)%mod
print(ans)

Measured memory_bytes: 46572
#include<stdio.h>

int main(void)
{

        int max = -25000000;
        int n=0,sum=0;
        int i = 0,j = 0,k=0;

        while(1)
        {
                scanf("%d", &n);
                int a[n];
                if(n == 0)
                {
                        break;
                }
                for(i = 0; i < n; i++)
                {
                        scanf("%d", &a[i]);
                }



                for(i = 0;i < n; i++)
                {
                        for(j = i; j < n; j++)
                        {
                                sum=sum+a[j];
                                if(max < sum)
                                {
                                        max = sum;
                                }
                        }
                        sum = 0;
                }
                printf("%d\n",max);
                max = -25000000;
        }
        return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll h; cin >> h;
    ll tmp = log2(h);
    ll ans = pow(2LL, tmp+1LL) - 1LL;
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
            c[i] = scan.nextInt();
        }
        int[][] dp = new int[n+1][3];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 3; j++) {
                dp[i][0] = Math.max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
                dp[i][1] = Math.max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
                dp[i][2] = Math.max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
            }
        }
        System.out.println(Math.max(dp[n][0],Math.max(dp[n][1],dp[n][2])));
    }
}


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

using namespace std;

const int N = 333; 
char s[N][N];
int a[N][N];

void solve() {
    int n,m,k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> (s[i]+1);
    }

    int u = 1, l = 1;
    int x = 1;
    for (int i = 1; i <= n; i++) {
        l = 1;
        bool find = false;
        for (int j = 1; j <= m; j++) {
            if (s[i][j]!='#')continue;
            find = true;
            for (int _i = u; _i <= i; _i++) {
                for (int _j = l; _j <= j; _j++) {
                    a[_i][_j] = x;
                }
            }
            x++;
            l = j+1;
        }
        if (find) u = i+1;
    }
    for (int i = 1; i <= n; i++) {
        if (!a[i][1]) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = a[i-1][j];
            }
        }
        for (int j = 1; j <= m; j++) {
            if (!a[i][j]) a[i][j] = a[i][j-1];
            cout << a[i][j] << ' ';
        }cout << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1280
f=[]
t=[]
r=[0]
for i in range(5):
    f.append(int(input()))
for i in range(5):
    if f[i]%10!=0:
        r.append(10-f[i]%10)
        t.append((f[i]//10+1)*10)
    else:
        t.append(f[i])
print(sum(t)-max(r))


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

using namespace std;

typedef long long ll;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define abs(a) ((a) < (0)? -(a):(a))
#define pb push_back

int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i, n) {
        int a; cin >> a;
        for(; a>0 && a%2==0; a/=2,ans++); 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli a;
		string s;
		cin>>a>>s;
		if(a>=3200)
		cout<<s<<endl;
		else
		cout<<"red"<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int a[2000000];
int out[2000001];
int c[10001]={0};
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        c[a[i]]++;
    }
    for(int i=0;i<10000;i++){
        c[i+1]=c[i]+c[i+1];
    }
    for(int i=n;i>=0;i--){
        out[(c[a[i]]--)]=a[i];
    }
    for(int i=1;i<n;i++)
        cout<<out[i]<<" ";
    cout<<out[n]<<endl;
    return 0;
}



Measured memory_bytes: 18744
n, m = map(int, input().split())
A = list(map(int, input().split()))

tmp = sum(A)
tmp2 = 0
for i in range(n):
  if A[i] >= tmp / (4 * m):
    tmp2 += 1
    
if tmp2 >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<iostream>

using namespace std;
int main(){
    int N;
    cin>>N;

    int A,sum=0;
    for(int i=0;i<N;++i){
        cin>>A;
        sum+=A;
    }

        if(sum%2==0){
            cout<<"YES";
        }else{
            cout<<"NO";
        }
}

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

int main() {
    string s;
    int ans;
    cin >> s;

    if (s == "111") {
        ans = 3;
    }
    else if (s == "110" || s == "101" || s == "011") {
        ans = 2;
    }
    else if (s == "100" || s == "010" || s == "001") {
        ans = 1;
    }
    else {
        ans = 0;
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;
using ll = long long int;

int main(void) {
    int x; cin >> x;
    for (ll i = -200; i <= 200; i++) {
        for (ll j = -200; j <= 200; j++) {
            if (pow(i, 5) - pow(j, 5) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

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

    double values[N];
    int temp;
    for (int i = 0; i < N; i++)
    {
        cin >> temp;
        values[i] = temp;
    }

    sort(values, values + N);

    for (int i = 1; i < N; i++)
    {
        values[i] = (values[i] + values[i - 1]) / 2;
    }

    cout << values[N - 1];
}


Measured memory_bytes: 256
#define ll long long
#define pi acos(-1.0)
#define Go "\n"
#define bye return 0
#define Afor(i,b) for(int i=0;i<b;i++)
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N,M,i,sum=0;
    cin>>N>>M;
    int A[M];
    Afor(i,M)
    {
        cin>>A[i];
        sum=sum+A[i];
    }
    if(sum>N)
    {
        cout<<"-1"<<Go;
    }
    else
    {
        cout<<N-sum<<Go;
    }
    bye;

}


Measured memory_bytes: 3620
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    A = NLI()
    A = [a%MOD for a in A]
    s = sum(A)
    ss = sum([a**2%MOD for a in A])
    print((s**2-ss)%MOD * pow(2, -1, MOD) %MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 32516
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node treeSearch(Node, int);
void insert(int);
void inorder(Node);
void preorder(Node);

Node root;

int main()
{
  int n, i, x;
  char com[20];

  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%s", com);
    if( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
    }

    else if( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }

    else if( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

/* 探索 */
Node treeSearch(Node u, int k)
{

  if(u == NIL || k == u->key) return u;   
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

/* 挿入 */
void insert(int k)
{

  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
 
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

/* 中間順巡回 */
void inorder(Node u)
{

  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }

}

/* 先行順巡回 */
void preorder(Node u)
{

  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }

}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
vi G[100005];
ll dist[100005][3];
const ll INF = 1e9;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  int n,m;
  cin >>n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
  }
  int s,t;
  cin >>s >> t;
  s--;t--;
  Fill(dist,INF);
  dist[s][0] = 0;
  queue<P> q;
  q.push(P(s,0));
  while(!q.empty()){
    int u = q.front().first;
    int k = q.front().second;
    q.pop();
    for(auto v: G[u]){
      if(dist[v][(k+1)%3] != INF)continue;
        dist[v][(k+1)%3] = dist[u][k]+1;
        q.push(P(v,(k+1)%3));
    }
  }
  if(dist[t][0] == INF)cout<<-1<<endl;
  else cout<<dist[t][0]/3<<endl;
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	cout<<min(A,B)<<" "<<max(0,A+B-N)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define LL long long
#define INF 2000000000
#define maxn 1010
using namespace std;
int n,m;
int k[][2]={{-1,0},{1,0},{0,-1},{0,1}};
int border[maxn][maxn][4];
int vis[maxn][maxn],qx[maxn*maxn],qy[maxn*maxn];
LL ans;
struct node{
	int a,b,c;
}f[maxn],g[maxn];
int X[maxn],Y[maxn],XN,YN;
int findX(int v){
	return lower_bound(X,X+XN,v)-X;
}
int findY(int v){
	return lower_bound(Y,Y+YN,v)-Y;
}
void bfs(int xx,int yy){
	int i,h,t,nx,ny,x,y;
	h=t=0;
	qx[t]=xx,qy[t]=yy,t++,vis[xx][yy]=1;
	while(h<t){
		x=qx[h],y=qy[h],h++;
		ans+=(LL)(X[x+1]-X[x])*(Y[y+1]-Y[y]);
		for(i=0;i<4;i++){
			if(border[x][y][i])continue;
			nx=x+k[i][0],ny=y+k[i][1];
			if(nx==0||nx==XN-1||ny==0||ny==YN-1){
				ans=-1;
				return;
			}
			if(vis[nx][ny])continue;
			vis[nx][ny]=1,qx[t]=nx,qy[t]=ny,t++;
		}
	}
}
void init(){
	int i,x,y,r,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%d%d%d",&f[i].a,&f[i].b,&f[i].c),X[XN++]=f[i].c;
	X[XN++]=-INF,X[XN++]=INF;
	sort(X,X+XN);
	XN=unique(X,X+XN)-X;
	for(i=0;i<m;i++)scanf("%d%d%d",&g[i].a,&g[i].b,&g[i].c),Y[YN++]=g[i].a;
	Y[YN++]=-INF,Y[YN++]=INF;
	sort(Y,Y+YN);
	YN=unique(Y,Y+YN)-Y;
	for(i=0;i<n;i++){
		x=findX(f[i].c);
		r=findY(f[i].b);
		if(Y[r]!=f[i].b)r--;
		for(j=findY(f[i].a);j<r;j++)
			border[x-1][j][1]=border[x][j][0]=1;
	}
	for(i=0;i<m;i++){
		y=findY(g[i].a);
		r=findX(g[i].c);
		if(X[r]!=g[i].c)r--;
		for(j=findX(g[i].b);j<r;j++)
			border[j][y-1][3]=border[j][y][2]=1;
	}
}
int main(){
	init();
	bfs(findX(0)-1,findY(0)-1);
	if(ans==-1)printf("INF\n");
	else printf("%lld\n",ans);
	return 0;
}

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

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

    ll s, c;
    cin >> s >> c;

    ll piece = min(s, c/2);
    ll rem = c - 2 * piece;
    if (rem > 0) {
        piece += rem / 4;
    }

    cout << piece << endl;
    return 0;
}

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


using namespace std;


int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    
    vector<int> x, y, a;
    for( int i = 0; i < N; ++i ){
        int X, Y, A;
        cin >> X >> Y >> A;
        x.push_back(X);
        y.push_back(Y);
        a.push_back(A);
    }
    
    
    int w_min = 0, w_max = W, h_min = 0, h_max = H;
    for( int i = 0; i < N; ++i ){
        switch( a[i] ){
            case 1: w_min = w_min < x[i] ? x[i] : w_min; break;
            case 2: w_max = x[i] < w_max ? x[i] : w_max; break;
            case 3: h_min = h_min < y[i] ? y[i] : h_min; break;
            case 4: h_max = y[i] < h_max ? y[i] : h_max; break;
        }
    }
    
    
    int ans = (w_max-w_min)*(h_max-h_min);
    if( w_max-w_min < 0 || h_max-h_min < 0 ) ans = 0;
    cout << ans << endl;
    
    
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);

    map<int, int> cnt;
    ll ans = 0;
    for(int i=0; i<N; i++)
    {
        ans += cnt[i+1 - A[i]];
        cnt[i+1 + A[i]]++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 21076
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int main(){
  int a,b;
  while(cin>>a>>b){
    cout << a+b << endl;
  }
  return 0;
}




Measured memory_bytes: 2972
require "prime"
N, P = gets.chomp.split(' ').map(&:to_i)
# puts "#{N} #{P}"

ans = 1
Prime.prime_division(P).each do |a, n|
    # puts "#{a}^#{n}"
    t = n / N
    ans *= a ** t if t > 0
end
puts ans

Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  vector<int> hs(N); for (auto &h: hs) cin >> h;
  int ans{0};
  for (int i = 0; i < 100; ++i)
    {bool b{true};
    for (auto &h : hs)
      if (h >= 1) {--h; if (b) ++ans; b = false;}
      else b = true;}
  cout << ans << endl;}

Measured memory_bytes: 3628
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
//fixed<< setprecision(2)
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
   string s1,s2;
   ll ans=0;
   cin>>s1>>s2;
   for(int i=0;i<s1.length();i++)
   {
       if(s1[i]!=s2[i])ans++;
   }
   cout<<ans<<'\n';
}

Measured memory_bytes: 3484
#include <iostream>

using namespace std ;


int main()
{
    int a, b ;
    int max ;

    cin >> a >> b ;

    max = a + b ;

    if ( max < a - b )
        max = a - b ;

    if ( max < a * b )
        max = a * b ;

    cout << max << endl ;

    return 0 ;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
X = int(input())

sm = 0

count = 0

for x in range(0, a+1):
    for y in range(0, b+1):
        for z in range(0, c+1):
            sm = 500*x + 100*y + 50*z
            if sm == X:
                count += 1
            sm = 0

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N, K;
    cin >> N >> K;
    int64_t n = K;
    int64_t count = 1;
    while (n - 1 < N) {
        n = n * K;
        count += 1;
    }

    cout << count << endl;
    return 0;
}

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

string s,t;

int main()
{
	cin>>s>>t;
	if(s==t)
	{
	 cout<<"Yes"<<endl;
	 return 0;
	 }
	for(int i=1;i<s.size();i++)
	{
	 string c="";
	 c=s.substr(s.size()-i,i);
	 c=c+s.substr(0,s.size()-i);
	 if(c==t) 
	 {
	  cout<<"Yes"<<endl;
	  return 0;
	  }
	 }
	cout<<"No"<<endl; 
 return 0;
 }


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

#define BUF 200002
#define LIM_N 100001

char str[BUF];

int A, B;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &A, &B);
}

int solve() {
	if (13 <= A) {
		return B;
	} else if (6 <= A && A <= 12) {
		return B/2;
	} else {
		return 0;
	}
}

int main(void) {
	receive_input();

	printf("%d\n", solve());

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n,k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    ans = n-(k-1)-1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 1e5 + 7;

bitset <N> can;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '1')
        {
            can[i + 1] = 1;
        }
    }
    if (!can[1])
    {
        cout << -1 << '\n';
        return 0;
    }
    if (can[n])
    {
        cout << -1 << '\n';
        return 0;
    }
    can[0] = can[n] = 1;
    for (int i = 0; i <= n; i++)
    {
        if (can[i] != can[n - i])
        {
            cout << -1 << '\n';
            return 0;
        }
    }
    int sz = 1;
    int prev = 0;
    int x = -1;
    for (int i = 1; i <= n; i++)
    {
        if (can[i])
        {
            int v = sz++;
            if (x != -1)
            {
                cout << v << ' ' << x << '\n';
            }
            for (int it = 0; it < i - prev - 1; it++)
            {
                cout << v << ' ' << sz++ << '\n';
            }
            x = v;
            prev = i;
        }
    }
}


Measured memory_bytes: 1616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

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

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

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N;
ll A[200010];
mint S[200010];

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

  rep( i, N )
    std::cin >> A[i];

  mint sum = 0, ans = 0;

  rep( i, N+1 ) {
    ans += sum*A[i];
    sum += A[i];
  }

  std::cout << ans.x << endl;

  return 0;
}

Measured memory_bytes: 6760
#include<stdio.h>
int main(){
    long long n;
    long long sho;
    int amari,count = 0;
    int a[1000];
    scanf("%lld",&n);
    while(n > 0){
        n--;
        sho = n /26;
        amari = n % 26;
        count++;
        a[count] = amari + 'a' ;
        n /= 26;
    }
    for(int i = count; i > 0; i--)
        printf("%c",a[i]);
    return 0;
}

Measured memory_bytes: 1664
# include <iostream>
#include <math.h>
#include <string>
#include <vector>

# include <map>

using namespace std;

typedef unsigned long long ll;

ll dp[2001];

ll n = 1000000007;

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

	dp[0] = 1;

	for (int i = 3; i < 2001; i++) {
		for (int j = 3; j <= s; j++) {
			if (i - j < 0) continue;
			dp[i] = (dp[i - j] + dp[i]) % n;
		}
	}

	cout << dp[s];
}


Measured memory_bytes: 3600
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
    aa = bisect.bisect_left(a, i)
    cc = n-bisect.bisect_right(c, i)
    ans += aa*cc
print(ans)

Measured memory_bytes: 23200
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
import bisect
def count(k):
    #幸福値がk以上となるような握手の総数
    cnt=0
    for i in range(n):
        cnt+=n-bisect.bisect_left(a,k-a[i])
    return cnt

l=0
r=2*10**5+10

while r-l>1:
    med=(r+l)//2
    if count(med)<m:
        r=med
    elif count(med)>=m:
        l=med
#合計がl以上の物の合計を足して、その値からl*(count(l)-m)を取ればいい

ans=0

dp=[0 for i in range(n+1)]
#dp[i]=aの後ろからi番目までの数の総数
for i in range(1,n+1):
    dp[i]=dp[i-1]+a[-i]

for i in range(n):
    x=a[i]
    index=n-bisect.bisect_left(a,l-x)
    ans+=dp[index]+x*index
    
print(ans-l*(count(l)-m))

    

Measured memory_bytes: 59928
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;
  repp(i, 1, N) {
    int sum = 0;
    int i_cp = i;
    while (i_cp) {
      sum += i_cp % 10;
      i_cp /= 10;
    }
    if (A <= sum && sum <= B) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256