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

using namespace std;

#define ll long long
#define ull unsigned long long

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

    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1) + m * (m - 1)) / 2 << '\n';
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr1, arr2 := make([]int, n), make([]int, n)
	scan(n, arr1); scan(n, arr2)

	sum := 0
	for i := 0; i < n; i++ {
		sum += arr1[i]
		arr1[i] = sum
	}

	sum = 0
	for i := n - 1; i >= 0; i-- {
		sum += arr2[i]
		arr2[i] = sum
	}

	mx := math.MinInt32
	for i := 0; i < n; i++ {
		cur := arr1[i] + arr2[i]
		if cur > mx {
			mx = cur
		}
	}

	fmt.Println(mx)
}

func scan(n int, arr []int)  {
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
}

Measured memory_bytes: 512
N = int(input())
P = list(map(float, input().split()))
dp = [[0]*(N+1) for _ in range(N)]
dp[0][0] = 1-P[0]
dp[0][1] = P[0]
for i in range(N):
    for k in range(N+1):
        if i-1 >= 0:
            dp[i][k] += dp[i-1][k]*(1-P[i])
            if k-1 >= 0:
                dp[i][k] += dp[i-1][k-1]*P[i]
ans = 0
for i in range(N+1):
    if i >= (-(-N//2)):
        ans += dp[-1][i]
print(ans)


Measured memory_bytes: 254344
#include <stdio.h>
int main (void)
{
	int h, w;
	int H, W;

	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W ==0) break;
		for(h=1; h<=H; h++){
			for(w=1; w<=W; w++){
				if(h%2 == 1 && w%2 == 1)
					printf("#");
				else if(h%2 == 1 && w%2 == 0)
					printf(".");
				else if(h%2 == 0 && w%2 == 1)
					printf(".");
				else
					printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}	
	return 0;	
}

Measured memory_bytes: 572
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
int n,m,sum;
long long ans;
int a[N];
void up(int x)
{
	for (int fa=x>>1;fa&&a[fa]<a[x];x=fa,fa>>=1)
		swap(a[fa],a[x]);
}
void down(int x)
{
	for (int son=x<<1;son<=sum;x=son,son<<=1)
	{
		if (son<sum&&a[son]<a[son+1])
			++son;
		if (a[x]<a[son])
			swap(a[x],a[son]);
		else
			break;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a[++sum]);
		up(sum);
	}
	for (int i=1;i<=m;++i)
	{
		a[1]/=2;
		down(1);
	}
	for (int i=1;i<=n;++i)
		ans+=a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 512
n=int(input())
AB=[]
B=[]
for _ in range(n):
    a,b=map(int,input().split())
    AB.append(a+b)
    B.append(b)
AB=sorted(AB,reverse=True)
#print(AB)
X=-sum(B)
for i in range(0,n,2):
    X+=AB[i]
print(X)

Measured memory_bytes: 12212
use std::collections::HashSet;
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn main() {
    let n: usize;
    input!(n);
    let mut v = HashSet::new();
    for _ in 0..n {
        let buf: usize;
        input!(buf);
        v.insert(buf);
    }
    p(v.len());
}

Measured memory_bytes: 4352
#include <iostream>
#include<stdio.h>
#include <algorithm>
using namespace std;

int answer[100005], preI[100005];

int main()
{
    int n,m,an,pr;
    cin>>n>>m;
    pair <int,pair <int,int> > v[m + 10];
    for(int i=0; i<m; i++){
        cin>>pr>>an;
        v[i].second.first=an;
        v[i].first=pr;
        v[i].second.second=i;
    }
    sort(v,v+m);

    int indx=1;
    for(int i=0; i<m; i++){
        if(i > 0 && v[i].first!=v[i-1].first){
            indx=1;
        }
        answer[v[i].second.second] = indx;
        preI[v[i].second.second] = v[i].first;
        indx++;
    }
    for(int i = 0; i < m; i++) {
        printf("%06d", preI[i]);
        printf("%06d\n", answer[i]);
    }

    return 0;

}


Measured memory_bytes: 3456
N, D, A = map(int, input().split())
XH = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans, R, S = 0, 0, [0] * (N + 2)
for L in range(N):
    while R < N and XH[R][0] - XH[L][0] <= 2 * D:
        R += 1
    S[L + 1] += S[L]
    bomb = (max(XH[L][1] - S[L + 1], 0) + A - 1) // A
    ans += bomb
    S[L + 1] += bomb * A
    S[R + 1] -= bomb * A
print(ans)


Measured memory_bytes: 81624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<ll, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<ldouble, ldouble> pdd;

int Get(int x) {
	printf("%d\n", x);
	fflush(stdout);
	string s; cin >> s;
	if(s == "Vacant") return -1;
	return (s == "Male");
}


void solve() {
	int N; scanf("%d", &N);
	int c = Get(0);
	if(c == -1) return;
	int low = 1, high = N - 1;
	int val = c;
	while(low <= high) {
		int mid = (low + high) >> 1;
		int cm = Get(mid);
		if(cm == -1) return;
		if((mid - low) % 2 == 0) {
			if(val == cm) high = mid - 1;
			else low = mid + 1, val = cm;
		}
		else {
			if(val == cm) low = mid + 1;
			else high = mid - 1;
		}
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




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

int main() {
  int N, K;
  cin >> N >> K;
  int mx = (N - 1) * (N - 2) / 2;
  if (K > mx) return cout << -1 << "\n", 0;
  int cnt = mx - K;
  cout << N - 1 + cnt << "\n";
  for (int i = 2; i <= N; i++) cout << 1 << " " << i << "\n";
  for (int i = 2; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (cnt) {
        cout << i << " " << j << "\n";
        cnt--;
      }
    }
  }
}

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

int main() {
    int n;
    cin >> n;
    int ar[n];
    for(int i = 0; i < n; i++) cin >> ar[i];
    int count = 0;
    for(int i = 0; i < n - 1; i++) {
        if(ar[i] == ar[i + 1]) {
            count++;
            i++;
        }
    }
    cout << count;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	h,w=MI()
	G=[]
	G+=["#"]*(w+2)
	for _ in range(h):
		G+=["#"]+list(RD())+["#"]
	G+=["#"]*(w+2)

	cnt=G.count(".")


	Q=deque()
	Q.append([w+3,1])
	G[w+3]=1

	while Q:
		now,d=Q.popleft()
		for i in [1,-1,w+2,-w-2]:
			if G[now+i]==".":
				G[now+i]=d+1
				Q.append([now+i,d+1])

	ans=-1
	if G[(w+2)*(h+2)-(w+4)]!=".":
		ans=cnt-G[(w+2)*(h+2)-(w+4)]

	print(ans)












if __name__ == "__main__":
	main()


Measured memory_bytes: 71088
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > edges(n);
    for(int i=0; i<n-1; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> v(n, -1);
    vector<int> cnt(2, 0);
    queue<int> q;
    v[0] = 0;
    q.push(0);
    while(!q.empty()){
        int a = q.front();
        q.pop();
        ++ cnt[v[a]];
        for(int b : edges[a]){
            if(v[b] == -1){
                v[b] = v[a] ^ 1;
                q.push(b);
            }
        }
    }

    vector<int> ans(n, -1);
    if(min(cnt[0], cnt[1]) <= n / 3){
        int k = min_element(cnt.begin(), cnt.end()) - cnt.begin();
        int a = 3;
        vector<bool> isUsed(n+1, false);
        for(int i=0; i<n; ++i){
            if(v[i] == k){
                ans[i] = a;
                isUsed[a] = true;
                a += 3;
            }
        }
        a = 1;
        for(int i=0; i<n; ++i){
            if(ans[i] == -1){
                while(isUsed[a])
                    ++ a;
                ans[i] = a;
                isUsed[a] = true;
            }
        }
    }
    else{
        int a = 1;
        int b = 2;
        for(int i=0; i<n; ++i){
            if(v[i] == 0 && a <= n){
                ans[i] = a;
                a += 3;
            }
            else if(v[i] == 1 && b <= n){
                ans[i] = b;
                b += 3;
            }
        }
        a = 3;
        for(int i=0; i<n; ++i){
            if(ans[i] == -1){
                ans[i] = a;
                a += 3;
            }
        }
    }

    cout << ans[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 15220
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
circle = Y - X + 1

D = [0] * N
for i in range(N):
    for j in range(i + 1, N):
        if i < X and X <= j <= Y:
            start_to_ent = X - i
            ent_to_goal = j - X
            d = min(ent_to_goal, circle - ent_to_goal) + start_to_ent
            D[d] += 1
        elif X <= i <= Y and X <= j <= Y:
            start_to_goal = j - i
            d = min(start_to_goal, circle - start_to_goal)
            D[d] += 1
        elif X <= i <= Y and Y < j:
            start_to_ent = j - Y
            ent_to_goal = Y - i
            d = min(ent_to_goal, circle - ent_to_goal) + start_to_ent
            D[d] += 1
        elif i < X and Y < j:
            start_to_ent = X - i
            ent2_to_goal = j - Y
            r = Y - X
            d = start_to_ent + min(r, circle-r) + ent2_to_goal
            D[d] += 1
        else:
            d = j - i
            D[d] += 1

for i in range(1, N):
    print(D[i])

# circle = Y - X + 1
# fline = X - 1
# bline = N - Y
#
# climit = circle // 2
# bin_flag = climit % 2 == 0
# if bin_flag:
#     climit -= 1
#
# for k in range(N):
#     F = min(fline - k + 1, 0)
#     if bin_flag:
#         FC = min(min(climit, fline) - k + 2) * 2
#         BC = min(min(climit, bline) - k + 1) * 2
#         if climit + 1 < k <

Measured memory_bytes: 48348
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


x,y = list(map(int, input().split()))

### 素数の逆元とCombination
M = 10**9+7 # 出力の制限
N = (x+y)//3 * 2 +100 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M


if (x+y)%3!=0:
    ans = 0
else:
    xy = (x+y)//3
    xx = y - xy
    yy = x - xy
    if xx<0 or yy<0:
        ans = 0
    else:
        ans = cmb(xx+yy, xx, M)
print(ans)

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

using namespace std;

typedef long long ll;

int solve(){
    string s;
    cin >> s;
    stack <char> x;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] != 'B'){
            x.push(s[i]);
        }
        else{
            if(!x.empty()){
                x.pop();
            }
        }
    }
    vector<char> v;
    while(!x.empty()){
        v.push_back(x.top());
        x.pop();
    }
    reverse(v.begin(), v.end());
    for(auto z : v){
        cout << z;
    }
    return 0;
 }

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[207],i,s;
int main(){
for(cin>>n,i=0;i<n*2;i++) cin>>a[i];
sort(a,a+2*n);
for(i=0;i<2*n;i+=2) s+=a[i];
cout<<s;
}

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

using namespace std;
int a[maxn],n,ans;

int main(){
    cin >> n;
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int i=2;i<=n;i++) if (a[i]==a[i-1]) ans++,a[i]=123456;
    cout << ans << endl;
}


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

int solve(int,int);

int n,q;
int *A,*m;

int main()
{
  int i;
  int x;
  
  //入力
  scanf("%d",&n);
  A = (int *)malloc( n * sizeof(int));

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

  scanf("%d",&q);
  m = (int *)malloc( q * sizeof(int));
  
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<q;i++) {
    x = solve(0,m[i]);
    if(x == 1) printf("yes\n");
    else printf("no\n");
  }
    

  free(A);
  free(m);
  return 0;
}

int solve(int i,int m)
{
  int res;
  if(m == 0) {
    // printf("yes\n");
    return 1;
  }
  if(i >= n) {
    // printf("no\n");
    return 0;
  }

  res = solve ( i+1 , m ) || solve(i+1 , m-A[i] );
  return res;
}
  



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 1e+8;

typedef long long ll;


// http://stackoverflow.com/questions/1838368/calculating-the-amount-of-combinationsb
unsigned long long choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

ll C[51][51];                   // C[n][k] -> nCk
void comb_table(int N) {
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 or j == i) {
        C[i][j] = 1LL;
      } else {
        C[i][j] = (C[i-1][j-1] + C[i-1][j]);
      }
    }
  }
}






