akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<limits.h>
#include <stdlib.h>
#include<string.h>

int main(){
	int n;
	scanf("%d",&n);
	char *input=(char*)malloc(n*(sizeof(int)+sizeof(' ') ) );
	scanf("\n%[^\n]",input);
	char *p=input;
	int digitcount=0;
	int Nums[n];
	for(int i=0;i<n;i++){
		for(digitcount=0;*(p+digitcount)!=0x20&&*(p+digitcount)!=0x00;digitcount++){
			//空白区切りまでポインタのインデックスを進める
		}
		char num[11]={0};
		strncpy(num,p,digitcount);
		int number =atoi(num);
		Nums[i]=number;
		p+=digitcount+1;
	}


	for(int i=n-1;i>=0;i--){
		printf("%d",Nums[i]);
		if(i!=0)printf(" ");
	}
	
	puts("");
	
	return 0;
}




Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int maxN = 10010; 
const int INF = 1000000000;

int n,k;
int main()
{
	scanf("%d %d",&n,&k);
	if(n%k == 0)
	{
		puts("0");
	}
	else
	{
		puts("1");
	}
	return 0;
}

Measured memory_bytes: 256
import sys


def main():
    N = int(sys.stdin.readline())
    A = [int(x) for x in sys.stdin.readline().split()]

    C = [0] * (max(A) + 1)

    # 個数を数える
    for a in A:
        C[a] += 1

    for i in range(1, len(C)):
        C[i] = C[i] + C[i - 1]

    B = [None] * N

    # 個数に基づいて新しい配列を設定する

    for a in reversed(A):
        # print(a, C[a], C)
        B[C[a] - 1] = a
        C[a] -= 1

    print(" ".join(list(str(x) for x in B)))


main()



Measured memory_bytes: 240856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx-sx;
  int dy = ty-sy;
  
  string S;
  for(int i = 1;i<=dx;i++){
    S += 'R';
  }
  for(int i = 1;i<=dy;i++){
    S += 'U';
  }
  for(int i = 1;i<=dx;i++){
    S += 'L';
  }
  for(int i = 1;i<=dy;i++){
    S += 'D';
  }
  S += 'D';
  
  for(int i = 1;i<=dx+1;i++){
    S += 'R';
  }
  for(int i = 1;i<=dy+1;i++){
    S += 'U';
  }
  S += 'L';
  
  S += 'U';
  for(int i = 1;i<=dx+1;i++){
    S += 'L';
  }
  for(int i = 1;i<=dy+1;i++){
    S += 'D';
  }
  S += 'R';
  
  cout << S << endl;
  
}

Measured memory_bytes: 256
(A, B, C, K) = list(map(int, input().split()))
items = [
    (A, 1),
    (B, 0),
    (C, -1)
]

_sum = 0
k = K
for num_cards, val in items:
    if num_cards <= k:
        num = num_cards
        k -= num_cards
    else:
        num = k
        k = 0
    _sum += (val * num)
    if k == 0:
        break

print(_sum)


Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : " ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ';
constexpr char newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    int m = 61;
    V<V<int>> to(m, V<int>(n, -1));
    for (int i = 0; i < n; i++) {
        cin >> to[0][i];
        --to[0][i];
    }
    for (int i = 1; i < m; i++) {
        for (int j = 0; j < n; j++) {
            to[i][j] = to[i - 1][to[i - 1][j]];
        }
    }
    int now = 0;
    for (int i = m - 1; i >= 0; i--) {
        if (kbit(k, i)) {
            now = to[i][now];
        }
    }
    cout << now + 1 << newl;
}

Measured memory_bytes: 51780
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef set <int> se;
typedef long long ll;
#define endl "\n"

#define mod 1000000007


