akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
    string S;
    cin >> S;
    string ss="";
    if(S == "Sunny"){
        ss = "Cloudy";
    }else if(S == "Cloudy"){
        ss = "Rainy";
    }else{
        ss = "Sunny";
    }

    cout << ss << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int x;
    cin>>x;
    
    long long int a=0, b=0,sum=0;
     
    a= 1000* (x/500);
    b= 5*((x%500)/5);
    
    sum=a+b;
    cout<<sum<<"\n";
}

Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;




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

	int N, M; cin >> N >> M;
	multiset<int>st;
	REP(i, N) {
		int x; cin >> x;
		st.insert(x);
	}
	REP(i, M) {
		auto itr = st.end(); itr--;
		int pos = *itr / 2;
		st.erase(itr);
		st.insert(pos);
	}
	ll ans = 0;
	for (auto x : st) {
		ans += x;
	}
	print(ans);
}


Measured memory_bytes: 4992
#include <stdio.h>

int main()
{
    long long int n, m, ans=0;
    scanf("%lld %lld", &n, &m);
    if(n<2)
        n = 3;
    if(m<2)
        m = 3;
    ans = (n-2) * (m-2);
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  k--;
  n--;
  cout << (n+k-1)/k << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int a,b,c;
	
	int ret;
	
	ret = scanf("%d %d",&a,&b);
	
	
	if(a<=(b*2)){
		c=0;
	} else{
		c=a-(b*2);
	}
	
	printf("%d\n",c);
	
	return 0;
	
}


Measured memory_bytes: 128
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 
    fast;

    ll n,k;
    cin>>n>>k;

    ll p[n];
    for(ll i=0;i<n;i++)
        cin>>p[i];

    ll invsn=0,orig=0,ans=0;
    set<ll> s;

    for(ll i=0;i<k;i++)
    {
        s.insert(p[i]);
        if(i==0)
            continue;
        if(p[i]<p[i-1])
            invsn++;
    }

    if(invsn) ans++;
    else orig=1;

     //cout<<" "<<ans<<" "<<orig<<endl;
  
    for(ll i=k;i<n;i++)
    {
        bool chk=0,f=0;

        auto it=s.find(p[i-k]);
        if(it==s.begin()) chk=1;
        s.erase(it);
        if(p[i-k]>p[i-k+1]) invsn--;
        if(p[i]<p[i-1])invsn++;

       auto qt=s.end();
        qt--;
          s.insert(p[i]);
        if(*qt<p[i]) f=1;
        if(invsn==0) orig=1;
        else if(f and chk) continue;
        else ans++;
      
        //cout<<i<<" "<<ans<<" "<<orig<<endl;
        
    }
    cout<<ans+orig<<endl;}


Measured memory_bytes: 11264
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    //cout << N << endl;

    int cnt = 0;


    for (int i = 1; i <= N; i++)
    {
        int keta = 0;
        for (int j = 1; j <= 100000; j = j * 10)
        {
            int tmp = i / j;
            //cout << tmp << endl;
            if (tmp > 0)
            {
                keta++;
            }
        }
        if (keta % 2)
        {
            cnt ++;
        }
    }

    cout << cnt;

    return 0;
}


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

using namespace std;
const int N = 2e5 + 3;
int res[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int n, q;
	scanf("%d %d", &n, &q);
	vector<pair<int, pair<int, int>>> events;
	for (int i = 0; i < n; ++i) {
		int s, e, x;
		scanf("%d %d %d", &s, &e, &x);
		events.push_back({x, {s, e - 1}});
	}
	set<pair<int, int>> st;
	for (int i = 0; i < q; ++i) {
		int s;
		scanf("%d", &s);
		st.insert({s, i});
	}
	sort(events.begin(), events.end());
	memset(res, -1, sizeof res);
	for (auto event: events) {
		int l = event.second.first - event.first;
		int r = event.second.second - event.first;
		auto it = st.lower_bound({l, 0});
		while (it != st.end() && it->first <= r) {
			res[it->second] = event.first;
			it = st.erase(it);
		}
	}
	for (int i = 0; i < q; ++i)
		printf("%d\n", res[i]);
	return 0;
}


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