int main() {
  ios::sync_with_stdio(false);

  int N, A, B;
  cin >> N >> A >> B;

  vector<ll> v(N);
  for(int i = 0; i < N; i++) { cin >> v[i]; }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  ll min_num = v[A-1];
  int mins_used = 0;

  ll sum = 0;
  for(int i = 0; i < A; i++) {
    sum += v[i];
    if( min_num == v[i] ) {
      mins_used++;
    }
  }
  double max_avr = (double)sum / A;

  int mins = 0;
  for( int i = 0; i < N; i++ ) {
    if( v[i] < min_num ) break;
    if( min_num == v[i] ) mins++;
  }

  // debug(min_num);
  // debug(mins);
  // debug(mins_used);

  cout << fixed;
  cout << max_avr << "\n";

  comb_table(N);

  if(min_num == max_avr) {
    cout << fixed;
    ll ans = 0;
    for(int i = A; i <= B; i++) {
      // ans += choose(mins, i);
      ans += C[mins][i];
    }
    cout << ans << "\n";
  } else {
    // cout << choose(mins, mins_used) << "\n";
    cout << C[mins][mins_used] << "\n";
  }


  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int r, d, x;
    cin >> r >> d >> x;

    rep(i, 10){
        x = r * x - d;
        OP(x);
    }
}


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

