akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
  
typedef struct {
  char suit;
  int value;
} Card;
  
void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
void print(Card *, int);
int isStable(Card *, Card *, int);
  
int main()
{
  Card c1[37], c2[37]; 
  int i, N;
    
  scanf("%d", &N);
  
  for( i = 0 ; i < N ; i++ ){
    scanf(" %c%d", &c1[i].suit, &c1[i].value);
  }
      
  for( i = 0 ; i < N ; i++ ) c2[i] = c1[i];
  
  BubbleSort(c1, N);  
  print(c1, N);
  printf("Stable\n");
  
  SelectionSort(c2, N);
  print(c2, N);
  
  if( isStable(c1, c2, N) == 0 ) printf("Stable\n");
  else printf("Not stable\n");
    
  return 0;
}
  
void BubbleSort(Card c1[], int N)
{
  int i, j;
  Card t;
    
  for( i = 0 ; i < N ; i++ ){
    for( j = N-1 ; j > i ; j-- ){
      if( c1[j].value < c1[j-1].value ){
    t = c1[j];
    c1[j] = c1[j-1];
    c1[j-1] = t;
      }
    }
  }
} 
  
void SelectionSort(Card c2[], int N)
{
  int i, j, minj;
  Card t;
  
  for( i = 0 ; i < N ; i++ ){
    minj = i;
    for( j = i ; j < N ; j++ ){
      if( c2[j].value < c2[minj].value ) minj = j;
    }
    t = c2[i];
    c2[i] = c2[minj];
    c2[minj] = t;
  }
}
      
void print(Card c[], int N)
{
  int i;
    
  for( i = 0 ; i < N ; i++ ){
    if( i > 0 ) printf(" ");
    printf("%c%d", c[i].suit, c[i].value);
  }
  printf("\n");
}
  
int isStable(Card c1[], Card c2[], int N)
{
  int i;
  
  for( i = 0 ; i < N ; i++ )
    if( c1[i].suit != c2[i].suit ) return 1;
    
  return 0;
}

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

int main(){
    
        int N,A,B,C,D;
        cin>>N>>A>>B>>C>>D;
        string S;
        cin>>S;
        if(C<D){
                bool check=true;
                for(int i=A;i<=D-1;i++){
                    if(S[i]=='#'&&S[i-1]=='#') check=false;
                }
                if(check) cout<<"Yes"<<endl;
                else cout<<"No"<<endl;
        }
        else{
            bool check=true;
            for(int i=A;i<=C-1;i++){
                if(S[i]=='#'&&S[i-1]=='#') check=false;
            }
            if(check){
                bool check2=false;
                for(int i=B;i<=D;i++){
                    if(S[i-2]=='.'&&S[i-1]=='.'&&S[i]=='.') check2=true;
                }
                if(check2) cout<<"Yes"<<endl;
                else cout<<"No"<<endl;
            }
            else cout<<"No"<<endl;
        }
    }



Measured memory_bytes: 640
from math import sqrt
from decimal import Decimal
# def sqrt2(n):
#     def f(prev):
#         while True:
#             m = (prev + n / prev) / 2
#             if m >= prev:
#                 return prev
#             prev = m
    
#     return f(math.sqrt(n) * (1 + 1e-10))
a,b,c = map(int, input().split())

# ra = math.sqrt(a)
# rb = math.sqrt(b)
# rc = math.sqrt(c)
ra = Decimal(a).sqrt()
rb = Decimal(b).sqrt()
rc = Decimal(c).sqrt()

if rc > ra + rb:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5076
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define LINE_BUF_SIZE 256
#define int long int

void merge_sort(int *A, int left, int right, int *tmp){

    if(right - left > 1){   /*最小のサブリストであるかどうか*/
        
        int i,j,k,half = (right+left)/2;

        merge_sort(A,left,half,tmp);    /*右のブロック*/
        merge_sort(A,half,right,tmp);   /*左のブロック*/

        for(i=left;i<right;i++){
            tmp[i]=A[i];
        }
        
        for(i = left,j = left,k = half;i<right;i++){
            if(k == right){
                A[i] = tmp[j];
                j++;
            }
            else if(tmp[j] <= tmp[k] && j < half){
                A[i] = tmp[j];
                j++;
            }
            else{
                A[i] = tmp[k];
                k++;
            }
        }

    }

}

void pre_merge_sort(int *A, int N){
    int *tmp = (int *)malloc(sizeof(int)*N);
    merge_sort(A,0,N,tmp);
    free(tmp);
}