int main()
{
 
 ll n;
 cin>>n;
  ll arr[n];
 for(int i  = 0;i<n;i++) {
     cin>>arr[i];
}
    ll sum[n]; 
    sum[n - 1] = arr[n - 1];  //
    for (int i = n - 2; i >= 0; i--)  
        sum[i] = (sum[i + 1] + arr[i])%mod; 
      
    ll res = 0; 
    for (int i = 0; i < n - 1; i++)  
        res = (res%mod+ (sum[i + 1] * arr[i])%mod)%mod; 
 

 
 cout<<res<<endl;

return 0;
   
}

Measured memory_bytes: 6740
n = int(input())
s = list(input())
a_li = []
b_li = []
c_li = []
for i,ss in enumerate(s):
    if ss == 'R':
        a_li.append(i+1)
    elif ss == 'G':
        b_li.append(i+1)
    else:
        c_li.append(i+1)
count = 0
for i in range(1,n+1):
    for d in range(1,n):
        if i + 2*d > n:
            break
        if s[i-1] != s[i+d-1] and s[i+d-1] != s[i+2*d-1] and s[i-1] != s[i+2*d-1]:
            count += 1
#print(len(a_li),len(b_li),len(c_li),count)
#print(count)
print(len(a_li)*len(b_li)*len(c_li)-count)


Measured memory_bytes: 9216
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 1e6 + 100, T = 4, OO = 1e9 + 100, M = 1e9 + 7, P = 6151, SQ = 50, lg = 21;
typedef pair <int, int> pii;

int is(int x) {
	if(x == 1)
		return 1;
	x /= 2;
	return (is(x) * 2 + 1);
}

int32_t main() {
	use_fast;
	int n;
	cin >> n;
	cout << is(n) << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long A, long long B, long long C){
    vector<int> n(3);
    n[0] = A;
    n[1] = B;
    n[2] = C;
    sort(n.begin(), n.end(), greater<int>());
    cout << n[0] * 10 + n[1] + n[2] << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

using namespace std;

#define ll long long

int main(void){
    double l;
    cin >> l;

    l = l/3.0;
    printf("%.9lf\n", l*l*l);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};

bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy < b.enemy;
}

bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget > b.budget;
	
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}

		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		while( !status.empty() ) {
			status.pop() ;
		}	

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
					if ( check( i ) ) {
						ncopy();
						add(i);
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 4632
n, q = map(int, input().split())
s = input()

d = [0]*n
for i in range(1, n):
    d[i] += d[i-1]
    if s[i-1] == 'A' and s[i] == 'C':
        d[i] += 1

for _ in range(q):
    l, r = map(int, input().split())
    print(d[r-1] - d[l-1])

Measured memory_bytes: 7748
#include <iostream>
#include <string>
#include <string.h>
#include <strings.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s2="";
    string s;
    cin>>s;
    int v=s.length();

cout<<s.at(0)<<v-2<<s.at(v-1);
    return 0;
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = get!(i32, i32, i32);
    println!("{}", if b-a == c-b { "YES" } else { "NO" });
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;

template<typename T,typename C>
ostream& operator<<(ostream& os,const pair<T,C> p){
    cout << p.first <<" "<< p.second << endl;
}

/*
template<typename T,typename C>
pair<T,C>& operator+=(const pair<T,C>& p,const pair<T,C>& t){
   p.second += t.second;
   return *p;
}
*/

int main(){
  string s;
  cin >> s;
  auto rl = vector<pair<char,int>>();
  char before=s[0];
  int c=1;
  for (int i = 1; i < s.size(); i++)
  {
      if(before == s[i]){    
          c++;
      }else{
          rl.push_back(make_pair(before,c));
          c=1;
      }
      before=s[i];
  }
  rl.push_back(make_pair(before,c));
  
  auto ans = vector<int>(s.size(),0);
  
  for (size_t i = 0,num=0; i!=string::npos; i++,num+=2)
  {
      i= s.find("RL",i);
      if(i==string::npos) {
        break;
      }
      ans[i+1]+=rl[num].second/2;
      ans[i]+=rl[num].second-rl[num].second/2;    
      ans[i]+=rl[num+1].second/2;
      ans[i+1]+=rl[num+1].second-rl[num+1].second/2;
  }

  copy(ans.begin(),ans.end(),ostream_iterator<int>(cout," "));
  
    return 0;
}

Measured memory_bytes: 1780
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n, k, h,ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) 
	{ 
		cin >> h;
		if (h >= k) { ans++; }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [1 if i == "E" else 0 for i in input()]

dp = [0] * n

# dp[0] = n - 1 - sum(s[1:])
dp[0] = sum(s[1:])

# print(s, dp)

for i in range(1, n):
    if s[i - 1] == 0:
        dp[i] = dp[i - 1] + 1 - s[i]
    else:
        dp[i] = dp[i - 1] - s[i]

print(min(dp))


Measured memory_bytes: 17648
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long h,n;cin>>h>>n;
  long long a,ans=0;

  for(int i=0;i<n;i++){
    cin>>a;
    ans+=a;
  }
  if(ans<h)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] Input = Console.ReadLine().Split(' ');
        int[] h = new int[N];
        int hMax = 0;
        int answer = 0;

        for (int i = 0; i < N; i++)
        {
            h[i] = int.Parse(Input[i]);
            if (hMax < h[i]) hMax = h[i];
        }
        //入力完了
        int tmp0;
        int tmp1;

        bool check0;
        bool check1;

        for (int i = 0; i < hMax; i++)
        {
            //0の数記録しとく
            tmp0 = 0;
            tmp1 = 0;

            check0 = false;
            check1 = false;
            for (int j = 0; j < N; j++)
            {
                if (h[j] == 0 && check0 == false)
                {
                    check0 = true;
                    check1 = false;
                    tmp0++;
                }
                if (h[j] >= 1 && check1 == false)
                {
                    check1 = true;
                    check0 = false;
                    tmp1++;
                }
                if (h[j] >= 1) h[j]--;
            }
            answer += tmp1;
        }

        Console.WriteLine(answer);
    }
    
}

Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int,int> P;

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