const int64_t mod = 1000000007;

int64_t fact(int n) {
    int64_t ans = 1;
    while (n > 1) { ans = ans * n-- % mod; }
    return ans;
}

int main() {
    int n;

    cin >> n;
    cout << fact(n) << endl;
}


Measured memory_bytes: 256
#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<int> a(N),b(N),c(N);
    rep(i,N) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int>> dp(N, vector<int>(3));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    rep(i,N-1) {
        dp[i+1][0] = max(dp[i][1],dp[i][2]) + a[i+1];
        dp[i+1][1] = max(dp[i][2],dp[i][0]) + b[i+1];
        dp[i+1][2] = max(dp[i][0],dp[i][1]) + c[i+1];
    }

    cout << max({dp[N-1][0],dp[N-1][1],dp[N-1][2]}) << endl;
}


Measured memory_bytes: 6912
N = int(input())
S = []
C = []
for _ in range(N):
  s, c = input().split()
  C.append(int(c))
  S.append(tuple(ord(c) - ord('a') for c in s))
#print(S)
INF = 10**30
dp = {}
def min_cost(l, r):
  if (l, r) in dp:
    return dp[(l, r)]
  if l and l == l[::-1]:
    dp[(l, r)] = 0
    return dp[(l, r)]
  if r and r == r[::-1]:
    dp[(l, r)] = 0
    return dp[(l, r)]
    
  #print(l, r)
  dp[(l, r)] = INF
  if not l:
    for c, s in zip(C, S):
      if len(s) > len(r):
        if s[len(s)-len(r):] == r:
          dp[(l, r)] = min(dp[(l, r)], c + min_cost(s[:len(s)-len(r)][::-1], () ))
      elif len(s) == len(r):
        if s == r:
          dp[(l, r)] = min(dp[(l, r)], c)
      else:
        if s == r[len(r)-len(s):]:
          dp[(l, r)] = min(dp[(l, r)], c + min_cost((), r[:len(r)-len(s)]))
        
  if not r:
    for c, s in zip(C, S):
      if len(s) > len(l):
        #print('equal', s[:len(l)] , l)
        if s[:len(l)] == l:
          dp[(l, r)] = min(dp[(l, r)], c + min_cost((), s[len(l):][::-1] ))
      elif len(s) == len(l):
        if s == l:
          dp[(l, r)] = min(dp[(l, r)], c)
      else:
        if s == l[:len(s)]:
          dp[(l, r)] = min(dp[(l, r)], c + min_cost(l[len(s):], ()))
        
  return dp[(l, r)]
        
  