const int MAX = 100000;
int main() {
	
	int N, a[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	sort(a, a + N);
	
	int j = a[0], c = 1, sum = 0;
	for (int i = 1;i < N;i ++) {
		if (j != a[i]) {
			if (j <= c) sum += c - j;
			else sum += c;
			j = a[i];
			c = 1;
		} else c ++;
	}
	if (j <= c) sum += c - j;
	else sum += c;
	cout << sum;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int N;
  int max = 1, min = 100;
  cin >> N;
  int *arr = new int[N];
  for(int i = 0; i < N; i++){
    cin >> arr[i];
    if(arr[i] > max){
      max = arr[i];
    }
    if(arr[i] < min){
      min = arr[i];
    }
  }
  
  int result = 0;
  for(int i = min; i <= max; i++){
    int temp = 0;
    for(int j = 0; j < N; j++){
      temp += (arr[j]-i)*(arr[j]-i);
    }
    if(i == min || result > temp){
      result = temp;
    }
  }
  cout << result << endl;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int d;
	int a[n] = {0};
	int b;
	for(int i = 0; i < k; i++) {
		cin >> d;
		for(int j = 0; j < d; j++) {
			cin >> b;
			a[b-1]++;
		}
	}
	int count = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] == 0) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { int v = a<b ? b : a; return v;}
int min(int a,int b) { int v = a<b ? a : b; return v;}

int main(void) {
  int R[MAX], n, i, maxv, minv;

  scanf("%d",&n);
  for (i=0;i<n;i++) scanf("%d",&R[i]);
  maxv = -2000000000;
  minv = R[0];

  for(i=1;i<n;i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  printf("%d\n",maxv);

  return 0;
}


Measured memory_bytes: 2632
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
    string[] inputa = Console.ReadLine().Split(' ');
		int c = int.Parse(inputa[0]);
		int d = int.Parse(inputa[1]);

    if(d == 1) Console.WriteLine(1);
    else Console.WriteLine(0);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cstring>

using Graph = std::vector<std::vector<uint32_t>>;

int32_t dp[100100];
Graph G;

uint32_t rec(uint32_t v) {
  if (dp[v] != -1) return dp[v];

  uint32_t ret = 0;
  for (auto &nv: G[v]) {
    ret = std::max(ret, rec(nv) + 1);
  }

  return dp[v] = ret;
}

int main() {
  //std::memset(dp, -1, 100100);

  uint32_t N, M;

  std::cin >> N >> M;
  G.assign(N, std::vector<uint32_t>());

  for (uint32_t i = 0; i < M; i++) {
    uint32_t x, y;
    std::cin >> x >> y;
    G[x - 1].push_back(y - 1);
  }

  for (int v = 0; v < N; ++v) dp[v] = -1;

  uint32_t ret = 0;
  for (uint32_t i = 0; i < N; i++) {
    ret = std::max(rec(i), ret);
  }

  std::cout << ret << std::endl;

  return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"Yes":"No")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int N,cnt=0;
    cin >>N;
    vi a(N);
    FOR(i,0,N-1) {
        cin >>a[i];
        cnt+=(a[i]-1);
    }
    cout <<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy


from math import *


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, X] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    x_list = [X]
    for i in range(N):
        x = int(input_raw[i])
        x_list.append(x)
    x_list.sort()
    D = x_list[1] - x_list[0]
    for i in range(1, len(x_list)):
        D = gcd(D, x_list[i] - x_list[i - 1])
    print D

if __name__ == '__main__':
    main()

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

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

    if (a==b && a!=c || b==c && b!=a || c==a && c!=b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,total;
	scanf("%d",&a);
	if(a<1200)
	{
		printf("ABC\n");
	}
	if(a>=1200 && a<2800)
	{
		printf("ARC\n");
	}
	if(a>=2800 && a<=4208)
	{
		printf("AGC\n");
	}
	//printf("%d\n",total);
	return 0;
}

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

long long MOD = 1000000007;
long long dp[1010][1010];