int main(){
	long a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	long ans=0,ans2=0;
	if(c*2<=a+b){
		if(x<y){
			ans+=c*2*x;
			ans+=b*(y-x);
			ans2=c*2*y;
		}
		else{
			ans+=c*2*y;
			ans+=a*(x-y);
			ans2=c*2*x;
		}
		cout<<min(ans,ans2);
		return 0;
	}
	else{
		ans=a*x+b*y;
	}
	cout<<ans;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
s = sum(W)
ans = 10 ** 10
sum_up = 0
sum_end = s
for i in range(N):
  sum_up += W[i]
  sum_end -= W[i]
  ans = min(ans, abs(sum_end-sum_up))
print(ans)


Measured memory_bytes: 38256
#include<stdio.h>

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key){
        i++;
    }
    return i != n;
}

int main(){
    int i,n,A[10000+1],q,key,sum = 0;

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

    scanf("%d",&q);
    for(i = 0; i< q; i++){
        scanf("%d",&key);
        if(search(A,n,key))sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 2768
import sys
count = 0

def merge_sort(arr):
	merge_sort_(arr, 0, len(arr))

def merge_sort_(arr, left, right):
	if left + 1 < right:
		mid = int(left + (right - left) / 2)
		merge_sort_(arr, left, mid)
		merge_sort_(arr, mid, right)
		merge(arr, left, mid, right)

def merge(arr, left, mid, right):
	global count
	
	n1 = mid - left
	n2 = right - mid
	
#	L = [0] * (n1 + 1)
#	R = [0] * (n2 + 1)
#	for i in range(n1):
#		L[i] = arr[left + i]
#	for i in range(n2):3
#		R[i] = arr[mid + i]
#	L[n1] = R[n2] = sys.maxsize
	
	L = arr[left:left + n1]
	R = arr[mid:mid + n2]
	L.append(sys.maxsize)
	R.append(sys.maxsize)

	i = j = 0
	for k in range(left, right):
		count += 1
		if L[i] <= R[j]:
			arr[k] = L[i]
			i += 1
		else:
			arr[k] = R[j]
			j += 1

n = int(input())
arr = list(map(int, input().split()))
merge_sort(arr)
print(" ".join(map(str, arr)))
#for i in range(n):
#	print(arr[i], end="")
#	if i != n - 1:
#		print(" ", end="")
#print()
print(count)


Measured memory_bytes: 66588
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


const int maxn = 405;
int n;
ll a[maxn], dp[maxn][maxn], ps[maxn];
ll solve(int l, int r){ //[L, R]
	if (l == r) return 0;
	if (dp[l][r] != -1) return dp[l][r];
	ll ret = 1e18;
	ll sum = ps[r]-ps[l-1];
	for(int i = l; i<r; i++) ret = min(ret, solve(l, i) + solve(i+1, r) + sum);
	return dp[l][r] = ret;
}


int main(){
	memset(dp, -1, sizeof(dp));
	scanf("%d", &n);
	for(int i = 1; i<=n; i++) scanf("%lld", &ps[i]), ps[i]+= ps[i-1]; 
	ll ans = solve(1, n);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1536
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var M = int.Parse(inputs[1]);
        var Q = int.Parse(inputs[2]);
        var x = new int[N + 1, N + 1];
        for (int i = 0; i < M; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            var l = int.Parse(inputs[0]);
            var r = int.Parse(inputs[1]);
            x[l, r]++;
        }

        var c = new int[N + 1, N + 1];
        for (int i = 1; i <= N; i++)
        {
            for (int j = 1; j <= N; j++)
            {
                c[i, j] = c[i, j - 1] + x[i, j];
            }
        }

        for (int i = 1; i <= Q; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            var p = int.Parse(inputs[0]);
            var q = int.Parse(inputs[1]);
            int sum = 0;
            for (int j = p; j <= q; j++)
                sum += c[j, q] - c[j, p - 1];
            Console.WriteLine(sum);
        }
    }

}



Measured memory_bytes: 17436
def era(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = num**0.5

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

Q=int(input())
l=[]
r=[]
for _ in range(Q):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)
N=max(r)
input_list=era(N+1)
Prime=set([i for i, b in enumerate(input_list) if b == True])
cnt=[0,0,0]
for i in range(3,N+1):
    cnt.append(cnt[-1])
    if i%2==1 and i in Prime and (i+1)//2 in Prime:
        cnt[i]+=1
#print(Prime)
#print(cnt)
for j in range(Q):
    print(cnt[r[j]]-cnt[l[j]-1])

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

int main(){
  int a, b, c, count;
  cin >> a >> b >> c;
  count = 0;
  for (int i = a; i < b+1; i++) {
    if (c == c/i*i) {
      count++;
    }
  }
  cout << count << endl;
}


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

int main() {
  char s[3];
  cin >> s;
  
  if (s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }
    else if (s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int k,p;
  for(int i=0;i<n;i++){
    cin >> k >> p;
    if(k%p!=0)
      cout << k % p << endl;
    else 
      cout << p << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
int a,b,c,k;
int main(void)
{
    cin >> a >> b >> c >> k;
    int m,res=0;
    res = a+b+c;
    m = max(a,b);
    m = max(m,c);
    res -= m;
    for(int i=0; i<k; i++){
        m = m*2;
    }
    res += m;
    cout << res;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Circle(void) {

	int r; cin >> r;
	cout << r * r << flush;
	return;
}

int main(void) {
	
	A_Circle();
	return 0;
}


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

a, b, x = map(int, input().split())

area = x / a

if (a * b / 2) == area:
    # print("just")
    θ = math.atan(b / a)
    # print(θ)
elif (a * b / 2) > area:
    # print("near empty")
    c = area / b * 2
    θ = math.atan(b / c)
    # print(θ)
elif (a * b / 2) < area:
    # print("fill")
    # 元々の水面の高さ
    h = x / (a * a)
    # 溢れるまで傾けた時の台形の短い部分のながさ
    # area == (d + b) * a / 2
    d = (area / (a / 2)) - b
    # 元々の水面から溢れるまで(bまで)の距離
    increment = h - d
    # print("h:{0}, d:{1} increment:{2}".format(h, d, increment))
    θ = math.atan(increment / (a / 2))
    # print(θ)

print(math.degrees(θ))


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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    int N,A[100010]={},f[100010]={};
    cin>>N;

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

    int next = 1;

    for(int i=1;i<=N+1;i++){
        if(A[next]==2){
            cout<<i<<endl;
            return 0;
            //2に到達
        }

        if(f[next]==1){
            cout<<-1<<endl;
            return 0;
        }

        f[next]=1;
        next=A[next];
    }

    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 1024
# ABC045
from collections import deque
S_A = deque(input())
S_B = deque(input())
S_C = deque(input())

# 最初はAから
next_turn = 'a'

while True:
    # 勝利判定
    if len(S_A) == 0 and next_turn == 'a':
        print("A")
        exit()
    elif len(S_B) == 0 and next_turn == 'b':
        print("B")
        exit()
    elif len(S_C) == 0 and next_turn == 'c':
        print("C")
        exit()
    else:
        if next_turn == 'a':
            next_turn = S_A.popleft()
        elif next_turn == 'b':
            next_turn = S_B.popleft()
        elif next_turn == 'c':
            next_turn = S_C.popleft()


Measured memory_bytes: 9348
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <unordered_map>

#define BIG 1000000007

using namespace std;

int main() {
    string s;
    cin >> s;
    int ws = 0;
    int bs = 0;
    for(int i = 0;i < s.size();++i){
        if((i % 2 == 0 && s[i] == '0') || (i % 2 == 1 && s[i] == '1'))++ws;
        else ++bs;
    }

    cout << (ws > bs ? bs : ws) << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
	int N;
	int minval = 0, maxval = 0;
	int a, b;
	cin >> N;
	cin >> a;
	cin >> b;
	if (a < b)
	{
		minval = a;
		maxval = b;
	}
	else
	{
		minval = b;
		maxval = a;
	}

	for (int i = 2; i < N; ++i)
	{
		cin >> a;
		if (a < minval)
			minval = a;
		else if (a > maxval)
			maxval = a;
	}
	cout << maxval - minval << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate

N,M=map(int,input().split())
A=list(map(int,input().split()))

acc=list(accumulate(A))

d=defaultdict(int)

ans=0
for i in range(N):
    if acc[i]%M==0:
        d[acc[i]%M]+=1
        ans+=d[acc[i]%M]
    else:
        d[acc[i]%M]+=1
        ans+=d[acc[i]%M]-1
print(ans)

Measured memory_bytes: 63128
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
//#define debug1 cout<<"?"<<endl;
//#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=3e5+9;
const double pi=acos(-1);
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	char s[maxn];
	scanf("%s",s+1);
	int i,len=strlen(s+1),ju=0;
	if(len&1)
	{
		puts("No");return 0;
	}
	for(i=1;i<=len&&!ju;i++)
	{
		if((i&1)&&s[i]!='h')ju=1;
		if((i&1)==0&&s[i]!='i')ju=1;
	}
	if(!ju)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

main = do

   n <- readLn :: IO Int
   an <- reverse. sort . map bsreadInt . BC.words <$> BC.getLine
   print $ solve an 0 0 0
   
solve :: [Int] -> Int -> Int -> Int -> Int
solve [] n x y = x-y
solve (a:an) 0 x y = solve an 1 (x+a) y
solve (a:an) 1 x y = solve an 0 x (y+a)

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    Rep(s.size()) cout << "x";
    cout << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

const int MOD = 1e9 + 7, N = 1e5 + 7;

int dp[N];
bool bad[N];

void solve() {
    int n, m;
    cin >> n >> m;
    int lst = 0, ans = 1;
    loop(i, m) {
        int x; cin >> x;
        bad[x] = 1;
    }
    dp[0] = 1;
    dp[1] = !bad[1];
    for (int i = 2; i <= n; ++i) {
        if (bad[i])
            continue;
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
    cout << dp[n];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

using namespace std;

#define show(x) cerr << #x << " = " << x << endl;


int main()
{
 vector<int> g1 = {1, 3, 5, 7, 8, 10, 12};
 vector<int> g2 = {4, 6, 9, 11};
 vector<int> g3 = {2};

 int x, y;
 cin>>x>>y;

  bool existXg1 = (find(g1.begin(), g1.end(), x) != g1.end())? true:false;
  bool existYg1 = (find(g1.begin(), g1.end(), y) != g1.end())? true:false;
  bool flagG1 = existXg1 && existYg1;

  bool existXg2 = (find(g2.begin(), g2.end(), x) != g2.end())? true:false;
  bool existYg2 = (find(g2.begin(), g2.end(), y) != g2.end())? true:false;
  bool flagG2 = existXg2 && existYg2;


  bool existXg3 = (find(g3.begin(), g3.end(), x) != g3.end())? true:false;
  bool existYg3 = (find(g3.begin(), g3.end(), y) != g3.end())? true:false;
  bool flagG3 = existXg3 && existYg3;

 if(flagG1 || flagG2 || flagG3)
 {
   cout<<"Yes"<<endl;
 }
 else
 {
   cout<<"No"<<endl;
 }


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				return;
			}
			int up1 = 0, up2 = 0;
			int[] k = new int[n];
			for (int i = 0; i < n; i++) {
				k[i] = sc.nextInt();
				if (k[i] > 0){
					up1++;
					if(k[i] >= 2) {
						up2++;
					}
				}
			}
			if (up2 == 0) {
				System.out.println("NA");
			} else {
				System.out.println(up1 + 1);
			}
		}
	}
}

Measured memory_bytes: 162144
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}



void solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = max({ a * c,b * c,a * d,b * d });
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 11840
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  int N;
  cin >> N;
  int a, b;
  vector<vector<int> > G(N + 1);
  vector<pair<int, int> > edges(N - 1);
  int kind = 0;
  rep(i, N - 1){
    cin >> a >> b;

    G[a].push_back(b);
    G[b].push_back(a);

    kind = max(kind, max((int)G[a].size(), (int)G[b].size()));
    
    edges[i] = make_pair(a, b);
  }
  
  map<pair<int, int>, int> ecol;
  vector<int> vcol(N + 1, 0);

  queue<int> que;
  vector<int> vis(N + 1, 0);
  que.push(1);
  int top, v;

  while(!que.empty()){
    top = que.front();
    vis[top] = 1;
    que.pop();
    int c = 1;

    rep(i, G[top].size()){
      v = G[top][i];
      if(vis[v] == 1) continue;
      if(c == vcol[top]) c++;
      ecol[{min(top, v), max(top, v)}] = c;
      vcol[v] = c;
      c++;
      
      que.push(v);
    }
  }

  cout << kind << endl;
  rep(i, N - 1){
    cout << ecol[edges[i]] << endl;
  }
    
  return 0;
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int  solve()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2])); 
	}
	// for(int i=0;i<n;i++)
	// {
	// 	cout<<dp[i]<<" ";
	// }
	return dp[n-1];
}
int main()
{
	int t;
	t=1;
	while(t--)
	{
	
		cout<<solve();		
	}

}