m = min_cost((), ())
for s, c in zip(S, C):
  if s == s[::-1]:
    m = min(m, c)
if m == INF:
  print(-1)
else:
  print(m)

Measured memory_bytes: 70508
from collections import defaultdict


def main():
    num_box, num_people = map(int, input().split())
    data = list(map(int, input().split()))

    dp = defaultdict(int)
    dp[0] += 1
    count = 0
    for i in range(num_box):
        count += data[i]
        count %= num_people
        dp[count] += 1

    ans = 0
    for ele in dp.values():
        if ele >= 2:
            ans += (ele - 1) * ele // 2

    print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 14912
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    a=0
    m=0
    do i=1,n
        if(x(i)==i)then
            if(a==0)then
                a=1
            else
                a=0
                m=m+1
            end if
        elseif(a==1)then
            a=0
            m=m+1
        end if
    end do
    if(a==1)then
        m=m+1
    end if

            
    write(*,*) m
  
    stop
end program sample
  



Measured memory_bytes: 3824
n = int(input())
a = sorted(list(map(int, input().split())))
if n % 2 == 1 and a[0] != 0:
    print(0)
    exit()
for i in range(n % 2, n, 2):
    if a[i] != a[i + 1] or a[i] != i + 1:
        print(0)
        exit()
print(2 ** (n // 2) % (10 ** 9 + 7))

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    int num = 0;
    for(int i=1; i<=n; i++){
        int cost = i%10 + (i/10)%10 + (i/100)%10 + (i/1000)%10 + (i/10000)%10;
        if(a <= cost && cost <= b){
            num += i;
        }
    }
    cout << num << endl;
  
    return 0;
}


Measured memory_bytes: 256
var
       x,y,g:char;
       m,n:longint;
 begin
       read(x,g,y);
       if x='A' then m:=10;
       if x='B' then m:=11;
       if x='C' then m:=12;
       if x='D' then m:=13;
       if x='E' then m:=14;
       if x='F' then m:=15;
       if Y='A' then n:=10;
       if Y='B' then n:=11;
       if Y='C' then n:=12;
       if Y='D' then n:=13;
       if Y='E' then n:=14;
       if Y='F' then n:=15;
       IF m>n then write('>') else if m<n then write('<') else write('=');
 end.

Measured memory_bytes: 128
s=list(input().split())

a=int(s[0])
b=int(s[1])
a_b=''
b_a=''

for i in range(b):#文字aをb回記載
 a_b+=s[0]


for i in range(a):#文字bをa回記載
 b_a+=s[1]

if a<b:
        print(a_b)
else:
        print(b_a)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long int n,a[200005],cnt[200005],p[200005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
	    cin>>a[i];
	    if(i>a[i]){
	        cnt[i-a[i]]++;
	    }
	}
	for(int i=1;i<=n;i++){
	    if(i+a[i]<=2e5){
	        p[i+a[i]]++;
	    }
	}
	long long ans=0;
	for(int i=1;i<=2e5;i++){
	    ans+=cnt[i]*p[i];
	}
	cout<<ans;
}