int main(){

    int i,j,k;
    int N;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%ld", &N);

    int *a = malloc(sizeof(int)*(N+1));
    int *a_hold = malloc(sizeof(int)*(N+1));

    for(i=0;i<N;i++){
        scanf("%ld",&a[i]);
        a_hold[i] = a[i];
    }

    pre_merge_sort(a,N);

    int max;
    int j_hold;

    max = a[N-1];
    int min=(int)1e10;
    int id;

    for(i=0;i<N-1;i++){
        if(fabs(a[i]-(max/2)) <= min){
            min = fabs(a[i]-(max/2));
            id = i;
        }
    }

    printf("%d\n",max);
    printf("%d",a[id]);

    return 0;

}

Measured memory_bytes: 2560
l = list(map(int,input().split()))

if l[0] < l[1]:
    mini = l[0]
else:
    mini = l[1]

ans_list = []
for i in range(1,mini+1):
    if l[0] % i == 0 and l[1] % i == 0:
        ans_list.append(i)

ans_list.sort(reverse=True)
print(ans_list[l[2]-1])

Measured memory_bytes: 3060
N=list(input())
K=int(input())
N=list(map(int,N))
#print(N)
dp=[[[0 for _ in range(4)] for _ in range(len(N))] for _ in range(2)]
for i in range(len(N)):
    num=N[i]
    mayover=0
    if i==0:
        id=0
        for j in range(10):
            if j==num:
                id=1
            elif j>num:
                break
            if j==0:
                dp[id][i][0]=dp[id][i][0]+1
            else:
                dp[id][i][1] = dp[id][i][1] + 1
    else:
        for j in range(2):
            for l in range(4):
                if j==0:
                    dp[j][i][l] = dp[j][i][l] + dp[j][i - 1][l]
                    if l != 0:
                        dp[j][i][l] = dp[j][i][l] + 9*dp[j][i - 1][l - 1]
                else:
                    if num==0:
                        for l in range(4):
                            dp[j][i][l] = dp[j][i - 1][l]
                    else:
                        dp[0][i][l] = dp[0][i][l] + dp[j][i - 1][l]
                        if l != 0:
                            dp[0][i][l] = dp[0][i][l] + (num - 1) * dp[j][i - 1][l - 1]
                            dp[1][i][l] = dp[1][i][l] + dp[j][i - 1][l - 1]
    #print(dp[0][i],dp[1][i])
    #input()
print(dp[0][len(N)-1][K]+dp[1][len(N)-1][K])








Measured memory_bytes: 63000
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int m = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();
			if((m + f + r) == -3){
				break;
			}else if(m == -1 || f == -1){
				System.out.println("F");
			}else if((m + f) >= 80){
				System.out.println("A");
			}else if((m + f) >= 65){
				System.out.println("B");
			}else if((m + f) >= 50){
				System.out.println("C");
			}else if((m + f ) >= 30){
				if (r >= 50) {
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else{
				System.out.println("F");
			}

		}
	}
}



Measured memory_bytes: 26280
N,X = map(int,input().split())
L = list(map(int,input().split()))
jumpNumber = 0

if sum(L) < X:
  print(N+1)
  exit()

for i in range(N):
  jumpNumber = jumpNumber + L[i]
  if jumpNumber > X:	
  	print(i+1)
  	break
  elif jumpNumber == X:
    print(i+2)
    break
  else:
    pass

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

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

int main() 
{
	int sum = 0;
	int a, b,c[10000],d[10000];
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> c[i];
	}
	cin >> b;
	for (int i = 0; i < b; i++) {
		cin >> d[i];
		if (LinearSearch(c, a, d[i])) {
			sum++;
		}
	}
	cout << sum<<endl;
}


Measured memory_bytes: 3136
N, M = map(int, input().split())
H = list (map(int, input() .split()))
A = [0]*M
B = [0]*M
ans = [True]*N
for i in range (M):
	A[i], B[i] = map (int, input() .split())
	if H[A[i]-1] < H[B[i]-1]:
		ans[A[i]-1] = False
	elif H[A[i]-1] > H[B[i]-1]:
		ans[B[i]-1] = False
	else:
		ans[A[i]-1] = False
		ans[B[i]-1] = False
print(ans.count(True))

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