Measured memory_bytes: 1024
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,d,e,f,g,h,w;
 
ll x[800005],y[800005],z[900005];
char s[500005];
ll dp[5000][5000];

int main(){
    cin>>a>>b;
	p(a*b-a-b+1);
	return 0;
}

Measured memory_bytes: 5248
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll X;

void solve()
{
    ll ans = 0;
    ans += 2 * (X / (6 + 5));
    X -= (6 + 5) * ans/2;
    ll d = 1;
    while(X > 0){
        X -= (d == 1 ? 6 : 5);
        ans++;
        d *= -1;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> X;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	string a,b;cin >> a >> b;
	
	REP(i,a.size())
	{
		cout << a[i];
		if(b.size() > i)cout << b[i];
		else break;
	}
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
INF = 10 ** 11
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
from heapq import heapify,heappush,heappop   

def main():
    x = int(input())
    a = x//500
    x -= a * 500
    b = 0
    if x > 0:
        b += x//5
    ans = 1000 * a + 5 * b
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
        
int main(){
  int N,count=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    string A=S.substr(i,3);
    if(A=="ABC"){
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    double sum = 0;

    for(int i = 0; i < n; i++){
        sum += double(1.0/v[i]);
        //cout << sum << endl;
    }

    //cout << double(1 / sum) << endl;
    double ans = 0;
    ans = 1 / sum;
    printf("%lf\n", ans);
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
S = input()

pa = pb = 0
for c in S:
    if c == 'a' and pa+pb < A+B:
        print('Yes')
        pa += 1
    elif c == 'b' and pa+pb < A+B and pb < B:
        print('Yes')
        pb += 1
    else:
        print('No')


Measured memory_bytes: 4016
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;
using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef complex<ll> G;
const int N=1e5+5;

const int INF = 1e9+5;


void done() {


    ll n;
    cin >> n;
    ll a[n];
    ll total = 0;
    vector<ll>frq(N, 0);
    for(int i=0;i < n;i++) {
        cin >> a[i];
        frq[a[i]]++;
        total += a[i];
    }
    ll q;
    cin >> q;
    for(int i=0; i< q;i++) {
        ll b, c;
        cin >> b >> c;

        ll p = total-(frq[b]*b) + (c*(frq[b]));

        frq[c] += frq[b];
        frq[b] = 0;

        total = p;

        /*for(int j=0; j< n;j++) {
            if(a[j]==b) {
                a[j] = c;
                frq[a[j]]--;
                frq[c]++;
            }
            total += a[j];
        }
        */
        cout << p << '\n';
    }

}
void solve() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i=0; i< n;i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    int sum = 0;
    for(int i=0;i < k;i++) {
        sum += a[i];
    }
    cout << sum << '\n';

}

void another() {

}
int main() {

    fast;
    done();

}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D
int a, b, c, d;
int main(){
    int n;
    cin>>n;
    string s;
    fori(n){
        cin>>s;
        if(s=="AC")a++;
        else if(s=="WA") b++;
        else if(s=="TLE") c++;
        else d++;
    }
    cout<<"AC x "<<a<<endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)


using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

LL cur = 100;
LL cnt(0);
LL x;
int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> x;
    while (1) {
        cur = cur + cur / 100;
        cnt++;
        if (cur >= x) break;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

double dp[301][301][301];
bool vis[301][301][301] = {0};
int n;

double solve(int x, int y, int z)
{
	if (x <= 0 && y <= 0 && z <= 0)
		return 0;
	if (vis[x][y][z])
		return dp[x][y][z];
	vis[x][y][z] = 1;
	double ans = 1.0;
	if (x > 0)
		ans += ((double)x / n) * solve(x - 1, y, z);
	if (y > 0)
		ans += ((double)y / n) * solve(x + 1, y - 1, z);
  	if (z > 0)
		ans += ((double)z / n) * solve(x, y + 1, z - 1);
  
	ans /= ((1.0 - ((double)n - x - y - z) / n));
  
	return dp[x][y][z] = ans;
}

int main()
{
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int x = 0, y = 0, z = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 1)
			x++;
		else if (a[i] == 2)
			y++;
		else if (a[i] == 3)
			z++;
	}
	printf("%.10lf", solve(x, y, z));
	return 0;
}


Measured memory_bytes: 239872
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  string ans = "";
  for(int i=0;i<s.length();i++){
  	if(s[i]=='1'){
  		ans+="1";
  	}else if(s[i]=='0'){
  		ans+="0";
  	}else if(s[i]=='B'&&ans.length()){
  		ans.erase(ans.begin()+ans.length()-1);
  	}
  }
  cout<<ans<<endl;
}  



Measured memory_bytes: 256