Measured memory_bytes: 8316
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x = max(x, y)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    int n;
    cin >> n;
    vector<int> d0(n), d1(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        int u = x + y;
        int v = x - y;
        d0[i] = v;
        d1[i] = u;
    }
    sort(rall(d1));
    sort(rall(d0));
    int a = d1[0] - d1[n-1];
    int b = d0[0] - d0[n-1];
    cout << max(a, b) << endl;
    return 0;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        int n, l; sii(n, l);
        vector<string> v(n);
        FOR(i, 0, n) cin >> v[i];
        sort(all(v));
        string ans = "";
        FOR(i, 0, n) ans += v[i];
        //vout(v);
        cout << ans << endl;

    return 0;
}

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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int count = 0;
    rp(i, 0, s.size()){
        if(s.at(i) == 'A' or s.at(i) == 'G' or s.at(i) == 'C' or s.at(i) == 'T') count++;
        else{
            chmax(ans, count);
            count = 0;
        }
    }
    chmax(ans, count);
    cout << ans << endl;
    return 0;
}



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

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

    vector<int> s(n, 0);
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        if (i == 0) {
            s[i] = tmp;
        } else {
            s[i] = s[i-1] + tmp;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int s1 = s[i];
        int s2 = s[n-1] - s1;
        if (i == 0) {
            ans = abs(s1 - s2);
        } else {
            if (abs(s1 - s2) < ans) {
                ans = abs(s1 - s2);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200010;

char s[N];
int a[N];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	scanf("%s", s + 1);
	
	Rep(i, n) a[i] = (s[i] == 'A');
	
	bool flag = false;
	int i = 1;
	
	while (i <= n) {
		if (!k) {
			for (int j = i; j <= n; j ++){
				if ((!(i & 1)) ^ a[j]) printf("A");
				else printf("B");
			}
			Rep(j, i - 1){
				if ((j & 1) ^ (i & 1)) printf("A");
				else printf("B");
			}
			printf("\n");
			flag = true; break;
		}
		if (a[i] ^ (!(i & 1))) a[i] ^= 1;
		else i ++;
		k --;
	}
	
	if (!flag) {
		if (!(n & 1)) {
			Rep(i, n){
				if (i & 1) printf("B");
				else printf("A");
			}
			printf("\n");
		}
		else {
			if (k & 1) printf("B");
			else printf("A");
			Rep(i, n - 1){
				if (i & 1) printf("B");
				else printf("A");
			}
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1280
function Main (input) {
    input = input.split("\n");
    tmp = input[0].split(" ");
    var a = parseInt(tmp[0], 10);
    var b = parseInt(tmp[1], 10);
    var k = parseInt(tmp[2], 10);
    //console.log(input[0]);
    //console.log(a);
    if (a >= k) {
        console.log('%d %d', a - k, b);
    } else if(b>=k-a){
        console.log('%d %d', 0, b - (k - a));
    } else {
        console.log('%d %d', 0, 0);
    }
  }
   
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//ctrl+Dで入力終

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;


struct dsu0 {
    vector<int> par, siz;
    int n;
    int cc;
    int largest;
    void init(int n) {
	assert(n>0);
	this->n=n;
	cc=n;
	par.resize(n+10);siz.resize(n+10);
	for (int i=0; i<n; i++) par[i]=i,siz[i]=1;
	largest=1;
    }
    int parent(int x) {
	assert(x>=0 && x<n);
	return par[x]==x?x:par[x]=parent(par[x]);
    }
    bool join(int x, int y) {
	x=parent(x);y=parent(y);
	if (x==y) return false;
	cc--;
	if (siz[x]<siz[y]) swap(x,y);
	siz[x]+=siz[y];par[y]=x;
	largest=max(largest,siz[x]);
	return true;
    }
};

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

int n, m;
int u[maxn], v[maxn];
ll w[maxn];

ll x;

vector<int> ord;

ll st(int mustUse=-1) {
    dsu0 dsu;
    dsu.init(n);
    ll tot = 0;
    if (~mustUse) {
	tot += w[mustUse];
	dsu.join(u[mustUse], v[mustUse]);
    }
    for (int i: ord) {
	if (dsu.join(u[i],v[i])) {
	    tot += w[i];
	}
    }

    return tot;
}

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

    cin>>n>>m;
    cin>>x;
    for (int i=0; i<m; i++) {
	cin>>u[i]>>v[i]>>w[i];
	--u[i]; --v[i];
    }
    
    ord.resize(m);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i, int j) {
	    return w[i]<w[j];
	});


    ll mst = st();
    if (mst > x) {
	out(0);
    }

    
    ll slack = 0;
    ll target = 0;

    for (int i=0; i<m; i++) {
	ll res = st(i);
	if (res == x) {
	    target++;
	} else if (res > x) {
	    slack++;
	}
    }

    // watch(slack);
    // watch(target);

    if (target == 0) {
	out(0);
    }


    
    if (mst == x) {
	// Any edge that is part of an MST can be whatever colors, as long as not all same
	ll res = pw(2, slack) * (pw(2, target)-2) % mod;
	res %= mod;
	res += mod;
	res %= mod;
	out(res);
    }

    assert(x > mst);


    // X-ST can be BBBBBB..W or WWWWW..B, then slacker edges can be whatever
    //   (B or W)    edges on X-ST can be mostly whatever, but at least 1 must be different from the rest
    ll res = 2  *  (pw(2, target)-1)%mod  *  pw(2, slack) % mod;

    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;
    
    return 0;
}


// 1. if mst<x, all edges of mst must be same color, otherwise we'd pick it over x-st/
// 2. mst needs to be 1 edge tweak away from x-st. this is because if one of the "tweaked" edges is opposite color,
// then we'd just pick that "semi-tweaked" st instead of tweaking all the way to the full x-st


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	while(a>0&&c>0){
    	c = c - b;
      	if(c<=0){break;}
      	a = a - d;
    }
  	if(c<=0){cout<<"Yes"<<endl;}
  	else cout << "No"<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		double d = Double.parseDouble(sc.next());
		double t = Double.parseDouble(sc.next());
		double s = Double.parseDouble(sc.next());
		
		double result = (d/t) ;
		if (result <= s ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
			
		}
	}	

}


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

