akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   RFOR(i,n,0)

using namespace std;

int main(){
	int X;
	scanf("%d", &X);
	int m = 1;
	FOR(i, 2, 33){
		int k = 2, p = pow(i, k);
		while (p <= X){
			if (p > m){
				m = p;
			}
			k++;
			p *= i;
		}
	}

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


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define VMAX 100000
#define MAX 200000001

int main (){
  unsigned short *A,*B;
  int C[VMAX+1]={0};
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++) C[i]=0;
  for(i=1;i<=n;i++) {
    scanf("%hu", &A[i]);
    C[A[i]]++;
  }
  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];  
  for(j=1;j<=n;j++) {
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++) {
    if(i>1)  printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 9972
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        System.out.printf("%d %d %.10f",d,r,f);
        System.out.println();
    }
}


Measured memory_bytes: 26408
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

    int v[3];

    cin >> v[0] >> v[1] >> v[2];

    sort(v, v + 3, [](int a, int b){ return a > b; });

    int n = 1;

    n = 10 * v[0] + v[1];

    cout << n + v[2];


}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 1e3 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int arr[N], n, Q, sum[N];
int dp[N][N];

int getsum(int s, int e)
{     
      return sum[e] - sum[s-1];
}

int getans(int s, int e)
{     
      if( s >= e ) return 0;
      int &mafia = dp[s][e];
      if( mafia != -1 ) return mafia;

      int ans = INF;
      
      for(int i = s; i < e; i++)
      {
            int a1 = getans(s,i), a2 = getans(i+1, e);
            int sum1 = getsum(s, i), sum2 = getsum(i+1, e);
            int res = a1 + a2 + sum1 + sum2;
            ans = min(ans, res);
      }

      return mafia = ans;
}
void solve()
{
      cin >> n;
      lop(i,1,n+1) cin >> arr[i];
      lop(i,1,n+1) sum[i] += sum[i-1] + arr[i];
      memset(dp, -1, sizeof dp);
      cout << getans(1, n) << endl ;
}


int32_t main()
{
      
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

      int t = 1;
      //cin >> t;
      while(t--) solve();

}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //




      

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

using namespace std;