int main() {
  int n;
  cin >> n;
  vector<float> a(n);
  rep(i, n) cin >> a[i];
  float ans;
  rep(i, n) ans += 1.0 / a[i];
  ans = 1.0 / ans;
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 3788
x, k, d = map(int, input().split())

cnt = abs(x) // d
x = abs(x)
if k % 2 == cnt % 2:
    ans = min(abs(x - d * min(k,cnt)), abs(x + d * min(k,cnt)))
elif k % 2 != cnt % 2:
    ans = min(abs(x - d * min(k,(cnt + 1))), abs(x - d * min(k,(cnt + 1))))
print(ans)


Measured memory_bytes: 61680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//標準入力から文字列を取得する(行単位)
		String s = sc.nextLine();
		//文字列を一文字に分解する
		String[] aryStr = s.split("");

		int money = 700;

		for(int i = 0; i < aryStr.length; i++) {
			if(aryStr[i].equals("o")) {
				money += 100;
			}
		}
		System.out.println(money);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef tuple<int, int, int> T;

const int MAX_N = (int)2e5 + 5;
const lint MOD = (lint)1e9 + 7;
lint E[MAX_N], inv_pow[MAX_N], ap[MAX_N], bp[MAX_N];
vector<lint> fact, fact_inv, inv;

T ExtendedGcd(int a, int b){
    if(b==0) return T(1, 0, a);
    int x, y, g; tie(x, y, g) = ExtendedGcd(b, a % b);
    return T(y, x-a/b*y, g);
}

void mod_add(lint &a, lint b){
    a = (a+b) % MOD;
}

lint mod_pow(lint n, lint x){
    lint res = 1;
    while(x){
        if(x&1) res = res * n % MOD;
        x >>= 1; n = n * n % MOD;
    }
    return res;
}

void createFactInvMod(int n){
    fact.resize((unsigned int)n+1); fact_inv.resize((unsigned int)n+1);
    fact[0] = 1;
    for(int i=1;i<=n;i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[n] = mod_pow(fact[n], MOD-2);
    for(int i=n-1;0<=i;i--) fact_inv[i] = fact_inv[i+1] * (i+1) % MOD;
}

void createInvMod(int n){
    inv.resize((unsigned int)n+1);
    createFactInvMod(n);
    inv[0] = 0;
    for(int i=1;i<=n;i++) inv[i] = fact[i-1] * fact_inv[i] % MOD;
}

lint comb(lint n, lint r){
    return fact[n] * fact_inv[r] % MOD * fact_inv[n-r] % MOD;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    lint N, A, B, C, ans = 0; cin >> N >> A >> B >> C;
    createInvMod(max(2*N, 100LL));
    ap[0] = 1, bp[0] = 1;
    for(lint i=0;i<2*N;i++){
        ap[i+1] = ap[i] * A % MOD;
        bp[i+1] = bp[i] * B % MOD;
        inv_pow[i] = mod_pow(A+B, MOD-i-1);
        E[i] = 100 * i * inv[100-C] % MOD;
    }
    for(lint i=N;i<2*N;i++){
        mod_add(ans, (ap[N]*bp[i-N]%MOD+ap[i-N]*bp[N]%MOD)%MOD*E[i]%MOD*inv_pow[i]%MOD*comb(i-1, N-1)%MOD);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
a,b,c,d,e,f=map(int,input().split())
water=[]
sugar=[]
ans,ans_2,con=0,0,0
for i in range(f//100+1):#f//100+1によりTLEを解消
    for j in range(f//100+1):
        x=100*a*i+100*j*b
        if 0<x<=f:
            water.append(x)
for i in range(f):
    for j in range(f):
        y=c*i+d*j
        if y<=f:
            sugar.append(y)
sugar=list(set(sugar))
for i in water:
    for j in sugar:
        if i+j<=f:
            if j<=i//100*e:
                now=(100*j)/(i+j)
                if con<=now:
                    ans=i+j
                    ans_2=j
                    con=now
print(ans,ans_2)


Measured memory_bytes: 12440
#include <stdio.h>

long q_head = 0;
long q_tail = 0;
long fin_num=0,cur_time=0;

struct Process{
	long time;
	char name[15];
};
struct Process q[1000000],fin[100000];

//functions
void output();
void enqueue(long l,char *c);
struct Process dequeue(void);
void sim(int i);

int main(void){
	int i,j;
	int n,quantum;
	char c;

	scanf("%d %d",&n,&quantum);
	for(i=0;i<n;i++){
		j=0;
		c = getchar();
		c = getchar();
		while(1){
			if(c == ' ' || c == '\n') break;
			q[i].name[j++]=c;
			c = getchar();
		}
		scanf("%ld",&q[i].time);
	}
	q_tail = n; 
	sim(quantum);
	for(i=0;i<fin_num;i++){
		printf("%s ",fin[i].name);
		printf("%ld\n",fin[i].time);
		//if(i<fin_num-1) printf(" ");
	}
	//printf("\n");
	return 0;
}
void output(){
	int i;
	for(i=q_head;i<q_tail;i++){
		printf("%s ",q[i].name);
		printf("%ld",q[i].time);
		if(i<q_tail-1) printf(" ");
	}
	printf("\n");
	return;
}
void enqueue(long time,char *name){
	int i = 0;
	q[q_tail].time  = time;
	while(name[i] != '\0'){
		q[q_tail].name[i] = name[i];
		i++;
	}
	q_tail++;
	return;
}

struct Process dequeue(){
	return q[q_head++];
}

void sim(int quantum){
	struct Process p;
	while(q_head != q_tail){
			p = dequeue();
			if(p.time<=quantum){
				cur_time += p.time;
				p.time = cur_time;
				fin[fin_num++] = p;
			}else{
				p.time -= quantum;
				cur_time += quantum;
				enqueue(p.time, p.name);
			}
			if(q_head == q_tail) break;
			//output();
	}

return;
}

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

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

    function<bool(int)> isOK = [&](ll n) {
        if(n==1) return N == 1;

        ll sm = (1+n)*n/2;
        if(sm>=N) return true;
        else return false;
    };

    function<ll(void)> nibutan = [&]() {
        int ng = 0;
        int ok = N;

        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;

            if (isOK(mid)) ok = mid;
            else
                ng = mid;
        }
        return ok;
    };

    ll mx = nibutan();
    while(N>0){
        if(N>=mx) {
            N-=mx;
            cout << mx << '\n';
            --mx;
        } else {
            --mx;
        }
    }
    
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;
	cout << A[K - 1] << endl;
}


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

int main(){
  int A, B;

  cin >> A >> B;

  int x, y, z;

  x = A+B;
  y = A-B;
  z = A*B;

  int ans1 = max(x, y);
  int ans2 = max(y, z);

  int ans = max(ans1, ans2);

  cout << ans << endl;

  return 0;

}

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

using namespace std;

template <class T> inline T updmax(T& a, T b) { return a = max(a, b); }
template <class T> inline T updmin(T& a, T b) { return a = min(a, b); }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(12);
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	double ret = a[0];
	for (int i = 1; i < n; i++) ret = (ret + a[i]) * 0.5;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int c,i,j,temp,h[11];
  for(c=0;c<10;c++){
    scanf("%d",&h[c]);
  }
  for(i=0;i<3;i++){
    for(j=c-1;j>0;j--){
      if(h[j]>h[j-1]){
	temp=h[j];
	h[j]=h[j-1];
	h[j-1]=temp;
      }
    }
  }
  printf("%d\n%d\n%d\n",h[0],h[1],h[2]);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end(),greater<int>());
  
  int result=0;
  for(int i=0;i<n;i++){
    result+=(i%2 ? -1:1)*v[i];  
  }
  cout<<result<<endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

ans = 0
for k in range(K):
    t = T[k::K]
    b = 'a'
    for i in range(len(t)):
        if t[i] == b:
            b = 'a'
        else:
            if t[i] == 'r':
                ans += P
            elif t[i] == 's':
                ans += R
            else:
                ans += S
            b = t[i]
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <cctype>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

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

  char init = s.at(0);
  int occ = 0;
  for (int i = 2; i < s.size()-1; ++i) {
    if (s.at(i) == 'C') {
      occ++;
    }
  }

  int lowocc = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (islower(s.at(i))) {
      lowocc++;
    }
  }

  if (init == 'A' && occ == 1 && lowocc == s.size()-2) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int main(){
    int x; cin >> x;
    if(x >= 30) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3644
mod = 10**9+7
N = int(input())
L = []
for _ in range(N):
    L.append([int(input()), 0])
for _ in range(N):
    L.append([int(input()), 1])
L.sort()
a = 0
b = 0
ans = 1
for val, ab in L:
    if ab==0:
        if b>0:
            ans = ans * b % mod
            b-=1
        else:
            a+=1
    else:
        if a>0:
            ans = ans * a % mod
            a-=1
        else:
            b+=1
print(ans)


Measured memory_bytes: 30740
import math
n = int(input())
s = input()
ans=0
for i in range(n):
    #print(i,n)
    maxim = i
    num=[0 for k in range(n-i)]
    count=0
    lmax=0
    for j in range(n-i):
        if(s[j]==s[i+j]):
            num[j]=1
            count+=1
            #print(count)
            if(lmax<count):
                lmax=count
        else:
            count=0
    #print(lmax)
    if(ans<lmax):
        ans=min(lmax,maxim)
print(ans)
        

Measured memory_bytes: 48356
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
xyh = [LIST() for _ in range(N)]
ins = (-1, -1, -1)

for x, y, h in xyh:
	if h >= 1:
		ins = (x, y, h)

x1, y1, h1 = ins   # h>=1 の条件中の任意の(x, y, h)

for Cx in range(101):
	for Cy in range(101):
		H = h1 + abs(x1-Cx) + abs(y1-Cy)  #Hは条件中の任意の(x, y, h)で決定できる。
		for x, y, h in xyh:
			if max(H-abs(x-Cx)-abs(y-Cy), 0) != h:
				break
		else:
			print(Cx, Cy, H)
			exit()



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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) cin >> h[i];

  int ans = 0;
  for (int l = 0; l < N; ++l) {
    while (h[l] > 0) {
      int r;
      for (r = l+1; r < N; ++r) {
        if (h[r] == 0) break;
      }

      for (int x = l; x < r; ++x) h[x]--;
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int n = 0, a = 0, b = 0, c = 0;
vector<int> v;

int dfs(int i, int x, int y, int z) {


	if (i == n) {
		if (!x || !y || !z) {
			return INF;
		}
		else {
			return abs(x - a) + abs(y - b) + abs(z - c);
		}
	}

	int res = dfs(i + 1, x, y, z);

	res = min(res, dfs(i + 1, x + v[i], y, z) + (x != 0 ? 10 : 0));
	res = min(res, dfs(i + 1, x, y + v[i], z) + (y != 0 ? 10 : 0));
	res = min(res, dfs(i + 1, x, y, z + v[i]) + (z != 0 ? 10 : 0));

	return res;

}

int main() {
	cin >> n >> a >> b >> c;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	cout << dfs(0, 0, 0, 0) << endl;
	
	return 0;

}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  double n;
  cin >> n;
  long double ans;
  ans = pow(n,3)/27;
  cout << fixed << setprecision(12) << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
int n, arr[200005];
priority_queue<pi> pq;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n) cin >> arr[i];
	sort(arr, arr + n);
	reverse(arr, arr + n);
	pq.push(MP(arr[1], arr[0]));
	pq.push(MP(arr[1], arr[0]));
	ll ans = arr[0];
	REP(i, 2, n){
		pi cur = pq.top();
		pq.pop();
		ans = ans + cur.first;
		pq.push(MP(arr[i], cur.first));
		pq.push(MP(arr[i], cur.second));
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 8196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	ll sum1=0;
	for(int i=3; i<=n; i+=3)
	 sum1-=i;
	for(int i=5; i<=n; i+=5)
	 sum1-=i;
	for(int i=15; i<=n; i+=15)
	 sum1+=i;
	for(int i=1; i<=n; i++)
	 sum1+=i;
	cout<<sum1;
	return 0;
	
}

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

int main() {
	ll A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	if (A == 0) cout << 1;
	if (B == 0) cout << 2;
	if (C == 0) cout << 3;
	if (D == 0) cout << 4;
	if (E == 0) cout << 5;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back

void solve(){
    int n;
    cin >> n;
    vector<int> P(n);
    REP(i,n){
        int p;
        cin >> p;
        if(p == i+1) P[i] = 0; //P中の0の個数と連続数を数えたい
        else P[i] = 1;
    }

    int res = 0;
    bool flag = false; //0が来たらtrueに。
    int cnt = 0; //連続数をカウント
    REP(i, n){
        if(P[i] == 0){
            if(flag == false){
                flag = true;
                cnt = 1;
            }
            else{
                cnt++;
            }
        }
        else{
            flag = false;
            res += ceil((double)cnt/2.0);
            cnt = 0;       
        }
    }
    if(flag = true) res += ceil((double)cnt/2.0);  

    cout << res << endl;


}

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

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();

        int answer = (a + b) % 24;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

#define fi first
#define se second

const int N = 300300;
const long long mod = 998244353;

using namespace std;

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        int n;
        cin >> n;
        long long sum = 0, shit = 1e18;
        for(int i = 0; i < n; i++){
                long long x, y;
                cin >> x >> y;
                if(x > y){
                        shit = min(shit, y);
                }
                sum += y;
        }
        cout << sum - min(sum, shit) << "\n";

}



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

int main() {
	int N;
	bool hina4Flag = false;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		string a;
		cin >> a;
		if (a == "Y")
		{
			hina4Flag = true;
		}
	}
	if (hina4Flag)cout << "Four" << endl;
	else cout << "Three" << endl;
}

Measured memory_bytes: 256
// C++ program to print all the cycles
// in an undirected graph
#include <bits/stdc++.h>
using namespace std;
int mod =1e9+7;
int main(){
int n;
cin >> n;
vector<long long int>A(n);
for(int i=0;i<n;++i)
    cin >> A[i];
vector<vector<long long int> >dp(n,vector<long long int>(n,INT_MAX));
int L,R;
for(L=n-1;L>=0;--L){
    for(R=L;R<n;++R){
        if(L==R){
            dp[L][R]=0;
        }else{
            long long int s=0;
            for(int i=L;i<=R;++i)
                s+=A[i];
         dp[L][R]=1e18+5;
           for(int i=L;i<R;++i){
            dp[L][R]=min(dp[L][R],dp[L][i]+dp[i+1][R]+s);

           }

        }

    }
}
cout << dp[0][n-1]<<endl;
return 0;



}


Measured memory_bytes: 4888
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+7;

int a , b;

int main () {
    scanf("%d%d" , &a , &b);
    int me = b-a;
    printf("%d\n" , me*(me+1)/2 - b);
}


Measured memory_bytes: 256
/* Eat a live frog first thing in the morning,
   and nothing worse will happen to you the rest of the day */

/* You can't connect the dots looking forward 
   you can only connect them looking backwards. */

/* Nothing is impossible; impossible itself says "I'm possible" */

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define N 500007

int test;

int n;
string s;

int t[N];

int t1[N];

void solve()
{
       cin >> n;

       FOR(j,1,26)
       {
              t[j]=inf;
       }

       FOR(i,1,n)
       {
              FOR(j,1,26)
              {
                     t1[j]=0;
              }

              cin >> s;

              REP(j,s.size())
              {
                     t1[s[j]-'a'+1]++;
              }

              FOR(j,1,26)
              {
                     t[j]=min(t[j],t1[j]);
              }
       }

       string res;

       FOR(i,1,26)
       {
              while(t[i]>0 && t[i]!=inf)
              {
                     char c='a'+i-1;
                     res+=c;
                     t[i]--;
              }
       }

       cout << res;

       return;
}

int32_t main()
{
    boost

    test=1;

    while(test--)
    {
         solve();
    }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
# print(a_list)
a_set = set(a_list)
length_dict = {}
for elm in a_set:
    length_dict[elm] = 0    

for ind in range(n):
    elm = a_list[ind]
    length_dict[elm] += 1

total_num = 0
for elm in a_set:
    total_num += int(length_dict[elm]*(length_dict[elm]-1)/2)
difference = {}
for elm in a_set:
    difference[elm] = int(length_dict[elm]*(length_dict[elm]-1)/2) - int((length_dict[elm]-1)*(length_dict[elm]-2)/2)


# print(num_dict0, num_dict1)
for ind in range(n):
    elm = a_list[ind]
    print(total_num-difference[elm])

Measured memory_bytes: 37024
#include <stdio.h>
void main(){
    int i=0;
    int num=0;
    char a[10000];
    scanf("%d",&num);
    scanf("%s",a);

    while (a[i] != 0){
        a[i]=a[i]+num;
        if (a[i] > 90){
            a[i] -= 26;
        }
        i++;
    }
    printf("%s\n",a);
}

Measured memory_bytes: 128
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 T+=R[::-1]
 return T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


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

int main()
{

    int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;

    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int k=0;k<=c;k++)
            {
                if( ( (500*i) + ( 100*j ) + ( 50*k ) ) == x )
                    {
                        ans++; 
                        }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
require 'prime'

n = gets.chomp.to_i
MOD = 10**9 + 7

h = Hash.new(0)

1.upto(n) do |i|
  arr = i.prime_division
  arr.each do |k,v|
    h[k] += v
  end
end

ans = 1

h.each do |k, v|
  ans = ans * (v + 1) % MOD
end

p ans

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while (a >= b) {
        b *= 2;
        cnt++;
    }
    while (b >= c) {
        c *= 2;
        cnt++;
    }
    cout << (cnt <= k ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3644
#include <stdio.h> 
int main(){
	int s1,s2,s3;
	scanf("%d %d %d", &s1,&s2,&s3);
	if(s1%5==0&s2%5==0||s1%5==0&s3%5==0||s2%5==0&s3%5==0)
	printf("YES");
	else
	printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-2;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int dp[2003][2];
int n,z,w,a[2002];

int dfs(int v,int turn){
	if(dp[v][turn] != -INF) return dp[v][turn];
	int ret = abs(a[v] - a[n + 1]);
	for(int i = v + 1;i <= n;i++){
		if(turn) ret = min(ret,dfs(i,!turn));
		else ret = max(ret,dfs(i,!turn));
	}
	return dp[v][turn] = ret;
}

signed main(){
	cin >> n >> a[0] >> a[1];
	for(int i = 0;i < n;i++) cin >> a[i + 2];
	for(int i = 0;i <= n + 2;i++){
		dp[i][0] = -INF;
		dp[i][1] = -INF;
	}
	cout << dfs(1,0) << endl;
	return 0;
}

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


using namespace std;


using ll = long long;


ll solve(vector<ll> &A, ll x) {
    ll l, r;
    l = r = 0;

    ll ans = 0;
    ll cum = 0;
    while (l < A.size()) {
        while (r < A.size() && cum + A[r] <= x) {
            cum += A[r++];
        }
        ans += r - l;
        // cout << cum << endl;
        // cout << "(" << l << ", " << r << ")" << endl;
        cum -= A[l++];
    }
    return ans;
}


int main(void) {
    ll N, Q;
    cin >> N >> Q;

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

    for (ll i = 0; i < Q; i++) {
        ll x;
        cin >> x;
        cout << solve(A, x) << endl;
    }
}



Measured memory_bytes: 3516
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define endl "\n"
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
      int x;
      cin>>x;
       if(x)
       cout<<0;
       else
       cout<<1;
        
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
typedef long long int llint;

bool dp[100001] = {true};

int main(void){

  int x;
  std::cin >> x;

  for(int i=0; i<=100000; i++){
    for(int j=100; j<=105; j++){
      if(i+j <= 100000) dp[i+j] |= dp[i];
    }
  }

  std::cout << int(dp[x]) << std::endl;
  
  return 0;
}


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

int pcnt(int x) {
    return __builtin_popcount(x);
}

int f(int x) {
    if (x == 0) return 0;
    return f(x % pcnt(x)) + 1;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        x[i] = s[i] - '0';
    }
    int pc = 0;
    for (int i = 0; i < n; ++i) {
        pc += x[i];
    }
    vector<int> ans(n);
    for (int b = 0; b < 2; ++b) {
        int npc = pc;
        if (b == 0)
            npc++;
        else
            npc--;
        // 例外処理
        if (npc <= 0) {
            continue;
        }

        int r0 = 0;
        for (int i = 0; i < n; ++i) {
            r0 = (r0 * 2) % npc;
            r0 += x[i];
        }
        int k = 1;
        for (int i = n - 1; i >= 0; --i) {
            if (x[i] == b) {
                int r = r0;
                if (b == 0)
                    r = (r + k) % npc;
                else
                    r = (r - k + npc) % npc;
                ans[i] = f(r) + 1;
            }
            k = (k * 2) % npc;
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5164
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int n=sc.nextInt();
		 int m=sc.nextInt();
		 int[][]A=new int [n][m];
		 int []B=new int[m];
		 int[]C=new int[n];
		 for(int i=0;i<n;i++) {
			 for(int j=0;j<m;j++) {
				 A[i][j]=sc.nextInt();
			 }
		 }
		 for(int i=0;i<m;i++) {
			 B[i]=sc.nextInt();
		 }
		 for(int i=0;i<n;i++) {
			 for(int j=0;j<m;j++) {
				 C[i]+=A[i][j]*B[j];
			 }
		 }
		 for(int i=0;i<n;i++) {
			 System.out.println(C[i]);
		 }
		 sc.close();
	 }
}



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

void solve(long long N, std::string S)
{
    long long changes = 0LL;
    for (size_t i = 0; i < N - 1; i++)
    {
        if (S[i] != S[i + 1])
        {
            changes++;
        }
    }
    long long res = changes + 1;
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(a,a+3);
    int sum=0;
    for(int i=1;i<3;i++){
        sum+=abs(a[i]-a[i-1]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		int length = st.length();
		char start = st.charAt(0);	
		char end = st.charAt(length-1);
		System.out.print(start);
		System.out.print(length-2);
		System.out.print(end);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=100*a+10*b+c;
  if(d%4==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import bisect

def solve(N: int, a: "List[int]"):
    a.sort()
    answer = 0
    for i in range(N):
        count = bisect.bisect_left(a,a[i]+3)
        answer = max(answer,count-i)
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;


public class Main {

    public static void main(String[] args) {

        Integer[] input = readInput();

        int W = input[0];
        int H = input[1];
        int x = input[2];
        int y = input[3];
        int r = input[4];

        Circle c = new Circle(x, y, r);
        if (c.isInside(new Rectangle(W, H))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    protected static class Point {
        private int x;
        private int y;

        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public boolean greaterThanOrEqual(Point other) {
            return this.x >= other.x && this.y >= other.y;
        }

        public boolean lessThanOrEqual(Point other) {
            return this.x <= other.x && this.y <= other.y;
        }
    }

    protected static class Circle {
        private int x;
        private int y;
        private int r;

        Circle(int x, int y, int r) {
            this.x = x;
            this.y = y;
            this.r = r;
        }

        public boolean isInside(Rectangle r) {
            return r.isInside(north()) &&
                r.isInside(south()) &&
                r.isInside(west()) &&
                r.isInside(east());
        }

        protected Point north() {
            return new Point(x, y + r);
        }

        protected Point south() {
            return new Point(x, y - r);
        }

        protected Point west() {
            return new Point(x - r, y);
        }

        protected Point east() {
            return new Point(x + r, y);
        }
    }

    public static class Rectangle {
        Point leftBottom;
        Point rightTop;

        Rectangle(int w, int h) {
            leftBottom = new Point(0, 0);
            rightTop = new Point(w, h);
        }

        public boolean isInside(Point p) {
            return p.greaterThanOrEqual(leftBottom) &&
                p.lessThanOrEqual(rightTop);
        }
    }

    public static Integer[] readInput() {
        List<Integer> l = new ArrayList<Integer>();

        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            l.add(sc.nextInt());
        }
        return l.toArray(new Integer[l.size()]);
    }
}

Measured memory_bytes: 26420
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
    x = 0;
    T fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= fh;
}
inline void d_read(double &x) {
    x = 0.0;
    int fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
    if (ch == '.') {
        double num = 1.0;
        ch = getchar();
        for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
    }
    x *= fh;
}
template <typename T>
inline void wt(T x) {
    if (x > 9) wt(x / 10);
    putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    wt(x);
    putchar(c);
}
const int N = 2e5 + 5;
int a[N << 2], t[N << 2], tg[N << 2];
inline void up(int p) {
    a[p] = min(a[p << 1], a[p << 1 | 1]);
    t[p] = min(t[p << 1], t[p << 1 | 1]);
}
inline void work(int p, int l, int r, int k) {
    a[p] = k;
    t[p] = k + l;
    tg[p] = k;
}
inline void build(int p, int l, int r) {
    tg[p] = -1e9;
    if (l == r) {
        a[p] = -l;
        t[p] = a[p] + l;
    }
    else {
        int mid = l + r >> 1;
        build(p << 1, l, mid);
        build(p << 1 | 1, mid + 1, r);
        up(p);
    }
}
inline void down(int p, int l, int r) {
    if (tg[p] != -1e9) {
        int mid = l + r >> 1;
        a[p << 1] = a[p << 1 | 1] = tg[p];
        tg[p << 1] = tg[p << 1 | 1] = tg[p];
        t[p << 1] = tg[p] + l;
        t[p << 1 | 1] = tg[p] + mid + 1;
        tg[p] = -1e9;
    }
}
int sum;
inline void ask(int p, int l, int r, int pos) {
    if (l == pos && pos == r) {
        sum = a[p];
    }
    else {
        down(p, l, r);
        int mid = l + r >> 1;
        if (pos <= mid) ask(p << 1, l, mid, pos);
        else ask(p << 1 | 1, mid + 1, r, pos);
    }
}
inline void modify(int p, int l, int r, int ql, int qr, int k) {
    if (l >= ql && r <= qr) {
        a[p] = k;
        t[p] = a[p] + l;
        tg[p] = k;
    }
    else {
        down(p, l, r);
        int mid = l + r >> 1;
        if (ql <= mid) modify(p << 1, l, mid, ql, qr, k);
        if (mid < qr) modify(p << 1 | 1, mid + 1, r, ql, qr, k);
        up(p);
    }
}
int n, m;
int main() {
    readin(n); readin(m);
    int x, y;
    build(1, 1, m);
    for (int i = 1; i <= n; i ++) {
        readin(x); readin(y);
        sum = 1e8;
        if (x > 1) ask(1, 1, m, x - 1);
        modify(1, 1, m, x, y, sum);
        if (t[1] + i >= 1e8) puts("-1");
        else writeln(t[1] + i, '\n');     
    }
    return 0;
}

Measured memory_bytes: 9788
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
using ll = long long;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int dp[1010][1010];
int H,W;
vector<string> s;
vector<vector<int> > G;
int main(){
    cin >> H >> W;
    s.resize(H);
    for(int i = 0; i < H; i++) cin >> s[i];
    dp[0][0] = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if (i+1 < H && s[i+1][j] == '.'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            } 
            if (j+1 < W && s[i][j+1] == '.'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
}
  



Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    int len=s.size();
    for(int i=0;i<=len;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i;j<=len;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0; 
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A, B;
  cin >> A >> B;
  vector <int> score(N);
  int t1 = 0;
  int t2 = 0;
  int t3 = 0;
  for(int i = 0; i < N; i++) {
    cin >> score.at(i);
  }
  for (int i = 0; i < N; i++) {
    int s = score.at(i);
    if (s <= A) {
      t1++;
    }
    else if (s <= B) {
      t2++;
    }
    else {
      t3++;
    }
  }
  cout << min(min(t1, t2), t3) << endl;
  return 0;
}

Measured memory_bytes: 3560