int main() {
  string ans;
  int Q;
  cin >> ans >> Q;
  bool rev = false;
  int L = ans.length();

  for (int i = 0; i < Q; i++) {
    int t;
    cin >> t;
    if (t == 1) rev ^= 1;

    if (t == 2) {
      if (ans.length() == L && rev == 1) {
        reverse(ans.begin(), ans.end());
        rev = 0;
      }
      int f;
      string c;
      cin >> f >> c;

      if ((f - 1) ^ rev) {
        ans += c;
      } else {
        ans.insert(0, c);
      }
    }
  }

  if (ans.length() == L && rev == 1) {
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
  }

  if (!rev) {
    cout << ans << endl;
  } else if (rev == 1) {
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 900
local mfl, mma = math.floor, math.max
local n = io.read("*n")
local f = {}
for i = 1, n * 10 do
  f[i] = (io.read("*n") == 1)
end
local p = {}
for i = 1, n * 11 do
  p[i] = io.read("*n")
end

local score = {}
for i = 1, 1023 do
  local cnt = {}
  local ti = i
  for k = 1, n do cnt[k] = 1 end
  for j = 1, 10 do
    local flg = ti % 2
    ti = mfl(ti / 2)
    if flg == 1 then
      for k = 1, n do
        if f[(k - 1) * 10 + j] then
          cnt[k] = cnt[k] + 1
        end
      end
    end
  end
  score[i] = 0
  for k = 1, n do
    score[i] = score[i] + p[(k - 1) * 11 + cnt[k]]
  end
end
local ret = score[1]
for i = 2, 1023 do
  ret = mma(ret, score[i])
end
print(ret)


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

int main() {

	int s;
	cin >> s;

	int front = s / 100;
	int rear  = s % 100;

	if(front > 0 && rear > 0 && front <= 12 && rear <= 12){
		cout << "AMBIGUOUS" << endl;
	}
	else if(front > 0 && front <= 12){
		cout << "MMYY" << endl;
	}
	else if(rear > 0 && rear <= 12){
		cout << "YYMM" << endl;
	}
	else{
		cout << "NA" << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> pr;
    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        pr.push_back(make_pair(a, b));
    }

    sort(all(pr));

    ll money = 0;
    ll num = 0;
    ll i = 0;
    while (num < m) {
        money += pr[i].first * pr[i].second;
        num += pr[i].second;
        i++;
    }

    if (num == m) {
        cout << money << endl;
        return 0;
    }

    i--;
    while (num != m) {
        money -= pr[i].first;
        num--;
    }

    cout << money << endl;
    return 0;
}


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

int main() {
	int a, b;
	while (1){
		cin >> a >> b;
		if (a == 0 && b == 0){
			break;
		}
		else if (a <= b){
			cout << a << " " << b << endl;
		}
		else if (a > b){
			cout << b << " " << a << endl;
		}
	}
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,a;
	cin>>s>>a;
	for(int i=0;i<s.length();i++){
		cout<<s[i];
		if(i<a.length()){
			cout<<a[i];
		}
	}
	return 0;
}

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

int main() {
  int a, b;
  cin >> a; //N円支払う。
  cin >> b; //1円硬貨の所持枚数
  if (a % 500 == 0) {
    cout << "Yes" << endl;
  }
  else if (a % 500 < b) {
    cout << "Yes" << endl;
  }
   else if (a % 500 > b) {
    cout << "No" << endl;
  }
}


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

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;


void check( int val ){
	
	cout << val << endl;
}

int main( int argc , char ** argv ){
	
	int a , b , c;
	cin >> a >> b >> c;

	if(a != b && a != c && b != c){
		cout << 3 << endl;
		
	}
	else if(a == b && b == c){
		cout << 1 << endl;
	}
	else if(a == b || a == c || b == c){
		cout << 2 << endl;
	}
	else {
		cout << "?" << endl;
	}

}



Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        s: String
    };

    let v = vec!["Sunny", "Cloudy", "Rainy"];
    let i = v.iter().position(|&x| x == s).unwrap();
    let res = v[(i + 1) % 3];
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=51 ;
int main()
{
   fast ;
   ll tests=1 ;
   //cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
     ///cout<<"Case #"<<testcase<<": " ;
     ///Read ,Think and Test Properly,then code
     ll n,m ;
     cin>>n>>m ;
     ll ans=0 ;
     ans+=(n*(n-1))/2 ;
     ans+=(m*(m-1))/2 ;


     cout<<ans ;


   }
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> pos(n);
  for (int i = 0; i < n; i++){
    cin >> pos.at(i);
    pos.at(i) = (pos.at(i) + 1);
  }
  double sum = 0;
  for (int i = 0; i < k; i++){
    sum += pos.at(i);
  }
  double max = sum;
  for (int i = k; i < n; i++){
    sum -= pos.at(i-k);
    sum += pos.at(i);
    if (max < sum){
      max = sum;
    }
  }
  cout << fixed;
  cout << setprecision(7) << (max / 2) << endl;
  
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    int X_pre = ceil((double) N / 1.08);
    int N_pre = X_pre * 1.08;
    if (N == N_pre) {
        cout << X_pre << "\n";
    }
    else {
        cout << ":(" << "\n";
    }
    return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
  if(n<=k){
    cout<<0<<endl;
    return 0;
  }
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	ll ans = 0;
	for (int i = n - 1; i >= n - k; i--) {
		h[i] = 0;
	}
	for (int i = 0; i <= n - k - 1; i++) ans += h[i];
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;
int n,i,x;
int s[52];
string num,k;
unordered_map <string, int> m;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>num>>x;
        s[i]=s[i-1]+x;
        m[num]=i;
    }
    cin>>k;
    cout<<s[n]-s[m[k]];
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int num[9] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