int main(void){
	int a,b;
	cin >> a>>b;
	if(1 != a && 1 != b){
		cout<<"1"<<endl;
	}
	else if(2 != a && 2 != b){
		cout<<"2"<<endl;
	}
	else{
		cout<<"3"<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define inf 1000000000000000001;
#define mem(a,val) memset(a,val,sizeof(a))
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define sep(i,a,b)    for(ll int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
     ll a;
     cin>>a;
     string s;
     cin>>s;
     if(a>=3200)cout<<s;
     else cout<<"red\n";   
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    double R;
    cin >> R;
    cout << 2*R*3.141592 << endl;
}


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

int main()
{
	int R[2][11],cnt;
	char str[80001];

	while(cin >> str, str[0]!='0'||str[1]!=NULL)
	{
		cnt = 0;
		for(int i=0; i<22; i++)
		{
			R[i/11][i%11] = 0;
		}
		
		for(int k=0; str[k]; k++)
		{
			for(int i=0; i<11; i++)
			{
				R[k%2][(i*10+str[k]-'0')%11] = R[(k+1)%2][i];
			}
			if(str[k]!='0')
			{
				R[k%2][str[k]-'0']++;
			}

			cnt+=R[k%2][0];
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 940
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int field[][] = new int[3][3];
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				field[i][j] = fs.nextInt();
			}
		}
		int s = field[0][0] + field[1][1] + field[2][2];
		int t = field[0][1] + field[1][2] + field[2][0];
		int u = field[0][2] + field[1][0] + field[2][1];
		if(s == t && t == u)System.out.println("Yes");
		else System.out.println("No");
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

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; }


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

    int n;
    cin >> n;

    ll ans = 0;
    int a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        while(a % 2 == 0){
            a /= 2;
            ans++;
        }
    }

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

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define re register
#define il inline
#define inf 0x3f3f3f

int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  std::cin >> n;
  int ans = 0, now = 0;
  while (n--) {
    int tmp;
    std::cin >> tmp;

    int a = log2(tmp);

    if ((1 << a) < tmp)
      if (now > a)
        now = a;
      else
        a++;

    if (a > now)
      ans += a - now;
    now = a;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <math.h>
#include <stdio.h>
#include <string.h>
long long a, b, c, k, ans = 0;
int main(void) {
    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
    if (k <= a) {
        printf("%lld\n", k);
    } else {
        for (int i = 0; i < a; i++) {
            ans++;
            k--;
        }
        if (k < b) {
            printf("%lld\n", ans);
        } else {
            for (int i = 0; i < b; i++) {
                k--;
            }
            ans = ans - k;
        }

        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 1708
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,k;
int dp[102][4][2];
int yt[102];

void debug(){
    for(int d=0;d<=n;d++){
        printf("%2d ",d);
        for(int i=1;i<=3;i++){
            printf("(%5d,%5d) ",d,dp[d][i][0],dp[d][i][1]);
        }
        cout << endl;
    }
}

int solve(){
    if(yt[1] == 0){
        dp[1][1][0] = dp[1][2][0] = dp[1][3][0] = 1;
    }else{
        dp[1][yt[1]][0] = 1;
    }
    for(int d=2;d<=n;d++){
        for(int i=1;i<=3;i++){
            if(yt[d] != 0 && yt[d] != i){ dp[d][i][0] = dp[d][i][1] = 0; continue; }
            dp[d][i][1] = dp[d-1][i][0] % 10000;
            dp[d][i][0] = 0;
            for(int j=1;j<=3;j++){
                if(i==j)continue;
                dp[d][i][0] += (dp[d-1][j][0] + dp[d-1][j][1]) % 10000;
            }
        }
    }
    int ans = 0;
    for(int i=1;i<=3;i++){
        ans += (dp[n][i][0] + dp[n][i][1]) % 10000;
    }
    return ans % 10000;
}

int main(){
    cin >> n >> k;
    int a,b;
    for(int i=0;i<k;i++){
        cin >> a >> b;
        yt[a] = b;
    }
    cout << solve() << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A * B >= C *D){
cout << A * B << endl;
 return 0;
  }else{
cout << C * D  << endl;
return 0;
  }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');//読み込んだ文字列を空白で区切る
            int A = Convert.ToInt32(imp[0]);//区切ったやつの1番目を代入
            int B = Convert.ToInt32(imp[1]);

            int AplsB = A + B;
            if (AplsB % 3 == 0)
            {
                Console.WriteLine("Possible");
            }
            else if (A % 3 == 0)
            {
                Console.WriteLine("Possible");
            }
            else if (B % 3 == 0)
            {
                Console.WriteLine("Possible");
            }
            else {
                Console.WriteLine("Impossible");
            }


            
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, A[300001] = {}, one[61] = {}, ans = 0, box = 1;
const ll MOD = 1e9 + 7;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		rep(j, 61) one[j] += (A[i] >> j) & 1;
	}
	rep(i, 61) {
		ans = (ans + ((one[i] * (N - one[i])) % MOD * box) % MOD) % MOD;
		box = (box * 2) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(A > 0 && C > 0)
    {
        C -= B;
        if(C <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3600
n=int(input())
l=[]
for i in range(n):
    l.append([i]+list(map(int,input().split())))
g = []
l.sort(key=lambda x: x[1])
for i in range(n-1):
    g.append([l[i][0],l[i+1][0],abs(l[i][1]-l[i+1][1])])
l.sort(key=lambda x: x[2])
for i in range(n-1):
    g.append([l[i][0],l[i+1][0],abs(l[i][2]-l[i+1][2])])

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def minimum_spanning_tree(g,n):
#g=list、「始点、終点、辺の重み」
#n=頂点数
    g.sort(key=lambda x: x[2])
    uf = UnionFind(n)
    ret = 0
    for sg in g:
        a,b,c = sg[0],sg[1],sg[2]
        if not uf.same(a,b):
            uf.union(a,b)
            ret += c
    return ret

print(minimum_spanning_tree(g,n))

Measured memory_bytes: 133028
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string s;
    ll k;
    cin >> s >> k;
    char ans;    
    int m = min(ll(s.length()), k);
    for (int i = 0; i < m; i++)
    {
        if(s[i]!='1'){
            ans=s[i];
            break;
        }else if(i==m-1){
            ans = '1';
        }
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
d = {}
e = {}
a = 0
b = 0
for _ in range(m):
    p, s = input().split()
    if p in d:
        continue
    else:
        if s == 'WA':
            if p in e:
                e[p] += 1
            else:
                e[p] = 1
        else:
            d[p] = 'AC'
            a += 1
            if p in e:
                b += e[p]
print(a,b)

Measured memory_bytes: 17108
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

int64_t mod_pow(int64_t x, int64_t n, int64_t mod) {
	int64_t res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod; // 最下位ビットが立っているときにx^(2^i)をかける
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

std::vector<int64_t> inv, fact_inv, com;
void combination_init(int64_t k_max, int64_t mod, int64_t n = -1) {
	int64_t size = k_max + 5;
	inv = std::vector<int64_t>(size);
	fact_inv = std::vector<int64_t>(size);
	inv[1] = 1;
	fact_inv[0] = fact_inv[1] = 1;
	for (int64_t i = 2; i < size; i++) {
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	if (n >= 0) {
		com = std::vector<int64_t>(size);
		com[0] = 1;
		for (int64_t i = 1; i < size; i++) {
			com[i] = com[i - 1] * ((n - i + 1) * inv[i] % mod) % mod;
		}
	}
}

signed main() {
	LL n, a, b;
	cin >> n >> a >> b;

	LL ans = mod_pow(2, n, MOD);
	combination_init(b, MOD, n);
	LL ncb = com[b];
	LL nca = com[a];
	ans = ans - nca - ncb - 1;
	while (ans < 0) {
		ans += MOD;
	}

	col(ans);
	return 0;
}


Measured memory_bytes: 7868
from math import cos, sin, pi
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A,B,H,M = map(int, readline().split())

    t_a = 2 * pi * H / 12 + (pi / 6) * (M / 60)
    t_b = 2 * pi * M / 60

    d = (A * cos(t_a) - B * cos(t_b))**2 + (A * sin(t_a) - B * sin(t_b))**2
    ans = pow(d, 0.5)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9580
N = int(input())

ans = [0] * N
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if not n > N:
                ans[n-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 9244
// Example program
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int main()
{
    
    
    int N,A,B;
    cin >> N >> A >> B;
    string s;
    cin >> s;
    char* S = (char*) malloc(sizeof(char)*N); // just omit the /0
    strcpy(S, s.c_str());
    
    int i;
    int offC = 0;
    int bRank = B;
    
    for (i=0; i<N; i++) {
        if (S[i] == 'a') {
            if ( (i-offC) < (A+B)) { cout << "Yes" << endl;
              } else { cout << "No" << endl; offC++;}
        }
        
        if (S[i] == 'b') {
            if ( (i-offC) < (A+B) && bRank >0 ) { cout << "Yes" << endl;
              } else { cout << "No" << endl; offC++;}
            bRank--;
        }
        
        if (S[i] == 'c') {
            cout << "No" << endl;
            offC++;
        }
        
    }
    
    
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<limits>
#include<math.h>
#include<bits/stdc++.h>

using namespace std;

#define make_graph(m,G) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b;G[a-1].push_back(b-1); G[b-1].push_back(a-1);}
#define make_dir_graph(m,G) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b;G[a-1].push_back(b-1);}
#define make_weighted_graph(m,G,w) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b; cin>>w[a-1][b-1];w[b-1][a-1]=w[a-1][b-1];G[a-1].push_back(b-1); G[b-1].push_back(a-1);}
#define make_weighted_dir_graph(m,G,w) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b; cin>>w[a-1][b-1]; G[a-1].push_back(b-1);}

string s,t;
int dp[3000][3000];

int lcs(int s1, int t1)
{
	int ans=0;
	if (s1 == -1 or t1 == -1)
	{
		ans = 0;
		return ans;
	}

	else if (dp[s1][t1] >= 0)
	{
		ans = dp[s1][t1];
	}
	else if (s[s1] == t[t1])
	{
		ans = 1 + lcs(s1-1, t1-1);
	}
	else
	{
		ans = max(lcs(s1-1,t1), lcs(s1,t1-1));
	}
	dp[s1][t1] = ans;
	return ans;
}
int main()
{
	int Testcases=1;
	//cin>>Testcases;
	while (Testcases--)
	{
		for (int i = 0; i<3000; i++)
		{
			for (int j = 0; j<3000; j++)
			{
				dp[i][j] = -1;
			}
		}
		// code
		cin>>s;
		cin>>t;
		int s1 = s.size() -1 , t1 = t.size() -1 ;
		lcs(s1,t1);

		int i = s1, j = t1;
		vector<char> l;
		if (dp[s1][t1] > 0) while (i >= 0 and j >= 0)
		{

			if (s[i] == t[j])
			{
				l.push_back(s[i]);
				i--; j--;
			}
			else
			{
				if (i > 0 and j==0)
				{
					i--;
				}
				else if (j>0 and i==0)
				{
					j--;
				}
				else if (i==0 and j==0)
				{
					break;
				}
				else if (dp[i-1][j] > dp[i][j-1])
				{
					i--;
				}
				else
				{
					j--;
				}
			}
			
		}
		if (dp[s1][t1] > 0) for (int i = l.size()-1; i>=0; i--)
		{
			cout<<l[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 35712
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
var line = chunk.toString().split('\n');
var seconds = Number(line[0]);
var hour_sec = 60*60;
var minute_sec = 60;

var hour = Math.floor(seconds / hour_sec);
var minute =  Math.floor((seconds % hour_sec) / minute_sec);
var sec = seconds % hour_sec % minute_sec;

console.log(hour + ':'+minute+':'+sec);
});

Measured memory_bytes: 15548
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)	for(ll i=(a); i<(b); i++)
#define REP(i,n)	FOR(i,0,(n))
typedef pair< ll, ll >	cp2;
typedef pair< ll, cp2 >	cp3;
const ll mod = 1000000007;
bool debug = false;


int N;
string S;
string str;
int cnt[30];
int num[30];
int ans;

int main(){
	
	while( cin>>N, N ){
		fill( cnt, cnt+30, 0 );
		ans = 0;
		REP( i, N ){
			cin>>S;
			int idx = S[0]-'A';
			cnt[idx]++;
			REP( j, 26 ) num[j] = cnt[j];
			sort( num, num+26, greater< int >() );
			if( num[0]-num[1] > (N-i-1) && ans == 0 ){
				ans = i+1;
				REP( i, 26 ){
					if( num[0] == cnt[i] ) str = 'A'+i;
				}
			}
		}
		if( debug ) cout<<"@ ";
		if( ans ) cout<<str<<" "<<ans<<endl;
		else{	cout<<"TIE"<<endl;}
	}
	
	return 0;
}


Measured memory_bytes: 3224
#include<stdio.h>
 
int ans;
int use[10];
int s;
 
void sumint(int n,int sum){
  int i;
  int max;
 
  if(n==0){
    if(sum == s)ans++;
    return;
  }
 
  max = 0;
  for(i=0;i<10;i++){
    if(use[i])max = i;
  }
 
  for(i=max;i<10;i++){
    if(!use[i]){
      use[i] = 1;
      sumint(n-1,sum+i);
      use[i] = 0;
    }
  }
}
 
int main(void){
  int i;
  int n;
 
  while(1){
    scanf("%d %d",&n,&s);
    if(!n && !s)break;
 
    ans = 0;
    for(i=0;i<10;i++)use[i] = 0;
 
    sumint(n,0);
 
    printf("%d\n",ans);
 
  }
 
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld h, a;
      cin >> h;
      cin >> a;
      if (h % a == 0)
      	cout << ((h/a) + 0);
      else
      	cout << ((h/a) + 1);
      return 0;
}

Measured memory_bytes: 256
#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;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

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 < (int)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 < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll X = 0;
    REP(i, N) X ^= A[i];
    REP(i, N) cout << (X^A[i]) << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int matrix[10][10];
vector<int> minMap(10, 10000);

int main(){
  int h, w;
  cin >> h >> w;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      cin >> matrix[i][j];
    }
  }
  for(int k=0; k<10; k++){
    for(int i=0; i<10; i++){
      for(int j=0; j<10; j++){
        matrix[i][j] = min(matrix[i][j], matrix[i][k]+matrix[k][j]);
      }
    }
  }
  int sum = 0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      int num;
      cin >> num;
      if(num != 1 && num != -1) sum += matrix[num][1];
    }
  }
  cout << sum << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a,b,sum=0,mx=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		sum+=max(n-a,0);
		mx=max(max(n-a,0),mx);
	}
	cout<<sum-mx<<endl;
}



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

int main() {
    string S;
    cin >> S;
    if (S.length() <= 7) {
        if (S == "dream" || S == "dreamer" || S == "erase" || S == "eraser") cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else if (S.length() < 10){
        cout << "NO" << endl;
    }
    else {
        bool flag = false;
        while (S.length() != 0) {
            if (S.length() < 5) {
                flag = true;
                break;
            }
            if (S[S.length() - 3] == 'e' && S.substr(S.length() - 5, S.length()) == "dream") S = S.substr(0, S.length() - 5);
            else if (S[S.length() - 3] == 'a' && S.substr(S.length() - 5, S.length()) == "erase") S = S.substr(0, S.length() - 5);
            else {
                if (S.length() < 6) {
                    flag = true;
                    break;
                }
                if (S[S.length() - 3] == 's' && S.substr(S.length() - 6, S.length()) == "eraser") S = S.substr(0, S.length() - 6);
                else {
                    if (S.length() < 7) {
                        flag = true;
                        break;
                    }
                    if (S[S.length() - 3] == 'm' && S.substr(S.length() - 7, S.length()) == "dreamer") S = S.substr(0, S.length() - 7);
                    else {
                        flag = true;
                        break;
                    }
                }
            }
        }
        if (flag) cout << "NO" << endl;
        else cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
if a[0] != 0:
    print("-1")
else:
    x = [0] * len(a)
    d = [0] * len(a)
    dd = [0] * len(a)

    c = 0
    s = 10**6
    #0 1 1 0 1 2 2 2 3
    wala = False
    for i in range(len(a) - 1, 0, -1):
        #print("-")
        if i <= s and a[i] == 0:
            #print("X")
            continue
        if i - a[i] < 0 or i - a[i] > s:
            #print("Y")
            wala = True
            break
        if s + a[i] == i:
            continue
        s = min(s, i - a[i])
        c += a[i]
    if wala:
        print("-1")
    else:
        print(c)


Measured memory_bytes: 17704
#!/usr/bin/env python3
def main():
    A, B, C, X, Y = map(int, input().split())

    all_double = 2 * max(X, Y) * C
    double = 2 * Y * C + (X - Y) * A if X >= Y else 2 * X * C + (Y - X) * B
    single = X * A + Y * B
    print(min(all_double, double, single))


if __name__ == '__main__':
    main()


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

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//素因数分解(素因数,何乗か？)
vector<pair<ll,ll>> fact(ll n){
	vector<pair<ll,ll>> res;
	for(ll i=2;i*i<=n;i++){
		if(n%i)continue;
		res.push_back(make_pair(i,0));//push_back(make_pair(a,b))よりらく
		while(n%i==0){
			n/=i;
			res.back().second++;
		}
	}
	if(n!=1)res.emplace_back(n,1);
	return res;
}

//考察よりgcd(A,B)の素因数を求めればよい
int main() {
	ll a,b,c;
	cin>>a>>b;
	
	c=gcd(a,b);
	auto f=fact(c);
	cout<<f.size()+1<<endl;
	
}


Measured memory_bytes: 256
#include<stdio.h>

int S;

int main(void){
  scanf("%d",&S);
  int a,b,c,d;
  a = S/1000;
  b = (S-a*1000)/100;
  c = (S-a*1000-b*100)/10;
  d = (S-a*1000-b*100-c*10);
  int f,s;
  f = a*10+b;
  s = c*10+d;
  if(f==0){
    if(s==0||12<s){
      printf("NA");
    }else{
      printf("YYMM");
    }
  }else if(f<=12){
    if(s==0||12<s){
      printf("MMYY");
    }else{
      printf("AMBIGUOUS");
    }
  }else{
    if(s==0||12<s){
      printf("NA");
    }else{
      printf("YYMM");
    }
  }
}

Measured memory_bytes: 128
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));
		StringBuilder sb = new StringBuilder();
		String P = "";

		while (true) {
			String[] str = br.readLine().split(" ");
			int m = Integer.parseInt(str[0]);
			int f = Integer.parseInt(str[1]);
			int r = Integer.parseInt(str[2]);
			if (m == -1 && f == -1 && r == -1) {
				break;
			}
			if (m == -1 || f == -1) {
				P = "F";
			} else if (m + f >= 80) {
				P = "A";
			} else if (m + f >= 65) {
				P = "B";
			} else if (m + f >= 50) {
				P = "C";
			} else if (m + f >= 30) {
				if (r >= 50) {
					P = "C";
				} else {
					P = "D";
				}
			} else {
				P = "F";
			}
			sb.append(P).append("\n");
		}
		System.out.print(sb);
	}
}

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

void trace(int A[], int N) {
  int i;
  for(int i = 0; i < N; ++i) {
    if(i > 0) {
      cout << " " << flush;
    }
    cout << A[i] << flush;
  }
  cout << endl;
}

void insertionSort(int A[], int N) {
  int j, i, v;
  for(int i = 1; i < N; ++i) {
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      --j;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

  cin >> N;
  for(i = 0; i < N; ++i) {
    cin >> A[i];
  }

  trace(A, N);
  insertionSort(A, N);
}

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

int main() {
  int N,ans = 0;
  cin >> N;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
    ans += vec[i];
  }
  sort(vec.begin(),vec.end());
  ans -= vec[N-1]/2;
  cout << ans << endl;
}


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

#define int long long int
const int N=1e5+4;
int A[N],B[N];

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	B[1] = abs(A[1]-A[0]);
	for(int i=2;i<n;i++)
		B[i] = min(abs(A[i]-A[i-1])+B[i-1],abs(A[i]-A[i-2])+B[i-2]);
	cout<<B[n-1];

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin>>n;
string s,ss,sss;
cin>>s>>ss;
for(int i=0;i<n;i++)
{
	cout<<s[i]<<ss[i];
}



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main()
{
    fast();
    vi a(3);
    cin>>a;
    ll ans=min(a[0]+a[1],min(a[1]+a[2],a[0]+a[2]));
    cout<<ans<<nl;
}


Measured memory_bytes: 3668
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
  int i;
  int A,B,C,D;
  int aa[200000]={};
  long cnt = 0;
  scanf("%d %d %d %d", &A, &B, &C, &D);

  for (i = 0; i < 1000; i++) {
    C -= B;
    if(C<=0){
      printf("Yes\n");
      return 0;
    }
    A -= D;
    if (A <= 0) {
      printf("No\n");
      return 0;
    }
  }
    return 0;
  }


Measured memory_bytes: 2088
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using ll = long long;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int k;
	k = (a + b) / 2;
	if ((a + b) % 2 != 0)cout << "IMPOSSIBLE" << endl;
	else if (abs(a - k) == abs(b - k))cout << k << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int s,i,j;
  int a[1000005];
  int min = 10000001;
  cin >> s;
  a[0] = s;
  for(i=1; i<=1000000; i++){
    if(s % 2 == 0){
      s = s / 2;
      a[i] = s;
    } else {
      s = (3 * s) + 1;
      a[i] = s;
    }
  }
  for(i=0; i<=1000000; i++){
    j = i;
    do{
      j++;
      if(a[i] == a[j]){
	if(j < min){
	  min = j;
	}
	break;
      }
      if(1000001 < j) break;
    }while(a[i] != a[j]);
  }
  cout << min + 1 << endl;
  return 0;
}


Measured memory_bytes: 4096
/*

*/
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)
#define repe(i,a) for(auto &i:a)
#define be begin()
#define en end()
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  string s;
  cin>>s;
  rep(i,3)cout<<s[i];
  cout<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  #include <map>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  int dp[105][4][2];

  int main(){
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;

    dp[0][0][0] = 1;
    rep(i,n) rep(j,4) rep(k,2){
      int nd = s[i]-'0';
      rep(d,10){
        int ni = i+1,nj = j,nk = k;
        if (d != 0) nj++;
        if (nj > K) continue;
        if (k == 0){
          if (d > nd) continue;
          if (d < nd) nk = 1;
        }
        dp[ni][nj][nk] += dp[i][j][k];
      }
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;

    return 0;
  }


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, q;
  string s;
  cin >> n >> s >> q;
  while (q--) {
    int k;
    cin >> k;

    vector<ll> cnt(3, 0);
    ll ans = 0;
    rep(i, n) {
      if (i - k >= 0) {
        if (s[i - k] == 'D') {
          cnt[0]--;
          cnt[2] -= cnt[1];
        }
        else if (s[i - k] == 'M') cnt[1]--;
      }
      if (s[i] == 'D') cnt[0]++;
      else if (s[i] == 'M') {
        cnt[1]++;
        cnt[2] += cnt[0];
      }
      else if (s[i] == 'C') ans += cnt[2];
    }
    cout << ans << '\n';
  }




  
  return 0;
}

Measured memory_bytes: 1948
def width(X,Y,x):
     n = len(X)
     lb,ub = float('inf'),-float('inf')
     for i in range(n):
          x1,y1,x2,y2 = X[i],Y[i],X[(i+1)%n],Y[(i+1)%n]
          if (x1-x)*(x2-x) <= 0 and x1 != x2:
               y = y1 + (y2-y1)*(x-x1)/(x2-x1)
               lb = min(lb,y)
               ub = max(ub,y)
     return max(0,ub-lb)

while 1:
     M,N = map(int,input().split())
     if not (M and N):
          break
     X1 = [0]*M
     Y1 = [0]*M
     X2 = [0]*N
     Z2 = [0]*N
     XS = [0]*N
     for i in range(M):
          X1[i],Y1[i] = map(int,input().split())
     for i in range(N):
          X2[i],Z2[i] = map(int,input().split())
     XS = X1+X2
     XS.sort()
     min1,max1 = min(X1),max(X1)
     min2,max2 = min(X2),max(X2)
     res = 0
     for i in range(len(XS)-1):
          a = XS[i]
          b = XS[i+1]
          c = (a+b)/2
          if min1 <= c <= max1 and min2 <= c <= max2:
               fa = width(X1,Y1,a)*width(X2,Z2,a)
               fb = width(X1,Y1,b)*width(X2,Z2,b)
               fc = width(X1,Y1,c)*width(X2,Z2,c)
               res += (b-a)/6 * (fa+4*fc+fb)
     print('%.10f'%res)



Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define ll long long int
#define ff first
#define pb push_back
#define ss second
#define debug 0
#define ff first
#define mp make_pair
 
using namespace std;
 
const ll MOD = 1000000007LL;
const long double pi=3.1415926535897;
 
ll fact[1000006];
ll ifact[1000006];
ll power2[1000006];
 
ll ar[5000056];
ll br[5000056];
vector<int> adj[5000005];
set<vector<int> > st;
set<int> sets;
 
bool vis[520];
ll sum;
 
bool prime[10000006];
 
vector<int> primes,vec,pec;
 
 
 
ll powr (ll a, ll  b)
{
    if (b == 0)
        return 1;
    long long int x = powr(a, b/2);
    if (b % 2 == 0)
        return (x*x)%MOD;
    else
        return ((x*x)%MOD*a%MOD)%MOD;
}
 
inline ll inv(ll x) {
  return powr(x, MOD - 2);
}
 
inline ll mulMod(ll a, ll b) {
  return (a%MOD * b%MOD) % MOD;
 
}
 
inline void process() {
  fact[0] = 1;
  power2[0] = 1;
  for(int i = 1; i < 1003; i++) {
    fact[i] = mulMod(fact[i - 1], i);
    power2[i] = mulMod(power2[i - 1], 2);
  }
  ifact[1002] = inv(fact[1002]);
  for(int i = 1002 - 1; i >= 0; i--) {
    ifact[i] = mulMod(ifact[i + 1], i + 1);
  }
}
 
inline ll ncr(ll n, ll r) {
  if(n < r) return 0;
  return mulMod(fact[n], mulMod(ifact[r], ifact[(n - r)]));
}
 
ll solve(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));
 
    C[0] = 1; 
 
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = C[j] + C[j-1];
    }
    return C[k];
}
 