int main(){
    string t, b;
    cin >> t >> b;

    for(int i = 0; i <= b.size(); i++){
        dp[0][i] = 0;
    }
    for(int i = 0; i <= t.size(); i++){
        dp[i][0] = 1;
    }

    for(int i = 0; i < t.size(); i++){
        for(int j = 0; j < b.size(); j++){
            if(t[i] == b[j]){
                dp[i+1][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
            }else{
                dp[i+1][j+1] = dp[i][j+1];
            }
        }
    }

    cout << dp[t.size()][b.size()] << endl;

    return 0;
}


Measured memory_bytes: 11104
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
MOD = 10**9 + 7

def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(k, n + 2):
        ans += i * (n - i + 1) + 1
    print(ans%MOD)


if __name__ == '__main__':
    main()

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

#define INF 1 << 30
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
ll a;
ll d[200010];

int main(){
  scanf("%d",&n);
  REP(i,n){
    scanf("%lld",&a);
    if(i==0){
      d[i] = a;
    }else{
      d[i] = d[i-1]+a;
    }
  }
  ll mi = LLONG_MAX;
  for(int i=0;i<n-1;i++){
    ll k = 2*d[i] - d[n-1];
    if(k<0) k*= -1;
    mi = min(mi,k);
  }
  printf("%lld\n",mi);
}


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

void kekka(int Array[], char mark){
    for(int i=1;i<14;i++){
        if(Array[i]==0){
            cout<<mark<<' '<<i<<endl;
        }
    }
}

int main(){
    int i,S[14],H[14],C[14],D[14];
    for(i=0;i<14;i++){
        S[i]=H[i]=C[i]=D[i]=0;
    }
    int n,number;
    char mark;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>mark>>number;
        switch(mark){
            case 'S':
                S[number]=1;
                break;
            case 'H':
                H[number]=1;
                break;
            case 'C':
                C[number]=1;
                break;
            case 'D':
                D[number]=1;
                break;
        }        
    }
    kekka(S,'S');
    kekka(H,'H');
    kekka(C,'C');
    kekka(D,'D');
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    map<int, int> mp;
    vi b(N);
    REP(i, N) {
        b[i] = a[i] + i;
    }
    REP(i, N) {
        ans += mp[i - a[i]];
        mp[b[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21928
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   int a; cin >> a;
   cout << a + a * a + a * a * a << endl;
 }


Measured memory_bytes: 3632
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
dp=[0 for j in range(A[len(A)-1]+1)]

for i in range(len(A)):
    num=A[i]
    while(num<len(dp)):
            dp[num]+=1
            num+=A[i]

count=0
for i in range(len(A)):
    if i!=0:
        if A[i]!=A[i-1]:
           if dp[A[i]]==1:
            count+=1
    else:
        if dp[A[i]]==1:
            count+=1

print(count)

Measured memory_bytes: 32300
S = list(input())
l = len(S)
if S[0]=="A" and "C" in S[2:l-1]:
  S.remove("A")
  S.remove("C")
  S = "".join(S)
  if S.islower():
    print("AC")
  else:
    print("WA")
else:
  print("WA")
  
  

Measured memory_bytes: 2940
a = input()
alpha = ['a','b','c','d','e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

if (a in alpha) : print('a')
else: print('A')

Measured memory_bytes: 9112
#include <bits/stdc++.h>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a, b) memset(a, b, sizeof(a))
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;
const int mod = 1e9 + 7;
 
 
#define FILENAME ""

set <ll> a;

void f (ll n) {
	a.insert(1);
	ll sz = sqrt(n);
 	for (ll i = 2; i <= sz; i++) {
 		ll r = 0;
 		while (n % i == 0) {
 		 	n /= i;
 		 	r++;
 		}
 		if (r != 0) {
 			a.insert(i); 	
 		}
 	}
 	if (n != 1) a.insert(n);
} 

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
   	ll ar, b;
   	cin >> ar >> b;
   	f(ar);
   	ll sz = sqrt(b);
   	ll ans = 1;
   	for (ll i = 2; i <= sz; i++) {
 		ll r = 0;
 		while (b % i == 0) {
 		 	b /= i;
 		 	r++;
 		}
 		if (r != 0) {
 			if (a.find(i) != a.end()) ++ans;
 		}
 	}
 	if (b != 1) {
 	 	if (a.find(b) != a.end()) ++ans;
 	}
 	cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
using namespace std;
int main()
{
	int n;
	cin>>n;
	int kg=0;
	for (int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		if (a%2==0 && a%3 && a%5)  kg=1;
	}
	if (kg==1)  cout<<"DENIED";
	else  cout<<"APPROVED";
	re 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	char s[50];
	int i,c=0;
	scanf("%d %s",&n,s);
	for(i=0;i<n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			c++;
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <climits>
using namespace std;

int main()
{
	int a, p;
	cin >> a >> p;


	cout << (a * 3 + p) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int N; cin >> N;
  string S; cin >> S;
  string &a = S;
  int R=0,G=0,B=0;
  for(int m=0;m<N;m++){
    if(a[m]=='R') R++;
    if(a[m]=='G') G++;
    if(a[m]=='B') B++;
  }
  ll ans = 0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N;j++){
      if(a[i]!='B'&&a[j]!='B'&&a[i]!=a[j]){
          ans+=B;
          if((i+j)%2==0&&a[(i+j)/2]=='B')ans--;
          if(2*j-i<N&&a[2*j-i]=='B')ans--;
          if(2*i-j>=0&&a[2*i-j]=='B')ans--;
      }
      if(a[i]!='G'&&a[j]!='G'&&a[i]!=a[j]){
          ans+=G;
          if((i+j)%2==0&&a[(i+j)/2]=='G')ans--;
          if(2*j-i<N&&a[2*j-i]=='G')ans--;
          if(2*i-j>=0&&a[2*i-j]=='G')ans--;
      }
      if(a[i]!='R'&&a[j]!='R'&&a[i]!=a[j]){
          ans+=R;
          if((i+j)%2==0&&a[(i+j)/2]=='R')ans--;
          if(2*j-i<N&&a[2*j-i]=='R')ans--;
          if(2*i-j>=0&&a[2*i-j]=='R')ans--;
      }
      }
    }
  cout << ans/3 <<endl;
  return 0;
}

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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

int h[100010];
int dp[100010];
int n, k;

int solveR(int i){
	if(i == n)
		return 0;
		
	if(dp[i] != -1)
		return dp[i];
	
	dp[i] = abs(h[i]-h[i+1]) + solveR(i+1);
	for(int j=2; (j<=k) and (i+j<=n); j++)
		dp[i] = min(dp[i], abs(h[i]-h[i+j]) + solveR(i+j) );

	return dp[i];
}

int solveI(){
	dp[1] = 0;
	
	for(int i=2; i<=n; i++){
		dp[i] = abs(h[i]-h[i-1]) + dp[i-1];
		for(int j=2; (j<=k) and (i-j>=1); j++){
			dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
		}
	}
	return dp[n];
}

int main() {
	
	scanf("%d %d", &n, &k);
	
	for(int i=1; i<=n; i++)
		scanf("%d", &h[i]);

//	memset(dp, -1, sizeof(dp));
//	printf("%d\n", solveR(1));
	printf("%d\n", solveI());
		
	return 0;	
}


Measured memory_bytes: 1024
#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()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    int cnt[n + 1] = {};
    rep(i, 0, m) {
        int l, r;
        cin >> l >> r;
        cnt[l]++;
        cnt[r + 1]--;
    }

    rep(i, 1, n + 1) {
        cnt[i] += cnt[i - 1];
    }

    int ans = 0;
    rep(i, 1, n + 1) {
        if (cnt[i] == m) ans++;
    }

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


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int width;
    int height;
    int x;
    int y;
    int r;
    
    cin >> width >> height >> x >> y >> r;
    
    if (
        ((x - r) >= 0) &&
        ((x + r) <= width) &&
        ((y - r) >= 0) &&
        ((y + r) <= height)
        )
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  char s[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> s[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#'){
        if(i == 0){
          if(s[i][j-1] != '#' && s[i][j+1] != '#' && s[i+1][j] != '#'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if(i == h-1){
          if(s[i][j-1] != '#' && s[i][j+1] != '#' && s[i-1][j] != '#'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if(j == 0){
          if(s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j+1] != '#'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if(j == w-1){
          if(s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j-1] != '#'){
            cout << "No" << endl;
            return 0;
          }
        }
        else{
          if(s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j-1] != '#' && s[i][j+1] != '#'){
            cout << "No" << endl;
            return 0;
          }
          
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
  int q,a,b;
  string str,p,m;

  cin>>str>>q;
  for(int i=0;i<q;i++){

    cin>>m;
    if(m=="replace"){
      cin>>a>>b>>p;
      str.replace(a,b-a+1,p);
      //cout<<str<<endl;
    }

    else if(m=="reverse"){
      cin>>a>>b;
      reverse(str.begin()+a,str.begin()+(b+1));
      //cout<<str<<endl;
    }
    else if(m=="print"){
      cin>>a>>b;
      string print=str.substr(a,b-a+1);
      //cout<<str<<endl;
      cout<<print<<endl;
    }

  }

  return 0;
}



Measured memory_bytes: 3156
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabCout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headCout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabHeadCout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];

	vector<int> m(N);

	rep(i, N)
	{
		m[A[i] - 1] = i;
	}

	rep(i, N)
	{
		cout << m[i] + 1 << " ";
	}

	return 0;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	Main();

	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int total;
	int happiness = 0;
	cin >> total;
	happiness = 1000 * (total / 500);
	total %= 500;
	happiness += 5 * (total / 5);
	cout << happiness;

	return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int n;
    cin>>n;
    int a[n];
    f1(i,0,n)
    cin>>a[i];

    int sum=0;
    f1(i,0,n)
    sum+=a[i];

    int sum1=0;
    int sum2=0;
    f1(i,0,n)
    {
    	sum1+=a[i];
    	sum2+=a[i];
    	if(sum1>sum/2)
    	{
    		sum1-=a[i];
    		break;
    	}
    }

    int ans=min(abs(sum-2*sum1),abs(sum-2*sum2));
    cout<<ans<<endl;

    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  s.erase(s.size() - 2, 2);

  while (s.length() >= 2) {
    int h = s.length() / 2;
    string a = s.substr(0, h);
    string b = s.substr(h);
    if (a == b) break;
    s.erase(s.size() - 2, 2);
  };
  cout << s.length() << endl;
}


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

int main() {
    long long int a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if(w >= v) {
        cout << "NO" << '\n';
        return 0;
    }
    cout << ((abs(a-b) <= abs(v-w)*t)?"YES":"NO") << '\n';
}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

V<V<int>> r(200001);
V<bool> saw(200001, false);

int dfs (int x) {//xのまだ見てない友達
    if (saw[x]) return 0;
    saw[x] = true;
    int res = 1;
    for (int fx : r[x]) {
        if (!saw[fx]) {
            res += dfs(fx);
        }
    }
    return res;
}

int main () {
    int n, m; cin >> n >> m;
    rep(i, m) {
        int a, b; cin >> a >> b; a--; b--;
        r[a].emplace_back(b); r[b].emplace_back(a);
    }
    int ans = 0;
    rep(i, n) chmax(ans, dfs(i));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 23420
#include<stdio.h>
#include<vector>
#include<queue>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=1e5+5;


int main()
{
	string s;
	cin>>s;
	int toa=0,tob=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='A') toa++;
		if(s[i]=='B') tob++;
	}
	if(toa>0&&tob>0) cout<<"Yes\n";
	else cout<<"No\n";
	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);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= n; i++) {
			int temp = i;
			int sum = 0;
			while(temp != 0) {
				sum += temp%10;
				temp = temp/10;
			}
			if(sum >= a && sum <= b) {
				ans += i;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<stack>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int t=1,flag=1;
    while(a--){
        if(flag<b)
        { flag=2*flag;
            t=flag;
            }
        else
            t+=b;
    }
    cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		xx := make([]float64, 4)
		yy := make([]float64, 4)
		for i := 0; i < 4; i++ {
			xx[i] = getNextFloat64(scanner)
			yy[i] = getNextFloat64(scanner)
		}
		ss := makeGrid(4, 4)
		for i := 0; i < 4; i++ {
			for j := 0; j < 4; j++ {
				ss[j][i] = complex(xx[i]-xx[j], yy[i]-yy[j])
			}
		}

		b1 := between(ss[0][1], ss[0][2], ss[0][3])
		b2 := between(ss[2][3], ss[2][0], ss[2][1])
		if b1 == 1 || b2 == 1 {
			fmt.Fprintln(writer, 0)
			continue
		}
		if b1 == -1 && b2 == -1 {
			fmt.Fprintln(writer, 1)
			continue
		}
		if overlap(ss[0][1], ss[0][2], ss[0][3]) {
			fmt.Fprintln(writer, 1)
			continue
		}

		fmt.Fprintln(writer, 0)
	}
}
func sign(a float64) int {
	eps := 1e-10
	if math.Abs(a) < eps {
		return 0
	}
	if a > eps {
		return 1
	}
	return -1
}
func between(s, a, b complex128) int {
	ia := imag(a / s)
	ib := imag(b / s)
	return sign(ia * ib)
}
func overlap(s, a, b complex128) bool {
	ra := real(a / s)
	rb := real(b / s)
	if sign(ra-1) == 1 && sign(rb-1) == 1 {
		return false
	}
	if sign(ra) == -1 && sign(rb) == -1 {
		return false
	}
	return true
}
func makeGrid(h, w int) [][]complex128 {
	index := make([][]complex128, h, h)
	data := make([]complex128, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}



Measured memory_bytes: 1620
input()

b = list(map(int,input().split()))

def nibu(low,high,i):
	middle = int((low+high)/2)
	if low == high:
		if i == b[low]:
			return 1 
		else:
			return 0

	if b[middle] < i:
		low = middle + 1
		return nibu(low,high,i)
	elif b[middle] >= i:
		high = middle
		return nibu(low,high,i)

a = int(input())
for i in range(a):
	k = int(input())
	print(nibu(0,len(b)-1,k))


Measured memory_bytes: 17420
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n,m;
	cin >> n >> m;
	
	int ok_l, ok_r;
	cin >> ok_l >> ok_r;

	rep(i, m - 1){
		int cl, cr;
		cin >> cl >> cr;
		chmax(ok_l, cl);
		chmin(ok_r, cr);
	}

	const int ans = max(0, ok_r - ok_l + 1);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4
0 0
3 1
2 3
0 3
3
2 1
0 2
3 2

output:
2
1
0
"""

import sys

EPS = 1e-9


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def check_contains(g, p):
    flag = False
    for j in range(edges):
        a, b = g[j] - p, g[(j + 1) % edges] - p
        if abs(cross(a, b)) < EPS and dot(a, b) < EPS:
            return 1
        elif a.imag > b.imag:
            a, b = b, a

        if a.imag < EPS < b.imag and cross(a, b) > EPS:
            flag = not flag
    return 2 if flag else 0


def solve(_p_info):
    for point in _p_info:
        px, py = map(int, point)
        p = px + py * 1j
        print(check_contains(polygon, p))
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    edges = int(_input[0])
    e_info = map(lambda x: x.split(), _input[1:edges + 1])
    points = int(_input[edges + 1])
    p_info = map(lambda x: x.split(), _input[edges + 2:])

    polygon = [int(x) + int(y) * 1j for x, y in e_info]
    solve(p_info)

Measured memory_bytes: 7920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A;
  int B;
  int C;
  int D;
  cin>>A>>B>>C>>D;
  int l=A+B;
  int r=C+D;
  if(r==l)cout<<"Balanced"<<endl;
    if(r>l)cout<<"Right"<<endl;
      if(r<l)cout<<"Left"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	double a,b;
	cin>>a>>b;
	printf("%.100lf",a/b);
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        k: i64,
    }

    let ta = std::cmp::min(a, k);
    let k = k - ta;
    let tb = std::cmp::min(b, k);

    println!("{} {}", a - ta, b - tb);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  int n;
  set<string> ss;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    ss.insert(s);
  }
  cout << ss.size() << endl;
  return 0;
}

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

int hmax;

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

#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

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

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

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  hmax = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20472
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(),
            min = (int)Math.pow(10, 9)+1;
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        int gcd = gcd(A[0], A[1]);
        for(int i = 2; gcd > 1 && i < N; i++){
            gcd = gcd(gcd, A[i]);
        }
        System.out.println(gcd);
    }

    public static int gcd(int a, int b){        
        if(b < a){
            int c = a;
            a = b;
            b = c;
        }
        int r;
        while((r = b%a) > 0){
            b = a;
            a = r;
        }
        return a;
    }   
}

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

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

  int cnt = 0;
  int p;
  rep(i, N) {
    cin >> p;
    if (i + 1 != p) cnt++;
  }
  if (cnt <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3620
n,t=map(int,input().split())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
mi=a[0]
sa=0
for i in range(n):
    if a[i]<mi:
        mi=a[i]
    if a[i]-mi>=sa:
        sa=a[i]-mi
        b.append(sa)
ans=b.count(sa)
print(ans)

Measured memory_bytes: 97316
#include <iostream>
#define REP(i, a, n) for(int i = a; i <= n; i++)
using namespace std;

int N, len[41];
int p[6] = { 0, 5, 7, 5, 7, 7 };

bool check(int s) {
  // cout << s << endl;
  REP(i, 1, 5) {
    int d = 0;
    while(s <= N) {
      d += len[s++];
      // cout << "  " << s << " " << i << " " << d << endl;
      if(d > p[i]) return false;
      if(d == p[i]) break;
    }
    if(d < p[i]) return false;
  }
  return true;
}

int main(void) {
  while(cin >> N, N) {
    REP(i, 1, N) {
      string S; cin >> S;
      len[i] = S.length();
    }

    REP(i, 1, N) {
      if(!check(i)) continue;
      cout << i << endl;
      goto CONTINUE;
    }

CONTINUE: continue;
  }

  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007
#define endl "\n"

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main()
{
    fastio
    int n,k,i,sum=0;
    cin >> n >> k ;

    int ar[n];

    for(i=0; i<n; i++) cin >> ar[i];

    sort(ar,ar+n);

    for(i=0; i<k; i++)
        sum+=ar[i];

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, ans = 0;
	ll D;
	
	cin>>n>>D;
	for(int i=0;i<n;++i){
		ll x, y;
		cin>>x>>y;
		
		if(x*x+y*y <= D*D) ++ans;
	}
	
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000009
# define pi acos(-1)
# define f first
# define s second
using namespace std;
vector<int> help(int x)
{
    vector<int> tt;
    for(int i=1;i*i<=x;i++)
    {
        if(x%i==0)
        {
            tt.push_back(i);
            if(x/i!=i)
                tt.push_back(x/i);
        }
    }
    return tt;
}
signed main()
{
    gok
    int n;
    cin>>n;
    vector<int> v2,v1;
    v1=help(n);
    v2=help(n-1);
    int an = v2.size()-1;
   // cout<<v1.size()<<" "<<v2.size()<<endl;
    for(int i=0;i<v1.size();i++)
    {
        if(v1[i]==1)
            continue;
       // cout<<v1[i]<<" ";
        int tt=n;
        while(tt%v1[i]==0)
            tt/=v1[i];
        if(tt%v1[i]==1)
            an++;
    }
    cout<<an;










      return 0;
    }


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL X, K, D; cin >> X >> K >> D;
  LL n = min(K, abs(X) / D);
  K -= n;
  if (X >= 0) {
    X -= n * D;
  } else {
    X += n * D;
  }

  if (K % 2 == 0) cout << abs(X) << endl;
  else            cout << min(abs(X-D), abs(X+D)) << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int col = 3;

int main() {
	LL n, A, B, C;
	cin>>n;
	vector<vector<LL>> a(n, vector<LL>(col));
	for(int i=0; i<n; i++) {
		cin>>A>>B>>C;
		a[i] = {A, B, C};
	}
	
	for(int i=1; i<n; i++) {
		a[i][0] += max(a[i-1][1], a[i-1][2]);
		a[i][1] += max(a[i-1][0], a[i-1][2]);
		a[i][2] += max(a[i-1][1], a[i-1][0]);
	}
	LL ans = INT_MIN;
	ans = max({a[n-1][0], a[n-1][1], a[n-1][2]});
	cout<<ans;
	return 0;
	
	
}

Measured memory_bytes: 8752