void chmax(string &a, string b) {
    if (a == "-") a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

int main()
{
  int N,M;
  cin>>N>>M;
  vector <int> A(M);

  for (int i=0;i<M;i++) cin>>A[i];
  for (int i = 0; i < 11000; ++i) dp[i] = "-";
  dp[0] = "";

  for(int i=0;i<=N;i++){
    if(dp[i]=="-") continue;
    for(auto a:A){
      string b = dp[i]+char('0'+a);
      chmax(dp[i+num[a-1]],b);
    }
   }
  cout<<dp[N]<<endl;
}


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

int main() {
  double a,b,x, ans;
  cin >> a >> b>> x ;
  
  if(a*a*b == x){
    ans = 0;
  }else if(x>=a*a*b*0.5){
  
    double h = x/a/a;
    double d = b-h;

    ans = atan(d/(a/2)) * 180 / M_PI;
    //cout<<h<<endl;
    //cout<<d<<endl;
  }else{
    double c = 2*x/(a*b);
    ans = atan(b/c) * 180 / M_PI;
  }
  cout << std::setprecision(15) << ans << endl;
  //cout << std::setprecision(12) << M_PI << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

vector<pair<long,long> > PrimeFactorize(llong N){
    
    llong prime=2;
    llong index=0;
    vector<pair<long,long> > P;
    pair<long,long> X;
    llong NUM=N;
    for(int prime=2; prime*prime<=NUM; prime++){
        while(N%prime==0){
            N = N / prime;
            index = index + 1;
        }
        if(index!=0){
            X.first = prime;
            X.second = index;
            P.push_back(X);
        }
        index = 0;
    }

    if(N!=1){
        X.first = N;
        X.second = 1;
        P.push_back(X);
    }
    return P;
}

int main(){
    llong X;
    llong n;
    cin >> X;
    for(int A=0; A<=300; A++){
        for(int B=-300; B<=300; B++){
            n = A*A*A*A*A - B*B*B*B*B;
            if(X==n){
                cout << A << " " << B << endl;
                exit(0);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3200
N, Q = map(int, input().split())
S = input()

LR = [list(map(int, input().split())) for _ in range(Q)]

cnt_lst = [0]
cnt = 0
for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        cnt += 1

    cnt_lst.append(cnt)


for l, r in LR:
    print(cnt_lst[r - 1] - cnt_lst[l - 1])


Measured memory_bytes: 29744
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pii make_pair
int ceil(int a, int b) { if(a%b==0) return a/b; else return a/b+1; }
bool checkbit(int pos, int mask) { return mask&(1<<pos); }
int turnon(int pos, int mask) { return mask|(1<<pos); }

main()
{
    int n, d, cnt=0;
    double x, y;
    cin>>n>>d;
    for(int i=0; i<n; i++) {
        cin>>x>>y;
        double k=sqrt(x*x+y*y);
        if(k<=d) cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 3780
l=[]
while 1:
    l_=[int(x) for x in input().split()]
    if l_==[-1,-1,-1]:
        break
    l.append(l_)
for i in l:
    if i[0]==-1 or i[1]==-1:
        print("F")
    elif i[0]+i[1]>=80:
        print("A")
    elif i[0]+i[1]<80 and i[0]+i[1]>=65:
        print("B")
    elif i[0]+i[1]<65 and i[0]+i[1]>=50:
        print("C")
    elif i[0]+i[1]<50 and i[0]+i[1]>=30 and i[2]>=50:
        print("C")
    elif i[0]+i[1]<50 and i[0]+i[1]>=30 and i[2]<50:
        print("D")
    else:
        print("F")


Measured memory_bytes: 5608
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N;
    cin >> N;

    vector<int> two(51);
    two[0] = 1;
    REP(i, 50) {
        two[i + 1] = 2 * two[i];
    }

    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int x = 0;
    REP(i, N) x ^= a[i];

    int ans = 0;
    REV(k, 30, 1) {
        if (((x >> (k - 1)) & 1) == 0) continue;
        REP(i, N) {
            if ((a[i] ^ a[i] - 1) == two[k] - 1) {
                ans++;
                x = x ^ a[i] ^ (a[i] - 1);
                break;
            }
        }
    }
    if (x != 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int H,W; cin >>H>>W;
    vector<string> g(H); cin >> g;
    vvi c(H, vi(W, 0));

    int l, r;
    rep(i, H) {
        l = r = -1;
        rep(j, W) {
            if (g[i][j]=='.') {
                if (l == -1) l = j;
                r = j;
            }
            if ((g[i][j]=='#' || j==W-1) && l != -1) {
                for (int k = l; k <= r; k++) c[i][k] = r-l+1;
                l = r = -1;
            }
        }
    }

    int ans = 0;

    int u, d;
    rep(j, W) {
        u = d = -1;
        rep(i, H) {
            if (g[i][j]=='.') {
                if (u == -1) u = i;
                d = i;
            }
            if ((g[i][j]=='#' || i==H-1) && u != -1) {
                for (int k = u; k <= d; k++) {
                    c[k][j] += d-u;
                    chmax(ans, c[k][j]);
                }
                u = d = -1;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 20096