void solve1(vector<ll> price, ll n, ll S[])
{
   
   stack<ll> st;
   st.push(0);
 
   S[0] = 1;
 
   for (ll i = 1; i < n; i++)
   {
 
      while (!st.empty() && price[st.top()] <= price[i])
         st.pop();
 
 
      S[i] = (st.empty())? (i + 1) : (i - st.top());
 
      st.push(i);
   }
}
 
void sieve()
{
    memset(prime,true,sizeof(prime));
    prime[0]=prime[1]=false;
    
    for(ll i=2;i*i<=100006;i++)
    {
        if(prime[i])
        {
            for(ll j=i*2;j<=100006;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    
    for(int i=2;i<=100005;i++)
    {
    	if(prime[i])
    	primes.pb(i);
	}
}
 
map<int,int> has[100008],occur[1000005];
bool flag;
 
 
void dfs0(int s)
{
	
	vis[s]=1;
	vector<int>::iterator it;
	
	for(it=adj[s].begin();it!=adj[s].end();++it)
	{
		if(!vis[*it])
		{
			sum^=ar[*it];
			dfs0(*it);
		}
	}
	
}
 
 

int main() 
{
    int n,m,t,p,q,s,a,b,c,d,e,f,g,h,res,u,v,i,j,l,k,len,ans=0,tot,rad,ds,rs,x,y,r,z,maxm,minm,pos,start,en;
    
    string str,ptr;
    
    cin>>n;
    
    for(i=0;i<n;i++)
    {
    	cin>>a>>b;
    	p=b-a+1;
    	ans=ans+p;
    	res=min(ans,100000);
	}
     
    cout<<res;
	return 0;
    
}

Measured memory_bytes: 174336
#include<stdio.h>
#define ll long long
using namespace std;
int fa[200005];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int l[200005],r[200005];
ll n,m,k,c,cnt;
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=n;i++) fa[i]=i;
	cnt=0;
	while(k--){
		ll u,v,opt;scanf("%lld%lld%lld",&u,&v,&opt);u++;v++;
		if(!opt) fa[find(u)]=find(v);
		else cnt++,l[cnt]=u,r[cnt]=v;
	}
	for(int i=1;i<=cnt;i++) if(find(l[i])==find(r[i])) return puts("No"),0;
	for(int i=1;i<=n;i++) if(find(i)==i) c++;
	ll L=cnt?c:c-1ll,R=c*(c-1ll)/2ll;
	return puts((L<=m-n+c&&m-n+c<=R)?"Yes":"No"),0;
}

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


int main() {
    int n;
    cin>>n;
    ll check=1e18;
    ll sum=1;
    bool zero=false;
    bool big=false;
    rep(i,n){
        ll a;
        cin>>a;
        if(a==0){zero=true;}

         if(big || check/sum < a){//ここの条件の移項でミスしていたのか！[sum*a>check]を[a>check/sum]で判別すれば桁もれず
            big=true;
        }
        sum*=a;
    }
    if(zero){
        cout<<0<<endl;
    }else if(big){
        cout<<-1<<endl;
    }else{
        cout<<sum<<endl;
    }

    
}


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

using namespace std;
int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        vector<int> v(n);
        int ave=0;
        for(int i=0;i<n;i++){
            cin>>v[i];
            ave+=v[i];
        }
        ave/=n;
        int ans=0;
        for(int i=0;i<n;i++){
            if(ave>=v[i])ans++;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3100
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		String str = null;
		
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			str = br.readLine();
		} catch (IOException e) {
			return;
		}
		
		int num = 0;
		for (int i = 0; i< 4; i++) {
			if (str.charAt(i) == '+') num++;
			else num--;
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 20948
#include <iostream>

using namespace std;

int main(){
  int a, c;
  string b;
  cin >> a >> b >> c;
    if(b.compare("+") == 0){
          cout << (a + c) << endl;  
    }else if(b.compare("-") == 0){
          cout << (a - c) << endl;
    }
  return 0;
}



Measured memory_bytes: 256
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 11/26/2018, 11:39:20 PM
# Powered by Visual Studio Code
#

n = gets.to_i
s = gets.chomp

x = 0
cnt = []
cnt << x
s.chars{|c|
  if c == 'I'
    x += 1
  elsif c == 'D'
    x -= 1
  end
  cnt << x;
}

puts cnt.max

Measured memory_bytes: 1788